Wednesday, October 16, 2013

Gerrit configuration on apache tomcat in linux



Download the latest gerrit.war from http://gerrit-releases.storage.googleapis.com/index.html and
deploy it in tomcat as follows

Deploying gerrit war directly in tomcat won't work and need several config modification before up
and running on tomcat.

The tomcat we use is running on 8085 which was created using steps in previous blog( http://balajipraba.blogspot.com/2013/10/creating-custom-tomcat-systemcrtl-daemon.html )

1) First modify tomcat context.xml located in /usr/share/tomcat/

Add the following lines in tag
name="jdbc/ReviewDB"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
username="gerrit2"
password="xxxxx"
url="jdbc:mysql://localhost:3306/ReviewDB?autoReconnect=true"
auth="Container"
/>

Don't forget to add double quotes around password

2) Create account in mysql as follows,

CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'xxxxxxx';
CREATE DATABASE ReviewDB;
ALTER DATABASE ReviewDB charset=latin1;
GRANT ALL ON ReviewDB.* TO 'gerrit2'@'localhost';
FLUSH PRIVILEGES;

3) Increase 524xxx size in Tomcat manager/WEB-INF/web.xml and also increase java memory size.

4) Configure the gerrit.config file as follows,

[gerrit]
basePath = /[path_git_folder]/All-Projects.git/.git
canonicalWebUrl = http://server:8085/gerrit/

[database]
type = mysql
hostname = localhost
database = ReviewDB
username = gerrit2

[auth]
type = LDAP

[ldap]
server = ldap://server.ch1.com
username = CN=Directory Manager
password = "xxxxxxxx"
accountBase = DC=ch2,DC=com
accountScope = subtree
groupBase = DC=ch,DC=com
accountFullName = DirectoryManager
sslVerify = false
referral = follow

[sendemail]
smtpServer = localhost

[container]
user = gerrit2
javaHome = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64/jre

[sshd]
listenAddress = *:29418

[httpd]
listenUrl = http://*:8085/

[cache]
directory = cache

Select Y if promted for plugin installation

Note:
i) In basePath variable you should give the absolute path ie. Upto .git folder otherwise you will
get errors like invalid counter etc...
ii) If you use LDAP for authentication then you must give the password of the bind account ex:
Directory Manager in double quotes otherwise gerrit won't accept the password

Now deploy the gerrit.war in tomcat and it should be up and running at http://server:8085/gerrit and don't forget to open the port on firewall for network access.


No comments:

Post a Comment