sersync+rsync实时同步

sersync-master.zip

172.21.45.52(Sersync server)源服务器

172.11.251.51(Rsync server)目标服务器

客户端安装rsync

yum -y install rsync

vim /etc/rsyncd.conf

# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:
uid = root
gid = root
use chroot = yes
max connections = 100
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
timeout = 600
log file = /home/log/rsync.log
ignore errors
read only = false
list = false
hosts allow = 172.21.45.0/24
host deny = 0.0.0.0/32
auth users = backup
secrets file = /etc/rsync.password
# ignore nonreadable = yes
# dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
# [ftp]
#        path = /home/ftp
#        comment = ftp export area
[html]
comment = html
path = /home/html

[root@Rsync ~]# echo “backup:damowang” > /etc/rsync.password

[root@Rsync ~]# chmod 600 /etc/rsync.password

[root@Rsync ~]# rsync --daemon

[root@Rsync ~]# ss -lntup |grep rsync

源端

[root@Sersync ~]# echo “damowang” > /etc/rsync.password

[root@Sersync ~]# chmod 600 /etc/rsync.password

源端测试

rsync -azvp /home/nmon.sh backup@192.168.3.5::htmlb/ --password-file=/etc/rsync.password

[root@Sersync ~]# unzip sersync-master.zip

[root@Sersync ~]# tar xf sersync-master/release/sersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/local/

[root@Sersync ~]# cd /usr/local/

[root@Sersync local]# mv GNU-Linux-x86/ sersync

[root@Sersync local]# cd sersync/

[root@Sersync sersync]# cp confxml.xml confxml.xml.$(date +%F)

[root@Sersync sersync]# vim confxml.xml

vim confxml.xml

# 修改24、25行
    <sersync>
        <localpath watch="/var/www/html">    # 本地同步目录
        <remote ip="192.168.94.44" name="www"/>     # rsync模块名

# 修改31行
    <rsync>
        <commonParams params="-artuz"/>
        <auth start="true" users="backup" passwordfile="/etc/rsync.password"/> 

sersync2 -d -r -o /usr/local/sersync/confxml.xml

服务脚本

#! /bin/bash  
#集合三同步
#sersyncd 
#  
. /etc/rc.d/init.d/functions  
case "$1" in  
       start)  
       cd /usr/local/sersync  
       /usr/local/sersync/sersync2 -d -r -o /usr/local/sersync/confxmlc.xml
        if [ $? -eq 0 ]  
                then   
                echo -e "Staring sersyncd      [  OK  ]" 
                exit 0  
        fi  
        ;;  
        stop)  
        kill 'ps aux | grep sersync2 | grep -v grep | awk '{print $2}''  
        if [ $? -eq 0 ]  
               then   
                echo -e "Stopping sersyncd     [  OK  ]" 
                exit 0  
        fi  
        ;;  
       status)  
        ps aux | grep sersync2 | grep -v grep  
        ;;  
esac
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值