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

相关文章

Linux中SSH服务配置的全面指南

《Linux中SSH服务配置的全面指南》作为网络安全工程师,SSH(SecureShell)服务的安全配置是我们日常工作中不可忽视的重要环节,本文将从基础配置到高级安全加固,全面解析SSH服务的各项参... 目录概述基础配置详解端口与监听设置主机密钥配置认证机制强化禁用密码认证禁止root直接登录实现双因素

嵌入式数据库SQLite 3配置使用讲解

《嵌入式数据库SQLite3配置使用讲解》本文强调嵌入式项目中SQLite3数据库的重要性,因其零配置、轻量级、跨平台及事务处理特性,可保障数据溯源与责任明确,详细讲解安装配置、基础语法及SQLit... 目录0、惨痛教训1、SQLite3环境配置(1)、下载安装SQLite库(2)、解压下载的文件(3)、

Linux如何快速检查服务器的硬件配置和性能指标

《Linux如何快速检查服务器的硬件配置和性能指标》在运维和开发工作中,我们经常需要快速检查Linux服务器的硬件配置和性能指标,本文将以CentOS为例,介绍如何通过命令行快速获取这些关键信息,... 目录引言一、查询CPU核心数编程(几C?)1. 使用 nproc(最简单)2. 使用 lscpu(详细信

Nginx 重写与重定向配置方法

《Nginx重写与重定向配置方法》Nginx重写与重定向区别:重写修改路径(客户端无感知),重定向跳转新URL(客户端感知),try_files检查文件/目录存在性,return301直接返回永久重... 目录一.try_files指令二.return指令三.rewrite指令区分重写与重定向重写: 请求

Nginx 配置跨域的实现及常见问题解决

《Nginx配置跨域的实现及常见问题解决》本文主要介绍了Nginx配置跨域的实现及常见问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来... 目录1. 跨域1.1 同源策略1.2 跨域资源共享(CORS)2. Nginx 配置跨域的场景2.1

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

MySQL MCP 服务器安装配置最佳实践

《MySQLMCP服务器安装配置最佳实践》本文介绍MySQLMCP服务器的安装配置方法,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下... 目录mysql MCP 服务器安装配置指南简介功能特点安装方法数据库配置使用MCP Inspector进行调试开发指

Redis Cluster模式配置

《RedisCluster模式配置》:本文主要介绍RedisCluster模式配置,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录分片 一、分片的本质与核心价值二、分片实现方案对比 ‌三、分片算法详解1. ‌范围分片(顺序分片)‌2. ‌哈希分片3. ‌虚

SpringBoot项目配置logback-spring.xml屏蔽特定路径的日志

《SpringBoot项目配置logback-spring.xml屏蔽特定路径的日志》在SpringBoot项目中,使用logback-spring.xml配置屏蔽特定路径的日志有两种常用方式,文中的... 目录方案一:基础配置(直接关闭目标路径日志)方案二:结合 Spring Profile 按环境屏蔽关

canal实现mysql数据同步的详细过程

《canal实现mysql数据同步的详细过程》:本文主要介绍canal实现mysql数据同步的详细过程,本文通过实例图文相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的... 目录1、canal下载2、mysql同步用户创建和授权3、canal admin安装和启动4、canal