rsync+sersync 实时同步备份

Linux文件系统上一般用scp&rsync来同步文件,而一般我们会选择后者来同步容量大的文件,而且可实现压缩、更新传输,配合sersync,更可实现同步传输。
环境部署:server(192168.3.11)端安装sersync,用来监控本机需备份目录,客户端(192.168.3.12)开启rsync守护进程即可,一旦所监控目录内容有变化,会实时更新目录内容至客户端。
sersync资源

  1. wget --no-check-certificate https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz
  2. git clone https://github.com/wsgzao/sersync.git
    Clinet端配置
    [root@varnish2 ~]# yum install rsync xinetd -y
    [root@varnish2 ~]# vim /etc/rsyncd.conf 
    uid = root
    gid = root
    port = 873
    address = 192.168.3.12
    hosts allow = 192.168.3.0/24
    use chroot = yes
    maxconnections = 5
    lock file = /var/run/rsync.lock
    logfile = /var/log/rsyncd.log
    motd file = /etc/rsyncd.motd
    [webback]
    path = /backup
    comment = web back server
    list = yes
    read only = false
    auth users = backer
    secrets file = /etc/rsync.passwd
    [root@varnish2 ~]# mkdir /backup
    [root@varnish2 ~]# vim /etc/rsync.passwd
    backer:123456789
    [root@varnish2 ~]# chmod 600 /etc/rsync.passwd 
    [root@varnish2 ~]# echo "welcome backup server" > /etc/rsyncd.motd
    [root@varnish2 ~]# systemctl start xinetd
    [root@varnish2 ~]# rsync --daemon --config=/etc/rsyncd.conf
    [root@varnish2 ~]# netstat -antup|grep 873
    tcp        0      0 192.168.3.12:873        0.0.0.0:*               LISTEN      7636/rsync

server端配置

[root@localhost html]# yum install rsync xinetd -y
[root@localhost html]# systemctl start xinetd
[root@localhost html]# rsync --daemon
[root@localhost html]# vim /etc/rsync.passwd
123456789
[root@localhost ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mv GNU-Linux-x86/ sersync
[root@localhost local]# cd sersync/
[root@localhost sersync]# ls
confxml.xml  sersync2
[root@localhost sersync]# vim confxml.xml 
        <localpath watch="/var/www/html">
            <remote ip="192.168.3.12" name="webback"/>
        ..........
         <auth start="true" users="backer" passwordfile="/etc/rsync.passwd"/>
[root@localhost sersync]# /usr/local/sersync/sersync2 -d -r -o /usr/local/sersync/confxml.xml 

测试
在server端/var/www/html 内创建或删除文件,Client端也会同步进行对应操作

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值