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 データベースの作成および設定

  1. 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.
  2. 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 にした場合)。 

  3. ユーザーには必ず、データベースに接続する権限ならびにテーブルの作成および事前設定を行う権限を与えます。これは、以下で提供されます。 
    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>;
  4. 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
  5. 変更内容を有効にするには、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 ドライバーをコピーする:

  1. 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.
  2. 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.
  3. Restart Jira / Jira service.
  4. 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 セットアップ ウィザード が表示されます。

  1. 最初の画面 の “Configure Language and Database” で、 “Database Connection” に My own database を選択します。
  2. データベース タイプMySQL に設定します。
  3. 下記の データベース接続関連フィールド を参照し、フィールド入力を行います。
  4. 接続をテストし、保存します。

Jira 設定ツール

  1. Jira 設定ツールを次のように実行します。
  2. データベース タブへ進み、データベースの種類 MySQL に設定します。
  3. 下記の データベース接続関連フィールド セクションを参照し、各フィールドに入力します。
  4. 接続をテストし、保存します。
  5. Jira を再起動します。

データベース接続フィールド

セットアップウィザード/設定ツールdbconfig.xml説明
ホスト名

<url> タグに配置されます (下記の例の太字部分):
<url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB</url>

IPv6 アドレスを使用している場合は、URL を以下のようにする必要があります。

<url>jdbc:mysql://address=(protocol=tcp)(host=dbserver)(port=3306)/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB</url>

MySQL サーバがインストールされている、マシンの名前あるいは IP アドレス。
ポート

<url> タグに配置されます (下記の例の太字部分):
<url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB</url>

MySQL サーバがリッスンしている TCP/IP ポート。デフォルトのポートを利用する際は、ここを空白にします。
データベース

<url> タグに配置されます (下記の例の太字部分):
<url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=default_storage_engine=InnoDB</url>

お使いの MySQL データベースの名前 (JIRA データの保存先)。上記 ステップ 1で作成済みのはずです。
ユーザ名

<username> タグに配置されます (下記の例の太字部分):
<username>jiradbuser</username>

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&amp;characterEncoding=UTF8&amp;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!

(tick) Congratulations, you now have Jira connected to your MySQL database.

既知の問題

以下は、このデータベースに関する既知の問題の一覧です。詳細については、それぞれを展開してください。

権限のホスト名が文字列として比較される...

localhost などのホスト名に MySQL の権限を付与する場合、Jira からデータベースに接続するときと同じ文字列を使用する必要があります。同じ場所に解決される場合であっても、127.0.0.1 を使用することはできません。これを行わない場合、Jira がセットアップされたときに JDBC 接続に新しいテーブルを作成する権限がないため、テーブルが見つからない旨の警告が表示されます。

コネクションの問題...

以下のいずれかを利用して MySQL データベースを使用している場合、コネクションが切断される問題が発生する可能性があります (詳しくは JRA-15731 を参照してください)。

  • Jira 3.13 以降
  • Tomcat 5 のバージョン 5.5.25 以上
  • Tomcat 6 のバージョン 6.0.13 以上

これに対処する方法の詳細については、「コネクション切断の問題を乗り越える方法」を参照してください。

データベース パスワードで特殊文字がサポートされない...

Jira が特殊文字を解釈できないため、データベース パスワードでは特殊文字はサポートされていません。

InnoDB ストレージ エンジンの使用...

The default storage engine used by MySQL Server versions prior to 5.5 is MyISAM. Because of that, a Jira database running on a default configuration of a MySQL Server earlier than version 5.5 could experience problems with creating tables (JRA-24124), which may result in data corruption in Jira.

To avoid this problem, we strongly recommend specifying the sessionVariables=default_storage_engine=InnoDB parameter in your database URL (as stated above). This will ensure that tables written to Jira's MySQL database use the InnoDB storage engine, which supports 'database transactions' required by Jira.

バイナリ ログ...

Jira は、MySQL の "READ-COMMITTED" トランザクション分離レベルを使用しており、これは現在は行ベースのバイナリ ログのみに対応しています。

MySQL のバイナリ ログ機能が必要な場合、MySQL のバイナリ ログの形式を '行ベース' に設定する必要があります。これを行わない場合、Jira で課題を作成する際に問題が生じる可能性があります。

4 バイト文字がサポートされない...

Jira doesn't support using MySQL with 4-byte characters.

最終更新日 2020 年 6 月 30 日

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

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