sersync同步

2019年6月30日 ⋅ 浏览量: 61   


环境

web1=172.16.1.10

web2=172.16.1.11

master端

#!/bin/bash
# --------------------------------------------------
#Author:       晴天
#Email:         admin@attacker.club
#website:      http://attacker.club
# --------------------------------------------------

yum install git -y
git clone https://github.com/wsgzao/sersync.git
cd sersync



function install_rsync()
{
    tar zxvf rsync-3.1.1.tar.gz
    cd rsync-3.1.1
    ./configure
    make && make install
    cd ..
    rm  rsync-3.1.1 -rf
}

function install_inotify()
{
    tar zxvf inotify-tools-3.14.tar.gz
    cd inotify-tools-3.14
    ./configure --prefix=/local/local/inotify
    make && make install
    cd ..
    rm inotify-tools-3.14 -rf
}

function install_sersync()
{
    tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
    mv  GNU-Linux-x86/ /usr/local/sersync
    echo "rsyncpass" >  /usr/local/sersync/pass
    chmod 600 /usr/local/sersync/pass
    grep sersync /etc/profile || echo "PATH=$PATH:/usr/local/sersync/">>/etc/profile

}



install_rsync
install_inotify
install_sersync

slave端 (添加同步目录)

#!/bin/bash
# --------------------------------------------------
#Author:       晴天
#Email:         admin@attacker.club
#website:      http://attacker.club
# --------------------------------------------------

yum install rsync -y

cat > /etc/rsyncd.conf<<EOF
#Rsync server
uid = root
gid = root
use chroot = no
# 安全相关
max connections = 2000
# 并发连接数
timeout = 600
# 超时时间(秒)
pid file =/var/run/rsyncd.pid
# 指定rsync的pid目录
lock file =/var/run/rsync.lock
# 指定rsync的锁文件【重要】
log file = /var/log/rsyncd.log
# 指定rsync的日志目录
ignore errors
read only = false
list = false

# limit access to private LANs
hosts allow = 10.0.0.0/8 172.16.0.0/16 192.168.0.0/16
hosts deny=*
# hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file =/etc/rsync.password
#################################################

# 模块 
# [bind]
# comment = dns config
# path = /var/named/app


[nginx]
comment = web config
path = /usr/local/nginx/conf/vhosts
EOF

## 权限
echo "rsync_backup:rsyncpass">/etc/rsync.password
chmod 600 /etc/rsync.password

## 开机启动
#pkill rsync && /bin/rsync --daemon
grep rsync  /etc/rc.local|| echo '/usr/bin/rsync --daemon' >> /etc/rc.local

systemctl restart rsyncd
systemctl enable rsyncd

nginx目录 (添加同步目录)

    <localpath watch="/usr/local/nginx/conf/vhosts">
        <remote ip="172.16.1.11" name="nginx"/>
    </localpath>

master端计划任务脚本(添加同步目录)

/usr/local/sersync/check_sersync.sh

sersync="/usr/local/sersync/sersync2"
nginx="/usr/local/sersync/nginx.xml"

status=$(ps aux |grep 'sersync2'|grep -v 'grep'|wc -l)

if [ $status -eq 0 ];then
 $sersync -d -r -o $nginx &
else
 exit 0;
fi
EOF
# 脚本监控

crontab -l

*/5 * * * *  sh /usr/local/sersync/check_sersync.sh
微信打赏

作者: 以谁为师

最后更新: 2019年7月1日

原始链接: http://attacker.club/detail/130.html

转载本文请注明出处





    留言区:


  • 1楼 StevSync 网站

    Ed Meds Overnight Delivery Strep Symptoms Even After Taking Amoxicillin Achat De Viagra Pfizer En Roubaix <a href=http://zgdkdz.com>buy viagra</a> Treatment For Gonorrhea Amoxicillin Revatio