Setting up JIRA on a Linux System using MySQL
Geschrieben von: Andrew Lui (Atlassian) Freitag, den 09. Oktober 2009 um 16:32 Uhr
This is a step-by-step supplement guide to installing the JIRA Standalone distribution
with a MySQL database, to replace the default HSQLDB.
Unpack the JIRA Standalone distribution
[tmp ~]$ tar zxvf ~/apps/atlassian-jira-professional-3.11-standalone.tar.gz[tmp ~]$ mv atlassian-jira-professional-3.11-standalone/ jira[tmp ~]$ cd jira[jira ~]$Enable MySQL TCP/IP networking
Some Linux distributions (eg. Debian) disable MySQL's TCP/IP networking as a security precaution.
You can test that MySQL is listening on the default port (3306) as follows:
jturner@teacup:~$ netstat -na | grep 3306tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:48211 127.0.0.1:3306 TIME_WAITtcp6 1 0 ::ffff:127.0.0.1:34785 ::ffff:127.0.0.1:3306 CLOSE_WAITjturner@teacup:~$ telnet localhost 3306Trying 127.0.0.1...Connected to localhost.localdomain.Escape character is '^]'.D5.0.13-rc-Debian_1-lo!X{$:;V#H!ju (press ctrl-] here)telnet> quitConnection closed.On Debian, you can enable MySQL TCP connections by editing /etc/my.cnf,
commenting out the 'skip-networking' flag, and restarting mysqld.
Create MySQL database and user
Create a MySQL user called 'jirauser' and database called 'jiradb':
jturner@teacup:~$ mysql --user=root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 559 to server version: 5.0.13-rc-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database jiradb character set utf8;Query OK, 1 row affected (0.02 sec)
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on jiradb.* TO 'jirauser'@'localhost' IDENTIFIED BY 'mypassword';Query OK, 0 rows affected (0.00 sec) mysql> flush privileges;Query OK, 0 rows affected (0.00 sec) mysql> quitByeNow verify that user 'jirauser' can connect:
jturner@teacup:~$ mysql \--user=jirauser \--password=mypassword \--database=jiradbWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 565 to server version: 5.0.13-rc-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>Access denied for user 'jirauser'@'localhost' (using password: YES)jturner@teacup:~$ mysql --user=root -p mysqlEnter password:Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 655 to server version: 5.0.13-rc-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select user, host from user;+------------------+-----------+| user | host |+------------------+-----------+| debian-sys-maint | localhost || jirauser | localhost || root | localhost || root | teacup |+------------------+-----------+4 rows in set (0.00 sec)
mysql> update user set host='localhost.localdomain' where user='jirauser';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.03 sec)If problems persist, see the MySQL Causes of Access Denied Errors page.
For more general information, see Adding New User Accounts to MySQL.
Copy the JDBC driver
jira ~]$ cp ../mysql-connector-java-3.1.12-bin.jar common/lib/[jira ~]$Customise conf/server.xml
Customise conf/server.xml with MySQL details:
[jira ~]$ cp conf/server.xml /tmp
[jira ~]$ vim conf/server.xml
[jira ~]$ diff -u /tmp/server.xml conf/server.xml
--- /tmp/server.xml 2007-02-16 17:09:52.000000000 +1100
+++ conf/server.xml 2007-02-16 17:10:55.000000000 +1100
@@ -11,12 +11,10 @@
<Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false">
<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
- username="sa"
- password=""
- driverClassName="org.hsqldb.jdbcDriver"
- url="jdbc:hsqldb:${catalina.home}/database/jiradb"
- minEvictableIdleTimeMillis="4000"
- timeBetweenEvictionRunsMillis="5000"
+ username="jirauser"
+ password="mypassword"
+ driverClassName="com.mysql.jdbc.Driver"
+ url="jdbc:mysql://localhost/jiradb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"
+ maxActive="20"
validationQuery="select 1" />
<!-- NOTE: When a database server reboots or their is a network failure all the connections in the
| The validationQuery parameter is required to prevent database connections from dropping out. This has been noted to occur when MySQL is used together with some Tomcat versions. JIRA 3.13 Standalone ships with one of the affected Tomcat versions (5.5.26). See JRA-15731 for further details. |
Customise entityengine.xml
[jira ~]$ cp atlassian-jira/WEB-INF/classes/entityengine.xml /tmp[jira ~]$ vim atlassian-jira/WEB-INF/classes/entityengine.xml[jira ~]$ diff \-u /tmp/entityengine.xml atlassian-jira/WEB-INF/classes/entityengine.xml--- /tmp/entityengine.xml 2007-02-16 17:11:49.000000000 \+1100\++\+ atlassian-jira//WEB-INF/classes/entityengine.xml 2007-02-16 17:12:04.000000000 \+1100@@ \-97,8 \+97,7 @@
PLEASE DO NOT set the use-foreign-key\* values to "true" as JIRA does not currently support this.\-->- <datasource name="defaultDS" field-type-name="hsql"- schema-name="PUBLIC"+ <datasource name="defaultDS" field-type-name="mysql"helper-class="org.ofbiz.core.entity.GenericHelperDAO"check-on-start="true"use-foreign-keys="false"Start JIRA
[jira ~]$ ./bin/startup.sh....Check for errors
Check the logs for any errors:16/02/2007 17:13:43 org.apache.coyote.http11.Http11BaseProtocol initINFO: Initializing Coyote HTTP/1.1 on http-808016/02/2007 17:13:43 org.apache.catalina.startup.Catalina loadINFO: Initialization processed in 1181 ms16/02/2007 17:13:43 org.apache.catalina.realm.JAASRealm setContainerINFO: Set JAAS app name Catalina16/02/2007 17:13:43 org.apache.catalina.core.StandardService startINFO: Starting service Catalina16/02/2007 17:13:43 org.apache.catalina.core.StandardEngine startINFO: Starting Servlet Engine: Apache Tomcat/5.5.2016/02/2007 17:13:43 org.apache.catalina.core.StandardHost startINFO: XML validation disabled2007-02-16 17:13:48,209 main [core.entity.jdbc.DatabaseUtil] Entity "Action" has no table in the database2007-02-16 17:13:48,497 main [core.entity.jdbc.DatabaseUtil] Entity "ChangeGroup" has no table in the database2007-02-16 17:13:48,671 main [core.entity.jdbc.DatabaseUtil] Entity "ChangeItem" has no table in the database2007-02-16 17:13:49,110 main [core.entity.jdbc.DatabaseUtil] Entity "ColumnLayout" has no table in the database2007-02-16 17:13:49,195 main [core.entity.jdbc.DatabaseUtil] Entity "ColumnLayoutItem" has no table in the database....2007-02-16 17:13:50,529 main [core.entity.jdbc.DatabaseUtil] Entity "WorkflowScheme" has no table in the database2007-02-16 17:13:50,535 main [core.entity.jdbc.DatabaseUtil] Entity "WorkflowSchemeEntity" has no table in the database2007-02-16 17:14:03,413 main INFO [atlassian.jira.upgrade.ConsistencyCheckImpl] Starting JIRA, Version: 3.X-#XXX2007-02-16 17:14:03,413 main INFO [atlassian.jira.upgrade.ConsistencyCheckImpl] Configured to use database: mysql2007-02-16 17:14:03,421 main INFO [atlassian.jira.upgrade.ConsistencyCheckImpl] Could not find Issue Cache Listener, adding.2007-02-16 17:14:04,532 main WARN [ofbiz.core.entity.SequenceUtil] [SequenceUtil.SequenceBank.fillBank] first select failed: trying to add row, result set was empty for sequence: ListenerConfig2007-02-16 17:14:04,666 main INFO [atlassian.jira.upgrade.ConsistencyCheckImpl] Could not find Mail Listener, adding.2007-02-16 17:14:04,790 main INFO [atlassian.jira.upgrade.ConsistencyCheckImpl] Could not find Mail Queue Service, adding.2007-02-16 17:14:04,805 main WARN [ofbiz.core.entity.SequenceUtil] [SequenceUtil.SequenceBank.fillBank] first select failed: trying to add row, result set was empty for sequence: ServiceConfig2007-02-16 17:14:05,034 main INFO [atlassian.jira.upgrade.ConsistencyCheckImpl] Input Language has not been set. Setting to 'English'2007-02-16 17:14:05,038 main WARN [ofbiz.core.entity.SequenceUtil] [SequenceUtil.SequenceBank.fillBank] first select failed: trying to add row, result set was empty for sequence: OSPropertyEntry2007-02-16 17:14:05,124 main INFO [atlassian.jira.upgrade.ConsistencyCheckImpl]
\****************************************************************************************************\*JIRA 3.X build: XXX started. You can now access JIRA through your web browser.\****************************************************************************************************\*
[Filter: profiling] Using parameter [jira_profile][Filter: profiling] defaulting to off [autostart=false][Filter: profiling] Turning filter off [jira_profile=off]2007-02-16 17:14:07,726 main [webwork.dispatcher.ServletDispatcher] Unable to find 'webwork.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir16/02/2007 17:14:08 org.apache.coyote.http11.Http11BaseProtocol startINFO: Starting Coyote HTTP/1.1 on http-808016/02/2007 17:14:09 org.apache.catalina.storeconfig.StoreLoader loadINFO: Find registry server-registry.xml at classpath resource16/02/2007 17:14:09 org.apache.catalina.startup.Catalina startINFO: Server startup in 25881 msAccess denied for user 'jirauser'@'localhost.localdomain' (using password: YES)Run the Setup Wizard
Point a browser at http://localhost:8080/, and set up JIRA, as described in the Setup Wizard.
Troubleshooting
Q: I get the following error message in MySQL, "Attempted reconnect 3 times. Giving up." What should I do?
A:
dbc:mysql://localhost/test?autoReconnect=true connection error :Server connection failure during transaction.Attempted reconnect 3 times. Giving up.
To troubleshoot your MySQL connection, please follow the steps below:
1. Enter the following command to connect to MySQL:
mysql -p -u [dbuser] -h 127.0.0.1 [dbname]mysql -p -u mydbuser -h 127.0.0.1 test2. If you cannot connect to MySQL after entering your password, login to your mysql with the root account:
mysql -p -u rootAnd enter following command:
mysql> GRANT ALL PRIVILEGES ON <dbname>.* to <user>@127.0.0.1 identified by '<password>';mysql> FLUSH PRIVILEGES;<dbname> is your database name,
<user> is your database user name,
<password> is your database password,
Don't forget the last command: 'FLUSH PRIVILEGES'
3. If you still cannot connect, please check that your MySQL is listening on the default port of 3306 and bind in your IP, 127.0.0.1 by running either of the following commands:
netstat -a |grep mysqlnetstat -a |grep 3306tcp 0 0 *:mysql *:* LISTENAlternatively, you also could check if your MySQL is listening on the default port by running this command:
