最新版 Gerrit 3.5.0.1 详细安装配置指南

                          最新版 Gerrit 3.5.0.1 详细安装配置指南

1、前言

2021/07/21 15:41   本人发布过一篇 ” Ubuntu 20.04 + Gerrit 3.4.0 + nginx 1.18.0 安装配置指南 “ 。

原文链接如下:   https://my.oschina.net/sh021/blog/5138883      阅读数 2.9K,我看 Gerrit 新版本又有了新的发布与改进,今天继续分享最新版本的详细安装配置指南,希望对各位有帮助。

2、系统平台

  • 操作系统:Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-91-generic x86_64)、

安装系统之前,首先要执行系统更新,执行如下两条指令:

$ sudo apt-get update
$ sudo apt-get -y upgrade
 

  • 代码审查系统Gerrit 3.5.0.1  直接官网选择下载

检查 JDK 版本及代理服务器版本

查看官方安装说明要求

3、执行安装

 按官方说明文档,执行安装指令:  $java -jar gerrit-3.5.0.1.war init -d /home/scm/review_site_path

 完整的安装配置指令如下:
$ java -jar gerrit-3.5.0.1.war init -d /home/scm/review_site_path
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2021-12-22 02:40:14,098] [main] INFO  com.google.gerrit.server.config.GerritServerConfigProvider : No /home/scm/review_site_path/etc/gerrit.config; assumi                              ng defaults

*** Gerrit Code Review 3.5.0.1
***

Create '/home/scm/review_site_path' [Y/n]? Y

*** Git Repositories
***

Location of Git repositories   [git]: git

*** JGit Configuration
***

Auto-configured "receive.autogc = false" to disable auto-gc after git-receive-pack.

*** Index
***

Type                           [lucene]:

*** User Authentication
***

Authentication method          [openid/?]: http
Get username from custom HTTP header [y/N]? N
SSO logout URL                 :
Enable signed push support     [y/N]?
Use case insensitive usernames [Y/n]?

*** Review Labels
***

Install Verified label         [y/N]? y

*** Email Delivery
***

SMTP server hostname           [localhost]:
SMTP server port               [(default)]:
SMTP encryption                [none/?]:
SMTP username                  :

*** Container Process
***

Run as                         [scm]:
Java runtime                   [/usr/local/jdk-11.0.10]:
Copy gerrit-3.5.0.1.war to /home/scm/review_site_path/bin/gerrit.war [Y/n]? Y
Copying gerrit-3.5.0.1.war to /home/scm/review_site_path/bin/gerrit.war

*** SSH Daemon
***

Listen on address              [*]:
Listen on port                 [29418]:
Generating SSH host key ... rsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done

*** HTTP Daemon
***

Behind reverse proxy           [y/N]? y
Proxy uses SSL (https://)      [y/N]?
Subdirectory on proxy server   [/]:
Listen on address              [*]:
Listen on port                 [8081]:
Canonical URL                  [http://scm/]: http://192.168.23.128

*** Cache
***


*** Plugins
***

Installing plugins.
Install plugin codemirror-editor version v3.5.0.1 [y/N]? y
Installed codemirror-editor v3.5.0.1
Install plugin commit-message-length-validator version v3.5.0.1 [y/N]? y
Installed commit-message-length-validator v3.5.0.1
Install plugin delete-project version v3.5.0.1 [y/N]? y
Installed delete-project v3.5.0.1
Install plugin download-commands version v3.5.0.1 [y/N]? y
Installed download-commands v3.5.0.1
Install plugin gitiles version v3.5.0.1 [y/N]? y
Installed gitiles v3.5.0.1
Install plugin hooks version v3.5.0.1 [y/N]? y
Installed hooks v3.5.0.1
Install plugin plugin-manager version v3.5.0.1 [y/N]? y
Installed plugin-manager v3.5.0.1
Install plugin replication version v3.5.0.1 [y/N]? y
Installed replication v3.5.0.1
Install plugin reviewnotes version v3.5.0.1 [y/N]? y
Installed reviewnotes v3.5.0.1
Install plugin singleusergroup version v3.5.0.1 [y/N]? y
Installed singleusergroup v3.5.0.1
Install plugin webhooks version v3.5.0.1 [y/N]? y
Installed webhooks v3.5.0.1
Initializing plugins.

============================================================================
Welcome to the Gerrit community

Find more information on the homepage: https://www.gerritcodereview.com
Discuss Gerrit on the mailing list: https://groups.google.com/g/repo-discuss
============================================================================
Initialized /home/scm/review_site_path
Init complete, reindexing accounts with: reindex --site-path /home/scm/review_site_path --threads 1 --index accountsReindexed 0 documents in accounts index                               in 0.0s (0.0/s)
Index accounts in version 11 is ready
Cache Statistics at the end of reindexing accounts
  Name                          |Entries              |  AvgGet |Hit Ratio|
                                |   Mem   Disk   Space|         |Mem  Disk|
--------------------------------+---------------------+---------+---------+
  groups_external               |                     |         |         |
  groups_bysubgroup             |                     |         |         |
  change_notes                  |                     |         |         |
  groups_byuuid                 |                     |         |         |
  default_preferences           |                     |         |         |
  prolog_rules                  |                     |         |         |
  groups                        |                     |         |         |
  projects                      |                     |         |         |
  groups_byname                 |                     |         |         |
  groups_external_persisted     |                     |         |         |
  groups_bymember               |                     |         |         |
  project_list                  |                     |         |         |
  permission_sort               |                     |         |         |
  external_ids_map              |                     |         |         |
D diff_summary                  |                0.00k|         |         |
D pure_revert                   |                0.00k|         |         |
D groups_byuuid_persisted       |                0.00k|         |         |
D change_kind                   |                0.00k|         |         |
D mergeability                  |                0.00k|         |         |
D conflicts                     |                0.00k|         |         |
D diff_intraline                |                0.00k|         |         |
D approvals                     |                0.00k|         |         |
D git_tags                      |                0.00k|         |         |
D gerrit_file_diff              |                0.00k|         |         |
D git_file_diff                 |                0.00k|         |         |
D accounts                      |                0.00k|         |         |
D persisted_projects            |                0.00k|         |         |
D git_modified_files            |                0.00k|         |         |
D modified_files                |                0.00k|         |         |

Collecting projects:    2 changes with: reindex --site-path /home/scm/review_site_path --threads 1 --index changes
Reindexing changes: done
Reindexed 0 documents in changes index in 0.0s (0.0/s)
Index changes in version 71 is ready
Cache Statistics at the end of reindexing changes
  Name                          |Entries              |  AvgGet |Hit Ratio|
                                |   Mem   Disk   Space|         |Mem  Disk|
--------------------------------+---------------------+---------+---------+
  groups_external               |                     |         |         |
  groups_bysubgroup             |                     |         |         |
  change_notes                  |                     |         |         |
  groups_byuuid                 |                     |         |         |
  default_preferences           |                     |         |         |
  prolog_rules                  |                     |         |         |
  groups                        |                     |         |         |
  projects                      |                     |         |         |
  groups_byname                 |                     |         |         |
  groups_external_persisted     |                     |         |         |
  groups_bymember               |                     |         |         |
  project_list                  |     1               |   2.3ms | 50%     |
  permission_sort               |                     |         |         |
  external_ids_map              |                     |         |         |
D diff_summary                  |                0.00k|         |         |
D pure_revert                   |                0.00k|         |         |
D groups_byuuid_persisted       |                0.00k|         |         |
D change_kind                   |                0.00k|         |         |
D mergeability                  |                0.00k|         |         |
D conflicts                     |                0.00k|         |         |
D diff_intraline                |                0.00k|         |         |
D approvals                     |                0.00k|         |         |
D git_tags                      |                0.00k|         |         |
D gerrit_file_diff              |                0.00k|         |         |
D git_file_diff                 |                0.00k|         |         |
D accounts                      |                0.00k|         |         |
D persisted_projects            |                0.00k|         |         |
D git_modified_files            |                0.00k|         |         |
D modified_files                |                0.00k|         |         |

Reindexing groups:      100% (2/2)ith: reindex --site-path /home/scm/review_site_path --threads 1 --index groups
Reindexed 2 documents in groups index in 0.1s (18.0/s)
Index groups in version 8 is ready
Cache Statistics at the end of reindexing groups
  Name                          |Entries              |  AvgGet |Hit Ratio|
                                |   Mem   Disk   Space|         |Mem  Disk|
--------------------------------+---------------------+---------+---------+
  groups_external               |                     |         |         |
  groups_bysubgroup             |                     |         |         |
  change_notes                  |                     |         |         |
  groups_byuuid                 |                     |  97.4ms |  0%     |
  default_preferences           |                     |         |         |
  prolog_rules                  |                     |         |         |
  groups                        |                     |         |         |
  projects                      |                     |         |         |
  groups_byname                 |                     |         |         |
  groups_external_persisted     |                     |         |         |
  groups_bymember               |                     |         |         |
  project_list                  |                     |         |         |
  permission_sort               |                     |         |         |
  external_ids_map              |                     |         |         |
D diff_summary                  |                0.00k|         |         |
D pure_revert                   |                0.00k|         |         |
D groups_byuuid_persisted       |                0.00k|  92.9ms |  0%     |
D change_kind                   |                0.00k|         |         |
D mergeability                  |                0.00k|         |         |
D conflicts                     |                0.00k|         |         |
D diff_intraline                |                0.00k|         |         |
D approvals                     |                0.00k|         |         |
D git_tags                      |                0.00k|         |         |
D gerrit_file_diff              |                0.00k|         |         |
D git_file_diff                 |                0.00k|         |         |
D accounts                      |                0.00k|         |         |
D persisted_projects            |                0.00k|         |         |
D git_modified_files            |                0.00k|         |         |
D modified_files                |                0.00k|         |         |

Reindexing projects:    100% (2/2) with: reindex --site-path /home/scm/review_site_path --threads 1 --index projects
Reindexed 2 documents in projects index in 0.1s (20.0/s)
Index projects in version 4 is ready
Cache Statistics at the end of reindexing projects
  Name                          |Entries              |  AvgGet |Hit Ratio|
                                |   Mem   Disk   Space|         |Mem  Disk|
--------------------------------+---------------------+---------+---------+
  groups_external               |                     |         |         |
  groups_bysubgroup             |                     |         |         |
  change_notes                  |                     |         |         |
  groups_byuuid                 |                     |         |         |
  default_preferences           |                     |         |         |
  prolog_rules                  |                     |         |         |
  groups                        |                     |         |         |
  projects                      |     2               |  42.2ms | 33%     |
  groups_byname                 |                     |         |         |
  groups_external_persisted     |                     |         |         |
  groups_bymember               |                     |         |         |
  project_list                  |     1               | 381.7us |  0%     |
  permission_sort               |                     |         |         |
  external_ids_map              |                     |         |         |
D diff_summary                  |                0.00k|         |         |
D pure_revert                   |                0.00k|         |         |
D groups_byuuid_persisted       |            2   0.90k|         |         |
D change_kind                   |                0.00k|         |         |
D mergeability                  |                0.00k|         |         |
D conflicts                     |                0.00k|         |         |
D diff_intraline                |                0.00k|         |         |
D approvals                     |                0.00k|         |         |
D git_tags                      |                0.00k|         |         |
D gerrit_file_diff              |                0.00k|         |         |
D git_file_diff                 |                0.00k|         |         |
D accounts                      |                0.00k|         |         |
D persisted_projects            |                0.00k|  38.1ms |  0%     |
D git_modified_files            |                0.00k|         |         |
D modified_files                |                0.00k|         |         |

Executing /home/scm/review_site_path/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 /home/scm/review_site_path/bin/gerrit.sh not being run as root.
         Consider changing the OOM score adjustment manually for Gerrit's PID=102579 with e.g.:
         echo '-1000' | sudo tee /proc/102579/oom_score_adj
OK
Waiting for server on 192.168.23.128:80 ... OK
Opening http://192.168.23.128/#/admin/projects/ ...FAILED
Open Gerrit with a JavaScript capable browser:
  http://192.168.23.128/#/admin/projects/
$
$

完整的安装配置选项就如上所示,需要的就选择Y,不需要的就默认回车即可。

Waiting for server on 192.168.23.128:80 ... OK  说明系统已经启动了,打开浏览器访问看看。

不友好的 403 提示,我不用多说什么,应该也知道是啥问题了吧?

4、系统参数配置

要修改那个配置文件,也应该要清楚了吧? 不清楚的看下图路径

安装完成后,原文件配置如下:

有4出地方我们需要进行修改,如下图所示标记处修改。

diff 查看区别

修改好配置,重新启动一下服务,然后在访问浏览器看看效果。

又一个不友好的 502 提示,不用多说了,应该也知道是啥问题了吧?

接着修改代理服务器的配置,把相关的参数修改一下,如下图绿框修改标注。

修改完成,重新启动代理服务。

在把 gerrit 系统也重新启动一下

可以看到相关的进程都正常运行了,说明修改的配置没有问题。

5、访问系统

使用创建好的用户登录系统,就能看到如下的系统界面了。

点击 Install plugins 按钮,就进入到如下的安装界面了。

其实可以忽略安装了,之前的指令安装都已经安装好了相关的插件,这里其实就不用再安装了。

直接跳入主页即可

熟悉的主页就登录进来了,最新的版本显示  Powered by Gerrit Code Review (3.5.0.1) .

点击右上角的 Settings 设置

创建个新仓库,点击 CREATE NEW 进行创建。

输入项目仓库名称,点击 CREATE 按钮创建。

创建的 Demo 仓库就创建好了

写好备注,方便后续的识别管理。

克隆刚才创建的仓库

查看克隆的仓库信息

log 信息显示为空仓库

下面添加个项目代码,然后完成提交,push 到远程服务器上去。

刷新页面,查看到有一条提交记录

页面显示的信息,就是刚才 push 提交的记录信息。

进行代码评审打分

点击 gitweb 页面显示如下

到此,最新版 Gerrit 3.5.0.1 详细安装配置指南,就分享结束了,对你有所帮助请给个红心点个赞吧,谢谢各位。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章