Gerrit安装配置
来源:互联网 发布:乐乎社区 编辑:程序博客网 时间:2024/05/22 01:48
Gerrit安装
默认安装(不推荐)
rpm -i https://gerritforge.com/gerritforge-repo-1-2.noarch.rpm
yum install -y gerritwar包安装
可以在https://gerrit-releases.storage.googleapis.com/中查找自己需要的版本的Key,拼在utl后面得到下载地址。wget https://gerrit-releases.storage.googleapis.com/gerrit-2.14.2.war
useradd gerrit 新建一个gerrit用户
su gerrit 切换到gerrit用户
java -jar gerrit*.war init -d ~/gerrit_site
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore[2017-08-17 10:50:16,724] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/gerrit_site/etc/gerrit.config; assuming defaults*** Gerrit Code Review 2.14.2*** Create '/home/gerrit/gerrit_site' [Y/n]? y*** Git Repositories*** Location of Git repositories [git]: *** SQL Database*** Database server type [h2]: mysqlGerrit Code Review is not shipped with MySQL Connector/J 5.1.41** This library is required for your configuration. **Download and install it now [Y/n]? yDownloading https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.41/mysql-connector-java-5.1.41.jar ... OKChecksum mysql-connector-java-5.1.41.jar OKServer hostname [localhost]: Server port [(mysql default)]: Database name [reviewdb]: gerritdbDatabase username [gerrit]: gerritgerrit's password : confirm password : *** Index*** Type [LUCENE/?]: *** User Authentication*** Authentication method [OPENID/?]: HTTPGet username from custom HTTP header [y/N]? SSO logout URL : Enable signed push support [y/N]? *** Review Labels*** Install Verified label [y/N]? Y*** Email Delivery*** SMTP server hostname [localhost]: smtp.163.comSMTP server port [(default)]: SMTP encryption [NONE/?]: SMTP username [gerrit]: xxx@163.comsz.lkl@163.com's password : confirm password : *** Container Process*** Run as [gerrit]: Java runtime [/usr/java/jdk1.8.0_144/jre]: Copy gerrit-2.14.2.war to /home/gerrit/gerrit_site/bin/gerrit.war [Y/n]? Copying gerrit-2.14.2.war to /home/gerrit/gerrit_site/bin/gerrit.war*** SSH Daemon*** Listen on address [*]: Listen on port [29418]: Generating SSH host key ... rsa... dsa... ed25519...unknown key type ed25519 ecdsa 256... ecdsa 384... ecdsa 521... done*** HTTP Daemon*** Behind reverse proxy [y/N]? YProxy uses SSL (https://) [y/N]? Subdirectory on proxy server [/]: Listen on address [*]: Listen on port [8081]: 8088Canonical URL [http://admin.banklun.com/]: *** Cache*** *** Plugins*** Installing plugins.Install plugin commit-message-length-validator version v2.14.2 [y/N]? yInstalled commit-message-length-validator v2.14.2Install plugin download-commands version v2.14.2 [y/N]? yInstalled download-commands v2.14.2Install plugin hooks version v2.14.2 [y/N]? yInstalled hooks v2.14.2Install plugin replication version v2.14.2 [y/N]? yInstalled replication v2.14.2Install plugin reviewnotes version v2.14.2 [y/N]? yInstalled reviewnotes v2.14.2Install plugin singleusergroup version v2.14.2 [y/N]? yInstalled singleusergroup v2.14.2Initializing plugins.fatal: DbInjector failedfatal: Unable to determine SqlDialectfatal: caused by java.sql.SQLException: Access denied for user 'gerrit'@'localhost' (using password: YES)[gerrit@admin ~]$ mysql -u gerrit -pEnter password: ERROR 1045 (28000): Access denied for user 'gerrit'@'localhost' (using password: YES)
注意:要搭建CI系统,这里需要选择安装 Label Verified 。
vim /etc/profile 配置环境变量
export GERRIT_HOME=/home/gerrit/gerrit_siteexport PATH=$NGINX_HOME/sbin:$GERRIT_HOME/bin:$PATH
Gerrit-webview安装
查看代码需要用到的
yum -y install gitweb
vim /etc/gitweb.conf
1 # The gitweb config file is a fragment of perl code. You can set variables 2 # using "our $variable = value"; text from "#" character until the end of a 3 # line is ignored. See perlsyn(1) man page for details. 4 # 5 # See /usr/share/doc/gitweb-*/README and /usr/share/doc/gitweb-*/INSTALL for 6 # more details and available configuration variables. 7 8 # Set the path to git projects. This is an absolute filesystem path which will 9 # be prepended to the project path. 10 #our $projectroot = "/var/lib/git"; 11 $projectroot = "/home/gerrit/gerrit_site/git";
$projectroot设置为Location of Git repositories的路径,安装Gerrit时指定的。
配置
mysql添加gerrit用户及数据库
- 查看用户表
select user,password,host from mysql.user;
- 插入新的用户
insert into mysql.user(Host,User,Password) values("localhost","gerrit",password("gerrit"));
- 创建gerrit所要使用的数据库
create database
gerritdbdefault character set utf8 collate utf8_general_ci;
flush privileges; //创建完成后一定要刷新一下,不然不生效
- 设置gerrit用户对gerritdb的操作权限
grant all privileges on gerritdb.* to gerrit@’localhost’ identified by ‘vhost’ with grant option;
SHOW GRANTS FOR gerrit@’localhost’; //验证结果
+---------------------------------------------------------------------------------------------------------------+| Grants for gerrit@localhost |+---------------------------------------------------------------------------------------------------------------+| GRANT USAGE ON *.* TO 'gerrit'@'localhost' IDENTIFIED BY PASSWORD '*AD8354BBE56D9AF515F3FC9A5CCB80E3483BA3E6' || GRANT ALL PRIVILEGES ON `gerritdb`.* TO 'gerrit'@'localhost' WITH GRANT OPTION |+---------------------------------------------------------------------------------------------------------------+2 rows in set (0.00 sec)
配置完成后一定要先用gerrit登录验证一下是否可以登录成功,这一步很关键 mysql -u gerrit -p
可能会出现登录不成功的情况,可以用root用户登录后重置一下gerrit用户的密码再试 SET PASSWORD FOR 'gerrit'@'localhost' = PASSWORD('gerrit');
gerrit.config文件配置
vim /etc/gerrit/gerrit.config
1 [gerrit] 2 basePath = git 3 serverId = ab8a6c3f-90b0-47b5-ac81-eed3d584c7b9 4 canonicalWebUrl = http://xxx:8088/ 5 [database] 6 type = mysql 7 hostname = localhost 8 database = gerritdb 9 username = gerrit 10 [index] 11 type = LUCENE 12 [auth] 13 type = HTTP 14 [receive] 15 enableSignedPush = false 16 [sendemail] 17 smtpServer = smtp.163.com 18 smtpUser = xxx@163.com 19 from = xxx@163.com 20 smtpPass = ****** 21 # smtpServer = localhost 22 [container] 23 user = gerrit 24 javaHome = /usr/java/jdk1.8.0_144/jre 25 [sshd] 26 listenAddress = *:29418 27 [httpd] 28 listenUrl = proxy-http://*:8088/ 29 [cache] 30 directory = cache 31 [gitweb] 32 type = gitweb 33 cgi = /var/www/git/gitweb.cgi
主要是增加了[gitweb],其他的在安装时已经默认配置好了,不过也可以修改,修改最多的就是httpd中的监听端口号,可以根据实际需求来变更。
Nginx反向代理配置
Nginx的安装配置:http://blog.csdn.net/lkl22/article/details/77244237
vim /usr/local/nginx/conf/vhost/gerrit.conf
server { #网址访问时的端口号 listen *:8089; server_name gerrit.microwu.com; allow all; deny all; auth_basic "Welcomme to Gerrit Code Review Site!"; #反向代理认证登录验证文件的路径,里面存储了用户名、密码 auth_basic_user_file /home/gerrit/gerrit_site/htpasswd.conf; location / { #8088为gerrit的监听端口 proxy_pass http://127.0.0.1:8088; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; } }
htpasswd指令配置登录用户名、密码
安装工具 yum install -y httpd-tools
cd /home/gerrit/gerrit_site/
创建用户、密码 htpasswd -c htpasswd.conf admin
添加/修改用户、密码 htpasswd -m htpasswd.conf admin
修改文件权限,不然用户登录会报500 Internal Server Error
chmod 755 /home/gerrit/
chmod 755 /home/gerrit/gerrit_site/htpasswd.conf
配置gitweb的反向代理
使用的是apache代理
vim /etc/httpd/conf.d/gitweb.conf
## gitweb#Alias /gitweb "/var/www/git"<Directory "/var/www/git"> Options +ExecCGI AddHandler cgi-script .cgi DirectoryIndex index.cgi gitweb.cgi Order allow,deny Allow from all</Directory>
- 开机自动启动apache代理
systemctl enable httpd
设置开机自动启动
sudo ln -s etc/gerrit.config /etc/init.d/gerrit
sudo ln -snf /etc/init.d/gerrit /etc/rc2.d/S90gerrit
sudo ln -snf /etc/init.d/gerrit /etc/rc3.d/S90gerrit
启动、停止、重启
配置好环境变量,可以直接通过下面的指令来启动、停止、重启gerrit
gerrit.sh start
gerrit.sh stop
gerrit.sh restart
常见问题
./bin/gerrit.sh: line 175: cd: /var/gerrit: No such file or directory
ERROR: Gerrit site /var/gerrit not found
vim /etc/default/gerritcodereviewGERRIT_SITE=/home/gerrit/gerrit_site
将GERRIT_SITE指定为安装时指定的路径500 Internal Server Error
可以通过nginx代理的错误日志查看原因
vim /usr/local/nginx/logs/error.log查看错误日志
vim /home/gerrit/gerrit_site/logs/error_log
- gerrit配置安装
- Ubuntu gerrit 安装配置
- gerrit安装配置
- Gerrit安装配置手册
- gerrit 安装配置
- Centos 安装配置gerrit
- Gerrit安装配置
- Gerrit安装配置
- gerrit安装中smtp配置
- centos 7 gerrit安装配置
- Git+gerrit+jenkins安装配置
- centos 7 gerrit安装配置
- gerrit 在fedora上的安装配置
- Gerrit+apache+H2数据库简单安装配置
- gerrit安装配置(http反向代理)
- ubuntu 安装配置 gerrit 服务器 [ HTTP 认证 ]
- Gerrit配置
- gerrit 配置
- axios资料整理
- ubuntu 14.04 LTS Docker安装(转载)
- spring boot 笔记(四):返回静态页面
- 深度学习:MATLAB 入门系列(一)
- css复习整理(一):选择器与创建
- Gerrit安装配置
- HDU 4763 Theme Section(kmp求前后缀)
- 说说函数中的极品-OFFSET
- undefined reference to symbol 'floor@@GLIBC_2.0'
- SQL学习笔记--限制于排序
- README.md 如何规范
- IO流复制文件并对文件进行更名---师承刘易老师
- 07_有趣的跳跃
- 卷积神经网络结构变迁历史二