Sersync 文件镜像同步
192.168.1.229上配置如下:
rpm -q rsync
vi /etc/rsyncd.conf
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
[benet]
path=/data/web/benet
comment = xoyo video files
ignore errors = yes
read only = no
hosts allow = 192.168.1.228/24
hosts deny = *
[accp]
path=/data/web/accp
comment = xoyo video files
ignore errors = yes
read only = no
hosts allow = 192.168.1.228/24
hosts deny = *
开启rsync守护进程rsync --deamon
192.168.1.228上配置如下:
tar zxvf sersync2.5beta1_32bit_binary.tar.gz
cd GNU-Linux-x86
cp confxml.xml confxml2.xml
vi confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.4">
<host hostip="localhost" port="8008"></host>
<filter start="false">
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
</inotify>
<sersync>
<localpath watch="/opt/benet" debug="false">
<remote ip="192.168.1.229" name="benet"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
</rsync>
<crontab start="false" schedule="600">
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="refreshCDN"/>
</sersync>
<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/p_w_picpaths"/>
</localpath>
</plugin>
<plugin name="socket">
<localpath watch="/opt/tongbu">
<deshost ip="192.168.138.20" port="8009"/>
</localpath>
</plugin>
</head>
vi confxml2.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.4">
<host hostip="localhost" port="8008"></host>
<filter start="false">
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
</inotify>
<sersync>
<localpath watch="/opt/accp" debug="false">
<remote ip="192.168.1.229" name="accp"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
</rsync>
<crontab start="false" schedule="600">
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="refreshCDN"/>
</sersync>
<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/p_w_picpaths"/>
</localpath>
</plugin>
<plugin name="socket">
<localpath watch="/opt/tongbu">
<deshost ip="192.168.138.20" port="8009"/>
</localpath>
</plugin>
</head>
开启sersync守护进程 ./sersync2 -o confxml.xml -d
./sersync2 -o confxml2.xml -d
测试:
在192.168.1.228上 /opt/benet/ 下创建文件 touch aa.txt
在192.168.1.229上/data/web/benet/ 下看是否同步过来。