Sunday, March 14, 2010

[UPDATE] Jira and Confluence

I will not explain what are Jira (v4.0.2) and Confluence (v3.1.2) (read at their corresponding description) but how to put both of them to run in a Fedora box using MySQL and Tomcat v5.5 (just one).

This procedure is based on the original documentation (given below) and when in doubt please DO read the originals.

Jira: http://confluence.atlassian.com/display/JIRA/Installing+JIRA+on+Tomcat+5.5
Confluence: http://confluence.atlassian.com/display/DOC/Installing+Confluence+EAR-WAR+on+Tomcat


NOTE: Before you start installing please do get it handy both licenses. I will also assume that you already downloaded both programs in the WAR/EAR form. This is *VERY* important because you do *NOT* want the standalone versions. The links are provided here: Jira v4.0.2 and Confluence v3.1.2.

Or:
#---
wget http://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-enterprise-4.0.2.tar.gz
wget http://www.atlassian.com/software/confluence/downloads/binary/confluence-3.1.2.tar.gz
#---


1. Install the necessary software:
#---
yum -y install \
mysql \
mysql-server \
mysql-connector-java \
javamail \
tomcat5
#---


2. Install Sun's JDK:
JDK: http://java.sun.com/javase/downloads/widget/jdk6.jsp

Get the some additional libs from Atlassian:
#---
wget http://confluence.atlassian.com/download/attachments/200709089/jira-jars-tomcat5.zip
#---


3. Put the necessary libs in the Tomcat lib dir:
#---
unzip jira-jars-tomcat5.zip -d /tmp/
mv /tmp/jira-jars-tomcat5/*.jar /var/lib/tomcat5/common/lib/
rm -rf /tmp/jira-jars-tomcat5/
unzip jaf-1_1_1.zip -d /tmp/
mv /tmp/jaf-1.1.1/activation.jar /var/lib/tomcat5/common/lib/
rm -rf /tmp/jaf-1.1.1/
ln -s /usr/share/java/mysql-connector-java-5.1.12.jar /var/lib/tomcat5/common/lib
ln -s /usr/share/java/javamail/mail-1.4.3.jar /var/lib/tomcat5/common/lib
ln -s /usr/share/java/javamail/dsn-1.4.3.jar /var/lib/tomcat5/common/lib
#---


4. Create a build directory for Jira and Confluence:
#---
mkdir -p /usr/local/atlassian/
tar -vxzf atlassian-jira-enterprise-4.0.2.tar.gz -C /usr/local/atlassian/
tar -vxzf confluence-3.1.2.tar.gz -C /usr/local/atlassian/
#---


5. Create the home directory for Jira and Confluence:
#---
mkdir -p /var/local/atlassian/jira/
mkdir -p /var/local/atlassian/confluence/
#---


6. Forces Tomcat to use Sun's JRE by editing [/etc/tomcat5/tomcat5.conf] and setting the following variables:

JAVA_HOME="/usr/java/default/"
JRE_HOME="/usr/java/default/jre/"


Also add the following statements (do NOT remove the already existing ones, just ADD):

JAVA_OPTS="$JAVA_OPTS -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true -Xms128m -Xmx512m -XX:MaxPermSize=256m"

7. Prepare the MySQL:

You need to create the databases for Jira and Confluence:
#---
mysql -u root -p
#---


[UPDATE]
At the MySQL shell:
#---
CREATE DATABASE jiradb CHARACTER SET utf8;
CREATE DATABASE confluencedb CHARACTER SET utf8;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX,LOCK TABLES ON jiradb.* TO 'jirauser'@'localhost' IDENTIFIED BY '<plain text pass for jirauser>';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX,LOCK TABLES ON confluencedb.* TO 'confluenceuser'@'localhost' IDENTIFIED BY '<plain text pass for confluenceuser>';
FLUSH PRIVILEGES;
\q
#---


Check if you can access the databases:
#---
mysql \--user=jirauser \--password=<plain text pass for jirauser> \--database=jiradb
#---


#---
mysql \--user=confluenceuser \--password=<plain text pass for confluenceuser> \--database=confluencedb
#---


8. Install Jira:

8.1. Set Jira to use MySQL in the file [/usr/local/atlassian/atlassian-jira-enterprise-4.0.2/edit-webapp/WEB-INF/classes/entityengine.xml]

Change from:
<datasource name="defaultDS" field-type-name="hsql"
schema-name="PUBLIC"


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

8.2. Set Jira home dir in the file: [/usr/local/atlassian/atlassian-jira-enterprise-4.0.2/edit-webapp/WEB-INF/classes/jira-application.properties]

It looks like this:
jira.home = /var/local/atlassian/jira/

8.3. Compile Jira:
#---
export JAVA_HOME="/usr/java/default/"
cd /usr/local/atlassian/atlassian-jira-enterprise-4.0.2/
rm -f /usr/local/atlassian/atlassian-jira-enterprise-4.0.2/webapp/WEB-INF/lib/{activation-1.1.1.jar,mail-1.4.1.jar}
sh ./build.sh
rm -f /var/local/atlassian/jira/atlassian-jira-4.0.2.war
cp /usr/local/atlassian/atlassian-jira-enterprise-4.0.2/dist-tomcat/atlassian-jira-4.0.2.war /var/local/atlassian/jira/
cp /usr/local/atlassian/atlassian-jira-enterprise-4.0.2/dist-tomcat/tomcat-5.5/jira.xml /etc/tomcat5/Catalina/localhost/
chown -R tomcat:tomcat /var/local/atlassian/jira/
chmod 755 /var/local/atlassian/jira/
chmod -R ug+rw /var/local/atlassian/jira/
chmod -R o+r /var/local/atlassian/jira/
chmod -R o-w /var/local/atlassian/jira/
#---


8.4. Setup the Jira application to use MySQL in file [/etc/tomcat5/Catalina/localhost/jira.xml]

The resource section must look like this:
<Context path="/jira" docBase="/var/local/atlassian/jira/atlassian-jira-4.0.2.war" debug="0">
...
<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
username="jirauser"
password="<plain text pass for jirauser>"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/jiradb?autoReconnect=true&amp;sessionVariables=storage_engine=InnoDB&amp;useUnicode=true&amp;characterEncoding=UTF8"/>


If a complementary build is necessary try this shorter form:
#---
export JAVA_HOME="/usr/java/default/"
cd /usr/local/atlassian/atlassian-jira-enterprise-4.0.2/
rm -f /usr/local/atlassian/atlassian-jira-enterprise-4.0.2/webapp/WEB-INF/lib/{activation-1.1.1.jar,mail-1.4.1.jar}
sh ./build.sh
rm -f /var/local/atlassian/jira/atlassian-jira-4.0.2.war
cp /usr/local/atlassian/atlassian-jira-enterprise-4.0.2/dist-tomcat/atlassian-jira-4.0.2.war /var/local/atlassian/jira/
chown tomcat:tomcat /var/local/atlassian/jira/atlassian-jira-4.0.2.war
#---



8.5. Checking it out if Jira is working:
#---
service mysqld restart
service tomcat5 restart
#---


Go to: http://localhost:8080/jira/

9. Install Confluence:

9.1. Set Confluence home dir in the file: [/usr/local/atlassian/confluence-3.1.2/confluence/WEB-INF/classes/confluence-init.properties]

It looks like this:
confluence.home = /var/local/atlassian/confluence

9.2. Compile Confluence:
#---
export JAVA_HOME="/usr/java/default/"
cd /usr/local/atlassian/confluence-3.1.2/
rm -f /usr/local/atlassian/confluence-3.1.2/confluence/WEB-INF/lib/{activation-1.0.2.jar,mail-1.4.1.jar}
sh ./build.sh
rm -f /var/local/atlassian/confluence/confluence-3.1.2.war
cp /usr/local/atlassian/confluence-3.1.2/dist/confluence-3.1.2.war /var/local/atlassian/confluence/
cat > /etc/tomcat5/Catalina/localhost/confluence.xml << __END__
<Context path="/confluence" docBase="/var/local/atlassian/confluence/confluence-3.1.2.war" debug="0" reloadable="true">
</Context>
__END__
chown -R tomcat:tomcat /var/local/atlassian/confluence/
chmod 755 /var/local/atlassian/confluence/
chmod -R ug+rw /var/local/atlassian/confluence/
chmod -R o+r /var/local/atlassian/confluence/
chmod -R o-w /var/local/atlassian/confluence/
#---


Shorter version for recompile:
#---
export JAVA_HOME="/usr/java/default/"
cd /usr/local/atlassian/confluence-3.1.2/
rm -f /usr/local/atlassian/confluence-3.1.2/confluence/WEB-INF/lib/{activation-1.0.2.jar,mail-1.4.1.jar}
sh ./build.sh
rm -f /var/local/atlassian/confluence/confluence-3.1.2.war
cp /usr/local/atlassian/confluence-3.1.2/dist/confluence-3.1.2.war /var/local/atlassian/confluence/
chown tomcat:tomcat /var/local/atlassian/confluence/confluence-3.1.2.war
#---


9.3. Checking it out if Confluence is working:
#---
service mysqld restart
service tomcat5 restart
#---


Go to: http://localhost:8080/confluence/

Setting up Confluence (at http://localhost:8080/confluence/)

9.4. Enter the key and go to Custom Installation

9.5. At External Database choose MySQL and click at External Database >>

At Configure Database choose Direct JDBC >>

9.6. For the Database configuration fill with the following:

Driver Class Name: com.mysql.jdbc.Driver
Database URL: jdbc:mysql://localhost/confluencedb?autoReconnect=true&amp;sessionVariables=storage_engine=InnoDB&amp;useUnicode=true&amp;characterEncoding=UTF8
User Name: confluenceuser
Password: <plain text pass for confluenceuser>



The rest is straight forward.

P.S.: You may want to change your MySQL maximum allowed packet size to allow plugin installation (which normally requires more than the default 1Mb size). Edit the file [/etc/my.cnf] and put the following line (or change it) to:
...
[mysqld]
...
max_allowed_packet = 16M


Important logs for trouble shooting:
System: /var/log/messages
Tomcat: /var/log/tomcat5/catalina.out
MySQL: /var/log/mysqld.log
Jira: /var/log/tomcat5/catalina.out (all gets thrown at the Tomcat log)
Confluence: /var/local/atlassian/confluence/logs/atlassian-confluence.log
Jira database config: /etc/tomcat5/Catalina/localhost/jira.xml
Confluence database config: /var/local/atlassian/confluence/confluence.cfg.xml

Related posts:
Jira and Confluence Backup: http://gka-linux.blogspot.com/2010/03/jira-and-confluence-backup.html
Fedora 12 Road Map: http://gka-linux.blogspot.com/2009/12/my-fedora-12-road-map.html
MySQL root password reset: http://gka-linux.blogspot.com/2010/03/mysql-root-password-reset.html

10 comments:

Alphadog said...

In your post, you seem to strongly say that you should not install the standalone version. Why do you not want to install the standalone version?

Gustavo said...

Because it, as a standalone version, comes with tomcat and as soon as you want to use another program/product that also needs tomcat you end up having several tomcats consuming "n" times resources and managing to setup internal tomcats to run in different ports (to no conflict with each other). The other point is that the delivered tomcat may not be entirely compatible with your distribution (in case you are thinking in running it with other JVMs)

In a nutshell: having 1 tomcat is already painful for you to administrate. And the tomcat delivered with your distribution is less likely to be a point of failure.

Branz Balugo said...

This very helpful post by Gustavo, however I've got an issue with my Java VM Memory even if I added this to my tomcat5.conf

JAVA_OPTS="$JAVA_OPTS -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true -Xms128m -Xmx512m -XX:MaxPermSize=256m"

This is the error in my catalina.out

java.lang.OutOfMemoryError: PermGen

I have a 3.9GB of memory and a swap memory of 6GB. Only jira and confluence running on my tomcat5. Hope you can help me with this issue. Thank you

Gustavo said...

It could be, in wild guess, a security issue. Look at your /etc/security/limits.conf and try to increase overall memory "allowance" for your tomcat user (maibe apache user, ps -auxww |grep tomcat will tell). To be sure about it: limits -a will tell the restrictions. Let me know if it was it.

Best regards,
Gustavo

Kalerky: Simply Cool Stuff said...

Thank you for your reply, very much appreciated! I checked already the /etc/security/limits.conf file. I already runned both JIRA and confluence on thesame port http://myipaddress.com:8080. JIRA was run properly before I installed confluence, but when both of them (JIRA and confluence) running then after a few minutes I got those errors. Then I check the memory and the result is this: (free -m)

total used free
Mem: 3940 3913 27

This is now the issue, I can't run both of them at the same time. How did you solve that issue? Thanks again for your help. you have a very nice blog. :)

Gustavo said...

Hi. Just free does not help much. I didn't got a memory issue with both running simultaneously. The better way is checking if it is tomcat who is memory hungry. Try the following command
ps -eo pid,user,cmd,pcpu,size,vsize | grep tomcat
The last two figures are the memory usage.

Branz Balugo said...

thanks again for the quick and detailed response.... using the command: "ps -eo pid,user,cmd,pcpu,size,vsize | grep tomcat" and this is the result:

15794 root grep --color tomcat 0.0 256 61188

26139 tomcat /usr/lib/jvm/jre-1.6.0-open 0.1 1174072 1303928


Anyway, I stopped confluence via tomcat manager before running the command.... How do you configure your tomcat5.conf?

Gustavo said...

That is my point I didn't. But, by your ps output it just consumes 1.17GB and allocates 1.30GB. This is not your memory culprit. But you could try to give more PermGen memory:
-XX:MaxPermSize=256m
Additionally you can set a more aggressive garbage collector:
-XX:+CMSPermGenSweepingEnabled
These settings should be enough to cover your memory problem.

Branz Balugo said...

This is now the current setup:
-Xms128m
-Xmx512m
-XX:MaxPermSize=256m
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled

I enabled both CMSPermGenSweepingEnabled and CMSClassUnloadingEnabled ..... and it works!!! thank you so much.. I will observe the system. Hope it will fight Tomcat's OutOfMemoryError PermGen issue.. thank you so much Gustavo, you're the man.. :)

Gustavo said...

Glad to help. Feel free to ask again.

Cheers,
Gustavo