Connecting Bitbucket Server to MySQL

このページの内容

お困りですか?

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

コミュニティに質問

このページでは、Bitbucket Server を MySQL または MariaDB データベースに接続する方法について説明します。移行の例外を除き、MySQL と MariaDB の手順は同じです。 全般的な情報については「Bitbucket Server を外部のデータベースに接続する」を参照してください。

MySQL / MariaDB のパフォーマンスの問題

MySQL および MariaDB は Bitbucket Server のサポート対象ですが、特に大規模なインスタンスでは現在推奨されません。これは、このデータベース エンジンでは、高負荷状況でパフォーマンスやデッドロックに関する固有の問題が確認されているためです。

影響を受けたシステムでは、応答時間の遅延やデッドロック エラーに加えて、極端な例ではデータベース コネクションの不足によるエラーが発生することがあります。これらの問題は MySQL および MariaDB に固有であり (Bitbucket Server のサポート対象プラットフォームの他のデータベース エンジンではこの動作は発生しません)、MySQL および MariaDB がトランザクションで行レベルのロックを実行する方法が原因になっています。この問題の一般的な情報は、http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html を参照してください。

Bitbucket Server では、MySQL / MariaDB の挙動に対応するための回避策を適用しています。STASH-4517STASH-4701 などを参照してください。ただし、非常に負荷が高い状況では、MySQL や MariaDB よりも、Bitbucket Server でサポートされている他のデータベース エンジン (無料の PostgreSQL など) を使用する場合のほうが、一般に優れたパフォーマンスが得られます。データを他のエンジンに移行する際の手順については、「Bitbucket Server を外部データベースに接続する」を参照してください。

MySQL および MariaDB は Bitbucket Data Center ではサポートされません

Bitbucket Data Center は、いかなるバージョンの MySQL または MariaDB もサポートしません。Bitbucket Data Center を使用する際は、Bitbucket Server でサポートされている他のデータベース エンジン (無料の PostgreSQL など) のいずれかを使用する必要があります。データを他のエンジンに移行する際の手順については、「Bitbucket Server を外部データベースに接続する」を参照してください。

MySQL 5.6.x の互換性

Bitbucket Server は 5.6.16 以前の MySQL 5.6 バージョンとの互換性を持ちません。これは、クエリ オプティマイザーのバグ (#68424, #69005) によるものです。この最新情報については STASH-3164 をご覧ください。Bitbucket Server は、5.6.16 以降の MySQL 5.6 バージョンはサポートします。

JDBC ドライバのサポート

MySQL JDBC ドライバのバージョン 8.0.11 はサポートされない点にご注意ください。

Bitbucket Server でサポートされる MySQL および MariaDB のバージョンについては、「サポート対象プラットフォーム」を参照してください。

Bitbucket Server で MySQL または Maria DB データベースを使用する場合の全体的な手順は次のとおりです。

  1. Bitbucket Server にアクセス可能な場所に MySQL または MariaDB をインストールします。ここでは、MySQL または MariaDB をすでにインストールし、実行中であることを想定しています。詳細は、MySQL ドキュメント (http://dev.mysql.com/doc/) を参照してください。
  2. 使用する Bitbucket Server 用に MySQL または MariaDB サーバーでデータベースおよびユーザーを作成します。
  3. JDBC ドライバをダウンロードおよびインストールします。
  4. Bitbucket Server を MySQL / MariaDB データベースに移行します。

Bitbucket Server データベースの作成

MySQL または MariaDB で Bitbucket Server を使用する前に、MySQL または MariaDB サーバーを次のようにセットアップする必要があります。

データベースの作成
Bitbucket Server で使用するデータベースを MySQL または MariaDB で作成します。

データベース ユーザーの作成
データベースに Bitbucket Server ユーザーを作成します。

Character encoding
Configure the database to use utf8 character set encoding.
Note that Bitbucket Server on MySQL and MariaDB does not support 4 byte UTF-8 characters.

Collation
Configure the database to use utf8_bin collation (to ensure case sensitivity).

Logging format
If MySQL or MariaDB is using binary logging, configure the database to use a binary logging format of either MIXED or ROW.

Refer to the MySQL documentation. Note that Bitbucket Server sets the MySQL / MariaDB transaction isolation level to READ-COMMITTED when it connects to the database.

Packages of MySQL or MariaDB in some Linux distributions may be configured with binlog_fmt=statement by default. Before using such packages with Bitbucket Server you must change this to either mixed or row. See this KB article for more information.

接続タイムアウト
Bitbucket Server では、データベースのアイドル接続を 10 分以上に維持する必要があります。
データベースの接続タイムアウトが 10 分未満に設定されている場合は、ランダムに見える接続エラーが発生します。


Here is an example of how to do that. When Bitbucket Server and MySQL / MariaDB run on the same physical computer (accessible through localhost), run the following commands (replacing bitbucketuser and password with your own values):

mysql> CREATE DATABASE bitbucket CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT ALL PRIVILEGES ON bitbucket.* TO 'bitbucketuser'@'localhost' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> QUIT

This creates an empty MySQL / MariaDB database with the name bitbucket, and a user that can log in from the host that Bitbucket Server is running on who has full access to the newly created database. In particular, the user should be allowed to create and drop tables, indexes and other constraints.

If the MySQL / MariaDB database and Bitbucket Server instances are on the same physical computer, you can use localhost and not set a password by omitting IDENTIFIED BY 'password' from the 2nd MySQL statement above (if you trust the security within this computer).

If the MySQL / MariaDB database and Bitbucket Server instances are on different computers, just replace the localhost part of the GRANT ALL statement above with the hostname of the machine that Bitbucket Server is running on. See the documentation at http://dev.mysql.com/doc/refman/5.1/en/account-names.html.

Bitbucket Server では一般に、データベース コネクションが約 25~30 必要です。最大コネクション数をシステム プロパティで構成できます。データベース プールを参照してください。

JDBC ドライバのダウンロードとインストール

MySQL / MariaDB 用の JDBC ドライバは Bitbucket Server にバンドルされていません (ライセンス上の制約のため)。Bitbucket Server をインストールした後に、ドライバを自身でダウンロードおよびインストールする必要があります。

  1. MySQL Connector/J JDBC ドライバをダウンロード サイトからダウンロードします。

    MariaDB Java Client には Bitbucket Server との互換性はありません

    MySQL Connector/J を MySQL と MariaDB の両方で使用する必要があります。MariaDB Java Client には Bitbucket Server との互換性がなく、サポートされません。

  2. ダウンロードした zip/tar.gz ファイルを解凍します。
  3. Copy the mysql-connector-java-5.1.XX-bin.jar file from the extracted directory to your <Bitbucket home directory>/lib directory (for Bitbucket Server 2.1 or later).
  4. Bitbucket Server を停止してから再起動します。「Bitbucket Server の開始および終了」をご参照ください。

Bitbucket Server の MySQL / MariaDB データベースへの移行

Bitbucket Server を、組み込みデータベース、または別の外部データベースから上記で作成した MySQL または MariaDB データベースに移行できます。

The migration process makes a backup of your existing Bitbucket Server database in exports under the Bitbucket Server home directory. See  Data recovery and backups  for further information about backing up Bitbucket Server.

次のように移行を実行します。

  1. 管理領域で、[設定] 配下の [データベース] をクリックします。
  2. [データベースの移行] をクリックします。
  3. [データベース タイプ] で [MySQL] を選択します。
  4. フォームに入力します。詳細は、以下の表を参照してください。
  5. [移行の開始] をクリックします。

データベース移行についてはこれらのノートを参照してください。



ホスト名
データベース サーバーを実行するコンピューターのホスト名または IP アドレス。

ポート
Bitbucket Server がデータベース サーバーに接続できる TCP ポート。既定値は、MySQL または MariaDB が実行される既定のポートです。MySQL または MariaDB インスタンスが使用しているポートを確認済みの場合は変更できます。

データベース名
Bitbucket Server が接続するデータベースの名前。

データベース ユーザー名
Bitbucket Server がデータベースへのアクセスに使用するユーザー名。

データベース パスワード
Bitbucket Server がデータベースへのアクセスに使用するパスワード。


最終更新日 2018 年 8 月 10 日

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

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