最新版 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 詳細安裝配置指南,就分享結束了,對你有所幫助請給個紅心點個贊吧,謝謝各位。

 

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