实时同步sersync

简介:

192.168.16.134 sersync

192.168.16.135 rsyncd


192.168.16.135:

安装rsyncd

tar xf rsync-3.1.1.tar.gz

cd rsync-3.1.1

./configure --prefix=/usr/local/rsync

make && make install


ln -s /usr/local/rsync/bin/rsync /usr/bin/


配置rsyncd:

mkdir /etc/rsyncd

vim /etc/rsyncd/rsyncd.conf 

uid=root

gid=root

use chroot=false

max connections=200

timeout=600

pid file=/var/run/rsyncd.pid

lock file=/var/run/rsyncd.lock

log file=/var/log/rsyncd.log


[test]

path=/data/test 文件路径

read only=false  不只读

auth users=rsync认证用户

secrets file=/etc/rsyncd/rsyncd.password 认证文件名


创建密码:

echo  'rsync:123456' >> /etc/rsyncd/rsyncd.password  <---- 创建认证文件

chmod 600 /etc/rsyncd/rsyncd.password   <----不修改会一直报没权限。


启动:

rsync --daemon --address=192.168.16.135  --port=873 --config=/etc/rsyncd/rsyncd.conf


设置开机启动:

echo "rsync --daemon --address=192.168.16.135  --port=873 --config=/etc/rsyncd/rsyncd.conf" >> /etc/rc.local


192.168.16.134

安装rsyncd

tar xf rsync-3.1.1.tar.gz

cd rsync-3.1.1

./configure --prefix=/usr/local/rsync

make && make install

 

ln -s /usr/local/rsync/bin/rsync /usr/bin/


安装sersync

tar xf sersync2.5_32bit_binary_stable_final.tar.gz

mv GNU-Linux-x86/ /usr/local/sersync


修改配置:

vim /usr/local/sersync/confxml.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<head version="2.5">

    <host hostip="localhost" port="8008"></host>

    <debug start="false"/>

    <fileSystem xfs="false"/>

    <filter start="false">

<exclude expression="(.*)\.svn"></exclude>

    </filter>

    <inotify>

<delete start="false"/>            //取消参数--delete

<createFolder start="true"/>

<createFile start="true"/>

<closeWrite start="true"/>

<moveFrom start="true"/>

<moveTo start="true"/>

<attrib start="false"/>

<modify start="true"/>

    </inotify>


    <sersync>

<localpath watch="/data/test">

   <remote ip="192.168.16.135" name="test"/>   //16.135服务器设置的rsync项目名称。

</localpath>

<rsync>

   <commonParams params="-az"/>

   <auth start="true" users="rsync" passwordfile="/etc/rsyncd/rsync.password.scrt"/>        //定义rsync用户与密码路径。

   <userDefinedPort start="true" port="873"/>  //定义端口为873。

   <timeout start="false" time="100"/>

   <ssh start="false"/>

</rsync>

<failLog path="/tmp/rsync_fail_log.log" timeToExecute="60"/> //失败日志。

<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>

    <plugin name="command">

<param prefix="/bin/sh" suffix="" ignoreError="true"/><!--prefix /opt/tongbu/mmm.sh suffix-->

<filter start="false">

   <include expression="(.*)\.php"/>

   <include expression="(.*)\.sh"/>

</filter>

    </plugin>


    <plugin name="socket">

<localpath watch="/opt/tongbu">

   <deshost ip="192.168.138.20" port="8009"/>

</localpath>

    </plugin>

    <plugin name="refreshCDN">

<localpath watch="/data0/htdocs/cms.xoyo.com/site/">

   <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>

   <sendurl base="http://pic.xoyo.com/cms"/>

   <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>

</localpath>

    </plugin>

</head>


配置按照自己的情况修改。


创建密码文件:

mkdir /etc/rsyncd

echo  'rsync:123456' >> /etc/rsyncd/rsync.password.scrt  <---- 创建认证文件

chmod 600 /etc/rsyncd/rsync.password.scrt


配置完成,先做一次整体同
/usr/local/sersync/sersync2 -r -o /usr/local/sersync/confxml.xml


对本地到远程整体同步一遍后,在后台运行实时同步
/usr/local/sersync/sersync2 -r -d -o /usr/local/sersync/confxml.xml

你可能感兴趣的:(rsync,sersync,实时同步)