当前位置:   article > 正文

git自动化部署+rsync文件同步

rsync git typechange

1、进入线上git裸仓库

 

2、编辑post-receive

  1. #!/bin/sh
  2. unset GIT_DIR
  3. cd /var/www/
  4. git pull http://web:xxxxxxx@120.31.131.xxx:8099/root/withdraw_api.git

3、使用rsync
①、服务器端 A (192.168.48.128)

  1. yum -y install rsync # 安装rsync同步服务
  2. echo "root:root" > /etc/rsyncd.secrets #账号密码
  3. chmod 600 /etc/rsyncd.secrets #这一步不可缺少,不然会报错。

  

# 编辑配置文件 /etc/rsyncd.conf

  1. pid file = /var/run/rsyncd.pid
  2. port = 873
  3. address = 192.168.48.128 # 绑定本机ip
  4. uid = root
  5. #gid = root
  6. use chroot = yes
  7. read only = yes
  8. #limit access to private LANs
  9. #hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0
  10. #hosts deny=*
  11. max connections = 5
  12. #motd file = /etc/rsyncd.motd
  13. #This will give you a separate log file
  14. #log file = /var/log/rsync.log
  15. #This will log every file transferred - up to 85,000+ per user, per sync
  16. #transfer logging = yes
  17. log format = %t %a %m %f %b
  18. syslog facility = local3
  19. timeout = 300
  20. #模块名 配置同步的文件目录
  21. [rhel4home]
  22. path = /var/www/html/
  23. list=yes
  24. ignore errors
  25. auth users = root
  26. secrets file = /etc/rsyncd.secrets
  27. comment = This is RHEL 4 data
  28. #exclude = easylife/ samba/ #排除要同步的目录

 

#添加端口放行
/sbin/iptables -I INPUT -p tcp --dport 873 -j ACCEPT

②、客户端 B(192.168.48.129)

  1. yum -y install rsync # 安装rsync同步服务
  2. # 客户端密码 /etc/rsyncd.secrets(仅保留明文密码就行)
  3. root
  4. rsync -auv --password-file=/etc/rsyncd.secrets root@192.168.48.128::rhel4home /var/www/html

  

说明:

客户端git推送文件到线上master裸仓库会触发git钩子并执行定义好的脚本同步拉取最新代码到项目部署目录
rsync作用是多台服务器同步一套代码

 

转载于:https://www.cnblogs.com/zc123/p/9133785.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/587814
推荐阅读
相关标签
  

闽ICP备14008679号