rsync服务器端配置:
rsync地址:http://rsync.samba.org/
tar zxvf rsync-3.0.4.tar.gz
cd rsync-3.0.4
./configure
make && make install
vi /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 10
strict modes = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[web1]
path = /var/data
comment = web1 file
ignore errors
read only = no
write only = no
hosts allow = *
hosts deny = 192.168.1.12
list = false
auth users = backup
secrets file = /etc/server.pass
创建密码文件:格式:username:password
echo "123.com" > /etc/server.pass
chmod 600 server.pass
Iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 873 -s sersync_ip -j ACCEPT
启动rsync服务:/usr/local/bin/rsync –daemon
在sersync服务器的布置:
1)下载安装包:
[root@qyeee ~]# wget http://sersync.googlecode.com/files/sersync2.5_64bit_binary_stable_final.tar.gz
--2012-03-26 12:10:00-- http://sersync.googlecode.com/files/sersync2.5_64bit_binary_stable_final.tar.gz
Resolving sersync.googlecode.com... 74.125.128.82
Connecting to sersync.googlecode.com|74.125.128.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
lication/x-gzip]
Saving to: `sersync2.5_64bit_binary_stable_final.tar.gz'
100%[=======================================================================================================================================>] 650,330 457K/s in 1.4s
2012-03-26 12:10:02 (457 KB/s) - `sersync2.5_64bit_binary_stable_final.tar.gz' saved [650330/650330]
[root@qyeee ~]# tar zxvf sersync2.5_64bit_binary_stable_final.tar.gz
GNU-Linux-x86/
GNU-Linux-x86/confxml.xml
GNU-Linux-x86/sersync2
2)将sersync根目录放到etc下:
[root@qyeee ~]# mv GNU-Linux-x86 /etc/sersync
[root@qyeee ~]# cd /etc/sersync/
[root@qyeee sersync]# ll
total 1596
-rwxr-xr-x 1 root root 2214 Jun 29 2010 confxml.xml
-rwxr-xr-x 1 root root 1617440 Jun 29 2010 sersync2
3)编辑主配置文件:
[root@qyeee sersync]# vi confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host> ##sersync服务器ip,对扩展插件调用
<debug start="true"/>
<fileSystem xfs="false"/>
<filter start="true"> ##开启文件过滤模块
<exclude expression="(.*)\.svn"></exclude>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="(.*)\.txt"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
<inotify> ##开启文件状态改变监控模块
<delete start="true"/>
<createFolder start="true"/>
<createFile start="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="true"/>
<modify start="true"/>
</inotify>
<sersync> ##监控源和远端rsync服务器设置
<localpath watch="/app/gm">
<remote ip="remostip" name="web1"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-azv"/> ##配置rsync同步参数
<auth start="true" users="backup" passwordfile="/etc/server.pass"/> ##开启密码认证机制
<userDefinedPort start="false" port="873"/><!-- port=874 --> ##自定义端口,默认873
<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="1"><!--600mins--> ##crontab完整同步,如果filter开启不起作用
<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>
4)创建密码认证文件:
[root@qyeee tmp]# echo "123.com" > /etc/server.pass
chmod 600 /etc/server.pass
关闭selinux
启动sersync服务:
./sersync2 -d
[root@qyeee tmp]# ps -ef | grep -v grep | grep rsync
root 29544 1 0 16:28 ? 00:00:18 ./sersync2 -d
测试ok!!
有扩展的地方请大家参与修改