Administer Bitbucket in AWS
このページでは、AWS での単一ノード インスタンスの Bitbucket Server の管理について説明します。AWS のアーキテクチャ原則にさらに準拠したデプロイメントが必要な場合、クラスタ化された Bitbucket Data Center インスタンスをデプロイすることをおすすめします。これは、大規模なパフォーマンス、高可用性、柔軟な拡張性を提供します。
Bitbucket AMI
Atlassian Bitbucket Server AMI は、AWS での Bitbucket Server の一般的なデプロイメントを提供します。一般的な Bitbucket Server デプロイメントで使用されるすべてのコンポーネント (リバース プロキシ、外部データベース、バックアップ ツール、データ ボリューム、一時ストレージ) が事前に構成された状態でバンドルされ、すぐに起動することができます。
Atlassian Bitbucket Server AMI は、AWS で Bitbucket Server インスタンスの "ターンキー" デプロイメントとして使用することも、自身のより複雑な Bitbucket Server デプロイメントに向けてカスタマイズするための出発点として使用することもできます。
このページの内容
Bitbucket Server AMI のコンポーネント
Atlassian Bitbucket Server AMI から起動したインスタンスには、次のコンポーネントが含まれます。
- Bitbucket Server (最新バージョンまたは選択したバージョン)。
- 外部 PostgreSQL データベース
- リバース プロキシとしての nginx
- ネイティブの AWS スナップショット用に設定済みの Bitbucket Server DIY Backup ユーティリティ
- データを格納する EBS ボリュームおよびインスタンス ストア
OS | Amazon Linux 64 ビット、2016.09.0 |
---|---|
Bitbucket Server | Bitbucket Server (最新の公開バージョンまたは任意のバージョン) が起動時にダウンロードおよびインストールされます。 |
管理ツール | AWS のネイティブ バックアップ用に構成された atlassian-bitbucket-diy-backup がインストール済みです。これには SSH 経由でアクセスできます。 |
リバース プロキシ | 次のように設定された nginx。
|
データベース | PostgreSQL 9.3 |
ブロック デバイス |
|
インスタンスの起動
Atlassian Bitbucket Server AMI は次のいずれかの方法で起動できます。
- 関連するセキュリティ グループおよび IAM ロールの作成を自動化する CloudFormation テンプレートを使用。詳細については「Bitbucket Server を AWS で開始するためのクイック ガイド」を参照してください。
- manually using the AWS Console, which gives finer control over the optional components in the instance and AWS-specific network, security, and block device settings. For more info, see Launch Bitbucket in AWS manually.
On first boot, the Atlassian Bitbucket Server AMI reads the file /etc/atl
(if any), which can override variables that enable each of the installed components. So for example to enable a self-signed SSL certificate, you can supply user data to the instance at launch time like this:
#!/bin/bash
echo "ATL_SSL_SELF_CERT_ENABLED=true" >>/etc/atl
次の変数を設定できます。
変数名 | 既定値 | 説明 |
---|---|---|
ATL_NGINX_ENABLED | true | Set to false to disable the Nginx reverse proxy, and leave Bitbucket Server's server.xml configured to listen on port 7990 with no proxy. |
ATL_POSTGRES_ENABLED | true | Set to false to disable the PostgreSQL service, and leave Bitbucket Server configured with its internal H2 database. |
ATL_SSL_SELF_CERT_ENABLED | false | Set to Requires |
ATL_BITBUCKET_VERSION | latest | Must be a valid Bitbucket version number (for example, |
See Proxy and secure Bitbucket for more information about Bitbucket Server's server.xml
configuration file.
SSH を使用したインスタンスへの接続
SSH 経由でインスタンスに接続する場合、ユーザー名として ec2-user
を使用します。例:
ssh -i keyfile.pem ec2-user@ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com
The ec2-user
has sudo
access. The Atlassian Bitbucket Server AMI does not allow SSH access by root
.
Bitbucket Server インスタンスへの SSL 証明書のインストール
If launched with a self-signed SSL certificate (you selected SSLCertificate > Generate a self-signed certificate in Quick Start with Bitbucket Server and AWS or you set ATL_SSL_SELF_CERT_ENABLED=true
in Launch Bitbucket in AWS manually), Bitbucket Server will be configured to force HTTPS and redirect all plain HTTP requests to the equivalent https://
URL.
It's highly recommended to replace this self-signed SSL certificate with a proper one for your domain, obtained from a Certification Authority (CA), at the earliest opportunity. See Secure Bitbucket in AWS. Once you have a true SSL certificate, install it as soon as possible.
自己署名 SSL 証明書を適切な SSL 証明書と交換する方法
- 証明書ファイルを
/etc/nginx/ssl/my-ssl.crt
などにに配置します。 - password-less 証明書キー ファイルを
/etc/nginx/ssl/my-ssl.key
に配置します。 - Edit
/etc/nginx/nginx.conf
as follows:/etc/nginx/ssl/self-ssl.crt
への参照を/etc/nginx/ssl/my-ssl.crt
に置き換えます。- Replace references to
/etc/nginx/ssl/self-ssl.key
with/etc/nginx/ssl/my-ssl.key
- Append the contents of
/etc/nginx/ssl/my-ssl.crt
to the default system PKI bundle (/etc/pki/tls/certs/ca-bundle.crt
) to ensure scripts on the instance (such as DIY backup) cancurl
successfully. - nginx を再起動します。
インスタンスのバックアップ
The Atlassian Bitbucket Server AMI includes a complete set of Bitbucket Server DIY Backup scripts which has been built specifically for AWS. For instructions on how to backup and restore your instance please refer to Using Bitbucket DIY Backup in AWS.
インスタンスのアップグレード
AWS で Bitbucket Server の最新バージョンにアップグレードするには、 SSH を使用してインスタンスに接続してから、「Bitbucket Server アップグレード ガイド」の手順に従います。
EC2 インスタンスの停止と開始
Atlassian Bitbucket Server AMI から起動した EC2 インスタンスは、他のマシンと同様にいつでも停止 / 起動できます。
EC2 インスタンスを停止する前に必要な手順
- Stop the
atlbitbucket
,atlbitbucket_search
, andpostgresql93
services. /media/atl
ファイルシステムをアンマウントします。
停止 / 再起動後に EC2 インスタンスを利用できなくなった場合
EC2 インスタンスをも再起動すると、インスタンスへのアクセスに Amazon で自動的に割り当てられたパブリック IP アドレス (固定のプライベート IP アドレスまたは Elastic IP アドレスではなく) に依存している場合、IP アドレスが変更されている場合があります。これが発生すると、インスタンスにアクセスできなくなり、"The host name for your Atlassin instance has changed" ページが表示されます。これを修正するには、Bitbucket Server インスタンスのホスト名を更新する必要があります。
Bitbucket Server インスタンスのホスト名を更新する方法
このコマンドを実行してすべてのアプリケーション ノードで Bitbucket サービスを再起動します。これにより、ホスト名が更新されます。
sudo service atlbitbucket restart
- Bitbucket Server が再起動するのを待ちます。
- Bitbucket Server のベース URL もパブリック DNS 名または IP アドレスにセットアップした場合、管理画面で Bitbucket Server のベース URL を更新して変更を反映させます。
既存の Bitbucket Server インスタンスまたは Bitbucket Data Center インスタンスの AWS への移行
既存のインスタンスを AWS に移行する作業には、${BITBUCKET_HOME}
とデータベースの一貫したバックアップを AWS インスタンスに移動する操作が含まれます。
既存のインスタンスを AWS に移行する方法
- Bitbucket Server ナレッジベースで、既知の問題がないかどうかを確認します。
- ユーザーに対し、今後のサービス停止を周知します。
- Create a user in the Bitbucket Server Internal User Directory with
SYSADMIN
permissions to the instance so you don't get locked out if the new server is unable to connect to your User Directory. - Bitbucket Server Backup Client (Bitbucket Server のみ) または Bitbucket Server DIY Backup (Bitbucket Server または Data Center) でインスタンスのバックアップを作成します。
- Launch Bitbucket Server in AWS using the Quick Start instructions, which uses a CloudFormation template.
- SSH を使用して AWS EC2 インスタンスに接続し、バックアップ ファイルをアップロードします。
- バックアップを作成したときと同じツールを使用してバックアップを復元します。
- If necessary, update the JDBC configuration in the ${
BITBUCKET_HOME}/shared/bitbucket.properties
file.
Bitbucket Server インスタンスでのデータ ボリュームのリサイズ
既定では、Atlassian Bitbucket Server AMI で起動したインスタンスのアプリケーション データ ボリュームは標準の Linux ext4 ファイルシステムであり、標準の Linux コマンド ライン ツールを使用してリサイズできます。
Bitbucket Server インスタンスでデータ ボリュームをリサイズする方法
atlbitbucket
、atlbitbucket_search
、postgresql93
サービスを停止します。- Unmount the
/media/atl
filesystem. - リサイズするボリュームのスナップショットを作成します。
- EC2 インスタンスと同じアベイラビリティ ゾーンで、必要なサイズの新しいボリュームをスナップショットから作成します。
- 古いボリュームを接続解除し、新しくリサイズされたボリュームを
/dev/sdf
として接続します。 - Resize
/dev/sdf
usingresize2fs
, verify that its size has changed, and remount it on/media/atl
. atlbitbucket
、atlbitbucket_search
、postgresql93
サービスを開始します。
For more information, see Expanding the Storage Space of an EBS Volume on Linux, Expanding a Linux Partition, and the Linux manual pages for resize2fs
and related commands.
インスタンス間での Bitbucket Server データ ボリュームの移動
ステージングおよび本番環境をセットアップする場合や、インスタンスを別のアベイラビリティ ゾーンに移動させる場合など、Bitbucket Server データを別のインスタンスに移動させる必要がある場合があります。
Bitbucket Server データ ボリュームを別のインスタンスに動かすには、2 つのアプローチがあります。
- Take a backup of your data volume with Bitbucket Server DIY Backup, and restore it on your new instance. See Using Bitbucket DIY Backup in AWS for this option.
既存のデータ ボリュームのスナップショットを使用して、Atlassian Bitbucket Server AMI から新しいインスタンスを起動します。
Bitbucket Server データ ボリュームは、元のバージョン以降の Bitbucket Server インスタンスにのみ移動できます。
既存の Bitbucket Server データ ボリュームを使用して Bitbucket Server AMI から新しいインスタンスを起動する方法
- 既存の Bitbucket Server インスタンス上で
atlbitbucket
、atlbitbucket_search
、postgresql93
サービスを停止します。 /media/atl
ファイルシステムをアンマウントします。- Create a snapshot of the Bitbucket Server data volume (the one attached to the instance as
/dev/sdf
). - Once the snapshot generation has completed, launch a new instance from the Atlassian Bitbucket Server AMI as described in Launch Bitbucket in AWS manually. When adding storage, change the EBS volume device to
/dev/sdf
as seen below and enter the id of the created snapshot. - If the host name (private or public) that users use to reach your Bitbucket Server instance has changed as a result of moving availability zones (or as a result of stopping an instance and starting a new one) you will need to SSH in and run
sudo /opt/atlassian/bin/atl-update-host-name.sh
<newhostname>
where <newhostname> is the new host name. - Bitbucket Server が再起動したら、新しいインスタンスを完全に使用できます。
- If the host name has changed you should also update the JDBC URL configuration in the
bitbucket.properties
file (typically located in/var/atlassian/application-data/bitbucket/shared/
), as well as Bitbucket Server's base URL in the administration screen to reflect this.