sersync 只传输改变的文件,对于网络压力较小
安装 sersync
目标服务器
yum install rsync
mkdir /usr/local/webserver/rsync
cd /usr/local/webserver/rsync
vim rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 10
strict modes = yes
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/run/rsyncd.log
ignore errors
read only = no
write only = no
hosts allow = 172.16.100.15
hosts deny = *
list = false
auth users = rsync
secrets file = /usr/local/webserver/rsync/rsync.passwd
[web]
path = /data/www
auth users = rsync
[conf]
path = /usr/local/webserver/nginx/conf
[php]
path = /usr/local/webserver/php/etc
vim rsync.passwd
#用户名:密码 随便起
rsync:rsync
源服务器
yum install rsync
vim rsync.passwd
chmod 600 rsync.passwd
ll /proc/sys/fs/inotify/
sysctl -a | grep max_q
sysctl -a | grep max_u
vim /etc/sysctl.conf
sysctl -w fs.inotify.max_queued_events="99999999"
sysctl -w fs.inotify.max_user_watches="99999999"
sysctl -w fs.inotify.max_user_instances="65535"
sysctl -p
tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
mv GNU-Linux-x86 sersync
sersync 配置文件:
<?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>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="false"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
</inotify>
<sersync>
<localpath watch="/data/www">
<remote ip="172.16.100.76" name="web"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-artuz --exclude-from=/usr/local/webserver/rsync/exfile"/>
<auth start="true" users="rsync" passwordfile="/usr/local/webserver/rsync/rsync.passwd"/>
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/usr/local/webserver/rsync/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>
<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>
启动
/usr/local/webserver/rsync/sersync/sersync2 -d -r -o /usr/local/webserver/rsync/sersync/confxml.xml &
参考:
http://www.jb51.net/LINUXjishu/142722.html
https://code.google.com/p/sersync/