Connecting Bitbucket Server to MySQL
This page describes how to connect Bitbucket Server to a MySQL or MariaDB database. The procedure for MySQL and MariaDB is the same, except where noted below. See Connect Bitbucket to an external database for general information.
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 does its best to work around the MySQL / MariaDB behavior - see issues STASH-4517, STASH-4701 and others for example. However, under very heavy load you will generally get better performance with any of the other database engines supported by Bitbucket Server (such as PostgreSQL which is also freely available) than you will with MySQL or MariaDB. Please see Connect Bitbucket to an external database for instructions on migrating your data to one of these other engines.
MySQL および MariaDB は Bitbucket Data Center ではサポートされません
Bitbucket Data Center does not support any version of MySQL or MariaDB. With Bitbucket Data Center you must use one of the other database engines supported by Bitbucket Server (such as PostgreSQL which is also freely available). Please see Connect Bitbucket to an external database for instructions on migrating your data to one of these other engines.
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 ドライバのサポート
Bitbucket Server only supports MySQL JDBC version 5.1.
Bitbucket Server でサポートされる MySQL および MariaDB のバージョンについては、「サポート対象プラットフォーム」を参照してください。
Bitbucket Server で MySQL または Maria DB データベースを使用する場合の全体的な手順は次のとおりです。
- Bitbucket Server にアクセス可能な場所に MySQL または MariaDB をインストールします。ここでは、MySQL または MariaDB をすでにインストールし、実行中であることを想定しています。詳細は、MySQL ドキュメント (http://dev.mysql.com/doc/) を参照してください。
- 使用する Bitbucket Server 用に MySQL または MariaDB サーバーでデータベースおよびユーザーを作成します。
- JDBC ドライバをダウンロードおよびインストールします。
- Bitbucket Server を MySQL / MariaDB データベースに移行します。
Bitbucket Server データベースの作成
MySQL または MariaDB で Bitbucket Server を使用する前に、MySQL または MariaDB サーバーを次のようにセットアップする必要があります。
Create database
Create a database on MySQL or MariaDB for Bitbucket Server to use.
Create database user
Create a Bitbucket Server user on the database.
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> CREATE USER 'bitbucketuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON bitbucket.* TO 'bitbucketuser'@'localhost';
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 をインストールした後に、ドライバを自身でダウンロードおよびインストールする必要があります。
MySQL Connector/J JDBC ドライバをダウンロード サイトからダウンロードします。
MariaDB Java Client には Bitbucket Server との互換性はありません
MySQL Connector/J を MySQL と MariaDB の両方で使用する必要があります。MariaDB Java Client には Bitbucket Server との互換性がなく、サポートされません。
- ダウンロードした zip/tar.gz ファイルを解凍します。
- 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). - Stop, and then restart Bitbucket Server. See Start and stop Bitbucket.
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.
次のように移行を実行します。
- 管理領域で、[設定] 配下の [データベース] をクリックします。
- [データベースの移行] をクリックします。
- [データベース タイプ] で [MySQL] を選択します。
- フォームに入力します。詳細は、以下の表を参照してください。
- [移行の開始] をクリックします。
データベース移行についてはこれらのノートを参照してください。
ホスト名
データベース サーバーを実行するコンピューターのホスト名または IP アドレス。
ポート
Bitbucket Server がデータベース サーバーに接続できる TCP ポート。既定値は、MySQL または MariaDB が実行される既定のポートです。MySQL または MariaDB インスタンスが使用しているポートを確認済みの場合は変更できます。
データベース名
Bitbucket Server が接続するデータベースの名前。
Database username
The username that Bitbucket Server should use to access the database.
Database password
The password that Bitbucket Server should use to access the database.