Gerrit与Gitlab同步配置replication&其他配置
一、Gerrit与Gitlab同步配置
当配置好gerrit环境后,还需要与现有gitlab库进行同步配置,否则会影响现有开发与打包流程。
1.安装gerrit replication插件
unzip gerrit.war
cp WEB-INF/plugins/replication.jar ~/temp/
ssh -p admin@172.19.16.64 gerrit plugin install -n replication.jar - <~/temp/replication.jar
ssh -p admin@172.19.16.64 gerrit plugin ls
Name Version Status File
-------------------------------------------------------------------------------
replication v2. ENABLED replication.jar
2.配置ssh config
cd ~/.ssh/
vim config
Host gitlab.***.cn
User gitlabowner
IdentityFile ~/.ssh/id_rsa #gitlab owner id_rsa
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
3.替换gitlab lubase(project owner) ssh key
cd ~/.ssh/
rm id_rsa
rm id_rsa.pub
vim id_rsa
(粘贴owner的id_rsa)
vim id_rsa.pub
(粘贴owner的id_rsa.pub)
chmod id_rsa
chmod id_rsa.pub
4.加入gitlab pubkey到kown_hosts
sh -c "ssh-keyscan -t rsa gitlab.***.cn >> ~/.ssh/known_hosts"
sh -c "ssh-keygen -H -f ~/.ssh/known_hosts"
或者
git clone git@gitlab.***.cn:mobile/***.git
Warning: Permanently added the RSA host key for IP address '172.19.14.64' to the list of known hosts.
5.配置replication.config
[remote "gitlab.***.cn"]
url = git@gitlab.***.cn:mobile/${name}.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
push = +refs/changes/*:refs/changes/*
timtout = 30
threads = 3
6.启动replication
~/gerrit_code/bin/gerrit.sh restart
ssh -p admin@172.19.16.64 gerrit plugin reload replication
ssh -p admin@172.19.16.64 replication start ***
二、Gerrit其他配置
1.invalid committer问题
gerrit默认关闭普通用户直接push master的权限,且普通用户需要配置git config global user.email与gerrit账户信息中的email一致
由于现在无法使用email功能,可考虑关闭email功能并开启forge committer功能,或者通过gerrit数据库远程修改gerrit账户中的email信息
*采用forge committer方式
vim ~/gerrit_code/etc/gerrit.config
[sendemail]
enable = false
按照下图加入forge权限

*采用修改gerrit数据库方式
ssh -p admin@172.19.16.64 gerrit gsql
gerrit>select * from account_external_ids;
ACCOUNT_ID | EMAIL_ADDRESS | PASSWORD | EXTERNAL_ID
-----------+----------------------------+----------+----------------------------------
| NULL | NULL | gerrit:admin
| NULL | NULL | username:admin
| NULL | NULL | gerrit:yanjunjie363
| NULL | NULL | username:yanjunjie363
gerrit>insert into account_external_ids values('', 'yanjunjie363@***.com.cn', 'NULL', 'yanjunjie363@***.com.cn');
gerrit>select * from account_external_ids;
ACCOUNT_ID | EMAIL_ADDRESS | PASSWORD | EXTERNAL_ID
-----------+----------------------------+----------+----------------------------------
| NULL | NULL | gerrit:admin
| NULL | NULL | username:admin
| NULL | NULL | gerrit:yanjunjie363
| NULL | NULL | username:yanjunjie363
| yanjunjie363@***.com.cn | NULL | mailto:yanjunjie363@***.com.cn
按照以上任意一种方式配置后,可git push origin HEAD:refs/for/master成功
2.admin remote access问题
在远程执行ssh -p 29418 admin@172.19.16.64 gerrit plugin ls时会提示报错,因为gerrit默认关闭远程admin操作权限
解决方法:
vim ~/gerrit_code/etc/gerrit.config
[plugins]
allowRemoteAdmin = true
在远程执行ssh -p 29418 admin@172.19.16.64 gerrit gsql时会提示报错,因为gerrit默认关闭操作database权限
解决方法:在Projects-Access中加入如上图中的Access Database功能
3.replication rejected问题
在执行ssh -p 29418 admin@172.19.16.64 replication start lubase时,gerrit replication日志中报错:replication_log
[-- ::,] [eb662c68] Created remote repository: git@gitlab.***.cn:mobile/All-Projects.git
[-- ::,] [eb662c68] Missing repository created; retry replication to git@gitlab.***.cn:mobile/All-Projects.git
这个问题是因为gerrit有两个默认git库All-Projects和All-Users,用来默认配置gerrit项目和账户权限,因为gitlab未开启创建git库权限,所以提示失败。
在执行ssh -p 29418 admin@172.19.16.64 replication start lubase时,gerrit replication日志中报错:replication_log
[-- ::,] [b716d4c2] Failed replicate of refs/changes/// to git@gitlab.***.cn:mobile/***.git, reason: pre-receive hook declined
这个问题是因为gitlab库权限问题导致,当***开启master protected,并使用yanjunjie363(master用户)的ssh-key push并replication时,会报该错误。
可关闭***的master protected权限,或者使用ufo(owner用户)的ssh-key push并replication即刻解决。
如果出现如下log,则表示replication插件安装成功:error_log
[-- ::,] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /home/gerrit/workspaces/gerrit_code/plugins
[-- ::,] [main] WARN com.googlesource.gerrit.plugins.replication.ReplicationFileBasedConfig : Config file /home/gerrit/workspaces/gerrit_code/etc/replication.config does not exist; not replicating
[-- ::,] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin replication, version v2.
[-- ::,] [main] INFO com.google.gerrit.server.change.ChangeCleanupRunner : Ignoring missing changeCleanup schedule configuration
[-- ::,] [main] INFO com.google.gerrit.sshd.SshDaemon : Started Gerrit SSHD-CORE-0.14. on *:
[-- ::,] [main] INFO org.eclipse.jetty.server.Server : jetty-9.2..v20150730
[-- ::,] [main] INFO org.eclipse.jetty.server.handler.ContextHandler : Started o.e.j.s.ServletContextHandler@{/,null,AVAILABLE}
[-- ::,] [main] INFO org.eclipse.jetty.server.ServerConnector : Started ServerConnector@189a9e6{HTTP/1.1}{0.0.0.0:}
[-- ::,] [main] INFO org.eclipse.jetty.server.Server : Started @4615ms
如果出现如下log,该表示gerrit与gitlab同步成功:replication_log
[-- ::,] [] scheduling replication ***:refs/heads/master => git@gitlab.***.cn:mobile/***.git
[-- ::,] [] scheduled ***:refs/heads/master => [9000013d] push git@gitlab.***.cn:mobile/***.git to run after 15s
[-- ::,] [9000013d] Replication to git@gitlab.***.cn:mobile/***.git started...
[-- ::,] [9000013d] Push to git@gitlab.***.cn:mobile/***.git references: [RemoteRefUpdate[remoteName=refs/heads/master, NOT_ATTEMPTED, (null)...a2e1f13bd12cd398ed45ab06fa231cac6334f0c8, srcRef=refs/heads/master, forceUpdate, message=null]]
[-- ::,] [9000013d] Replication to git@gitlab.***.cn:mobile/***.git completed in 660ms, 15000ms delay, retries
三、权限配置参考

参考链接
安装与配置gerrit replication插件
https://gerrit.libreoffice.org/plugins/replication/Documentation/config.html
https://gist.github.com/Aricg/56f1a769cbdcbb93b459
gerrit主机中加入gitlab sshkey http://www.cnblogs.com/zhanchenjin/p/5032218.html
Gerrit与Gitlab同步配置replication&其他配置的更多相关文章
- Gitlab Jenkins WebHook 持续集成配置踩坑记
Jenkins相关介绍 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. 目的 配置Gitla ...
- MySQL主从同步、读写分离配置步骤、问题解决笔记
MySQL主从同步.读写分离配置步骤.问题解决笔记 根据要求配置MySQL主从备份.读写分离,结合网上的文档,对搭建的步骤和出现的问题以及解决的过程做了如下笔记: 现在使用的两台服务器已经 ...
- Linux centosVMware MySQL主从介绍、准备工作、配置主、配置从、测试主从同步
一.MySQL主从介绍 MySQL主从又叫做Replication.AB复制.简单讲就是A和B两台机器做主从后,在A上写数据,另外一台B也会跟着写数据,两者数据实时同步的 MySQL主从是基于binl ...
- Mariadb之半同步复制集群配置
首先我们来了解下在mariadb/mysql数据库主从复制集群中什么是同步,什么是异步,什么是半同步:所谓同步就是指主节点发生写操作事件,它不会立刻返回,而是等到从节点接收到主节点发送过来的写操作事件 ...
- .NET Core采用的全新配置系统[10]: 配置的同步机制是如何实现的?
配置的同步涉及到两个方面:第一,对原始的配置文件实施监控并在其发生变化之后从新加载配置:第二,配置重新加载之后及时通知应用程序进而使后者能够使用最新的配置.要了解配置同步机制的实现原理,先得从认识一个 ...
- linux下实现多台服务器同步文件(inotify-tools+rsync实时同步文件安装和配置)
inotify-tools+rsync实时同步文件安装和配置 注:转载https://www.linuxidc.com/Linux/2012-06/63624.htm
- [ASP.NET Core 3框架揭秘] 配置[5]:配置数据与数据源的实时同步
在<配置模型总体设计>介绍配置模型核心对象的时候,我们刻意回避了与配置同步相关的API,现在我们利用一个独立文章来专门讨论这个话题.配置的同步涉及到两个方面:第一,对原始的配置源实施监控并 ...
- gitlab docker中postgresql远程访问配置
1.配置postgresql远程访问 配置postgresql远程访问,需要修改两个文件,在gitlab-ce的docker中位置为 /var/opt/gitlab/postgresql/data 首 ...
- 一文搞懂GitLab安装部署及服务配置
GitLab安装部署 Git,GitHub,GitLab,这三个东东长得好像呀,都是个啥? Git是Linus Torvalds(如果不知道这位大神是谁,请出门左转,慢走不送~)为了帮助管理Linux ...
随机推荐
- Nginx的继续深入(日志轮询切割,重写,负载均衡等)
Nginx的访问日志轮询切割 通常什么情况Nginx会把所有的访问日志生成到一个制定的访问日志文件access.log里面,但时间一长,日志个头很大不利于日志的分析和处理. 有必要对Nginx日志进行 ...
- WebService -- Java 实现之 CXF ( 使用CXF工具生成client 程序)
1. 下载CXF 工具解压到磁盘 2.添加工具bin目录到PATH环境变量 3.创建一个CXF client新项目 4. run -> cmd 到指定目录,并运行工具目录下的批处理 “wadl2 ...
- orm 语法 数据库连接、建表、增删改查、回滚、单键关联 、多键关联、三表关联
1.数据库连接, #!usr/bin/env/python # -*- coding:utf-8 -*- # from wangteng import sqlalchemy from sqlalche ...
- 常用的windows cmd 的使用
cd/:返回根目录 cd 文件名:进入某文件 md 文件名:新建文件 dir:显示当前文件夹内的文件目录 del:删除文件 rd:删除空目录(目录中不能有子目录和文件) deltree:删除目录并删除 ...
- des (C语言)
/** * \file des.h * * \brief DES block cipher * * Copyright (C) 2006-2010, Brainspark B.V. * * This ...
- error-unable-to-access-the-iis-metabase或者无法加载VS项目中的网站
参考:http://stackoverflow.com/questions/12859891/error-unable-to-access-the-iis-metabase 1.确定IIS是否安装完整 ...
- Jetty官方文档翻译
最近在学习Jetty,没有找到合适的资料,所有只能看官方文档了,但是只有英文的,想着自己翻译着学也是学还不如把学习的过程放到网上,也可以给需要的人看,英文水平毕竟有限,也是用有道翻译着来的,不过也加了 ...
- Word中一些问题解决
word图片不显示或显示不全怎么办? http://jingyan.baidu.com/article/0f5fb099c5cb7a6d8334ea06.html
- ios数据永久存储之----NSUserDefaults
我们在开发app时不可避免的会在本地存储一些数据,NSUserDefaults就是系统提供的一个用来数据存储的类,本片文章就来介绍一些NSserdefazults的用法. 详细内容:https://m ...
- oracle 安装
一 : 建议安装在64位机器上,程序下载地址 http://download.oracle.com/otn/nt/oracle11g/112010/win64_11gR2_database_1of2. ...