Gerrit代码审计系统实战-Gerrit 2.15.14版本快速搭建

         Gerrit代码审计系统实战-Gerrit 2.15.14版本快速搭建 

                                      作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.Gerrit版本选择

1>.查看Gerrit官网

    Gerrit官方地址:https://www.gerritcodereview.com/

2>.查看Gerrit帮助文档

    官方地址:https://www.gerritcodereview.com/project-configuration.html

3>.Gerrit版本的选择

  虽说主流的Gerrit版本是2.15系列,但官网已经发布了3.0.0系列,因此,我们在安装和使用Gerrit时候,我们会同时学习Gerrit和Gerrit这两个版本。
    关于Gerrit2.15.x 下载地址::https://www.gerritcodereview.com/2.15.html
    关于Gerrit3.0.x下载地址:https://www.gerritcodereview.com/3.0.html

  本片博客主要演示gerrit2.15.14版本的安装,而gerrit3.0.0版本的安装可参考我之前的笔记:https://www.cnblogs.com/yinzhengjie/p/11007383.html.

二.安装OpenJDK

1>.查看CentOS的yum源支持的openjdk版本

[root@node201.yinzhengjie.org.cn ~]# yum search jdk
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: ftp.riken.jp
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
===================================================== N/S matched: jdk ======================================================
copy-jdk-configs.noarch : JDKs configuration files copier
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without audio and video support
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8
java-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility-debug.i686 : OpenJDK accessibility connector for packages with debug on
java-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK 8 accessibility connector for packages with debug on
java-1.8.0-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment 8 with full debug on
java-1.8.0-openjdk-demo.i686 : OpenJDK Demos
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos 8
java-1.8.0-openjdk-demo-debug.i686 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos 8 with full debug on
java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment 8
java-1.8.0-openjdk-devel-debug.i686 : OpenJDK Development Environment with full debug on
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 8 with full debug on
java-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 8
java-1.8.0-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK 8 API documentation for packages with debug on
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed in single archive
java-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK 8 API documentation compressed in single archive for packages with
                                            : debug on
java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle 8
java-1.8.0-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with debug on
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 8 for packages with debug on
java-11-openjdk.i686 : OpenJDK Runtime Environment 11
java-11-openjdk.x86_64 : OpenJDK Runtime Environment 11
java-11-openjdk-debug.i686 : OpenJDK Runtime Environment 11 with full debug on
java-11-openjdk-debug.x86_64 : OpenJDK Runtime Environment 11 with full debug on
java-11-openjdk-demo.i686 : OpenJDK Demos 11
java-11-openjdk-demo.x86_64 : OpenJDK Demos 11
java-11-openjdk-demo-debug.i686 : OpenJDK Demos 11 with full debug on
java-11-openjdk-demo-debug.x86_64 : OpenJDK Demos 11 with full debug on
java-11-openjdk-devel.i686 : OpenJDK Development Environment 11
java-11-openjdk-devel.x86_64 : OpenJDK Development Environment 11
java-11-openjdk-devel-debug.i686 : OpenJDK Development Environment 11 with full debug on
java-11-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 11 with full debug on
java-11-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 11
java-11-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full debug on
java-11-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-11-openjdk-javadoc.i686 : OpenJDK 11 API documentation
java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
java-11-openjdk-javadoc-debug.i686 : OpenJDK 11 API documentation for packages with debug on
java-11-openjdk-javadoc-debug.x86_64 : OpenJDK 11 API documentation for packages with debug on
java-11-openjdk-javadoc-zip.i686 : OpenJDK 11 API documentation compressed in single archive
java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in single archive
java-11-openjdk-javadoc-zip-debug.i686 : OpenJDK 11 API documentation compressed in single archive for packages with debug on
java-11-openjdk-javadoc-zip-debug.x86_64 : OpenJDK 11 API documentation compressed in single archive for packages with debug
                                         : on
java-11-openjdk-jmods.i686 : JMods for OpenJDK 11
java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
java-11-openjdk-jmods-debug.i686 : JMods for OpenJDK 11 with full debug on
java-11-openjdk-jmods-debug.x86_64 : JMods for OpenJDK 11 with full debug on
java-11-openjdk-src.i686 : OpenJDK Source Bundle 11
java-11-openjdk-src.x86_64 : OpenJDK Source Bundle 11
java-11-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with debug on
java-11-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 11 for packages with debug on
java-latest-openjdk.x86_64 : OpenJDK Runtime Environment 12
java-latest-openjdk-debug.x86_64 : OpenJDK Runtime Environment 12 with full debug on
java-latest-openjdk-demo.x86_64 : OpenJDK Demos 12
java-latest-openjdk-demo-debug.x86_64 : OpenJDK Demos 12 with full debug on
java-latest-openjdk-devel.x86_64 : OpenJDK Development Environment 12
java-latest-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 12 with full debug on
java-latest-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 12
java-latest-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-latest-openjdk-javadoc.x86_64 : OpenJDK 12 API documentation
java-latest-openjdk-javadoc-debug.x86_64 : OpenJDK 12 API documentation for packages with debug on
java-latest-openjdk-javadoc-zip.x86_64 : OpenJDK 12 API documentation compressed in single archive
java-latest-openjdk-javadoc-zip-debug.x86_64 : OpenJDK 12 API documentation compressed in single archive for packages with
                                             : debug on
java-latest-openjdk-jmods.x86_64 : JMods for OpenJDK 12
java-latest-openjdk-jmods-debug.x86_64 : JMods for OpenJDK 12 with full debug on
java-latest-openjdk-src.x86_64 : OpenJDK Source Bundle 12
java-latest-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 12 for packages with debug on
ldapjdk-javadoc.noarch : Javadoc for ldapjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation
ldapjdk.noarch : The Mozilla LDAP Java SDK
openprops.noarch : An improved java.util.Properties from OpenJDK

  Name and summary matches only, use "search all" for everything.
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# yum search jdk

2>.安装OpenJDK1.8

[root@node201.yinzhengjie.org.cn ~]# yum -y install java-1.8.0-openjdk-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                  | 8.1 kB  00:00:00     
 * base: mirrors.aliyun.com
 * epel: mirrors.yun-idc.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                  | 3.6 kB  00:00:00     
epel                                                                                                  | 5.3 kB  00:00:00     
extras                                                                                                | 3.4 kB  00:00:00     
updates                                                                                               | 3.4 kB  00:00:00     
(1/2): epel/x86_64/updateinfo                                                                         | 976 kB  00:00:00     
(2/2): epel/x86_64/primary_db                                                                         | 6.7 MB  00:00:03     
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.212.b04-0.el7_6 will be installed
--> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.212.b04-0.el7_6 for package: 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64
--> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64
--> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.212.b04-0.el7_6 will be installed
--> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
--> Processing Dependency: libgif.so.4()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.212.b04-0.el7_6 will be installed
--> Processing Dependency: tzdata-java >= 2015d for package: 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64
--> Processing Dependency: copy-jdk-configs >= 3.3 for package: 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64
--> Processing Dependency: pcsc-lite-libs(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64
--> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64
--> Processing Dependency: jpackage-utils for package: 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64
--> Running transaction check
---> Package copy-jdk-configs.noarch 0:3.3-10.el7_5 will be installed
---> Package giflib.x86_64 0:4.1.6-9.el7 will be installed
---> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-javapackages = 3.4.1-11.el7 for package: javapackages-tools-3.4.1-11.el7.noarch
---> Package lksctp-tools.x86_64 0:1.0.17-2.el7 will be installed
---> Package pcsc-lite-libs.x86_64 0:1.8.8-8.el7 will be installed
---> Package tzdata-java.noarch 0:2019a-1.el7 will be installed
---> Package xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 will be installed
--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Running transaction check
---> Package python-javapackages.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-11.el7.noarch
---> Package ttmkfdir.x86_64 0:3.0.9-42.el7 will be installed
--> Running transaction check
---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                                 Arch               Version                                Repository           Size
=============================================================================================================================
Installing:
 java-1.8.0-openjdk-devel                x86_64             1:1.8.0.212.b04-0.el7_6                updates             9.8 M
Installing for dependencies:
 copy-jdk-configs                        noarch             3.3-10.el7_5                           base                 21 k
 giflib                                  x86_64             4.1.6-9.el7                            base                 40 k
 java-1.8.0-openjdk                      x86_64             1:1.8.0.212.b04-0.el7_6                updates             270 k
 java-1.8.0-openjdk-headless             x86_64             1:1.8.0.212.b04-0.el7_6                updates              32 M
 javapackages-tools                      noarch             3.4.1-11.el7                           base                 73 k
 lksctp-tools                            x86_64             1.0.17-2.el7                           base                 88 k
 pcsc-lite-libs                          x86_64             1.8.8-8.el7                            base                 34 k
 python-javapackages                     noarch             3.4.1-11.el7                           base                 31 k
 python-lxml                             x86_64             3.2.1-4.el7                            base                758 k
 ttmkfdir                                x86_64             3.0.9-42.el7                           base                 48 k
 tzdata-java                             noarch             2019a-1.el7                            updates             187 k
 xorg-x11-fonts-Type1                    noarch             7.5-9.el7                              base                521 k

Transaction Summary
=============================================================================================================================
Install  1 Package (+12 Dependent packages)

Total download size: 44 M
Installed size: 149 M
Downloading packages:
(1/13): giflib-4.1.6-9.el7.x86_64.rpm                                                                 |  40 kB  00:00:00     
(2/13): javapackages-tools-3.4.1-11.el7.noarch.rpm                                                    |  73 kB  00:00:00     
(3/13): copy-jdk-configs-3.3-10.el7_5.noarch.rpm                                                      |  21 kB  00:00:00     
(4/13): java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64.rpm                                           | 270 kB  00:00:00     
(5/13): lksctp-tools-1.0.17-2.el7.x86_64.rpm                                                          |  88 kB  00:00:00     
java-1.8.0-openjdk-headless-1. FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/updates/x86_64/Packages/java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
(6/13): pcsc-lite-libs-1.8.8-8.el7.x86_64.rpm                                                         |  34 kB  00:00:00     
python-javapackages-3.4.1-11.e FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/python-javapackages-3.4.1-11.el7.noarch.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
(7/13): ttmkfdir-3.0.9-42.el7.x86_64.rpm                                                              |  48 kB  00:00:00     
(8/13): tzdata-java-2019a-1.el7.noarch.rpm                                                            | 187 kB  00:00:00     
(9/13): xorg-x11-fonts-Type1-7.5-9.el7.noarch.rpm                                                     | 521 kB  00:00:01     
(10/13): python-javapackages-3.4.1-11.el7.noarch.rpm                                                  |  31 kB  00:00:00     
(11/13): python-lxml-3.2.1-4.el7.x86_64.rpm                                                           | 758 kB  00:00:02     
(12/13): java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64.rpm                                    | 9.8 MB  00:00:05     
(13/13): java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64.rpm                                 |  32 MB  00:00:18     
-----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        2.2 MB/s |  44 MB  00:00:19     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ttmkfdir-3.0.9-42.el7.x86_64                                                                             1/13 
  Installing : xorg-x11-fonts-Type1-7.5-9.el7.noarch                                                                    2/13 
  Installing : lksctp-tools-1.0.17-2.el7.x86_64                                                                         3/13 
  Installing : pcsc-lite-libs-1.8.8-8.el7.x86_64                                                                        4/13 
  Installing : tzdata-java-2019a-1.el7.noarch                                                                           5/13 
  Installing : python-lxml-3.2.1-4.el7.x86_64                                                                           6/13 
  Installing : python-javapackages-3.4.1-11.el7.noarch                                                                  7/13 
  Installing : javapackages-tools-3.4.1-11.el7.noarch                                                                   8/13 
  Installing : copy-jdk-configs-3.3-10.el7_5.noarch                                                                     9/13 
  Installing : 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64                                              10/13 
  Installing : giflib-4.1.6-9.el7.x86_64                                                                               11/13 
  Installing : 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64                                                       12/13 
  Installing : 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64                                                 13/13 
  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.212.b04-0.el7_6.x86_64                                                  1/13 
  Verifying  : giflib-4.1.6-9.el7.x86_64                                                                                2/13 
  Verifying  : xorg-x11-fonts-Type1-7.5-9.el7.noarch                                                                    3/13 
  Verifying  : copy-jdk-configs-3.3-10.el7_5.noarch                                                                     4/13 
  Verifying  : python-javapackages-3.4.1-11.el7.noarch                                                                  5/13 
  Verifying  : python-lxml-3.2.1-4.el7.x86_64                                                                           6/13 
  Verifying  : tzdata-java-2019a-1.el7.noarch                                                                           7/13 
  Verifying  : pcsc-lite-libs-1.8.8-8.el7.x86_64                                                                        8/13 
  Verifying  : javapackages-tools-3.4.1-11.el7.noarch                                                                   9/13 
  Verifying  : 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64                                              10/13 
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64                                                       11/13 
  Verifying  : lksctp-tools-1.0.17-2.el7.x86_64                                                                        12/13 
  Verifying  : ttmkfdir-3.0.9-42.el7.x86_64                                                                            13/13 

Installed:
  java-1.8.0-openjdk-devel.x86_64 1:1.8.0.212.b04-0.el7_6                                                                    

Dependency Installed:
  copy-jdk-configs.noarch 0:3.3-10.el7_5                   giflib.x86_64 0:4.1.6-9.el7                                      
  java-1.8.0-openjdk.x86_64 1:1.8.0.212.b04-0.el7_6        java-1.8.0-openjdk-headless.x86_64 1:1.8.0.212.b04-0.el7_6       
  javapackages-tools.noarch 0:3.4.1-11.el7                 lksctp-tools.x86_64 0:1.0.17-2.el7                               
  pcsc-lite-libs.x86_64 0:1.8.8-8.el7                      python-javapackages.noarch 0:3.4.1-11.el7                        
  python-lxml.x86_64 0:3.2.1-4.el7                         ttmkfdir.x86_64 0:3.0.9-42.el7                                   
  tzdata-java.noarch 0:2019a-1.el7                         xorg-x11-fonts-Type1.noarch 0:7.5-9.el7                          

Complete!
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# yum -y install java-1.8.0-openjdk-devel

3>.查看JDK版本

[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# which java
/usr/bin/java
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
[root@node201.yinzhengjie.org.cn ~]# 

三.安装git

1>.下载git安装包(强烈不推荐大家使用yum方式安装,建议大家使用源码安装git,这种方式不推荐使用,因为它默认安装的版本是1.8.3,它和gerrit集成并不太友好,尤其是gerrit3.0.0版本。

[root@node201.yinzhengjie.org.cn ~]# yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.yun-idc.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                  Arch                       Version                               Repository                   Size
=============================================================================================================================
Installing:
 wget                     x86_64                     1.14-18.el7_6.1                       updates                     547 k

Transaction Summary
=============================================================================================================================
Install  1 Package

Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm                                                                       | 547 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7_6.1.x86_64                                                                               1/1 
  Verifying  : wget-1.14-18.el7_6.1.x86_64                                                                               1/1 

Installed:
  wget.x86_64 0:1.14-18.el7_6.1                                                                                              

Complete!
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# yum -y install wget      #安装Linux系统的下载工具
[root@node201.yinzhengjie.org.cn ~]# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.12.2.tar.gz

2>.安装git依赖包

[root@node201.yinzhengjie.org.cn ~]# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.12.2.tar.gz
--2019-06-17 06:03:29--  https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.12.2.tar.gz
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.101.1, 2604:1380:2001:3900::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.101.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6389118 (6.1M) [application/x-gzip]
Saving to: ‘git-2.12.2.tar.gz’

100%[===================================================================================>] 6,389,118    148KB/s   in 49s    

2019-06-17 06:04:20 (127 KB/s) - ‘git-2.12.2.tar.gz’ saved [6389118/6389118]

[root@node201.yinzhengjie.org.cn ~]# yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Package perl-ExtUtils-MakeMaker-6.68-3.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package expat-devel.x86_64 0:2.1.0-10.el7_3 will be installed
---> Package gcc.x86_64 0:4.8.5-36.el7_6.2 will be installed
--> Processing Dependency: libgomp = 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: cpp = 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libgcc >= 4.8.5-36.el7_6.2 for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-36.el7_6.2.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-36.el7_6.2.x86_64
---> Package gettext-devel.x86_64 0:0.19.8.1-2.el7 will be installed
--> Processing Dependency: gettext-common-devel = 0.19.8.1-2.el7 for package: gettext-devel-0.19.8.1-2.el7.x86_64
--> Processing Dependency: git for package: gettext-devel-0.19.8.1-2.el7.x86_64
---> Package libcurl-devel.x86_64 0:7.29.0-51.el7 will be installed
---> Package openssl-devel.x86_64 1:1.0.2k-16.el7_6.1 will be installed
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-16.el7_6.1 for package: 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64
---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-36.el7_6.2 will be installed
---> Package gettext-common-devel.noarch 0:0.19.8.1-2.el7 will be installed
---> Package git.x86_64 0:1.8.3.1-20.el7 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-20.el7 for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: rsync for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-20.el7.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.3.1-20.el7.x86_64
---> Package krb5-devel.x86_64 0:1.15.1-37.el7_6 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-37.el7_6 for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: krb5-libs(x86-64) = 1.15.1-37.el7_6 for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-37.el7_6.x86_64
---> Package libgcc.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libgomp.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-16.el7 for package: 1:openssl-1.0.2k-16.el7.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package krb5-libs.x86_64 0:1.15.1-34.el7 will be updated
---> Package krb5-libs.x86_64 0:1.15.1-37.el7_6 will be an update
---> Package libcom_err-devel.x86_64 0:1.42.9-13.el7 will be installed
---> Package libkadm5.x86_64 0:1.15.1-37.el7_6 will be installed
---> Package libselinux-devel.x86_64 0:2.5-14.1.el7 will be installed
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-14.1.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-14.1.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-14.1.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
---> Package openssl.x86_64 1:1.0.2k-16.el7 will be updated
---> Package openssl.x86_64 1:1.0.2k-16.el7_6.1 will be an update
---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
---> Package perl-Git.noarch 0:1.8.3.1-20.el7 will be installed
---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
---> Package rsync.x86_64 0:3.1.2-6.el7_6.1 will be installed
--> Running transaction check
---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                             Arch                  Version                              Repository              Size
=============================================================================================================================
Installing:
 expat-devel                         x86_64                2.1.0-10.el7_3                       base                    57 k
 gcc                                 x86_64                4.8.5-36.el7_6.2                     updates                 16 M
 gettext-devel                       x86_64                0.19.8.1-2.el7                       base                   320 k
 libcurl-devel                       x86_64                7.29.0-51.el7                        base                   302 k
 openssl-devel                       x86_64                1:1.0.2k-16.el7_6.1                  updates                1.5 M
 zlib-devel                          x86_64                1.2.7-18.el7                         base                    50 k
Installing for dependencies:
 cpp                                 x86_64                4.8.5-36.el7_6.2                     updates                5.9 M
 gettext-common-devel                noarch                0.19.8.1-2.el7                       base                   410 k
 git                                 x86_64                1.8.3.1-20.el7                       updates                4.4 M
 keyutils-libs-devel                 x86_64                1.5.8-3.el7                          base                    37 k
 krb5-devel                          x86_64                1.15.1-37.el7_6                      updates                271 k
 libcom_err-devel                    x86_64                1.42.9-13.el7                        base                    31 k
 libkadm5                            x86_64                1.15.1-37.el7_6                      updates                178 k
 libmpc                              x86_64                1.0.1-3.el7                          base                    51 k
 libselinux-devel                    x86_64                2.5-14.1.el7                         base                   187 k
 libsepol-devel                      x86_64                2.5-10.el7                           base                    77 k
 libverto-devel                      x86_64                0.2.5-4.el7                          base                    12 k
 mpfr                                x86_64                3.1.1-4.el7                          base                   203 k
 pcre-devel                          x86_64                8.32-17.el7                          base                   480 k
 perl-Error                          noarch                1:0.17020-2.el7                      base                    32 k
 perl-Git                            noarch                1.8.3.1-20.el7                       updates                 55 k
 perl-TermReadKey                    x86_64                2.30-20.el7                          base                    31 k
 rsync                               x86_64                3.1.2-6.el7_6.1                      updates                404 k
Updating for dependencies:
 krb5-libs                           x86_64                1.15.1-37.el7_6                      updates                803 k
 libgcc                              x86_64                4.8.5-36.el7_6.2                     updates                102 k
 libgomp                             x86_64                4.8.5-36.el7_6.2                     updates                158 k
 openssl                             x86_64                1:1.0.2k-16.el7_6.1                  updates                493 k
 openssl-libs                        x86_64                1:1.0.2k-16.el7_6.1                  updates                1.2 M

Transaction Summary
=============================================================================================================================
Install  6 Packages (+17 Dependent packages)
Upgrade             (  5 Dependent packages)

Total download size: 34 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/28): expat-devel-2.1.0-10.el7_3.x86_64.rpm                                                         |  57 kB  00:00:00     
(2/28): gettext-devel-0.19.8.1-2.el7.x86_64.rpm                                                       | 320 kB  00:00:00     
(3/28): gettext-common-devel-0.19.8.1-2.el7.noarch.rpm                                                | 410 kB  00:00:00     
(4/28): gcc-4.8.5-36.el7_6.2.x86_64.rpm                                                               |  16 MB  00:00:08     
(5/28): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm                                                    |  37 kB  00:00:00     
(6/28): git-1.8.3.1-20.el7.x86_64.rpm                                                                 | 4.4 MB  00:00:02     
(7/28): krb5-devel-1.15.1-37.el7_6.x86_64.rpm                                                         | 271 kB  00:00:00     
(8/28): libcom_err-devel-1.42.9-13.el7.x86_64.rpm                                                     |  31 kB  00:00:00     
(9/28): krb5-libs-1.15.1-37.el7_6.x86_64.rpm                                                          | 803 kB  00:00:00     
(10/28): libcurl-devel-7.29.0-51.el7.x86_64.rpm                                                       | 302 kB  00:00:00     
(11/28): libgcc-4.8.5-36.el7_6.2.x86_64.rpm                                                           | 102 kB  00:00:00     
(12/28): libgomp-4.8.5-36.el7_6.2.x86_64.rpm                                                          | 158 kB  00:00:00     
(13/28): libkadm5-1.15.1-37.el7_6.x86_64.rpm                                                          | 178 kB  00:00:00     
(14/28): libselinux-devel-2.5-14.1.el7.x86_64.rpm                                                     | 187 kB  00:00:00     
(15/28): libmpc-1.0.1-3.el7.x86_64.rpm                                                                |  51 kB  00:00:00     
(16/28): libsepol-devel-2.5-10.el7.x86_64.rpm                                                         |  77 kB  00:00:00     
(17/28): mpfr-3.1.1-4.el7.x86_64.rpm                                                                  | 203 kB  00:00:00     
(18/28): libverto-devel-0.2.5-4.el7.x86_64.rpm                                                        |  12 kB  00:00:00     
(19/28): openssl-1.0.2k-16.el7_6.1.x86_64.rpm                                                         | 493 kB  00:00:00     
(20/28): openssl-devel-1.0.2k-16.el7_6.1.x86_64.rpm                                                   | 1.5 MB  00:00:00     
(21/28): perl-Error-0.17020-2.el7.noarch.rpm                                                          |  32 kB  00:00:00     
(22/28): openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm                                                    | 1.2 MB  00:00:00     
(23/28): perl-Git-1.8.3.1-20.el7.noarch.rpm                                                           |  55 kB  00:00:00     
(24/28): perl-TermReadKey-2.30-20.el7.x86_64.rpm                                                      |  31 kB  00:00:00     
(25/28): rsync-3.1.2-6.el7_6.1.x86_64.rpm                                                             | 404 kB  00:00:00     
(26/28): zlib-devel-1.2.7-18.el7.x86_64.rpm                                                           |  50 kB  00:00:00     
(27/28): cpp-4.8.5-36.el7_6.2.x86_64.rpm                                                              | 5.9 MB  00:00:14     
(28/28): pcre-devel-8.32-17.el7.x86_64.rpm                                                            | 480 kB  00:00:02     
-----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        2.1 MB/s |  34 MB  00:00:15     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64                                                                  1/33 
  Updating   : krb5-libs-1.15.1-37.el7_6.x86_64                                                                         2/33 
  Installing : mpfr-3.1.1-4.el7.x86_64                                                                                  3/33 
  Installing : libmpc-1.0.1-3.el7.x86_64                                                                                4/33 
  Installing : 1:perl-Error-0.17020-2.el7.noarch                                                                        5/33 
  Installing : cpp-4.8.5-36.el7_6.2.x86_64                                                                              6/33 
  Installing : libkadm5-1.15.1-37.el7_6.x86_64                                                                          7/33 
  Installing : libsepol-devel-2.5-10.el7.x86_64                                                                         8/33 
  Installing : gettext-common-devel-0.19.8.1-2.el7.noarch                                                               9/33 
  Updating   : libgomp-4.8.5-36.el7_6.2.x86_64                                                                         10/33 
  Updating   : libgcc-4.8.5-36.el7_6.2.x86_64                                                                          11/33 
  Installing : zlib-devel-1.2.7-18.el7.x86_64                                                                          12/33 
  Installing : perl-TermReadKey-2.30-20.el7.x86_64                                                                     13/33 
  Installing : libverto-devel-0.2.5-4.el7.x86_64                                                                       14/33 
  Installing : libcom_err-devel-1.42.9-13.el7.x86_64                                                                   15/33 
  Installing : rsync-3.1.2-6.el7_6.1.x86_64                                                                            16/33 
  Installing : perl-Git-1.8.3.1-20.el7.noarch                                                                          17/33 
  Installing : git-1.8.3.1-20.el7.x86_64                                                                               18/33 
  Installing : pcre-devel-8.32-17.el7.x86_64                                                                           19/33 
  Installing : libselinux-devel-2.5-14.1.el7.x86_64                                                                    20/33 
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                  21/33 
  Installing : krb5-devel-1.15.1-37.el7_6.x86_64                                                                       22/33 
  Installing : 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64                                                                23/33 
  Installing : gettext-devel-0.19.8.1-2.el7.x86_64                                                                     24/33 
  Installing : gcc-4.8.5-36.el7_6.2.x86_64                                                                             25/33 
  Updating   : 1:openssl-1.0.2k-16.el7_6.1.x86_64                                                                      26/33 
  Installing : libcurl-devel-7.29.0-51.el7.x86_64                                                                      27/33 
  Installing : expat-devel-2.1.0-10.el7_3.x86_64                                                                       28/33 
  Cleanup    : 1:openssl-1.0.2k-16.el7.x86_64                                                                          29/33 
  Cleanup    : 1:openssl-libs-1.0.2k-16.el7.x86_64                                                                     30/33 
  Cleanup    : krb5-libs-1.15.1-34.el7.x86_64                                                                          31/33 
  Cleanup    : libgomp-4.8.5-36.el7.x86_64                                                                             32/33 
  Cleanup    : libgcc-4.8.5-36.el7.x86_64                                                                              33/33 
  Verifying  : gettext-devel-0.19.8.1-2.el7.x86_64                                                                      1/33 
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                   2/33 
  Verifying  : pcre-devel-8.32-17.el7.x86_64                                                                            3/33 
  Verifying  : gcc-4.8.5-36.el7_6.2.x86_64                                                                              4/33 
  Verifying  : rsync-3.1.2-6.el7_6.1.x86_64                                                                             5/33 
  Verifying  : libcom_err-devel-1.42.9-13.el7.x86_64                                                                    6/33 
  Verifying  : krb5-devel-1.15.1-37.el7_6.x86_64                                                                        7/33 
  Verifying  : expat-devel-2.1.0-10.el7_3.x86_64                                                                        8/33 
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                                                                        9/33 
  Verifying  : perl-TermReadKey-2.30-20.el7.x86_64                                                                     10/33 
  Verifying  : zlib-devel-1.2.7-18.el7.x86_64                                                                          11/33 
  Verifying  : krb5-libs-1.15.1-37.el7_6.x86_64                                                                        12/33 
  Verifying  : perl-Git-1.8.3.1-20.el7.noarch                                                                          13/33 
  Verifying  : libgcc-4.8.5-36.el7_6.2.x86_64                                                                          14/33 
  Verifying  : libgomp-4.8.5-36.el7_6.2.x86_64                                                                         15/33 
  Verifying  : gettext-common-devel-0.19.8.1-2.el7.noarch                                                              16/33 
  Verifying  : 1:openssl-1.0.2k-16.el7_6.1.x86_64                                                                      17/33 
  Verifying  : 1:perl-Error-0.17020-2.el7.noarch                                                                       18/33 
  Verifying  : git-1.8.3.1-20.el7.x86_64                                                                               19/33 
  Verifying  : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64                                                                 20/33 
  Verifying  : libmpc-1.0.1-3.el7.x86_64                                                                               21/33 
  Verifying  : libsepol-devel-2.5-10.el7.x86_64                                                                        22/33 
  Verifying  : 1:openssl-devel-1.0.2k-16.el7_6.1.x86_64                                                                23/33 
  Verifying  : libkadm5-1.15.1-37.el7_6.x86_64                                                                         24/33 
  Verifying  : mpfr-3.1.1-4.el7.x86_64                                                                                 25/33 
  Verifying  : libcurl-devel-7.29.0-51.el7.x86_64                                                                      26/33 
  Verifying  : libselinux-devel-2.5-14.1.el7.x86_64                                                                    27/33 
  Verifying  : cpp-4.8.5-36.el7_6.2.x86_64                                                                             28/33 
  Verifying  : libgcc-4.8.5-36.el7.x86_64                                                                              29/33 
  Verifying  : 1:openssl-libs-1.0.2k-16.el7.x86_64                                                                     30/33 
  Verifying  : 1:openssl-1.0.2k-16.el7.x86_64                                                                          31/33 
  Verifying  : libgomp-4.8.5-36.el7.x86_64                                                                             32/33 
  Verifying  : krb5-libs-1.15.1-34.el7.x86_64                                                                          33/33 

Installed:
  expat-devel.x86_64 0:2.1.0-10.el7_3    gcc.x86_64 0:4.8.5-36.el7_6.2              gettext-devel.x86_64 0:0.19.8.1-2.el7  
  libcurl-devel.x86_64 0:7.29.0-51.el7   openssl-devel.x86_64 1:1.0.2k-16.el7_6.1   zlib-devel.x86_64 0:1.2.7-18.el7       

Dependency Installed:
  cpp.x86_64 0:4.8.5-36.el7_6.2                              gettext-common-devel.noarch 0:0.19.8.1-2.el7                    
  git.x86_64 0:1.8.3.1-20.el7                                keyutils-libs-devel.x86_64 0:1.5.8-3.el7                        
  krb5-devel.x86_64 0:1.15.1-37.el7_6                        libcom_err-devel.x86_64 0:1.42.9-13.el7                         
  libkadm5.x86_64 0:1.15.1-37.el7_6                          libmpc.x86_64 0:1.0.1-3.el7                                     
  libselinux-devel.x86_64 0:2.5-14.1.el7                     libsepol-devel.x86_64 0:2.5-10.el7                              
  libverto-devel.x86_64 0:0.2.5-4.el7                        mpfr.x86_64 0:3.1.1-4.el7                                       
  pcre-devel.x86_64 0:8.32-17.el7                            perl-Error.noarch 1:0.17020-2.el7                               
  perl-Git.noarch 0:1.8.3.1-20.el7                           perl-TermReadKey.x86_64 0:2.30-20.el7                           
  rsync.x86_64 0:3.1.2-6.el7_6.1                            

Dependency Updated:
  krb5-libs.x86_64 0:1.15.1-37.el7_6      libgcc.x86_64 0:4.8.5-36.el7_6.2             libgomp.x86_64 0:4.8.5-36.el7_6.2     
  openssl.x86_64 1:1.0.2k-16.el7_6.1      openssl-libs.x86_64 1:1.0.2k-16.el7_6.1     

Complete!
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

3>.配置git的安装路径

[root@node201.yinzhengjie.org.cn ~]# ll
total 6240
-rw-r--r-- 1 root root 6389118 Mar 24  2017 git-2.12.2.tar.gz
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# tar -zxf git-2.12.2.tar.gz 
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# cd git-2.12.2
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# 
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# ll | wc -l
370
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# 
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# 
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# ll | grep configure
-rwxr-x---  1 110493 5000 247637 Mar 24  2017 configure
-rw-rw-r--  1 root   root  35929 Mar 24  2017 configure.ac
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# 
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# ./configure prefix=/yinzhengjie/softwares/git/
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
configure: CHECKS for programs
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking for inline... inline
checking if linker supports -R... no
checking if linker supports -Wl,-rpath,... yes
checking for gar... no
checking for ar... ar
checking for gtar... gtar
checking for gnudiff... no
checking for gdiff... no
checking for diff... diff
checking for asciidoc... no
Using 'grep -a' for sane_grep
configure: CHECKS for libraries
checking for SHA1_Init in -lcrypto... yes
checking for curl_global_init in -lcurl... yes
checking for curl-config... curl-config
checking if Curl supports SSL... yes
checking for XML_ParserCreate in -lexpat... yes
checking for iconv in -lc... yes
checking for deflateBound in -lz... yes
checking for socket in -lc... yes
checking for inet_ntop... yes
checking for inet_pton... yes
checking for hstrerror... yes
checking for basename in -lc... yes
checking for gettext in -lc... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
configure: CHECKS for header files
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking for inttypes.h... (cached) yes
checking for old iconv()... no
configure: CHECKS for typedefs, structures, and compiler characteristics
checking for socklen_t... yes
checking for struct itimerval... yes
checking for struct stat.st_mtimespec.tv_nsec... no
checking for struct stat.st_mtim.tv_nsec... yes
checking for struct dirent.d_type... yes
checking for struct passwd.pw_gecos... yes
checking for struct sockaddr_storage... yes
checking for struct addrinfo... yes
checking for getaddrinfo... yes
checking for library containing getaddrinfo... none required
checking whether the platform regex supports REG_STARTEND... yes
checking whether system succeeds to read fopen'ed directory... no
checking whether snprintf() and/or vsnprintf() return bogus value... no
checking whether the platform uses typical file type bits... yes
configure: CHECKS for library functions
checking libgen.h usability... yes
checking libgen.h presence... yes
checking for libgen.h... yes
checking paths.h usability... yes
checking paths.h presence... yes
checking for paths.h... yes
checking libcharset.h usability... no
checking libcharset.h presence... no
checking for libcharset.h... no
checking for strings.h... (cached) yes
checking for locale_charset in -liconv... no
checking for locale_charset in -lcharset... no
checking for clock_gettime... yes
checking for library containing clock_gettime... none required
checking for CLOCK_MONOTONIC... yes
checking for setitimer... yes
checking for library containing setitimer... none required
checking for strcasestr... yes
checking for library containing strcasestr... none required
checking for memmem... yes
checking for library containing memmem... none required
checking for strlcpy... no
checking for uintmax_t... yes
checking for strtoumax... yes
checking for library containing strtoumax... none required
checking for setenv... yes
checking for library containing setenv... none required
checking for unsetenv... yes
checking for library containing unsetenv... none required
checking for mkdtemp... yes
checking for library containing mkdtemp... none required
checking for initgroups... yes
checking for library containing initgroups... none required
checking for getdelim... yes
checking for library containing getdelim... none required
checking for BSD sysctl... no
checking for POSIX Threads with ''... no
checking for POSIX Threads with '-mt'... no
checking for POSIX Threads with '-pthread'... yes
configure: creating ./config.status
config.status: creating config.mak.autogen
config.status: executing config.mak.autogen commands
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# echo $?
0
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# 
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# ./configure prefix=/yinzhengjie/softwares/git/

3>.编译git

[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# make -j 4
......
    BUILTIN git-rm
    BUILTIN git-send-pack
    BUILTIN git-shortlog
    BUILTIN git-show-branch
    BUILTIN git-show-ref
    BUILTIN git-stripspace
    BUILTIN git-submodule--helper
    BUILTIN git-symbolic-ref
    BUILTIN git-tag
    BUILTIN git-unpack-file
    BUILTIN git-unpack-objects
    BUILTIN git-update-index
    BUILTIN git-update-ref
    BUILTIN git-update-server-info
    BUILTIN git-upload-archive
    BUILTIN git-var
    BUILTIN git-verify-commit
    BUILTIN git-verify-pack
    BUILTIN git-verify-tag
    BUILTIN git-worktree
    BUILTIN git-write-tree
    BUILTIN git-cherry
    BUILTIN git-cherry-pick
    BUILTIN git-format-patch
    BUILTIN git-fsck-objects
    BUILTIN git-init
    BUILTIN git-merge-subtree
    BUILTIN git-show
    BUILTIN git-stage
    BUILTIN git-status
    BUILTIN git-whatchanged
    SUBDIR git-gui
GITGUI_VERSION = 0.20.0.44.gccc98
    * new locations or Tcl/Tk interpreter
    MSGFMT    po/de.msg     MSGFMT po/pt_pt.msg     MSGFMT    po/vi.msg     MSGFMT    po/hu.msg 520 translated.
550 translated.
    MSGFMT    po/nb.msg 514 translated.
543 translated.
    MSGFMT    po/sv.msg     MSGFMT    po/fr.msg     MSGFMT    po/it.msg 474 translated, 39 untranslated.
547 translated.
    MSGFMT    po/ja.msg 519 translated, 1 untranslated.
520 translated.
    MSGFMT po/pt_br.msg     MSGFMT    po/bg.msg     MSGFMT    po/ru.msg 546 translated, 1 untranslated.
520 translated.
    MSGFMT po/zh_cn.msg     MSGFMT    po/el.msg 565 translated.
520 translated.
    GEN git-gui
    INDEX lib/
366 translated, 7 fuzzy, 17 untranslated.
    * tclsh failed; using unoptimized loading
381 translated, 4 fuzzy, 6 untranslated.
    SUBDIR gitk-git
Generating catalog po/de.msg
Generating catalog po/pt_pt.msg
msgfmt --statistics --tcl po/de.po -l de -d po/
msgfmt --statistics --tcl po/pt_pt.po -l pt_pt -d po/
    * new Tcl/Tk interpreter location
Generating catalog po/vi.msg
Generating catalog po/ca.msg
msgfmt --statistics --tcl po/vi.po -l vi -d po/
307 translated messages.
msgfmt --statistics --tcl po/ca.po -l ca -d po/
311 translated messages.
Generating catalog po/hu.msg
msgfmt --statistics --tcl po/hu.po -l hu -d po/
307 translated messages.
Generating catalog po/es.msg
Generating catalog po/sv.msg
307 translated messages.
msgfmt --statistics --tcl po/es.po -l es -d po/
msgfmt --statistics --tcl po/sv.po -l sv -d po/
Generating catalog po/fr.msg
msgfmt --statistics --tcl po/fr.po -l fr -d po/
277 translated messages, 18 fuzzy translations, 12 untranslated messages.
Generating catalog po/it.msg
msgfmt --statistics --tcl po/it.po -l it -d po/
184 translated messages, 46 fuzzy translations, 77 untranslated messages.
311 translated messages.
Generating catalog po/ja.msg
Generating catalog po/pt_br.msg
msgfmt --statistics --tcl po/ja.po -l ja -d po/
msgfmt --statistics --tcl po/pt_br.po -l pt_br -d po/
311 translated messages.
Generating catalog po/bg.msg
274 translated messages, 17 fuzzy translations, 16 untranslated messages.
msgfmt --statistics --tcl po/bg.po -l bg -d po/
Generating catalog po/ru.msg
msgfmt --statistics --tcl po/ru.po -l ru -d po/
279 translated messages, 16 fuzzy translations, 12 untranslated messages.
311 translated messages.
    GEN gitk-wish
311 translated messages.
317 translated messages.
    SUBDIR perl
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Editor.pm >blib/lib/Git/SVN/Editor.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Migration.pm >blib/lib/Git/SVN/Migration.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Log.pm >blib/lib/Git/SVN/Log.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN.pm >blib/lib/Git/SVN.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Memoize/YAML.pm >blib/lib/Git/SVN/Memoize/YAML.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Ra.pm >blib/lib/Git/SVN/Ra.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/I18N.pm >blib/lib/Git/I18N.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Prompt.pm >blib/lib/Git/SVN/Prompt.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/GlobSpec.pm >blib/lib/Git/SVN/GlobSpec.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Fetcher.pm >blib/lib/Git/SVN/Fetcher.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/IndexInfo.pm >blib/lib/Git/IndexInfo.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Utils.pm >blib/lib/Git/SVN/Utils.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git.pm >blib/lib/Git.pm
Manifying blib/man3/Git::SVN::Editor.3pm
Manifying blib/man3/Git::SVN::Memoize::YAML.3pm
Manifying blib/man3/Git::SVN::Ra.3pm
Manifying blib/man3/Git::I18N.3pm
Manifying blib/man3/Git::SVN::Prompt.3pm
Manifying blib/man3/Git::SVN::Fetcher.3pm
Manifying blib/man3/Git::SVN::Utils.3pm
Manifying blib/man3/Git.3pm
    SUBDIR templates
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]#
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# make -j 4

4>.安装git

[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# make install
    SUBDIR perl
/usr/bin/perl Makefile.PL PREFIX='/yinzhengjie/softwares/git' INSTALL_BASE='' --localedir='/yinzhengjie/softwares/git/share/locale'
Writing perl.mak for Git
    GEN git-add--interactive
    GEN git-archimport
    GEN git-cvsexportcommit
    GEN git-cvsimport
    GEN git-cvsserver
    GEN git-send-email
    GEN git-svn
    SUBDIR git-gui
    SUBDIR gitk-git
    SUBDIR perl
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Editor.pm >blib/lib/Git/SVN/Editor.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Migration.pm >blib/lib/Git/SVN/Migration.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Log.pm >blib/lib/Git/SVN/Log.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN.pm >blib/lib/Git/SVN.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Memoize/YAML.pm >blib/lib/Git/SVN/Memoize/YAML.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Ra.pm >blib/lib/Git/SVN/Ra.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/I18N.pm >blib/lib/Git/I18N.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Prompt.pm >blib/lib/Git/SVN/Prompt.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/GlobSpec.pm >blib/lib/Git/SVN/GlobSpec.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Fetcher.pm >blib/lib/Git/SVN/Fetcher.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/IndexInfo.pm >blib/lib/Git/IndexInfo.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git/SVN/Utils.pm >blib/lib/Git/SVN/Utils.pm
/usr/bin/perl -pe "s<Q++LOCALEDIR++E></yinzhengjie/softwares/git/share/locale>" <Git.pm >blib/lib/Git.pm
    SUBDIR templates
install -d -m 755 '/yinzhengjie/softwares/git/bin'
install -d -m 755 '/yinzhengjie/softwares/git/libexec/git-core'
install   git-credential-store git-daemon git-fast-import git-http-backend git-imap-send git-sh-i18n--envsubst git-shell git-show-index git-upload-pack git-remote-testsvn git-http-fetch git-http-push git-credential-cache git-credential-cache--daemon git-remote-http git-remote-https git-remote-ftp git-remote-ftps git-bisect git-difftool--helper git-filter-branch git-merge-octopus git-merge-one-file git-merge-resolve git-mergetool git-quiltimport git-rebase git-request-pull git-stash git-submodule git-web--browse git-add--interactive git-archimport git-cvsexportcommit git-cvsimport git-cvsserver git-send-email git-svn git-p4 git-instaweb '/yinzhengjie/softwares/git/libexec/git-core'
install -m 644  git-mergetool--lib git-parse-remote git-rebase--am git-rebase--interactive git-rebase--merge git-sh-setup git-sh-i18n '/yinzhengjie/softwares/git/libexec/git-core'
install git git-upload-pack git-receive-pack git-upload-archive git-shell git-cvsserver '/yinzhengjie/softwares/git/bin'
make -C templates DESTDIR='' install
make[1]: Entering directory `/root/git-2.12.2/templates'
install -d -m 755 '/yinzhengjie/softwares/git/share/git-core/templates'
(cd blt && gtar cf - .) | 
(cd '/yinzhengjie/softwares/git/share/git-core/templates' && umask 022 && gtar xof -)
make[1]: Leaving directory `/root/git-2.12.2/templates'
install -d -m 755 '/yinzhengjie/softwares/git/libexec/git-core/mergetools'
install -m 644 mergetools/* '/yinzhengjie/softwares/git/libexec/git-core/mergetools'
install -d -m 755 '/yinzhengjie/softwares/git/share/locale'
(cd po/build/locale && gtar cf - .) | 
(cd '/yinzhengjie/softwares/git/share/locale' && umask 022 && gtar xof -)
make -C perl prefix='/yinzhengjie/softwares/git' DESTDIR='' install
make[1]: Entering directory `/root/git-2.12.2/perl'
make[2]: Entering directory `/root/git-2.12.2/perl'
Installing /yinzhengjie/softwares/git/share/perl5/Git.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/I18N.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/IndexInfo.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Editor.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Migration.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Log.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Ra.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Prompt.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/GlobSpec.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Fetcher.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Utils.pm
Installing /yinzhengjie/softwares/git/share/perl5/Git/SVN/Memoize/YAML.pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git::SVN::Editor.3pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git::SVN::Memoize::YAML.3pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git::SVN::Ra.3pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git::I18N.3pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git::SVN::Prompt.3pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git::SVN::Fetcher.3pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git::SVN::Utils.3pm
Installing /yinzhengjie/softwares/git/share/man/man3/Git.3pm
Appending installation info to /yinzhengjie/softwares/git/lib64/perl5/perllocal.pod
make[2]: Leaving directory `/root/git-2.12.2/perl'
make[1]: Leaving directory `/root/git-2.12.2/perl'
make -C gitweb install
make[1]: Entering directory `/root/git-2.12.2/gitweb'
make[2]: Entering directory `/root/git-2.12.2'
make[2]: `GIT-VERSION-FILE' is up to date.
make[2]: Leaving directory `/root/git-2.12.2'
    GEN gitweb.cgi
    GEN static/gitweb.js
install -d -m 755 '/yinzhengjie/softwares/git/share/gitweb'
install -m 755 gitweb.cgi '/yinzhengjie/softwares/git/share/gitweb'
install -d -m 755 '/yinzhengjie/softwares/git/share/gitweb/static'
install -m 644 static/gitweb.js static/gitweb.css static/git-logo.png static/git-favicon.png '/yinzhengjie/softwares/git/share/gitweb/static'
make[1]: Leaving directory `/root/git-2.12.2/gitweb'
make -C gitk-git install
make[1]: Entering directory `/root/git-2.12.2/gitk-git'
install -d -m 755 '/yinzhengjie/softwares/git/bin'
install -m 755 gitk-wish '/yinzhengjie/softwares/git/bin'/gitk
install -d -m 755 '/yinzhengjie/softwares/git/share/gitk/lib/msgs'
install -m 644 po/de.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/ja.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/sv.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/it.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/hu.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/pt_pt.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/fr.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/pt_br.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/ru.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/ca.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/vi.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/bg.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' &&  install -m 644 po/es.msg '/yinzhengjie/softwares/git/share/gitk/lib/msgs' && true
make[1]: Leaving directory `/root/git-2.12.2/gitk-git'
make -C git-gui gitexecdir='/yinzhengjie/softwares/git/libexec/git-core' install
make[1]: Entering directory `/root/git-2.12.2/git-gui'
  DEST /yinzhengjie/softwares/git/libexec/git-core
    INSTALL 755 git-gui
    INSTALL 755 git-gui--askpass
    LINK        git-citool -> git-gui
  DEST /yinzhengjie/softwares/git/share/git-gui/lib
    INSTALL 644 tclIndex
    INSTALL 644 themed.tcl
    INSTALL 644 line.tcl
    INSTALL 644 console.tcl
    INSTALL 644 checkout_op.tcl
    INSTALL 644 transport.tcl
    INSTALL 644 remote_add.tcl
    INSTALL 644 browser.tcl
    INSTALL 644 tools.tcl
    INSTALL 644 branch_checkout.tcl
    INSTALL 644 spellcheck.tcl
    INSTALL 644 status_bar.tcl
    INSTALL 644 diff.tcl
    INSTALL 644 remote.tcl
    INSTALL 644 choose_font.tcl
    INSTALL 644 option.tcl
    INSTALL 644 mergetool.tcl
    INSTALL 644 tools_dlg.tcl
    INSTALL 644 search.tcl
    INSTALL 644 shortcut.tcl
    INSTALL 644 branch_rename.tcl
    INSTALL 644 class.tcl
    INSTALL 644 remote_branch_delete.tcl
    INSTALL 644 choose_repository.tcl
    INSTALL 644 about.tcl
    INSTALL 644 blame.tcl
    INSTALL 644 branch.tcl
    INSTALL 644 win32.tcl
    INSTALL 644 sshkey.tcl
    INSTALL 644 branch_create.tcl
    INSTALL 644 commit.tcl
    INSTALL 644 branch_delete.tcl
    INSTALL 644 index.tcl
    INSTALL 644 encoding.tcl
    INSTALL 644 logo.tcl
    INSTALL 644 date.tcl
    INSTALL 644 choose_rev.tcl
    INSTALL 644 database.tcl
    INSTALL 644 error.tcl
    INSTALL 644 merge.tcl
    INSTALL 644 git-gui.ico
    INSTALL 644 win32_shortcut.js
  DEST /yinzhengjie/softwares/git/share/git-gui/lib/msgs
    INSTALL 644 pt_br.msg
    INSTALL 644 hu.msg
    INSTALL 644 zh_cn.msg
    INSTALL 644 de.msg
    INSTALL 644 sv.msg
    INSTALL 644 it.msg
    INSTALL 644 ja.msg
    INSTALL 644 pt_pt.msg
    INSTALL 644 fr.msg
    INSTALL 644 ru.msg
    INSTALL 644 el.msg
    INSTALL 644 vi.msg
    INSTALL 644 bg.msg
    INSTALL 644 nb.msg
make[1]: Leaving directory `/root/git-2.12.2/git-gui'
bindir=$(cd '/yinzhengjie/softwares/git/bin' && pwd) && 
execdir=$(cd '/yinzhengjie/softwares/git/libexec/git-core' && pwd) && 
{ test "$bindir/" = "$execdir/" || 
  for p in git git-shell git-upload-pack git-cvsserver; do 
        rm -f "$execdir/$p" && 
        test -z "" && 
        ln "$bindir/$p" "$execdir/$p" 2>/dev/null || 
        cp "$bindir/$p" "$execdir/$p" || exit; 
  done; 
} && 
for p in git-receive-pack git-upload-archive; do 
        rm -f "$bindir/$p" && 
        test -z "" && 
        ln "$bindir/git" "$bindir/$p" 2>/dev/null || 
        ln -s "git" "$bindir/$p" 2>/dev/null || 
        cp "$bindir/git" "$bindir/$p" || exit; 
done && 
for p in  git-add git-am git-annotate git-apply git-archive git-bisect--helper git-blame git-branch git-bundle git-cat-file git-check-attr git-check-ignore git-check-mailmap git-check-ref-format git-checkout-index git-checkout git-clean git-clone git-column git-commit-tree git-commit git-config git-count-objects git-credential git-describe git-diff-files git-diff-index git-diff-tree git-diff git-difftool git-fast-export git-fetch-pack git-fetch git-fmt-merge-msg git-for-each-ref git-fsck git-gc git-get-tar-commit-id git-grep git-hash-object git-help git-index-pack git-init-db git-interpret-trailers git-log git-ls-files git-ls-remote git-ls-tree git-mailinfo git-mailsplit git-merge git-merge-base git-merge-file git-merge-index git-merge-ours git-merge-recursive git-merge-tree git-mktag git-mktree git-mv git-name-rev git-notes git-pack-objects git-pack-redundant git-pack-refs git-patch-id git-prune-packed git-prune git-pull git-push git-read-tree git-receive-pack git-reflog git-remote git-remote-ext git-remote-fd git-repack git-replace git-rerere git-reset git-rev-list git-rev-parse git-revert git-rm git-send-pack git-shortlog git-show-branch git-show-ref git-stripspace git-submodule--helper git-symbolic-ref git-tag git-unpack-file git-unpack-objects git-update-index git-update-ref git-update-server-info git-upload-archive git-var git-verify-commit git-verify-pack git-verify-tag git-worktree git-write-tree git-cherry git-cherry-pick git-format-patch git-fsck-objects git-init git-merge-subtree git-show git-stage git-status git-whatchanged; do 
        rm -f "$execdir/$p" && 
        test -z "" && 
        ln "$execdir/git" "$execdir/$p" 2>/dev/null || 
        ln -s "git" "$execdir/$p" 2>/dev/null || 
        cp "$execdir/git" "$execdir/$p" || exit; 
done && 
remote_curl_aliases="git-remote-https git-remote-ftp git-remote-ftps" && 
for p in $remote_curl_aliases; do 
        rm -f "$execdir/$p" && 
        test -z "" && 
        ln "$execdir/git-remote-http" "$execdir/$p" 2>/dev/null || 
        ln -s "git-remote-http" "$execdir/$p" 2>/dev/null || 
        cp "$execdir/git-remote-http" "$execdir/$p" || exit; 
done && 
./check_bindir "z$bindir" "z$execdir" "$bindir/git-add"
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# echo $?
0
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# 
[root@node201.yinzhengjie.org.cn ~/git-2.12.2]# make install

5>.为git配置环境变量

[root@node201.yinzhengjie.org.cn ~]# tail -3 /etc/profile
#ADD git PATH by yinzhengjie
GIT_HOME=/yinzhengjie/softwares/git
PATH=$PATH:$GIT_HOME/bin
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# source /etc/profile
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# git version
git version 2.12.2
[root@node201.yinzhengjie.org.cn ~]# 

 6>.配置Git

[root@node201.yinzhengjie.org.cn ~]# git config --list                            #查看全局配置信息,等效于"git config -l"
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# git config --global user.name "yinzhengjie"                   #提交git用户信息,即配置使用者git的用户
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# git config --global user.email "y1053419035@qq.com"          #提交邮箱,即配置git使用的邮箱
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# git config --global color.ui true                      #显示语法高亮
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# git config --list         
user.name=yinzhengjie
user.email=y1053419035@qq.com
color.ui=true
[root@node201.yinzhengjie.org.cn ~]#


  关于git命令的基本使用博主推荐阅读:https://www.cnblogs.com/yinzhengjie/p/9545646.html

四.三.安装MySQL数据库(如果你要是用Gerrit默认的数据库则不需要执行这一步)

  安装Mysql 5.7详情请参考:https://www.cnblogs.com/yinzhengjie/p/10371899.html
[root@node201.yinzhengjie.org.cn ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> 
mysql> SELECT USER();                                                  #查看当前登陆用户
+----------------+
| USER()         |
+----------------+
| root@localhost |
+----------------+
row in set (0.01 sec)

mysql> 
mysql> 
mysql> CREATE DATABASE gerrit DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;          #创建数据库,并制定默认的字符编码及排序规则
Query OK, 1 row affected (0.00 sec)

mysql> 
mysql> CREATE USER gerrit@'172.30.1.20%' IDENTIFIED WITH mysql_native_password BY 'yinzhengjie';      #创建一个'gerrit'@'172.30.1.20%'的用户
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> GRANT ALL PRIVILEGES ON gerrit.* TO gerrit@'172.30.1.20%';                        #为我们刚刚创建的用户授权。
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> FLUSH PRIVILEGES;                                                 #刷新权限。
Query OK, 0 rows affected (0.00 sec)

mysql> 
mysql> SELECT user,host,plugin FROM mysql.user;                                   #查看创建的用户是否在user列表
+---------------+--------------+-----------------------+
| user          | host         | plugin                |
+---------------+--------------+-----------------------+
| root          | localhost    | mysql_native_password |
| mysql.session | localhost    | mysql_native_password |
| mysql.sys     | localhost    | mysql_native_password |
| gerrit        | 172.30.1.20% | mysql_native_password |
+---------------+--------------+-----------------------+
rows in set (0.00 sec)

mysql> 
mysql> QUIT
Bye
You have new mail in /var/spool/mail/root
[root@node201.yinzhengjie.org.cn ~]#
[root@node203.yinzhengjie.org.cn ~]# mysql -ugerrit -h node201.yinzhengjie.org.cn -pyinzhengjie
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 6
Server version: 5.7.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| gerrit             |
+--------------------+
2 rows in set (0.00 sec)

mysql> 
mysql> QUIT
Bye
[root@node203.yinzhengjie.org.cn ~]# 
[root@node203.yinzhengjie.org.cn ~]# mysql -ugerrit -h node201.yinzhengjie.org.cn -pyinzhengjie      #测试连通性

五.部署Gerrit

1>.创建gerrit用户

[root@node201.yinzhengjie.org.cn ~]# useradd -d /yinzhengjie/softwares/gerrit gerrit
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/gerrit/
total 0
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# ll -d /yinzhengjie/softwares/gerrit/
drwx------ 2 gerrit gerrit 62 Jun 17 06:15 /yinzhengjie/softwares/gerrit/
[root@node201.yinzhengjie.org.cn ~]# 

2>.切换到gerrit的家目录

[root@node201.yinzhengjie.org.cn ~]# su gerrit
[gerrit@node201.yinzhengjie.org.cn /root]$ cd
[gerrit@node201.yinzhengjie.org.cn ~]$ 
[gerrit@node201.yinzhengjie.org.cn ~]$ pwd
/yinzhengjie/softwares/gerrit
[gerrit@node201.yinzhengjie.org.cn ~]$ 
[gerrit@node201.yinzhengjie.org.cn ~]$ ll
total 0
[gerrit@node201.yinzhengjie.org.cn ~]$ 

3>.下载Gerrit2.15.14版本

[gerrit@node201.yinzhengjie.org.cn ~]# wget https://gerrit-releases.storage.googleapis.com/gerrit-2.15.14.war

4>.安装Gerrit

[gerrit@node201.yinzhengjie.org.cn ~]$ mkdir soft && mv gerrit-2.15.14.war soft/ && cd soft
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ll
total 72204
-rw-r--r-- 1 gerrit gerrit 73935344 Jun 17 05:17 gerrit-2.15.14.war
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ java -jar gerrit-2.15.14.war init 
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2019-06-17 06:24:32,976] [main] INFO  com.google.gerrit.server.config.GerritServerConfigProvider : No /yinzhengjie/softwares/gerrit/./etc/gerrit.config; assuming defaults

*** Gerrit Code Review 2.15.14
*** 


*** Git Repositories
*** 

Location of Git repositories   [git]:         #指定gerrit存储库的位置,我们可以自定义存储路径,以后我们在Gerrit上创建的存储库都会在我们指定的这个路径中。

*** SQL Database
*** 

Database server type           [h2]: ?        #默认使用h2数据库,我并不推荐大家使用咱们不熟悉的数据库,因此我们可以输入"?"查看gerrit都支持哪些数据库
       Supported options are:
         db2
         derby
         h2
         hana
         jdbc
         mariadb
         maxdb
         mysql
         oracle
         postgresql
Database server type           [h2]: mysql     #我们这里选择MySQL数据库,我们在前面已经安装了数据库并配置了相应的权限

Gerrit Code Review is not shipped with MySQL Connector/J 5.1.43    
**  This library is required for your configuration. **
Download and install it now [Y/n]? y        #这里是在询问我们是否要下载MySQL的连接器,想必大家也都知道他是干嘛的,没错,就是链接数据库用的驱动包而已,因此我们这里要输入"y"他会自动去下载
Downloading https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.43/mysql-connector-java-5.1.43.jar ... OK
Checksum mysql-connector-java-5.1.43.jar OK    #很显然,这里提示驱动下载完成啦
Server hostname                [localhost]: node201.yinzhengjie.org.cn    #这里输入MySQL的主机名
Server port                    [(mysql default)]: 3306              #这里输入MySQL的默认端口
Database name                  [reviewdb]: gerrit                 #这里输入MySQL的存放数据的数据库名称
Database username              [gerrit]:                         #这里输入MySQL的用户名,默认就是gerrit,没错,我们创建用户时指定的yoghurt就是Gerrit,因此这里回车即可
gerrit's password              :                           #这里需要输入2次链接数据库的密码
              confirm password : 

*** Index
*** 

Type                           [lucene/?]:      #选择索引类型,我们默认使用lucene即可,如果不知道使用
       Supported options are:
         lucene
         elasticsearch

*** User Authentication
*** 

Authentication method          [openid/?]: ?    #查看支持的认证类型
       Supported options are:
         openid
         openid_sso
         http
         http_ldap
         client_ssl_cert_ldap
         ldap
         ldap_bind
         custom_extension
         development_become_any_account
         oauth
Authentication method          [openid/?]: development_become_any_account    #第一次安装我们选择这种模式,用这种模式我们可以去整一个管理员。
Enable signed push support     [y/N]? n      #是否启用签名的推送支持

*** Review Labels
*** 

Install Verified label         [y/N]? y     #安装已验证标签,即进行校验。

*** Email Delivery
*** 

SMTP server hostname           [localhost]: smtp.qq.com      #输入自动发送邮箱的SMTP服务器
SMTP server port               [(default)]: 465           #465/994是SSL协议端口,25是非SSL协议端口
SMTP encryption                [none/?]: SSL             #如果上一步输入的是465/994,此处输入SSL,否则直接回车即可
SMTP username                  [gerrit]: y1053419035@qq.com    #这里的SMTP的用户名为你用来发送邮箱的账号
y1053419035@qq.com's password  :                    #需要输入2授权码验证,注意,它是邮箱的授权码,而非邮箱密码!QQ邮箱有获取授权码的链接教程,感兴趣的小伙伴可以戳进去看看。
              confirm password : 

*** Container Process
*** 

Run as                         [gerrit]:               #指定运行gerrite程序的运行用户,默认是当前用户,我们默认即可
Java runtime                   [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre]:     #JAVA的运行环境,如果它识别有误,你可以只当你服务器的运行环境
Copy gerrit-2.15.14.war to ./bin/gerrit.war [Y/n]? Y        #拷贝gerrit安装包
Copying gerrit-2.15.14.war to ./bin/gerrit.war

*** SSH Daemon
*** 

Listen on address              [*]: node201.yinzhengjie.org.cn  #指定SSH后台服务器的监听地址
Listen on port                 [29418]:                #只当SSH后台服务的端口号
Generating SSH host key ... rsa... dsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done

*** HTTP Daemon
*** 

Behind reverse proxy           [y/N]? N                  #是否使用反向代理
Use SSL (https://)             [y/N]? N                  #不使用SSL
Listen on address              [*]: node201.yinzhengjie.org.cn    #指定gerrit监听地址
Listen on port                 [8080]:                    #只当gerrit的服务端口
Canonical URL                  [http://node201.yinzhengjie.org.cn:8080/]:   http://172.30.1.201:8080    #指定访问的URL,我们默认也是可以的

*** Cache
*** 


*** Plugins
*** 

Installing plugins.
Install plugin commit-message-length-validator version v2.15.14 [y/N]? Y    #接下来就是询问我们是否安装插件,一路输入"Y"即可~
Installed commit-message-length-validator v2.15.14
Install plugin download-commands version v2.15.14 [y/N]? Y
Installed download-commands v2.15.14
Install plugin hooks version v2.15.14 [y/N]? Y
Installed hooks v2.15.14
Install plugin replication version v2.15.14 [y/N]? Y
Installed replication v2.15.14
Install plugin reviewnotes version v2.15.14 [y/N]? Y
Installed reviewnotes v2.15.14
Install plugin singleusergroup version v2.15.14 [y/N]? Y
Installed singleusergroup v2.15.14
Initializing plugins.

*** Experimental features
*** 

Enable any experimental features [y/N]? Y
Default to PolyGerrit UI       [Y/n]? Y
Enable GWT UI                  [Y/n]? Y

Mon Jun 17 08:34:53 EDT 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Mon Jun 17 08:34:54 EDT 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Mon Jun 17 08:34:55 EDT 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

*** Gerrit Administrator
*** 

Create administrator user      [Y/n]? Y         #是否创建管理员用哦过户
username                       [admin]:         #指定用户名,默认是admin
name                           [Administrator]: 
HTTP password                  [secret]: admin    #指定HTTP的密码
public SSH key file            []: 
email                          [admin@example.com]: y1053419035@qq.com  #指定邮箱地址
Initialized /yinzhengjie/softwares/gerrit/soft
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 

  如果你使用的MySQL 5.7版本作为Gerrit的数据库可能会抛出以下异常:(手动创建出对应的表后,我们就会)

mysql> CREATE TABLE account_group_by_id_aud (added_by INT DEFAULT 0 NOT NULL, removed_by INT, removed_on TIMESTAMP NULL DEFAULT NULL, group_id INT DEFAULT 0 NOT NULL, include_uuid VARCHAR(255) BINARY DEFAULT '' NOT NULL, added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(group_id,include_uuid,added_on));
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql>  CREATE TABLE account_group_members_audit (added_by INT DEFAULT 0 NOT NULL, removed_by INT, removed_on TIMESTAMP NULL DEFAULT NULL, account_id INT DEFAULT 0 NOT NULL, group_id INT DEFAULT 0 NOT NULL, added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(account_id,group_id,added_on));
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql> 



参考链接:https://my.oschina.net/hopeMan/blog/1543780
mysql> CREATE TABLE changes (change_key VARCHAR(60) BINARY DEFAULT '' NOT NULL, created_on TIMESTAMP NOT NULL, last_updated_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, owner_account_id INT DEFAULT 0 NOT NULL, dest_project_name VARCHAR(255) BINARY DEFAULT '' NOT NULL, dest_branch_name VARCHAR(255) BINARY DEFAULT '' NOT NULL, status CHAR(1) DEFAULT ' ' NOT NULL, current_patch_set_id INT DEFAULT 0 NOT NULL, subject VARCHAR(255) BINARY DEFAULT '' NOT NULL, topic VARCHAR(255) BINARY, original_subject VARCHAR(255) BINARY, submission_id VARCHAR(255) BINARY, note_db_state TEXT, row_version INT DEFAULT 0 NOT NULL, change_id INT DEFAULT 0 NOT NULL ,PRIMARY KEY(change_id));
Query OK, 0 rows affected (0.01 sec)

mysql> 
解决方案:手动创建失败的表(详情请戳我)

 

[gerrit@node201.yinzhengjie.org.cn ~/soft]$ java -jar gerrit-2.15.14.war init  -d review-site      #使用-d参数会指定安装的文件都存在在当前目录的review-site的包中,否则他会把所偶的文件都解压到当前目录中哟~

 

六.启动Gerrit服务

1>.运行启动命令

[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh  status
Checking arguments to Gerrit Code Review:
  GERRIT_SITE            =  /yinzhengjie/softwares/gerrit/soft
  GERRIT_CONFIG          =  /yinzhengjie/softwares/gerrit/soft/etc/gerrit.config
  GERRIT_PID             =  /yinzhengjie/softwares/gerrit/soft/logs/gerrit.pid
  GERRIT_TMP             =  /yinzhengjie/softwares/gerrit/soft/tmp
  GERRIT_WAR             =  /yinzhengjie/softwares/gerrit/soft/bin/gerrit.war
  GERRIT_FDS             =  1024
  GERRIT_USER            =  gerrit
  GERRIT_STARTUP_TIMEOUT =  90
  JAVA                   =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java
  JAVA_OPTIONS           =  
  RUN_EXEC               =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview
  RUN_ARGS               =  -jar /yinzhengjie/softwares/gerrit/soft/bin/gerrit.war daemon -d /yinzhengjie/softwares/gerrit/soft

[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh status      #启动前
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh  start
Starting Gerrit Code Review: WARNING: Could not adjust Gerrit's process for the kernel's out-of-memory killer.
         This may be caused by ./bin/gerrit.sh not being run as root.
         Consider changing the OOM score adjustment manually for Gerrit's PID=33791 with e.g.:
         echo '-1000' | sudo tee /proc/33791/oom_score_adj
OK
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh  status
Checking arguments to Gerrit Code Review:
  GERRIT_SITE            =  /yinzhengjie/softwares/gerrit/soft
  GERRIT_CONFIG          =  /yinzhengjie/softwares/gerrit/soft/etc/gerrit.config
  GERRIT_PID             =  /yinzhengjie/softwares/gerrit/soft/logs/gerrit.pid
  GERRIT_TMP             =  /yinzhengjie/softwares/gerrit/soft/tmp
  GERRIT_WAR             =  /yinzhengjie/softwares/gerrit/soft/bin/gerrit.war
  GERRIT_FDS             =  1024
  GERRIT_USER            =  gerrit
  GERRIT_STARTUP_TIMEOUT =  90
  JAVA                   =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java
  JAVA_OPTIONS           =  
  RUN_EXEC               =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview
  RUN_ARGS               =  -jar /yinzhengjie/softwares/gerrit/soft/bin/gerrit.war daemon -d /yinzhengjie/softwares/gerrit/soft

Gerrit running pid=33791
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh status     #启动后

2>.查看运行状态

[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ss -ntl
State      Recv-Q Send-Q                                   Local Address:Port                                                  Peer Address:Port              
LISTEN     0      50                                        172.30.1.201:29418                                                            *:*                  
LISTEN     0      50                                        172.30.1.201:8080                                                             *:*                  
LISTEN     0      128                                                  *:22                                                               *:*                  
LISTEN     0      100                                          127.0.0.1:25                                                               *:*                  
LISTEN     0      80                                                  :::3306                                                            :::*                  
LISTEN     0      128                                                 :::22                                                              :::*                  
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 

3>.访问WebUI

七.制作gerrit systemd启动脚本

1>.编写脚本

[root@node201.yinzhengjie.org.cn ~]# cat /usr/lib/systemd/system/gerrit.service
[Unit]
Description=Web based code review and project management for Git based projects
After=network.target

[Service]
Type=forking
User=gerrit
EnvironmentFile=/yinzhengjie/softwares/gerrit/soft/etc/gerrit.config
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=gerrit
ExecStart=/yinzhengjie/softwares/gerrit/soft/bin/gerrit.sh start
ExecStop=/yinzhengjie/softwares/gerrit/soft/bin/gerrit.sh stop
PIDFile=/yinzhengjie/softwares/gerrit/soft/logs/gerrit.pid

[Install]
WantedBy=multi-user.target
[root@node201.yinzhengjie.org.cn ~]# 

2>.添加权限

[root@node201.yinzhengjie.org.cn ~]# ll /usr/lib/systemd/system/gerrit.service
-rw-r--r-- 1 root root 505 Jun 18 07:48 /usr/lib/systemd/system/gerrit.service
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# chmod u+x /usr/lib/systemd/system/gerrit.service
[root@node201.yinzhengjie.org.cn ~]# 
[root@node201.yinzhengjie.org.cn ~]# ll /usr/lib/systemd/system/gerrit.service
-rwxr--r-- 1 root root 505 Jun 18 07:48 /usr/lib/systemd/system/gerrit.service
[root@node201.yinzhengjie.org.cn ~]# 

3>.停止Gerrit服务

[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh stop
Stopping Gerrit Code Review: OK
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh status
Checking arguments to Gerrit Code Review:
  GERRIT_SITE            =  /yinzhengjie/softwares/gerrit/soft
  GERRIT_CONFIG          =  /yinzhengjie/softwares/gerrit/soft/etc/gerrit.config
  GERRIT_PID             =  /yinzhengjie/softwares/gerrit/soft/logs/gerrit.pid
  GERRIT_TMP             =  /yinzhengjie/softwares/gerrit/soft/tmp
  GERRIT_WAR             =  /yinzhengjie/softwares/gerrit/soft/bin/gerrit.war
  GERRIT_FDS             =  1024
  GERRIT_USER            =  gerrit
  GERRIT_STARTUP_TIMEOUT =  90
  JAVA                   =  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre/bin/java
  JAVA_OPTIONS           =  
  RUN_EXEC               =  /usr/bin/perl -e '$x=$ENV{JAVA};exec $x @ARGV;die $!' -- GerritCodeReview
  RUN_ARGS               =  -jar /yinzhengjie/softwares/gerrit/soft/bin/gerrit.war daemon -d /yinzhengjie/softwares/gerrit/soft

[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ss -ntl
State       Recv-Q Send-Q                                                   Local Address:Port                                                                  Peer Address:Port              
LISTEN      0      128                                                                  *:22                                                                               *:*                  
LISTEN      0      100                                                          127.0.0.1:25                                                                               *:*                  
LISTEN      0      80                                                                  :::3306                                                                            :::*                  
LISTEN      0      128                                                                 :::22                                                                              :::*                  
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 

4>.使用自定义脚本启动Gerrit服务

[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ./bin/gerrit.sh stop
Stopping Gerrit Code Review: OK
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ systemctl start gerrit
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: Jason Yin (jason)
Password: 
==== AUTHENTICATION COMPLETE ===
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ systemctl status gerrit
● gerrit.service - Web based code review and project management for Git based projects
   Loaded: loaded (/usr/lib/systemd/system/gerrit.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-06-18 13:18:52 EDT; 13s ago
  Process: 23985 ExecStart=/yinzhengjie/softwares/gerrit/soft/bin/gerrit.sh start (code=exited, status=0/SUCCESS)
 Main PID: 24014 (java)
   CGroup: /system.slice/gerrit.service
           └─24014 GerritCodeReview -jar /yinzhengjie/softwares/gerrit/soft/bin/gerrit.war daemon -d /yinzhengjie/softwares/gerrit/soft --run-id=1560878325.23985
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ ss -ntl
State       Recv-Q Send-Q                                                   Local Address:Port                                                                  Peer Address:Port              
LISTEN      0      50                                                        172.30.1.201:29418                                                                            *:*                  
LISTEN      0      50                                                        172.30.1.201:8080                                                                             *:*                  
LISTEN      0      128                                                                  *:22                                                                               *:*                  
LISTEN      0      100                                                          127.0.0.1:25                                                                               *:*                  
LISTEN      0      80                                                                  :::3306                                                                            :::*                  
LISTEN      0      128                                                                 :::22                                                                              :::*                  
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 
[gerrit@node201.yinzhengjie.org.cn ~/soft]$ 

5>.遇到的问题 (下面是查看系统日志的相关报错)

问题分析:
  编译安装的git貌似我们在编写启动脚本时,systemd进程识别不到,可以是路径问题。


解决方案:
  最简单的解决方案就是使用yum方式安装,问题自然迎刃而解。
  [root@node201.yinzhengjie.org.cn ~]# yum -y install git

总结:
   好像 gerrit 服务器端,使用1.8就行 
    [root@node201.yinzhengjie.org.cn ~]# git --version
    git version 1.8.3.1
    [root@node201.yinzhengjie.org.cn ~]#
   只有客户端的git才要求1.8以上,因为我之前在使用gerrit3.0版本时,使用git1.8会报错哟~

启动服务时,我们应该查看日志信息,如果启动成功会有以下日志输出:
  

[root@node201.yinzhengjie.org.cn ~]# tail -100f /var/log/messages

原文地址:https://www.cnblogs.com/yinzhengjie/p/11013878.html