下面是本人安装Gerrit的笔记。
1、运行环境
本人将使用 mysql 数据库,Gerrit默认的数据库是 h2(H2是一个短小精干的嵌入式数据库引擎),安装mysql参考这里:Mysql5.7初次安装的注意事项
Gerrit 是java的代码,所以需要安装java的环境。这个自行安装.
2、下载Gerrit
Gerrit是google的一个项目,需要翻墙下载,太郁闷了。我在百度网盘放了一个2.12的版本。下载地址:https://pan.baidu.com/s/1cJ5Y0I
3、创建Gerrit的用户
# groupadd gerrit # useradd -g gerrit gerrit
4、创建数据库
创建数据库 gerrit ,并创建数据库用户mysql
mysql> create database gerrit; mysql> ALTER DATABASE gerrit charset=latin1; mysql> GRANT ALL ON gerrit.* to gerrit@'%' IDENTIFIED BY '123456'; mysql> FLUSH PRIVILEGES
5、安装gerrit
安装的目录:/home/gerrit/web
# mkdir -p /home/gerrit/web # java -jar gerrit-2.12.war init -d /home/gerrit/web/
- Create ‘/home/gerrit/web’ [Y/n]? y
- Location of Git repositories [git]: /home/git
- Database server type [h2]: mysql
Gerrit Code Review is not shipped with MySQL Connector/J 5.1.21
** This library is required for your configuration. **
Download and install it now [Y/n]? y
Downloading http://repo2.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar … OK
Checksum mysql-connector-java-5.1.21.jar OK - #mysql 的相关设置
Server hostname [localhost]:
Server port [(mysql default)]: 3306
Database name [reviewdb]: gerrit
Database username [root]: gerrit
gerrit’s password :
confirm password : - Type [LUCENE/?]:
- Authentication method [OPENID/?]:
- Enable signed push support [y/N]? y
Gerrit Code Review is not shipped with Bouncy Castle Crypto Provider v152
** This library is required for your configuration. **
Download and install it now [Y/n]? y
如果下载失败,请自行下载:bcprov-jdk15on-152.jar,并将其放在目录:/home/gerrit/web/lib/bcprov-jdk15on-152.jar,下载地址:http://polydistortion.net/bc/download/,这里下载的比较慢,可到百度网盘下载:https://pan.baidu.com/s/1dEDJZwP - Install Verified label [y/N]? y
- SMTP server hostname [localhost]:
SMTP server port [(default)]:
SMTP encryption [NONE/?]:
SMTP username : - Run as [root]:
- Java runtime [/usr/java/jdk1.8.0_11/jre]:
- Listen on address [*]:
- Listen on port [29418]:
- Behind reverse proxy [y/N]? y
Proxy uses SSL (https://) [y/N]?
Subdirectory on proxy server [/]:
Listen on address [*]: 127.0.0.1
Listen on port [8081]:
Canonical URL [http://127.0.0.1/]:
6、安装过程的错误
#1067 – Invalid default value for ‘added_on’
解决办法:MySQL 5.6版本引入 explicit_defaults_for_timestamp 来控制对timestamp NULL值的处理,如果该参数不开启,则对timestamp NOT NULL插入NULL值,不报错,无warning,插入后的值为当前时,如果在my.cnf中explicit_defaults_for_timestamp=1 ,那么插入该值的时候会报错提示该列can not be null ,建议开启该值。
show variables like '%explicit_defaults_for_timestamp%'; set explicit_defaults_for_timestamp="ON"
Bad sshd.listenaddress: n:29418: unknown host: n:29418
ERROR com.google.gerrit.pgm.Daemon : Unable to start daemon