双服务器文件实现双向同步rsync+sersync2

server1:192.168.1.10
server1:192.168.1.11

下面以在192.168.1.10 安装为例(红色部分为需要修改的地方,具体IP在192.168.1.11对调就可以)

#安装rsync
yum -y install rsync

#设置本机用户名与密码
vi /etc/rsync.pas
peter:111111

#设置远程服务的密码
vi /etc/rsync_server.pas
111111

chmod 600 /etc/rsync.pas
chmod 600 /etc/rsync_server.pas

vi /etc/rsyncd.conf

uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
lock file=/var/run/rsyncd.lock

[tongbu]
path=/opt/tongbu
comment = server1
ignore errors = yes
read only = no
auth users=peter
secrets file=/etc/rsync.pas
hosts allow = 192.168.1.11
hosts deny = *

#独立启动
rsync --daemon

#配置开机启动,配置xinetd
vi /etc/xinetd.d/rsync
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
#reboot
netstat -tnlp | grep 873
grep 'rsync' /etc/services #可以看到873端口

#安装sersync2
tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
cd GNU-Linux-x86
vi confxml.xml

<sersync>
        <localpath watch="/opt/tongbu">
            <remote ip="192.168.56.103" name="tongbu"/>
            <!--<remote ip="192.168.8.39" name="tongbu"/>-->
            <!--<remote ip="192.168.8.40" name="tongbu"/>-->
        </localpath>
        <rsync>
            <commonParams params="-artuz"/>
            <auth start="true" users="peter" passwordfile="/etc/rsync_server.pas"/>
            <userDefinedPort start="false" port="874"/><!-- port=874 -->
            <timeout start="false" time="100"/><!-- timeout=100 -->
            <ssh start="false"/>
        </rsync>
        <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
        <crontab start="false" schedule="600"><!--600mins-->
            <crontabfilter start="false">
                <exclude expression="*.php"></exclude>
                <exclude expression="info/*"></exclude>
            </crontabfilter>
        </crontab>
        <plugin start="false" name="command"/>
    </sersync>

#独立启动
/home/GNU-Linux-x86/sersync2 -d -r -o /home/GNU-Linux-x86/confxml.xml
#配置开机启动,修改rc.local
vi /etc/rc.d/rc.local
#增加
/home/GNU-Linux-x86/sersync2 -d -r -o /home/GNU-Linux-x86/confxml.xml

转载于:https://blog.51cto.com/jxlwc/2048833

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值