first, write in frontThe company's Android department in the expansion, especially when we this new recruit, the load is very heavy Gerrit server more unbearable. Some time ago, I was fortunate to participate in building the Gerrit server cluster, here will build the process summary record down, give yourself also to others to do a reference, wrong or better suggestions are looking forward to advice ~
Second, Gerrit Server IntroductionIn short, is based on git introduced a mandatory code audit mechanism, originally is Git Push->git library, now becomes git Push->gerrit (Code Manager Audit pass)->git Library. Of course, this is a non-rigorous description, a more detailed introduction , see http://www.worldhello.net/2010/11/10/2059.html
Third, installation Gerritwe need to be familiar with how to build a Gerrit server before we explore what kind of solution to build a server cluster. On this aspect of online information is very much, here summarizes the use of PostgreSQL database +ldap authentication method of the building configuration. LDAP is a Lightweight Directory Access protocol that can be approximated as a database, and the encyclopedia tells me it differs from a generic database in that it targets fast response and bulk queries and provides information replication capabilities for multiple directory servers . Well, so the MIS department used this to store all the company's employee's account password, for us, only need to Gerrit in the authentication part of the LDAP server configuration, we can eliminate the registration, directly with their own account password login. Gerrit supports three database choices during initialization, namely H2, MySQL, and PostgreSQL. Choose PostgreSQL database, mainly to facilitate the real-time sharing of database data between multiple servers, MySQL can also do, as to why the need to share the database in real-time, follow-up will be further explained.
1. Preparation before installation(1) Git installation
sudo Install Git-core
(2) Java installation
sudo Install openjdk-7-jdk
(3) database installation + initialization (only need to be completed on master)
Install postgresql-9.4
PostgreSQL will create the user by default after installation, named Postgres. The first time the software will automatically assign a MD5 encrypted password, so although the first login does not need to enter a password, you also need to modify the user Postgres password, or the next time you log on this user will be due to the password error failure (if you encounter this situation can be modified by modifying the configuration file Pg_ Hba.conf solution). The specific process is as follows:
#Login Default Usersu postgres#access to the database operator interfacePsql#Modify the Default user passwordalter user postgres with password ' new password ';#Create a new role, named Gerrituser, and grant permission to create DB, role, user, and login with a login password of 777777Create role Gerrituser createdb createrole createuser login password ' 777777';#Exit Current User\q#Log in to the new user databasePsql-u git-h localhost-d postgres#new database, named GerritdbCreate Database Gerritdb;
2. Gerrit installation + detailed configuration(1) Gerrit installation
Java-jar gerrit-2.9. 4. War init-d Review_site
(2) Gerrit Configuration documentafter the Gerrit initialization is complete, the Gerrit.config file is generated in the ETC folder in the Site directory, and the current configuration information is recorded. The contents of this file are as follows:
[Gerrit]basepath= Git#make a git repository location, at which point the full path is a subdirectory of git under Gerrit_site. Canonicalweburl = http://localhost:8080/[Database]type= PostgreSQL#fill in the database information that you just created, and note that the password is not explicitly rendered in this configuration file. Database =Gerritdbhostname=Localhostusername=Gerrituser[index]type=Lucene[auth]type=Ldap[ldap]server= ldap://*#LDAP authentication method, where configuration involves sensitive information, omitted. [Sendemail]smtpserver=Localhost[container]user=xx#the hostname of your computerJavahome =/usr/lib/jvm/jdk1.8.0_31/jre[sshd]listenaddress= *:29418#port number to be listened to when downloading via SSH protocol, default is 29418[Httpd]listenurl= http://*:8080/#Gerrit Server Web interface listening Port[Cache]directory= Cache
(3) If you need to access the remote database, you need to modify the section:--For Master (this refers to the host that created the database)A. Modifying the/etc/postgresql/9.4/main/postgresql.conf
Original content:
# listen_addresses = ' localhost '
after modification ( Remove the # comment):
listen_addresses = ' * ' #监听来自所有ip的访问数据库请求
B. Modifying/etc/postgresql/9.4/main/pg_hba.conf (hba=host-based authentication)
# IPv4 Local connections:host all 127.0.0.1/32#新增内容, you can add several IP segments that allow the host connection to the network segment to use the database
-For slaves (this refers to a host with access requirements)Note that you need to initialize through the interface, not directly change the config file, because the process will be required to enter the database password, where the remote host corresponding to the password.
[Database] = jdbc #Gerrit服务器还提供了接口访问数据库, humanized, likes ~ = gerritdb #注意与远程主机gerrit的dat Abase name consistent = localhost #这里需要 to remote host IP = Gerrituser #注意与远程主机管理该database的用户名一致 = Jdbc:postgresql://master IP Address: 5432/#jdbc的url格式, here IP refers to the remote host Ip,port for PostgreSQL port, the default value is 5432 = org.postgresql.Drive
[Gerrit Server cluster Construction (i)] initial knowledge Gerrit code review system