Gerrit+replication 同步Gitlab

Posted 砖家组

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gerrit+replication 同步Gitlab相关的知识,希望对你有一定的参考价值。

配置环境:
gerrit 192.168.1.100
gitlab 192.168.1.101


1.创建秘钥
[root@gerrit ~]# ssh-keygen -m PEM -t rsa
2.添加hosts 解析
[root@gerrit ~]#echo "192.168.1.101 gitlab" >> /etc/hosts
3.确保远程系统的主机密钥已经在 Gerrit 用户的~/.ssh/known_hosts文件中。添加主机密钥的最简单方法是使用命令行手动连接一次
ssh root@gitlab
The authenticity of host \'gitlab (192.168.101.74)\' can\'t be established.
ECDSA key fingerprint is SHA256:Ngq+dewHhDc5NY0cDGq4VoIW3TQDKuk4AV6QwciJCf0.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added \'gitlab\' (ECDSA) to the list of known hosts.
root@gitlab\'s password: 
Last failed login: Sun Jun  6 12:59:06 CST 2021 from 192.168.101.73 on ssh:notty
There were 2 failed login attempts since the last successful login.
Last login: Sun Jun  6 12:57:44 2021 from 192.168.101.73
[root@gerrit ~]# cat .ssh/known_hosts 
gitlab ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKVuUh/ej1JAC34mA2kFYgll90OG7tEG7VST4iWZN8vDD8zPN97zlwygjzwOipFqBlHFdcFkMHCI3hUql2yBN+U=
4.创建config 文件
[root@gerrit ~]# vim .ssh/config

Host *
    IdentityFile ~/.ssh/id_rsa
    PreferredAuthentications publickey
5.创建 /opt/gerrit/etc/replication.config
[root@gerrit ~]# vim /opt/gerrit/etc/replication.config

[remote "192.168.1.101"]
   projects = gerrit_rsync
   url = git@192.168.1.101:gerrit_rsync_test/gerrit_rsync.git
   push = +refs/heads/*:refs/heads/*
   push = +refs/tags/*:refs/tags/*
   threads = 3

 

6.复制 .ssh/id_rsa.pub 到gitlab管理员页面
[root@gerrit ~]# cat .ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDeHBS/mw8pwbMGtpZW8SvR3NeIuciBap2lo7nkHCQDaKhm3AG9o+YdAL+dMT2SwKBrse0b6hpma9Rze/EKCqRhbuGo9EZ2N9mynD46u1/bucazNMA3r3RObGhLxZV1Hx5pnMgcB2qPIdHEFN7HihPifsYUMhV7ew0EqbuLOgwiCgNxOfSP412VWLvYJULzcLbIY+f5KCLPtuCwjrxmclTHAEHIfNmlLfcl9c/q8ovlrKjQxIn5Yh+7JMPJEPcsIUHtiyh4tAJI5RGl2tGhVHQ4c9c22GHt8aCBOaGovISzl3WWBEKGiUbd4Lq03fjpqEHMcx5O/HCctizfTZM8BiFA9VuMY61EJ1sYa6UkdmcG2gg5UghXz7O8TUo+DCQaoPmGsRgp7cj0CAGbqtw6FtakAiHks2ZH7b5CffrEVV9Ppq+8fY781YIYz8YKIX0HW8qgSv9mZMJiTvMwq87C0bR/p3WsayTs8M9ZpfsXqXci8vvB45gC7uydCAVOICdNjx8= root@gerrit

 

 

7.复制 .ssh/id_rsa.pub 到gerrit管理员页面 

 

 

8.重新加载 reload replication
[root@gerrit ~]# ssh -p 29418 sunpengfei@localhost gerrit plugin reload replication #sunpengfei用户为Gerrit web 页面管理员用户,第7步添加.ssh/id_rsa.pub的地方。

 

9.手动同步 
ssh -p 29418 sunpengfei@localhost replication start

 




以上是关于Gerrit+replication 同步Gitlab的主要内容,如果未能解决你的问题,请参考以下文章

centos部署配置gerrit+gitlab实现代码的review与自动同步

MySQL Replication--半同步复制(Semi-Sync Replication)

如何设置mysql同步(replication)

如何设置mysql同步(replication)

MySQL使用Replication实现主从同步复制

gerrit用户管理及权限配置