Friday 19 July 2013

How to migrate JIRA

  • Find current running jira version information:
    • Example: The current running is: jira standard 3.12 standalone version.
      • you can download the same from there official site: atlassian-jira-standard-3.12-standalone.zip

Steps:

  1. Download the jira standard 3.12 standalone version from there official site.
  2. Login to the new server. 
  3. Create a user account [ sudo useradd -d /home/svn svn ]  [ given "svn" because most of the time the jira and svn repo runs at the same time ]
  4. Create the home directory [ sudo mkdir /home/svn ]
  5. Update the permission of the new home directory [ sudo chmod svn:svn /home/svn ]
  6. Create a password for the user [ sudo passwd svn ]
  7. Login as new jira user on the new server [ over here I have created svn, so login as svn. ]
  8. Download the jira zip file to the new server.
  9. Keep the jira zip file under /home/svn directory.
  10. Extract the jira zip file.
  11. Renamed the jira-xxx directory as "jira"
  12. Make sure all the is owned by the user, if not [ sudo chown -R svn.svn jira ]

Config Jira After completing the above steps

  1. Go to jira/bin directory and update the proper file permission. [ chmod +x /home/svn/jira/bin/*.sh ]
  2. NOTE as we are importing the data and indexes so we need a higher java mem.
  3. In the following I have updated the java memory size min to 512m and max to 1024m
~/jira/bin$ cat setenv.sh 
JAVA_OPTS="-Xms512m -Xmx1024m $JAVA_OPTS -Djava.awt.headless=true -Datlassian.standalone=JIRA -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true "



From current JIRA server

  1. Go to the current server running JIRA server UI
  2. Log in as Administrator user.
  3. Take the backup.
  4. Ask users to stop using JIRA.
  5. Stop JIRA service from the current running server.
  6. upload the new backup_file [ that you did by login as Admin ] and the indexes file from the current running server to the new running server.
  7. NOTE: Good to upload these file under the new jira home directory. [ /home/jira/svn/ImportFromRunningJiraServer ]

What to do in the new JIRA server

  1. Login to the new JIRA server as the new user.
  2. Start the jira server [./home/svn/jira/bin/startup.sh ] [ To stop the service if needed is ~/jira/bin/shutdown.sh ]
  3. Open the new jira ui in the browser. [ usually http://<new_server_ip>:8080/ ]
  4. Select the option on restoring from backup option.
  5. In this page there 2 options that you have to fill.
  6. Provide the Absolute path of the back-file and index file that you have uploaded to the new server.
  7. It will take some of your time, and once you are done.
  8. Open the url again and do the check now.


Not yet done

  1. In the above steps the jira will be up but, it use the in-memory database, which is not good, so we have to configure jira for exernal db.
You are using HSQL DB, which is an in-memory database and susceptible to corruption when abnormally terminated. DO NOT USE THIS IN A PRODUCTION SYSTEM. Instead we recommend using an external database, for a list of supported databases please see our documentation


~/jira/database$ head jiradb.script
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE MEMORY TABLE JIRAACTION(ID BIGINT NOT NULL,ISSUEID BIGINT,AUTHOR VARCHAR,ACTIONTYPE VARCHAR,ACTIONLEVEL VARCHAR,ROLELEVEL BIGINT,ACTIONBODY VARCHAR,CREATED TIMESTAMP,UPDATEAUTHOR VARCHAR,UPDATED TIMESTAMP,ACTIONNUM BIGINT,CONSTRAINT PK_JIRAACTION PRIMARY KEY(ID))


<Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false">
          <Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
            username="jirauser"
            password="password"
            driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost/jiradb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"/>"
            maxActive="20" />


Configuring mysql for jira

  1. Copy the mysql database and jiradb from the current running server and update the same to the new jira server
  2. Is coping mysql database is needed? Not really, you can just create a user and grant the user the jira db access.
  3. Is the jira db migration is needed? yes. Because its having all the details.
  4. Check for the mysql jdbc driver so that the jira application should be able to connect.
  5. sudo apt-get install libmysql-java [ If the jdbc is not there ]
  6. Note the above package install the driver but, not at the location where jira look for the driver.
  7. So, create a sym link of the same to the correct path where jira look for the driver.
  8. Original driver location [ can be found by using: sudo dpkg --listfiles libmysql-java ]
  9. In this case which is /usr/share/java/mysql-connector-java-5.1.10.jar
  10. And create a sym link [ at jira looking place] in this case: /home/svn/jira/common/lib ]

Configuring the server.xml

  1. you can see a database directory [ under jira ] which will be having the details about the in-memory db, so I just renamed it.. making sure that jira can not use it.
  2. Update the server.xml file [ ~/jira/conf ] with the db access details. [ In this case as following ]
            username="jirauser"
            password="password"
            driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost/<jiraDB>?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"/>"
  1. Make sure you have the correct username at the db and that user have the correct grant for the the db.
  2. as per the above example, the user is connecting using the mysql.jdbc dirver located at [ ~/jira/common/lib ] to a local database.
  3. After this I found the following error:
Database type is invalid. entityengine.xml is configured for 'hsql', but the database is indicating 'MySQL' with the driver 'MySQL-AB JDBC Driver'. Please ensure entityengine.xml is correct.

  1. So, you have to fix entiyengine.xml: [~/jira/atlassian-jira/WEB-INF/classes/entityengine.xml ]
Following will be default entry [ line number around 100 ]

>     <datasource name="defaultDS" field-type-name="hsql"
>       schema-name="PUBLIC"

That you have to update as following:

<     <datasource name="defaultDS" field-type-name="mysql"

which is: [ field-type-name= <from hsql> to <mysql>
and delete/comment schema-name




What else


  1. I check the catalina.out log file [ ~/jira/logs ] and found the following error, and that was again causing jira giving 404 error.
  2. As per the above log it was looking for 2 more directory that was missing, so I created that.
  3. 1. ~/jira/attachments [ attachments directory ] [ NOTE: do everything as the user that you have created for jira, e,g. here as svn ]
  4. 2. ~/jira/backups [ backups directory ]
  5. [ check for the log again to find further issue. e.g. mail services. ]
  6. After this I have restarted the jira service and found it is working. ] 
For new version, on migration process:

The new version don't have configurable index folder or file path. Old version used to have this. and by default the indexing is disabled on the database and that need to be enabled. It need to be enabled:

Following are the steps:

$ sudo su -
$ cd /jiraHome/jira/bin
$ ./shutdown.sh

$ mysql -u root -p

mysql> select * from propertynumber where id in (select id from propertyentry where property_key = 'jira.path.index.use.default.directory' or property_key = 'jira.option.indexing');

mysql> update propertynumber set propertyvalue = 1 where id in (select id from propertyentry where property_key = 'jira.path.index.use.default.directory' or property_key = 'jira.option.indexing');

Login to Jira using admin credntial
goto administration link or tab
then indexing in left menu add index


Amit Kumar Mund

No comments:

Post a Comment