rsync sersync2 文件实时双向同步

来源:互联网 发布:襄阳蓝芯软件 编辑:程序博客网 时间:2024/05/16 19:14
操作系统:centos7 64 mini安装 如何安装

server1:192.168.56.102
server1:192.168.56.103

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

#安装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.56.103
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
0 0
原创粉丝点击