Jira アプリケーションの MySQL への接続
These instructions will help you connect Jira to a supported MySQL database.
はじめる前に
- ご使用の MySQL のバージョンがサポートされていることを確認します。サポート対象プラットフォームを参照してください。
- 以下の既知の問題を確認してください。
- Jira を他のサーバーに移行する場合は、データのエクスポートを XML バックアップ形式で作成します。その後、「データベースの切り替え」で説明されているように、元のデータベースから新しいデータベースにデータを移行できます。
- If you plan to set up Confluence and Jira on the same MySQL server, read the Confluence MySQL setup guide. Confluence requirements are more strict than Jira's, so you should configure MySQL to suit Confluence. This configuration will work for Jira, too.
- セットアップ ウィザードを実行中の場合を除き、開始する前に Jira をシャットダウンします。
1. MySQL データベースの作成および設定
- Create a database user which Jira will connect as (e.g.
jiradbuser
).
Remember this database user name, as it will be used to configure Jira's connection to this database in subsequent steps. Create a database for JIRA to store issues in (e.g.
jiradb
). The database must have a character set of UTF8. Enter the following command from within the MySQL command client.
Remember this database name, as it will be used to configure Jira's connection to this database in subsequent steps.CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
(データベース名を
jiradb
にした場合)。ユーザーには必ず、データベースに接続する権限ならびにテーブルの作成および事前設定を行う権限を与えます。これは、以下で提供されます。
MySQL 5.5、MySQL 5.6、および MySQL 5.7.0 〜 MySQL 5.7.5 の場合:GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on <JIRADB>.* TO '<USERNAME>'@'<JIRA_SERVER_HOSTNAME>' IDENTIFIED BY '<PASSWORD>'; flush privileges;
MySQL 5.7.6 以上の場合は、REFERENCES 権限も含める必要があります。
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,REFERENCES,ALTER,INDEX on <JIRADB>.* TO '<USERNAME>'@'<JIRA_SERVER_HOSTNAME>' IDENTIFIED BY '<PASSWORD>'; flush privileges;
ポイント:
To confirm if the permissions were granted successfully, log into the DB server with the Jira DB user and run the command below:
SHOW GRANTS FOR <USERNAME>@<JIRA_SERVER_HOSTNAME>;
my.cnf
ファイル (Windows OS では通常 my.ini
) を編集します (my.cnf
およびmy.ini
を編集する際の詳細な手順については、MySQL オプション ファイルを参照してください)。ファイルの[mysqld]
セクションを見つけ、以下のパラメータを追加あるいは修正します。デフォルトのストレージエンジンを InnoDB に設定します:
[mysqld] ... default-storage-engine=INNODB ...
max_allowed_packet
の値が 256 M 以上になるように指定します。[mysqld] ... max_allowed_packet=256M ...
MySQL 5.5 以下の場合、
innodb_log_file_size
の値が 256 M 以上になるように指定します。[mysqld] ... innodb_log_file_size=256M ...
注意:MySQL 5.6 以上の場合、この値を少なくとも 2G に設定する必要があります。
sql_mode パラメーターが NO_AUTO_VALUE_ON_ZERO に指定されていないことを確認します。
// remove this if it exists sql_mode = NO_AUTO_VALUE_ON_ZERO
変更内容を有効にするには、MySQL サーバーを再起動します:
- Windows 上では、Windows サービスマネージャーを利用してサービスを再起動します。
- Linux の場合
- お使いのセットアップに応じて、以下のコマンドを実行します: "
/etc/init.d/mysqld stop
"、"/etc/init.d/mysql stop
”、"service mysqld stop
"。 - 次に "
stop
" を "start
" に置き替えて同じコマンドを再び実行します。
- お使いのセットアップに応じて、以下のコマンドを実行します: "
2. お使いのアプリケーションサーバに MySQL JDBC ドライバーをコピーする
If you are upgrading Jira and you are using the recommended MySQL driver (Connector/J JDBC driver v5.1), you can skip the instructions in this section. The Jira upgrade task will automatically copy over your existing driver to the upgraded installation.
お使いのアプリケーションサーバに MySQL JDBC ドライバーをコピーする:
- MySQL ドライバーを取得します:
- If you are installing Jira, download the recommended MySQL driver JDBC Connector/J 5.1.
You can download either the.tar.gz
or the.zip
file by selecting the 'Platform Independent' option. Extract the jar for the driver (e.g.mysql-connector-java-5.x.x-bin.jar
) from the archive. - If you are upgrading Jira and you are not using the recommended MySQL driver (JDBC Connector/J 5.1), back up the driver from your Jira installation before you upgrade.
The driver will be in the <Jira installation directory>
/lib/
directory.
- If you are installing Jira, download the recommended MySQL driver JDBC Connector/J 5.1.
- Copy the MySQL JDBC driver jar to the <
Jira installation directory>
/lib/
directory for your new/upgraded installation. If you are installing Jira using the Windows installer, you will need to do this step after running the Windows installer, but before running the setup wizard. - Restart Jira / Jira service.
- If you are installing Jira, skip the rest of the instructions on this page and access Jira in your browser to run the setup wizard instead.
注意:
- 我々は、MySQL の Connector/J ドライバーを推奨しています(上にリンクあり)。あるユーザから、MySQL の Resin JDBC ドライバーを使用した際に問題があったという報告がありました。
3. Configure your Jira server to connect to your MySQL database
There are two ways to configure your JIRAJiraserver to connect to your MySQL database:
- Using the Jira setup wizard — Use this method if you have just installed Jira, and are setting it up for the first time. Your settings will be saved to the
dbconfig.xml
file in your Jira home directory. - Using the JIRA configuration tool — Use this method, if you have an existing Jira instance. Your settings will be saved to the
dbconfig.xml
file in your JIRA home directory.
各設定手法の手順説明
Jira セットアップ ウィザード
ブラウザから初めて Jira にアクセスすると、Jira セットアップ ウィザード が表示されます。
- 最初の画面 の “Configure Language and Database” で、 “Database Connection” に My own database を選択します。
- データベース タイプを MySQL に設定します。
- 下記の データベース接続関連フィールド を参照し、フィールド入力を行います。
- 接続をテストし、保存します。
Jira 設定ツール
- Jira 設定ツールを次のように実行します。
- Windows: コマンド プロンプトを開いて、Jira インストール ディレクトリの
bin
サブディレクトリにあるconfig.bat
を実行します。 - Linux/Unix: Open a console and execute
config.sh
in thebin
sub-directory of the Jira installation directory.This may fail with the error as described in our Unable to Start Jira applications Config Tool due to No X11 DISPLAY variable was set error KB article. Please refer to it for the workaround.
- Windows: コマンド プロンプトを開いて、Jira インストール ディレクトリの
- データベース タブへ進み、データベースの種類 を MySQL に設定します。
- 下記の データベース接続関連フィールド セクションを参照し、各フィールドに入力します。
- 接続をテストし、保存します。
- Jira を再起動します。
データベース接続フィールド
セットアップウィザード/設定ツール | dbconfig.xml | 説明 |
---|---|---|
ホスト名 |
IPv6 アドレスを使用している場合は、URL を以下のようにする必要があります。 | MySQL サーバがインストールされている、マシンの名前あるいは IP アドレス。 |
ポート |
| MySQL サーバがリッスンしている TCP/IP ポート。デフォルトのポートを利用する際は、ここを空白にします。 |
データベース |
| お使いの MySQL データベースの名前 (JIRA データの保存先)。上記 ステップ 1で作成済みのはずです。 |
ユーザ名 |
| MySQL サーバに接続する際に JIRA が利用するユーザ。上記 ステップ 1で作成済みのはずです。 |
パスワード | <password> タグに配置されます (下記の例の太字部分):<password> jiradbuser</password> | MySQL サーバとの認証に利用する、ユーザのパスワードです。 |
dbconfig.xml ファイルのサンプル
- 上記の
dbconfig.xml
ファイルに含まれる、pool
で始まる<jdbc-datasource/>
の子要素の詳細については、「データベース接続のチューニング」を参照してください。 - Both the Jira setup wizard and database configuration tool also add the element
<validation-query>select 1</validation-query>
to this file, which is usually required when running JIRA with default MySQL installations. See Surviving connection closures for more information. - 以下の例のデータベース URL は、UTF-8 データベースを想定しています。つまり、データベースが
create database jiradb character set utf8;
などのコマンドを使用して作成されています。このデータベースの作成時にcharacter set utf8
を指定しない場合、データのインポート時に "Data truncation: Data too long for column
" エラーが発生したり、サポート対象外の文字の文字化けが発生したりする可能性があります。 - 以下の例のデータベース URL には、
sessionVariables=default_storage_engine=InnoDB
パラメーターが含まれます。データ破損を防ぐために、このパラメーターを追加することを強くお勧めします。
<?xml version="1.0" encoding="UTF-8"?>
<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>mysql</database-type>
<jdbc-datasource>
<url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&characterEncoding=UTF8&sessionVariables=default_storage_engine=InnoDB</url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<username>jiradbuser</username>
<password>password</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>
<pool-max-idle>20</pool-max-idle>
<pool-remove-abandoned>true</pool-remove-abandoned>
<pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
<validation-query>select 1</validation-query>
<min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
<time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
<pool-test-while-idle>true</pool-test-while-idle>
<pool-test-on-borrow>false</pool-test-on-borrow>
<validation-query-timeout>3</validation-query-timeout>
</jdbc-datasource>
</jira-database-config>
4. Jira の起動
You should now have Jira configured to connect to your MySQL database. The next step is to start it up!
Congratulations, you now have Jira connected to your MySQL database.
既知の問題
以下は、このデータベースに関する既知の問題の一覧です。詳細については、それぞれを展開してください。