文章目录
- 0.环境准备
- 1.安装Git
- 2.下载Gerrit
- 3.安装Java
-
- 4.安装MySQL
- 4.1 卸载Mariadb
- 4.2 安装MySQL
- 4.3 创建数据库
- 5.初始化Gerrit
- 6.使用HTTP认证配置
- 6.1 nginx服务认证
- 6.2 httpd服务认证
服务 | 版本 |
---|
Git | 1.8.3.1 |
Gerrit | 3.5.1 |
Java | 11.0.13 |
MySQL | 5.7.27 |
0.环境准备
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
SELINUX=disabled
:wq!
[root@gerrit ~]
1.安装Git
[root@gerrit ~]
[root@gerrit ~]
git version 1.8.3.1
2.下载Gerrit
官网下载地址:https://www.gerritcodereview.com/
![在这里插入图片描述](https://img-blog.csdnimg.cn/a4e79044ee004ce5b9519908287c6942.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQFRhbmdYaW4=,size_20,color_FFFFFF,t_70,g_se,x_16)
[root@gerrit ~]
3.安装Java
3.1 旧JDK卸载
[root@gerrit ~]
rpm -qa:表示查询所有已经安装的软件包
grep -i:表示过滤时不区分大小写
xargs -n1:表示一次获取上次执行结果的一个值
rpm -e --nodeps:表示卸载软件
3.2 安装指定JDK
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
export JAVA_HOME=/opt/software/jdk-11.0.13
export JRE_HOME=$JAVA_HOME
export CLASSPATH=.:$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
[root@gerrit ~]
[root@gerrit ~]
java 11.0.13 2021-10-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.13+10-LTS-370)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.13+10-LTS-370, mixed mode)
4.安装MySQL
- 部署完Gerrit之后,数据库中是空,好像数据库并没有用到
4.1 卸载Mariadb
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
4.2 安装MySQL
[https://dev.mysql.com/downloads/mysql/5.7.html
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
2022-03-23T11:31:03.443772Z 1 [Note] A temporary password is generated for root@localhost: WF
mysql>alter user user() identified by "Spark@V123";
mysql>SHOW variables LIKE 'validate_password%';
mysql>set global validate_password_policy=0;
mysql>set global validate_password_length=4;
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY "bigdata123";
mysql>flush privileges;
mysql>use mysql;
mysql>update user set host = '%' where user ='root';
mysql>flush privileges;
mysql>exit;
collation_server=utf8_general_ci
character_set_server=utf8
default-storage-engine=INNODB
default_character-set=utf8
[root@gerrit ~]
[root@gerrit ~]
4.3 创建数据库
mysql>CREATE DATABASE reviewdb CHARACTER SET utf8;
mysql>set global validate_password_policy=0;
mysql>CREATE USER 'gerrit'@'%'IDENTIFIED BY 'bigdata123';
mysql>GRANT ALL PRIVILEGES ON reviewdb.* TO 'gerrit'@'%';
mysql>FLUSH PRIVILEGES;
5.初始化Gerrit
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[gerrit@gerrit ~]$ mkdir -p /home/gerrit/code_review
[gerrit@gerrit ~]$ java -jar gerrit-3.5.1.war init -d /home/gerrit/code_review
6.使用HTTP认证配置
[gerrit@gerrit ~]$ java -jar gerrit-3.5.1.war init -d /home/gerrit/code_review
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2022-03-23 18:27:08,050] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/code_review/etc/gerrit.config; assuming defaults
*** Gerrit Code Review 3.5.1
***
Create '/home/gerrit/code_review' [Y/n]?
*** Git Repositories
***
Location of Git repositories [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]?
SSO logout URL :
Enable signed push support [y/N]?
Use case insensitive usernames [Y/n]?
*** Review Labels
***
Install Verified label [y/N]?
*** Email Delivery
***
SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [none/?]:
SMTP username :
*** Container Process
***
Run as [gerrit]:
Java runtime [/opt/software/jdk-11.0.13]:
Copy gerrit-3.5.1.war to /home/gerrit/code_review/bin/gerrit.war [Y/n]?
Copying gerrit-3.5.1.war to /home/gerrit/code_review/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]?
Use SSL (https://) [y/N]?
Listen on address [*]:
Listen on port [8080]:
Canonical URL [http://gerrit:8080/]: http://192.168.120.11:8080/
*** Cache
***
*** Plugins
***
Installing plugins.
Install plugin codemirror-editor version v3.5.1 [y/N]? y
Installed codemirror-editor v3.5.1
Install plugin commit-message-length-validator version v3.5.1 [y/N]? y
Installed commit-message-length-validator v3.5.1
Install plugin delete-project version v3.5.1 [y/N]? y
Installed delete-project v3.5.1
Install plugin download-commands version v3.5.1 [y/N]? y
Installed download-commands v3.5.1
Install plugin gitiles version v3.5.1 [y/N]? y
Installed gitiles v3.5.1
Install plugin hooks version v3.5.1 [y/N]? y
Installed hooks v3.5.1
Install plugin plugin-manager version v3.5.1 [y/N]? y
Installed plugin-manager v3.5.1
Install plugin replication version v3.5.1 [y/N]? y
Installed replication v3.5.1
Install plugin reviewnotes version v3.5.1 [y/N]? y
Installed reviewnotes v3.5.1
Install plugin singleusergroup version v3.5.1 [y/N]? y
Installed singleusergroup v3.5.1
Install plugin webhooks version v3.5.1 [y/N]? y
Installed webhooks v3.5.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/gerrit/code_review
Init complete, reindexing accounts,changes,groups,projects with: reindex --site-path /home/gerrit/code_review --threads 1 --index accounts --index changes --index groups --index projects --disable-cache-statsReindexed 0 documents in accounts index in 0.0s (0.0/s)
Index accounts in version 11 is ready
Reindexing groups: 100% (2/2)
Reindexed 2 documents in groups index in 0.2s (8.4/s)
Index groups in version 8 is ready
Reindexing changes: Slicing projects: 100% (2/2), done
Reindexed 0 documents in changes index in 0.0s (0.0/s)
Index changes in version 71 is ready
Reindexing projects: 100% (2/2)
Reindexed 2 documents in projects index in 0.0s (44.4/s)
Index projects in version 4 is ready
Executing /home/gerrit/code_review/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/gerrit/code_review/bin/gerrit.sh not being run as root.
Consider changing the OOM score adjustment manually for Gerrit's PID=6996 with e.g.:
echo '-1000' | sudo tee /proc/6996/oom_score_adj
OK
Waiting for server on 192.168.120.11:8080 ... OK
Opening http://192.168.120.11:8080/
[gerrit@gerrit ~]$ /home/gerrit/code_review/bin/gerrit.sh restart
![在这里插入图片描述](https://img-blog.csdnimg.cn/3cb19872c9884e4980d59d210e7852dd.png)
- 此时,访问8080端口,显示需要认证设置。HTTP认证有两种服务认证方式:ngin、httpd
![在这里插入图片描述](https://img-blog.csdnimg.cn/a9afb331419d4828abe427beaf2dcdee.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQFRhbmdYaW4=,size_20,color_FFFFFF,t_70,g_se,x_16)
6.1 nginx服务认证
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
location / {
auth_basic "Gerrit Code Review";
auth_basic_user_file /passwords;
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
New password:
Re-type new password:
Adding password for user admin
![在这里插入图片描述](https://img-blog.csdnimg.cn/779848cd843c410fb3129849e6d7a668.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQFRhbmdYaW4=,size_20,color_FFFFFF,t_70,g_se,x_16)
![在这里插入图片描述](https://img-blog.csdnimg.cn/8a1e3574ba03432aaf6c7b77803c72c3.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQFRhbmdYaW4=,size_20,color_FFFFFF,t_70,g_se,x_16)
![在这里插入图片描述](https://img-blog.csdnimg.cn/fcccabde68894b97947b87ed90ae21ac.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQFRhbmdYaW4=,size_20,color_FFFFFF,t_70,g_se,x_16)
6.2 httpd服务认证
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
<VirtualHost 192.168.120.11:80>
ServerName 192.168.120.11
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /login/>
AuthType Basic
AuthName "Gerrit Code Review"
Require valid-user
AuthUserFile /gerrit.password
</Location>
ProxyPass / http://192.168.120.11:8080/
</VirtualHost>
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
[root@gerrit ~]
New password:
Re-type new password:
Adding password for user admin
![在这里插入图片描述](https://img-blog.csdnimg.cn/f93fa04f42fe463db39a66c7741d37f2.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQFRhbmdYaW4=,size_20,color_FFFFFF,t_70,g_se,x_16)
![在这里插入图片描述](https://img-blog.csdnimg.cn/47bb7b45805c427b8bfec7b4edb8e54d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQFRhbmdYaW4=,size_20,color_FFFFFF,t_70,g_se,x_16)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)