Administer Bitbucket in AWS

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

このページでは、AWS での単一ノード インスタンスの Bitbucket Server の管理について説明します。AWS のアーキテクチャ原則にさらに準拠したデプロイメントが必要な場合、クラスタ化された Bitbucket Data Center インスタンスをデプロイすることをおすすめします。これは、大規模なパフォーマンス、高可用性、柔軟な拡張性を提供します。

このページでは Atlassian Bitbucket Amazon Machine Image (AMI) の概要、内容、起動方法、および Amazon Web Services (AWS) 環境で管理タスクを実行する方法について説明します。

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 ServerBitbucket Server (最新の公開バージョンまたは任意のバージョン) が起動時にダウンロードおよびインストールされます。
管理ツールAWS のネイティブ バックアップ用に構成された atlassian-bitbucket-diy-backup がインストール済みです。これには SSH 経由でアクセスできます。
リバース プロキシ

次のように設定された nginx

  • ポート 80 および 443 (任意) でリッスンします。
  • (任意) SSL (HTTPS) をターミネートし、プレーン HTTP 経由で Bitbucket Server に渡します。
  • Bitbucket Server サービスが実行中でない場合は静的な HTML ページを表示します。
データベースPostgreSQL 9.3
ブロック デバイス
  1. 次の情報を格納する、1 つのEBS ボリューム (/dev/xvdf/media/atl としてマウント)。
    • Bitbucket Server のすべてのリポジトリ、添付ファイル、およびその他のデータを含む Bitbucket Server の共有ホーム ディレクトリ。
    • PostgreSQL のデータ ディレクトリ。
  2. Bitbucket Server の一時ファイルとキャッシュ ファイルを格納する、1 つのEC2 インスタンス ストア (/dev/xvdb、/media/ephemeral0) にマウント 

インスタンスの起動

Atlassian Bitbucket Server AMI は次のいずれかの方法で起動できます。

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_ENABLEDtrueSet 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_ENABLEDtrueSet to false to disable the PostgreSQL service, and leave Bitbucket Server configured with its internal H2 database.
ATL_SSL_SELF_CERT_ENABLEDfalse

Set to true to enable a self-signed SSL certificate to be generated at launch time, and for Bitbucket Server's server.xml and Nginx's nginx.conf to be configured for HTTPS.

Requires ATL_NGINX_ENABLED also to be true.

ATL_BITBUCKET_VERSIONlatest

Must be a valid Bitbucket version number (for example, 5.5.0), or latest for the latest public release.

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 証明書と交換する方法

  1. 証明書ファイルを /etc/nginx/ssl/my-ssl.crt などにに配置します。
  2. password-less 証明書キー ファイルを /etc/nginx/ssl/my-ssl.key に配置します。
  3. Edit /etc/nginx/nginx.conf as follows:
    1. /etc/nginx/ssl/self-ssl.crt への参照を /etc/nginx/ssl/my-ssl.crt に置き換えます。
    2. Replace references to /etc/nginx/ssl/self-ssl.key with /etc/nginx/ssl/my-ssl.key
  4. 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) can curl successfully. 
  5. 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 インスタンスを停止する前に必要な手順

  1. Stop the atlbitbucket, atlbitbucket_search, and postgresql93 services.
  2. /media/atl ファイルシステムをアンマウントします。

停止 / 再起動後に EC2 インスタンスを利用できなくなった場合

EC2 インスタンスをも再起動すると、インスタンスへのアクセスに Amazon で自動的に割り当てられたパブリック IP アドレス (固定のプライベート IP アドレスまたは Elastic IP アドレスではなく) に依存している場合、IP アドレスが変更されている場合があります。これが発生すると、インスタンスにアクセスできなくなり、"The host name for your Atlassin instance has changed" ページが表示されます。これを修正するには、Bitbucket Server インスタンスのホスト名を更新する必要があります。

Bitbucket Server インスタンスのホスト名を更新する方法

  1. このコマンドを実行してすべてのアプリケーション ノードで Bitbucket サービスを再起動します。これにより、ホスト名が更新されます。

    sudo service atlbitbucket restart
  2. Bitbucket Server が再起動するのを待ちます。
  3. Bitbucket Server のベース URL もパブリック DNS 名または IP アドレスにセットアップした場合、管理画面で Bitbucket Server のベース URL を更新して変更を反映させます。

既存の Bitbucket Server インスタンスまたは Bitbucket Data Center インスタンスの AWS への移行

既存のインスタンスを AWS に移行する作業には、${BITBUCKET_HOME}  とデータベースの一貫したバックアップを AWS インスタンスに移動する操作が含まれます。

既存のインスタンスを AWS に移行する方法

  1. Bitbucket Server ナレッジベースで、既知の問題がないかどうかを確認します。
  2. ユーザーに対し、今後のサービス停止を周知します。
  3. 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.
  4. Bitbucket Server Backup Client (Bitbucket Server のみ) または Bitbucket Server DIY Backup (Bitbucket Server または Data Center) でインスタンスのバックアップを作成します。
  5. Launch Bitbucket Server in AWS using the Quick Start instructions, which uses a CloudFormation template.
  6. SSH を使用して AWS EC2 インスタンスに接続し、バックアップ ファイルをアップロードします。
  7. バックアップを作成したときと同じツールを使用してバックアップを復元します。
  8. 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 インスタンスでデータ ボリュームをリサイズする方法

  1. atlbitbucketatlbitbucket_searchpostgresql93 サービスを停止します。
  2. Unmount the /media/atl filesystem.
  3. リサイズするボリュームのスナップショットを作成します。
  4. EC2 インスタンスと同じアベイラビリティ ゾーンで、必要なサイズの新しいボリュームをスナップショットから作成します。
  5. 古いボリュームを接続解除し、新しくリサイズされたボリュームを /dev/sdf として接続します。
  6. Resize /dev/sdf using resize2fs, verify that its size has changed, and remount it on /media/atl
  7. atlbitbucketatlbitbucket_searchpostgresql93 サービスを開始します。

For more information, see Expanding the Storage Space of an EBS Volume on LinuxExpanding a Linux Partition, and the Linux manual pages for resize2fs and related commands. 

インスタンス間での Bitbucket Server データ ボリュームの移動

ステージングおよび本番環境をセットアップする場合や、インスタンスを別のアベイラビリティ ゾーンに移動させる場合など、Bitbucket Server データを別のインスタンスに移動させる必要がある場合があります。 

Bitbucket Server データ ボリュームを別のインスタンスに動かすには、2 つのアプローチがあります。

  1. 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. 
  2. 既存のデータ ボリュームのスナップショットを使用して、Atlassian Bitbucket Server AMI から新しいインスタンスを起動します。

    Bitbucket Server データ ボリュームは、元のバージョン以降の Bitbucket Server インスタンスにのみ移動できます。

既存の Bitbucket Server データ ボリュームを使用して Bitbucket Server AMI から新しいインスタンスを起動する方法

  1. 既存の Bitbucket Server インスタンス上で atlbitbucketatlbitbucket_searchpostgresql93 サービスを停止します。
  2. /media/atl ファイルシステムをアンマウントします。
  3. Create a snapshot of the Bitbucket Server data volume (the one attached to the instance as /dev/sdf).
  4. 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.
  5. 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. 
  6. Bitbucket Server が再起動したら、新しいインスタンスを完全に使用できます。 
  7. 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.
最終更新日: 2023 年 1 月 31 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.