zoukankan      html  css  js  c++  java
  • git自动化部署+rsync文件同步

    1、进入线上git裸仓库

    2、编辑post-receive

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

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

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

      

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

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

     

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

    ②、客户端 B(192.168.48.129)

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

      

    说明:

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

  • 相关阅读:
    (一)Kafka0.8.2官方文档中文版系列入门指南
    Hbase TTL(Time To Live)详解
    java源码学习详解Object类
    设计模式详细解读简单工厂方法模式
    (二)Kafka0.8.2官方文档中文版系列API
    Scala对象相等性判断
    scala中跳出循环的3种方法
    wpf 中借助 Grid 实现随着 Form 大小变化而按比例自动改变宽度或高度。
    static and cache
    约定编程之 Dictionary 的 String 类型的 Key
  • 原文地址:https://www.cnblogs.com/zc123/p/9133785.html
Copyright © 2011-2022 走看看