Record Gerrit2.8.4 environment Migration, installation, configuration, and problem resolution

Source: Internet
Author: User
Tags ldap uuid using git version control system docker hub docker run

Some time ago, due to the company's internal adjustment, the original Gerrit system needs to be part of the business split into a new Gerrit system, where I will be the entire environmental migration, environmental construction, environmental configuration, version selection, etc. to do a record, to share with you.

Speaking of Gerrit, not heard of the classmate may feel more unfamiliar, then first copy a paragraph on the Gerrit Description:

Gerrit is a free, open source code review software that uses the Web interface. With web browsers, software programmers from the same team can review each other's modified code and decide whether to submit, return, or continue to modify it.

I am explaining that Gerrit is using Git as a low-level version control system, through the Web interface, can easily do code audit work a lightweight framework, from the Google Team open source projects.

OK, no more, here I introduce the next stage version of the choice,

1, At the beginning of the plan to use the latest version of the Gerrit Docker Mirror 2.13.x build environment, the advantage is that the installation configuration is simple, good container transplant, but after practice, found that the Gerrit version of the upgrade, database MySQL table structure will undergo a great change, if the direct copy of the original version of the data, found And users do not want to reconfigure a variety of group permissions, SSH key, etc., while taking into account the new version of the old version of the database table will have compatibility problems, late extension problems, so pass out this scenario.

2, with the original system Gerrit version of the same, to build a new environment, so that the data Environment consistent smooth migration (do not ask me why not Docker mirror to build, because the original system version is very old, Wood has ready-made Docker mirror, oneself in writing a mirror is also very troublesome ... )。

So , now start recording the migration process. Gerrit 2.8.4 Environment Installation and configuration process

first, the installation environment JDK: java 1.7.0 Apache : httpd-2.2.32.tar.gz git: git-1.8.3.1.tar.gz Gerrit: Gerrit-2.8.4.war gitweb: yum install gitweb mysql: 5.1 +

Note:
    1, Gerrit is written by Java code, so JDK environment must.
    2, Apache as a proxy service, agent Gerrit service.
    3, git as Gerrit low-level version control system.
    4, Gitweb This is a visualization of GIT operation environment, interface operation, intuitive.
    5, MySQL we use MySQL here as a Gerrit data storage.
    6, Gerrit, with the original system version of the same choice 2.8.4

Second, installation configuration steps

1. Install JDK

    Ignore the installation process, the Linux system defaults to install, if not manually installed, finished using Java-version to view version information

2, install git

    1) # TAR-XZF git-1.8.1.5.tar.gz 
    2) # CD git-1.8.1.5
    3) # make prefix=/usr/local all
    4) # make prefix=/usr/ Local Install
    5) # git--version

3. Installation Gitweb

    1) # yum install Gitweb
    2) Modify git.conf
       # vi/etc/httpd/conf.d/git.conf Change
       "Alias/git/var/www/git" to "Alias/gi" Tweb/var/www/git "
    3" modifies gitweb.conf
       # vi/etc/gitweb.conf to
       set $projectroot = "/home/xxx" to the folder where the Git code base resides, Here we set the code base path for the Gerrit configuration/data1/gerrit2.8.4/git

4. Install and configure Apache

    Download: http://archive.apache.org/dist/httpd/Installation: 1) # TAR-XVZF httpd-2.2.32.tar.gz 2) # CD httpd-2.2.32 3) #/configure--prefix=/usr/soft/apache--enable-mods-shared= ' proxy proxy_ajp proxy_balancer proxy _connect proxy_ftp proxy_http proxy_rewrite ' 4 # make 5) # make install configuration: Modify Httpd.conf < VirtualHost *:80> ServerName gerritserver proxyrequests off Proxyvia off PROXYP 

          Reservehost on <proxy *> order Deny,allow allow </Proxy>
            <Location/gerrit/login/> # authtype Basic # authname "Gerrit Code Review" # Require Valid-user # authuserfile/usr/soft/git/htpasswd </Location> Allow Encodedslashes on Redirectmatch ^gerrit$/gerrit/proxypass/gerrit/http://xx.xx.xx.xx:9080/gerrit/n Ocanon ProxypaSsreverse/gerrit/http://xx.xx.xx.xx:9080/gerrit/nocanon </VirtualHost> Note: 1, here Apache listens for 80 ports,  Through the proxy/gerrit/request forwarding to the Gerrit service, also need to configure ServerName xx.xx.xx.xx:80 2, here location configuration is to configure Apache simple login authentication, if the use of command ' HTPASSWD
        -CMB directory and filename username password ' generated, for example: HTPASSWD-CMB user ABC 123456, this landing I use the Gerrit LDAP configuration login, so do not need Apache login authentication. 3, here I use the Apache Agent Gerrit service. Access http://xx.xx.xx.xx/gerrit/The service proxy to the Gerrit service: HTTP://XX.XX.XX.XX:9080/GERRIT/4, Nocanon here if you do not set, Gerrit a may appear when you visit

    ccess permission issue.
        Tuning: Modify httpd.conf, extra/httpd-mpm.conf pressure test, the discovery of large concurrency, there will be access denied, so you need to adjust the maximum number of Apache concurrent 1, first view the current Apache use of the MPM module # httpd-l or Apachectl-l 2, in httpd.conf file, release reference to the module configuration Note # Include conf/extra/httpd-mpm.conf 3, modify  
        extra/httpd-mpm.conf, find the corresponding current Apache use module corresponding part, modify the configuration.
            For example Mpm_perfork module: <ifmodule mpm_prefork_module> serverlimit 1000 #推荐设置: Consistent with maxclients values Startservers #推荐设置: small = default =20~50 large =50~Minspareservers #推荐设置: Consistent with startservers maxspareservers #推荐设置: =30~80 in small =20 =80~120 maxclients 1000 #推荐设置: Small =500 =500~1500 large =1500~3000 maxrequestsperchild 0 #推荐设 Place: small =10000 Medium or large =10000~500000 </IfModule>

5, install and configure Gerrit

    Download: https://gerrit-releases.storage.googleapis.com/index.html Installation: 1) # Java-jar Gerrit-2.8.4.war

    Init-d/data1/gerrit2.8.4 2) According to the installation prompts to enter information in turn, the information entered eventually generated to {$review _site}/etc/gerrit.conf up, you can modify the gerrt.conf configuration file after the installation is completed Configuration: Modify Gerrit.conf [gerrit] BasePath =/data1/gerrit2.8.4/git Canonicalweburl = http://xx.
            Xx.xx.xx/gerrit [Database] type = mysql hostname = xx.xx.xx.xx Port = 3306 Database = reviewdb Username = xxx Password = Hu Jintao [auth] type = LD AP [container] user = root Javahome =/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.121-2.6.8.0.el 7_3.x86_64/jre [sshd] listenaddress = *:29418 [httpd] Listenurl = proxy-http://xx. Xx.xx.xx:9080/gerrit [Cache] directory = cache [SendEmail] smtpserver = xx.xx.com. CN SmtpserveRport = 587 Smtpencryption = TLS Enable = True Smtpuser = xxx@xxx.com.cn s
            Mtppass = Hu Jintao from = Code Review <xxx@xxx.com.cn> [LDAP] Server = Ldap://ip:port Sslverify = False username = CN=XX,OU=XX,OU=XX,DC=XX,DC=XX,DC=COM,DC=CN Password = * * * Referral = Follow Accountbase = OU=XX,DC=XX,DC=XX,DC=COM,DC=CN groupbase = ou=xx,d C=XX,DC=XX,DC=COM,DC=CN [Gitweb] cgi =/var/www/git/gitweb.cgi [plugins] Allowremo  Teadmin = True [Theme] BackgroundColor = Fcfeef TextColor = 000000 Trimcolor = D4e9a9 SelectionColor = ffffcc Topmenucolor = d4e9a9 Changetableoutdatedcolor = F0808 0 [Theme "signed-in"] BackgroundColor = FFFFFF Note: 1, this configuration Gerrit use the MySQL database, authentication method for LADP, send mail
        Configuration, and Gitweb. 2, thisThe Warehouse directory is:/data1/gerrit2.8.4/git defaults to the Gerrit installation directory git directory.
        3, Gitweb configuration, if already installed, then Gerrit will automatically obtain path configuration, if after installation, here can manually configure the next path.
        4, sshd default port is 29418,httpd the default listening port is 8080, here I modified the port to 9080.
        5, LDAP Configuration comparison this piece of trouble, need to try many times, here's groupname if not configured, the default is the same as accountbase, if different, can be configured separately. 6, start Gerrit, if the use of MySQL as a database storage, then the first time to start, you also need to copy the MySQL database driver Mysql-connector-java-5.1.21.jar to/data1/gerrit2.8.4/lib/
        directory, or error, the default is the H2 database. 7, here the MySQL database password, sendmail password, ladp password if completed by the way of installation step 2, Gerrit will automatically save the password to the disk specified path/data1/gerrit2.8.4/etc/
        Secure.config file. 8, plugins inside set allowremoteadmin = True Default False, here overload Gerrit Replication Synchronization Service, you need to specify true, otherwise it may be an error fatal:remote plugin Administration is disabled 9, theme theme settings, you can modify the theme colors for the simple modification of the current Gerrit system.

6, Start | Stop Apache and Gerrit

Start/Stop Apache:/usr/soft/apahe/bin/apachectl start|stop  
start/stop Gerrit:/data1/gerrit2.8.6/bin/gerrit.sh start|stop

7, visit the Gerrit page

Access Address: Http://xx.xx.xx.xx/gerrit

8. Attention Matters

1 when initializing a version of Gerrit, it automatically creates the project All-project.git, as well as two user groups administrators, non-interactive users, if the migrated version directly uses the original version of the database, Attention should be paid to modifying two points:

1, modify the Schema_version table Version_nbr field, because each version of this field is fixed, you need to modify the current version of the corresponding number, or start an error. For example: The schema version number for gerrit2.8.4 is 84.  

2, administrators and the Non-interactive Users group will re-create the new group_uuid, which is inconsistent with the corresponding original set of UUID in the Database account_groups table. Causes the system to modify the Group_uuid and Owner_group_uuid in the database to correspond to the newly generated group_uuid, and then reboot the Gerrit, even if the administrator does not have read and write access. 

3, get the new generation of administrators, Non-interactive users Group_uuid method: Clone all-projects to the local, find groups file, which is stored in the GroupName -UUID.  

2 each Gerrit version of the corresponding database table structure is inconsistent, can not be a simple copy of the data table and git warehouse data copy, may lead to Gerrit startup failure, as well as later expansion issues. based on Docker to build the latest version of Gerrit 2.13.x steps

1, pull Gerrit Mirror

From Docker Hub website pull Openfrontier/gerrit Mirror
address: https://hub.docker.com/r/openfrontier/gerrit/
command: # Docker pull Openfrontier/gerrit

2. Start Gerrit Container

1 start the simplest default configuration # Docker run-d-P 8080:8080-p 29418:29418 openfrontier/gerrit 2) Start custom parameters # Docker run \--name Gerrit \ -P 8080:8080 \ p 29418:29418 \ e weburl=http://xx.xx.xx.xx:8080 \ e database_type=mysql \ e db_port _3306_tcp_addr=xx.xx.xx.xx \ e db_port_3306_tcp_port=3306 \ e db_env_mysql_db=reviewdb \ e DB_ENV_MYSQL_USE R=XXX \ e db_env_mysql_password=****** \ e smtp_server=xx.xx.com.cn \ e smtp_user=xxx@xxx.com.cn \ e S mtp_pass=****** \ e smtp_from= ' Code Review <xxx@xxx.com.cn> '/e auth_type=ldap \ e ldap_server=ldap: Ip:port \ e ldap_accountbase=ou=xx,dc=xx,dc=xx,dc=com,dc=cn \ e ldap_username=cn=xx,ou=xx,ou=xx,dc=xx,dc=xx,dc =COM,DC=CN \ e ldap_password=****** \ e ldap_sslverify=false \ e ldap_referral=follow \ e gerrit_init_ args= '--install-plugin=download-commands ' \-v/data1/gerrit/review_site:/var/gerrit/review_site \ Openfrontier/ge Rrit Description: 1, here through-e KEThe Y=value form specifies the parameter type of the configuration Gerrit, where database storage, mail notification, authentication type and configuration, and Plug-ins are specified. 2, here key and gerrit.conf file in the key mapping relationship, can be passed [GitHub Openfrontier/docker-gerrit] (https://github.com/openfrontier/ Docker-gerrit) to view custom script map associations.

Resources:
Gerrit website
Gerrit official website documents
GitHub Docker-gerrit mirrors

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.