Bitbucket Data Center のインストール
このガイドでは、Linux 環境で、クラスタ化ソリューションである Bitbucket Data Center のインストールを実行します。
このガイドでは、既存のデータのない初回インストールや、Bitbucket Server の本番環境インスタンスがある場合のインストール、および Bitbucket Data Center インスタンスへの移行を考えている場合のインストールについて説明します。
Bitbucket Data Center のその他のインストール方法
- AWS Quick Start - AWS に簡単にデプロイ
クラスタ化の要件および専門用語
Bitbucket をクラスタで実行するには、Bitbucket Data Center ライセンスを所有しているか、評価ライセンスを取得する必要があります。
このページの内容
このガイドでは以下の用語について説明します:
- インストール ディレクトリ - <Bitbucket インストール ディレクトリ> は、Bitbucket を単体ノードにインストールした場合のディレクトリです。
- 共有ホームディレクトリ – <Bitbucket 共有ホーム> は、同一パス経由でクラスタのすべてのノードにアクセス可能なディレクトリです。
Bitbucket Data Center コンポーネントの要件
「Bitbucket Data Center の要件」ページおよび「サポートされているプラットフォーム」ページで、一般的な Bitbucket Data Center インスタンスのコンポーネント図や、各コンポーネントの詳細な要件をご確認ください。
Bitbucket Data Center インスタンスは、それぞれ専用マシンで実行されるコンポーネントのクラスタで構成されています。
- すべて同じバージョンの Bitbucket Data Center Web アプリケーションを実行している Bitbucket アプリケーション ノードのクラスタ。これらは仮想マシンまたは物理マシンとすることができ、クロックが同期されており (例: NTP を使用)、同一のタイムゾーンで構成され、Bitbucket クラスタ ノードの Hazelcast ポートへの接続が許可されています (デフォルト ポートは 5701)。
- HTTP モード (Web トラフィック用) と TCP モード (SSH トラフィック用) の両方をサポートし、セッション アフィニティ ("スティッキー セッション") をサポートするロード バランサ。
- すべてのクラスタ ノードで共有され、利用可能なサポート対象の外部データベース。
- 同じデータ センターに物理的に存在し、すべてのクラスタ ノードで利用可能で、シングル マウント ポイントとして NFS でアクセス可能な共有ファイル システム。
- Bitbucket に対するリモート接続を 1 つだけ持ったリモート Elasticsearch インスタンス。インスタンスはスタンドアロンの Elasticsearch インストールでも、ロード バランサの背後のクラスタ化されたインストールでもかまいません。Bitbucket Data Center は Elasticsearch 5.5 でのみ動作することにご注意ください。
本番環境にデプロイする前に、Bitbucket Data Center のインストールを入念にテストするようにします。
使用するインストール プロセスにかかわらず、各ステップで Bitbucket Data Center インスタンスをスモーク テストするようにします。次の内容を実行します。
- 本番環境にデプロイする前に、ステージング環境で Bitbucket Data Center をセットアップしてテストします。
- 本番環境と同一のデータ (リポジトリ、ユーザー、アドオン) で Bitbucket Data Center をテストします。
Bitbucket Data Center インストールへのアクセス
インストール プロセスの最後に、Bitbucket Data Center インスタンスの URL はロード バランサの URL となるため、このマシンには DNS で Bitbucket Data Center インスタンスの名前を割り当てる必要があります。残りのマシン (Bitbucket クラスタ ノード、共有データベース、および共有ファイル システム) はユーザーがパブリックにアクセスできる必要はありません。
はじめる前に
Bitbucket Data Center をインストールする前に、いくつかの質問に答える必要があります。
すでに Bitbucket Server の本番インスタンスを実行していますか?
最初のアプリケーション ノードへの Bitbucket Data Center のインストール
1. Bitbucket Data Center のダウンロード
最新のインストーラーをダウンロードします: www.atlassian.com/software/bitbucket/download
2. インストーラーを実行する
インストーラーを実行可能にします。
Run the installer – we recommend using
sudo
to run the installer as this will create a dedicated account to run Bitbucket and allow you to run Bitbucket as a service.- プロンプトに従ってBitbucket をインストールします。次の情報を提供します。
- Type of Bitbucket instance - インストールのタイプ。この手順では [Data Center] を選択します。
- Installation directory - Bitbucket のインストール先。
- Home directory - Bitbucket のアプリケーション データの保存先。
- TCP ports - Bitbucket が実行される HTTP コネクタ ポートおよび制御ポート。
共有データベース、ファイル システム、Elasticsearch ノードのプロビジョニング
「Bitbucket Data Center の要件」ページを読み、それぞれの要件を事前に確認しておきます。
最初の Bitbucket アプリケーション ノードをインストールしたら、Bitbucket Data Center で使用する共有データベースと共有ファイル システムのプロビジョニングが必要になります。
3. 共有データベースのプロビジョニング
共有データベース サーバーをセットアップします。
- Bitbucket Server を PostgreSQL に接続する
- Bitbucket Server を SQL Server に接続する
- Bitbucket Server を Oracle に接続する
Ensure your database is configured to allow enough concurrent connections. Bitbucket Server by default uses up to 80 connections per cluster node, which can exceed the default connection limit of some databases. For example, in PostgreSQL the default limit is usually 100 connections. If you use PostgreSQL, you may need to edit your postgresql.conf
file, to increase the value of max_connection
s
, and restart Postgres.
詳細については、「Bitbucket Server を外部データベースに接続する」を参照してください。クラスタ化されたデータベースはサポートされていないことに注意してください。
4. 共有ファイルシステムのプロビジョニング
Create a Bitbucket Server user account named
atlbitbucket
on the shared file system server using this command:Do not run Bitbucket Server as
root
. Many NFS servers squash accesses byroot
to another user.sudo useradd -c "Atlassian Bitbucket" -u 1001 atlbitbucket
- このアカウントは Bitbucket Server 共有ホーム ディレクトリのすべてを所有します。
このユーザー アカウントは、すべてのクラスタ ノードと共有ファイル システム サーバーで同じ UID である必要があります。
共有ファイル システム サーバーで NFS ロック サービスが有効であることを確認します。
Ensure the user running Bitbucket Server,
atlbitbucket
, is able to read and write everything in the Bitbucket shared home directory, both the node-local part and the shared part (in NFS). The easiest way to do this is to ensure that:atlbitbucket
owns all files and directories in the Bitbucket home directory,atlbitbucket
has the recommendedumask
of0027
, andatlbitbucket
has the same UID on all machines.
- Bitbucket Server から Bitbucket Data Center に移行する場合、次の手順を実行します。
Restore the content of directory
<Bitbucket shared home directory>/shared
from the backup you have taken into the new shared database and shared home directory.Only the
shared
directory in the Bitbucket Server home directory needs to be restored into the shared home directory. The remaining directories (bin
,caches
,export
,lib
,log
,plugins
, andtmp
) contain only caches and temporary files, and do not need to be restored.
NFS を使用する場合のパフォーマンス ガイドラインについては、「Bitbucket Data Center FAQ」を参照してください。
5. Elasticsearch ノードのプロビジョニング
Elasticsearch サーバーをセットアップするには、以下を実行します。
- リモート マシンに Elasticsearch をインストールします。
- Configure Elasticsearch's
elasticsearch.yml
file to work with Bitbucket Data Center. - Bitbucket が Elasticsearch へのアクセスに使用するユーザー名とパスワードを使用して、Elasticsearch を保護します。最低限の HTTP 制限付きアクセスを使用します。
- Elasticsearch を Bitbucket に接続します。
「リモート Elasticsearch インスタンスのインストールと設定」ページに、リモート Elasticsearch インストールをプロビジョニングするのに役立つ詳細な手順があります。
アプリケーション クラスタ ノードのプロビジョニング
6. アプリケーション クラスタ ノードのプロビジョニング
クラスタ ノード インフラストラクチャをプロビジョニングします。Chef、Puppet、または Vagrant などの構成管理ツールを使用したり、同一の仮想マシン スナップショットをスピンアップしたりすることで、これを自動化できます。
On each cluster node, mount the shared home directory as
${BITBUCKET_HOME}/shared
. Note that only the${BITBUCKET_HOME}/shared
directory should be shared between cluster nodes. All other directories, including${BITBUCKET_HOME}
, should be node-local (that is, private to each node).For example, suppose your Bitbucket home directory is
/var/atlassian/application-data/bitbucket
, and your shared home directory is available as an NFS export calledbitbucket-san:/bitbucket-shared
. Add the following line to/etc/fstab
on each cluster node:/etc/fstabbitbucket-san:/bitbucket-shared /var/atlassian/application-data/bitbucket/shared nfs lookupcache=pos,noatime,intr,rsize=32768,wsize=32768 0 0
これをマウントします。
mkdir -p /var/atlassian/application-data/bitbucket/shared sudo mount -a
すべてのクラスタ ノードのクロックが同期されており、タイムゾーン設定が同一であることを確認します。以下はこの方法のいくつかの例です。
手順 1 と 2 を繰り返して、プロビジョニングされた各アプリケーション クラスタ ノードに Bitbucket Data Center をインストールします。
7. 最初のクラスタ ノードの起動
Edit the file ${BITBUCKET_HOME}/shared/bitbucket.properties
and add the following lines:
# Use multicast to discover cluster nodes (recommended).
hazelcast.network.multicast=true
# If your network does not support multicast, you may uncomment the following lines and substitute
# the IP addresses of some or all of your cluster nodes. (Not all of the cluster nodes have to be
# listed here but at least one of them has to be active when a new node joins.)
#hazelcast.network.tcpip=true
#hazelcast.network.tcpip.members=192.168.0.1:5701,192.168.0.2:5701,192.168.0.3:5701
# The following should uniquely identify your cluster on the LAN.
hazelcast.group.name=your-bitbucket-cluster
hazelcast.group.password=your-bitbucket-cluster
Using multicast to discover cluster nodes (hazelcast.network.multicast=true
) is recommended, but requires all your cluster nodes to be accessible to each other via a multicast-enabled network. If your network does not support multicast then you can set hazelcast.network.multicast=false
, hazelcast.network.tcpip=true
, and hazelcast.network.tcpip.members
to a comma-separated list of cluster nodes instead. Only enable one of hazelcast.network.tcpip
or hazelcast.network.multicast
, not both.
Choose a name for hazelcast.group.name
and hazelcast.group.password
that uniquely identifies the cluster on your LAN. If you have more than one cluster on the same LAN (for example, other Bitbucket Data Center instances or other products based on similar technology such as Confluence Data Center) then you must assign each cluster a distinct name, to prevent them from attempting to join together into a "super cluster".
Bitbucket Server を起動します。「Bitbucket Server の開始および終了」をご参照ください。
Then go to http://<bitbucket>:7990/admin/license
, and install your Bitbucket Data Center license. Restart Bitbucket Server for the change to take effect. If you need a Bitbucket Data Center license, you can purchase one that fits your needs, or, get an evaluation license.
ロード バランサのインストールと構成
8. ロード バランサのインストール
ハードウェアでもソフトウェアでもお好みのロード バランサを使用できます。Bitbucket Data Center にはロード バランサがバンドルされません。
ロード バランサは 3 つのプロトコルをプロキシする必要があります。
プロトコル | ロード バランサの一般的なポート | Bitbucket クラスタ ノードの一般的なポート | 注意 |
---|---|---|---|
http | 80 | 7990 | HTTP mode. Session affinity ("sticky sessions") should be enabled using the 52-character BITBUCKETSESSIONID cookie. |
HTTPS | 443 | 7990 | HTTP モード。ロード バランサで SSL を終了し、Bitbucket クラスタ ノードに対してプレーン HTTP を実行することを強くおすすめします。 |
ssh | 7999 | 7999 | TCP モード。 |
Your load balancer must support session affinity ("sticky sessions") using the BITBUCKETSESSIONID
cookie. Bitbucket Data Center assumes that your load balancer always directs each user's requests to the same cluster node. If it does not, users may be unexpectedly logged out or lose other information that may be stored in their HTTP session.
ロード バランサを選択する場合、それは HTTP、HTTPS、TCP プロトコルをサポートしている必要があります。注意:
- Apache では、TCP モードの負荷分散がサポートされていません。
- 1.5.0 より古い HAProxy バージョンでは、HTTPS がサポートされていません。
If your load balancer supports health checks of the cluster nodes, configure it to perform a periodic HTTP GET of http:// <bitbucket>:7990/status
, where <bitbucket>
is the cluster node's name or IP address. This returns one of two HTTP status codes:
- 200 OK
- 500 Internal Server Error
クラスタ ノードが合理的な時間内に 200 OK を返さない場合、ロード バランサはそのクラスタ ノードにトラフィックを転送するべきではありません。
You should then be able to navigate to http://<load-balancer>/
, where <load-balancer>
is your load balancer's name or IP address. This should take you to your Bitbucket Server front page.
例: HAProxy ロード バランサ
使用するロード バランサが決まっていなかったり、ロード バランサに対するポリシーがなかったりする場合、人気のオープン ソースおソフトウェア ロード バランサである HAProxy を使用できます。
HAProxy を選択する場合、バージョン 1.5.0 以上を使用する必要があります。それ以前のバージョンの HAProxy では HTTPS がサポートされません。
使用している HAProxy のバージョンを確認するには、以下のコマンドを実行します。
haproxy --version
Here is an example haproxy.cfg
configuration file (typically found in the location /etc/haproxy/haproxy.cfg
). This assumes:
- Bitbucket クラスタ ノードのアドレスは 192.168.0.1 であり、デフォルト ポート 7990 (HTTP) および 7999 (SSH) でリッスンしている。
- You have a valid SSL certificate at
/etc/cert.pem
.
global
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
tune.ssl.default-dh-param 1024
defaults
log global
option dontlognull
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
errorfile 408 /dev/null # Workaround for Chrome 35-36 bug. See http://blog.haproxy.com/2014/05/26/haproxy-and-http-errors-408-in-chrome/
frontend bitbucket_http_frontend
bind *:80
bind *:443 ssl crt /etc/cert.pem ciphers RC4-SHA:AES128-SHA:AES256-SHA
default_backend bitbucket_http_backend
backend bitbucket_http_backend
mode http
option httplog
option httpchk GET /status
option forwardfor
option http-server-close
appsession BITBUCKETSESSIONID len 52 timeout 1h
balance roundrobin
cookie BITBUCKETSESSIONID prefix
stick-table type string len 52 size 5M expire 30m
stick store-response set-cookie(BITBUCKETSESSIONID)
stick on cookie(BITBUCKETSESSIONID)
server bitbucket01 192.168.0.1:7990 check inter 10000 rise 2 fall 5
#server bitbucket02 192.168.0.2:7990 check inter 10000 rise 2 fall 5
# The following "backup" servers are just here to show the startup page when all nodes are starting up
server backup01 192.168.0.1:7990 backup
#server backup02 192.168.0.2:7990 backup
frontend bitbucket_ssh_frontend
bind *:7999
default_backend bitbucket_ssh_backend
timeout client 15m
maxconn 50
backend bitbucket_ssh_backend
mode tcp
balance roundrobin
server bitbucket01 192.168.0.1:7999 check port 7999
#server bitbucket02 192.168.0.2:7999 check port 7999
timeout server 15m
listen admin
mode http
bind *:8090
stats enable
stats uri /
Review the contents of the haproxy.cfg
file carefully, and customize it for your environment. See http://www.haproxy.org/ for more information about installing and configuring haproxy
.
Once you have configured the haproxy.cfg
file, start the haproxy
service.
sudo service haproxy start
You can also monitor the health of your cluster by navigating to HAProxy's statistics page at http://<load-balancer>:8090/
. You should see a page similar to this:
9. HAProxy 用の Bitbucket の設定
Bitbucket を、HAProxy と連携するように設定する必要があります。例:
server.proxy-name=bitbucket.company.com
server.proxy-port=443
server.secure=true
server.require-ssl=true
詳細については、「SSL を使用した HAProxy の背後にある Bitbucket の保護」を参照してください。
10. 新しい Bitbucket アプリケーション ノードをクラスタに追加
新しいクラスタ ノードに移動し、Bitbucket Server を起動します。「Bitbucket Server の開始および終了」をご参照ください。
Once Bitbucket Server has started, go to https://<load-balancer>/admin/clustering
. You should see a page similar to this:
Verify that the new node you have started up has successfully joined the cluster. If it does not, please check your network configuration and the ${BITBUCKET_HOME}/log/atlassian-bitbucket.log
files on all nodes. If you are unable to find a reason for the node failing to join successfully, please contact Atlassian Support .
11. 新しい Bitbucket クラスタ ノードをロード バランサに接続
独自のハードウェアまたはソフトウェア ロード バランサを使用している場合、新しい Bitbucket クラスタ ノードをロード バランサに追加する方法については、ベンダーのドキュメントを参照してください。
HAProxy を使用している場合、次の行のコメント化を解除します。
server bitbucket02 192.168.0.2:7990 check inter 10000 rise 2 fall 5
server bitbucket02 192.168.0.2:7999 check port 7999
in your haproxy.cfg
file and restart haproxy
:
sudo service haproxy restart
新しいノードがクラスター内にあり、リクエストを受信することを検証します。これを行うには、各ノードでログを調べ、いずれもトラフィックを受信していることを確認し、さらに、一方のノードで実行された更新をもう一方のノードで表示できるかどうかも調べます。
残りのアプリケーション ノードをクラスタに追加
12. 追加の各クラスタ ノードに対して手順 10 と 11 を実行
おめでとうございます!
これで完了です。Bitbucket Data Center には、http://<load_balancer_IP_address>:<port> のような URL からアクセスできます。
次のステップ
本番環境に Bitbucket をセットアップする場合、次に、以下の部分を設定することをおすすめします。
- Bitbucket Server をユーザー ディレクトリに接続 - 外部ディレクトリに保存されているユーザー / グループを管理します。
- Bitbucket Server を専用ユーザーとして実行 - 制限された権限を持つユーザー アカウントを使用して Bitbucket Server を実行します。
- Bitbucket のホーム ディレクトリの保護 - ホーム ディレクトリを不正アクセスから保護します。
- Bitbucket Server のプロキシと安全性確保 - リバース プロキシの内側で Bitbucket Server を実行し、HTTPS アクセスを有効化します。
- データ復旧計画の作成 - インスタンスのホーム ディレクトリおよびデータベースをバックアップします。
大規模な組織を対象とした Bitbucket Server のセットアップの詳細については、「大規模な組織で Bitbucket Server を使用する」を参照してください。