Gerrit与Gitlab同步配置replication其他配置

2024-09-08 06:48

本文主要是介绍Gerrit与Gitlab同步配置replication其他配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、Gerrit与Gitlab同步配置

当配置好gerrit环境后,还需要与现有gitlab库进行同步配置,否则会影响现有开发与打包流程。

1.安装gerrit replication插件

unzip gerrit.war
cp WEB-INF/plugins/replication.jar ~/temp/
ssh -p 29418 admin@172.19.16.64 gerrit plugin install -n replication.jar - <~/temp/replication.jar
ssh -p 29418 admin@172.19.16.64 gerrit plugin ls
Name                           Version    Status   File
-------------------------------------------------------------------------------
replication                    v2.8       ENABLED  replication.jar
 

复制代码

2.配置ssh config

复制代码

cd ~/.ssh/
vim config
Host gitlab.***.cnUser gitlabownerIdentityFile ~/.ssh/id_rsa #gitlab owner id_rsaStrictHostKeyChecking noUserKnownHostsFile /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 600 id_rsa
chmod 644 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}.gitpush = +refs/heads/*:refs/heads/*push = +refs/tags/*:refs/tags/*push = +refs/changes/*:refs/changes/*timtout = 30threads = 3

复制代码

6.启动replication

~/gerrit_code/bin/gerrit.sh restart
ssh -p 29418 admin@172.19.16.64 gerrit plugin reload replication
ssh -p 29418 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 29418 admin@172.19.16.64 gerrit gsql
gerrit>select * from account_external_ids;ACCOUNT_ID | EMAIL_ADDRESS              | PASSWORD | EXTERNAL_ID-----------+----------------------------+----------+----------------------------------1000000    | NULL                       | NULL     | gerrit:admin1000000    | NULL                       | NULL     | username:admin1000005    | NULL                       | NULL     | gerrit:yanjunjie3631000005    | NULL                       | NULL     | username:yanjunjie363
gerrit>insert into account_external_ids values('1000005', 'yanjunjie363@***.com.cn', 'NULL', 'yanjunjie363@***.com.cn');
gerrit>select * from account_external_ids;ACCOUNT_ID | EMAIL_ADDRESS              | PASSWORD | EXTERNAL_ID-----------+----------------------------+----------+----------------------------------1000000    | NULL                       | NULL     | gerrit:admin1000000    | NULL                       | NULL     | username:admin1000005    | NULL                       | NULL     | gerrit:yanjunjie3631000005    | NULL                       | NULL     | username:yanjunjie3631000005    | 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

[2016-10-18 15:09:40,861] [eb662c68] Created remote repository: git@gitlab.***.cn:mobile/All-Projects.git
[2016-10-18 15:09:40,861] [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

[2016-10-17 17:26:46,210] [b716d4c2] Failed replicate of refs/changes/02/2/1 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

复制代码

[2016-10-18 11:19:51,301] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /home/gerrit/workspaces/gerrit_code/plugins
[2016-10-18 11:19:51,381] [main] WARN  com.googlesource.gerrit.plugins.replication.ReplicationFileBasedConfig : Config file /home/gerrit/workspaces/gerrit_code/etc/replication.config does not exist; not replicating
[2016-10-18 11:19:51,383] [main] INFO  com.google.gerrit.server.plugins.PluginLoader : Loaded plugin replication, version v2.12
[2016-10-18 11:19:51,542] [main] INFO  com.google.gerrit.server.change.ChangeCleanupRunner : Ignoring missing changeCleanup schedule configuration
[2016-10-18 11:19:51,579] [main] INFO  com.google.gerrit.sshd.SshDaemon : Started Gerrit SSHD-CORE-0.14.0 on *:29418
[2016-10-18 11:19:51,581] [main] INFO  org.eclipse.jetty.server.Server : jetty-9.2.13.v20150730
[2016-10-18 11:19:51,798] [main] INFO  org.eclipse.jetty.server.handler.ContextHandler : Started o.e.j.s.ServletContextHandler@1304204{/,null,AVAILABLE}
[2016-10-18 11:19:51,800] [main] INFO  org.eclipse.jetty.server.ServerConnector : Started ServerConnector@189a9e6{HTTP/1.1}{0.0.0.0:8088}
[2016-10-18 11:19:51,801] [main] INFO  org.eclipse.jetty.server.Server : Started @4615ms

复制代码

 

如果出现如下log,该表示gerrit与gitlab同步成功:replication_log

复制代码

[2016-10-18 15:15:48,160] [] scheduling replication ***:refs/heads/master => git@gitlab.***.cn:mobile/***.git
[2016-10-18 15:15:48,160] [] scheduled ***:refs/heads/master => [9000013d] push git@gitlab.***.cn:mobile/***.git to run after 15s
[2016-10-18 15:16:03,160] [9000013d] Replication to git@gitlab.***.cn:mobile/***.git started...
[2016-10-18 15:16:03,161] [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]]
[2016-10-18 15:16:03,820] [9000013d] Replication to git@gitlab.***.cn:mobile/***.git completed in 660ms, 15000ms delay, 0 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其他配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1147414

相关文章

SpringBoot+MyBatis-Flex配置ProxySQL的实现步骤

《SpringBoot+MyBatis-Flex配置ProxySQL的实现步骤》本文主要介绍了SpringBoot+MyBatis-Flex配置ProxySQL的实现步骤,文中通过示例代码介绍的非常详... 目录 目标 步骤 1:确保 ProxySQL 和 mysql 主从同步已正确配置ProxySQL 的

Spring Boot整合log4j2日志配置的详细教程

《SpringBoot整合log4j2日志配置的详细教程》:本文主要介绍SpringBoot项目中整合Log4j2日志框架的步骤和配置,包括常用日志框架的比较、配置参数介绍、Log4j2配置详解... 目录前言一、常用日志框架二、配置参数介绍1. 日志级别2. 输出形式3. 日志格式3.1 PatternL

配置springboot项目动静分离打包分离lib方式

《配置springboot项目动静分离打包分离lib方式》本文介绍了如何将SpringBoot工程中的静态资源和配置文件分离出来,以减少jar包大小,方便修改配置文件,通过在jar包同级目录创建co... 目录前言1、分离配置文件原理2、pom文件配置3、使用package命令打包4、总结前言默认情况下,

VScode连接远程Linux服务器环境配置图文教程

《VScode连接远程Linux服务器环境配置图文教程》:本文主要介绍如何安装和配置VSCode,包括安装步骤、环境配置(如汉化包、远程SSH连接)、语言包安装(如C/C++插件)等,文中给出了详... 目录一、安装vscode二、环境配置1.中文汉化包2.安装remote-ssh,用于远程连接2.1安装2

Redis多种内存淘汰策略及配置技巧分享

《Redis多种内存淘汰策略及配置技巧分享》本文介绍了Redis内存满时的淘汰机制,包括内存淘汰机制的概念,Redis提供的8种淘汰策略(如noeviction、volatile-lru等)及其适用场... 目录前言一、什么是 Redis 的内存淘汰机制?二、Redis 内存淘汰策略1. pythonnoe

windos server2022的配置故障转移服务的图文教程

《windosserver2022的配置故障转移服务的图文教程》本文主要介绍了windosserver2022的配置故障转移服务的图文教程,以确保服务和应用程序的连续性和可用性,文中通过图文介绍的非... 目录准备环境:步骤故障转移群集是 Windows Server 2022 中提供的一种功能,用于在多个

windos server2022里的DFS配置的实现

《windosserver2022里的DFS配置的实现》DFS是WindowsServer操作系统提供的一种功能,用于在多台服务器上集中管理共享文件夹和文件的分布式存储解决方案,本文就来介绍一下wi... 目录什么是DFS?优势:应用场景:DFS配置步骤什么是DFS?DFS指的是分布式文件系统(Distr

关于Maven中pom.xml文件配置详解

《关于Maven中pom.xml文件配置详解》pom.xml是Maven项目的核心配置文件,它描述了项目的结构、依赖关系、构建配置等信息,通过合理配置pom.xml,可以提高项目的可维护性和构建效率... 目录1. POM文件的基本结构1.1 项目基本信息2. 项目属性2.1 引用属性3. 项目依赖4. 构

龙蜥操作系统Anolis OS-23.x安装配置图解教程(保姆级)

《龙蜥操作系统AnolisOS-23.x安装配置图解教程(保姆级)》:本文主要介绍了安装和配置AnolisOS23.2系统,包括分区、软件选择、设置root密码、网络配置、主机名设置和禁用SELinux的步骤,详细内容请阅读本文,希望能对你有所帮助... ‌AnolisOS‌是由阿里云推出的开源操作系统,旨

mysql-8.0.30压缩包版安装和配置MySQL环境过程

《mysql-8.0.30压缩包版安装和配置MySQL环境过程》该文章介绍了如何在Windows系统中下载、安装和配置MySQL数据库,包括下载地址、解压文件、创建和配置my.ini文件、设置环境变量... 目录压缩包安装配置下载配置环境变量下载和初始化总结压缩包安装配置下载下载地址:https://d