How to Install and configure a remote Elasticsearch instance
このページでは、Bitbucket Data Center で機能するようにリモート Elasticsearch インスタンスをプロビジョニングする方法について説明します。
Bitbucket Data Center にはリモート Elasticsearch インスタンスがバンドルまたはインストールされないため、Bitbucket Data Center 用にリモート Elasticsearch インスタンスを用意する必要があります。
Bitbucket Data Center はクラスタの Elasticsearch へのリモート接続を 1 つのみ持つことができます。これは、スタンドアロンの Elasticsearch インストールまたはロード バランサの背後のクラスタ化されたインストールにすることができます。
For details of about how Bitbucket uses Elasticsearch, including troubleshooting tips and frequently asked questions, see Administer code search.
ステップ 1: リモート マシンに Elasticsearch をインストールする
We don't provide specific instructions for installing Elasticsearch, but a good place to start is the Elasticsearch guide for installation. Elastic provides installation packages in several different formats here. Note that the authentication plugin – Buckler, described within the Secure Elasticsearch section – only supports specific versions of Elasticsearch. Refer to the Supported platforms - Additional Tools section to see the current Elasticsearch release we support.
ステップ 2: Elasticsearch を構成する
The elasticsearch.yml
file contains configuration details for your Elasticsearch instance.
リモート Elasticsearch インスタンスを構成する方法
- Locate the
elasticsearch.yml
file within the configuration directory of your Elasticsearch (6.8.6) instance.
Add these parameters to your
elasticsearch.yml
fileaction.auto_create_index: ".watches,.triggered_watches,.watcher-history-*" network.host: 0.0.0.0 xpack.security.enabled: false
Third party plugins, such as Elastic's Shield plugin, may require specific exceptions to be set foraction.auto_create_index
. Consult your provider's documentation for more information.
ステップ 3: Elasticsearch を保護する
リモート Elasticsearch インスタンスへのアクセスをユーザー名とパスワードで保護する必要があります。接続するすべてのユーザーに認証資格情報を要求するセキュリティ プラグインでリモート Elasticsearch インスタンスを保護することをお勧めします。アトラシアンはこのための、Buckler と呼ばれる無料のプラグインを提供しています。また、Bitbucket Server は、基本認証を提供する他のプラグイン (Elastic の Shield プラグインなど) を通じた Elasticsearch への認証もサポートしています。
Buckler プラグインを使用して リモート Elasticsearch インスタンスを保護する方法
Buckler プラグインの URL をクリップボードにコピーします。
Elasticsearch version | Buckler plugin |
---|---|
Elasticsearch 7.16.3 | Buckler 3.0.1 |
Elasticsearch 7.16.2 | Buckler 3.0.0 |
Elasticsearch 7.10.2 | Buckler 2.1.5 |
Elasticsearch 7.9.3 | Buckler 2.1.4 |
Elasticsearch 7.5.2 | Buckler 2.1.3 |
Elasticsearch 6.8.23 | Buckler 2.2.1 |
Elasticsearch 6.8.22 | Buckler 2.2.0 |
Elasticsearch 6.8.6 | Buckler 2.1.2 |
Elasticsearch 6.6.1 | Buckler 2.1.1 |
Elasticsearch 6.5.3 | Buckler 2.0.1 |
Install the plugin onto your remote Elasticsearch instance using the plugin helper in the Elasticsearch /bin
directory:
./elasticsearch-plugin install -b "<link from table above>"
リモート Elasticsearch インストールにアクセスするには、Bitbucket の基本認証を設定します。Bitbucket Data Center と連携するリモート Elasticsearch インスタンスでは少なくとも基本 HTTP 認証を有効化することを強く推奨します。
- Create a directory called
buckler
within theelasticsearch/config/
directory. Within the
elasticsearch/config/buckler
directory, create a file namedbuckler.yml
.rpm または deb ファイルを使用してインストールする場合
The location of your configuration directory varies depending on how you installed Elasticsearch. For rpm/deb installations the location is typically in
/etc/elasticsearch
ファイルが誤った場所に置かれた場合、Buckler は権限を行使しないため、インスタンス / クラスタは保護されません。
Enable Buckler: at this point there are no configuration properties within
buckler.yml
, so the features of the Buckler plugin are disabled.
基本 HTTP 認証で Buckler を有効にするには、次のプロパティをファイルに追加し、Bitbucket が Elasticsearch へのアクセスに使用するユーザー名とパスワードを作成します (後の手順で構成します)。elasticsearch/config/buckler/buckler.ymlauth.basic.http.enabled: true auth.basic.username: <username> auth.basic.password: <password>
If you enable TLS, the following block will need to be added to
elasticsearch.yml
http.type: buckler transport.type: buckler
これは、Buckler バージョン 1.0.1 以降で有効です。- Start your remote Elasticsearch instance. See Elasticsearch (6.8.6) documentation for specific instructions.
ステップ 4: Elasticsearch を Bitbucket に接続する
Elasticsearch インスタンスの構成が完了したら、それを Bitbucket に接続する必要があります。
To configure your remote Elasticsearch instance using the bitbucket.properties
file
bitbucket.properties
file, it cannot be edited later from the admin UI. Any changes that need to be made to the Elasticsearch configuration must be made within the bitbucket.properties
file.
- Locate the
bitbucket.properties
file in the<Bitbucket home directory>/shared
directory. Elasticsearch インスタンスの詳細 (上記の ステップ 3.3 で作成したもの) を追加します。
<Bitbucket ホーム ディレクトリ>/shared/bitbucket.propertiesplugin.search.elasticsearch.baseurl=http://localhost:9200/ plugin.search.elasticsearch.username=<username> plugin.search.elasticsearch.password=<password>
- ファイルを保存して閉じます。
組み込みの Elasticsearch インスタンスを開始せずに Bitbucket Server を起動します。
Linux の場合 start-bitbucket.sh --no-search
Windows の場合 start-bitbucket.bat /no-search
これで、リモート Elasticsearch インスタンスと Bitbucket Server の連携に必要な構成は完了です。