拓扑图如下:
同步目标服务器
Vim /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 [web] path=/data0/web comment = McShell web ignore errors = yes read only = no hosts allow = 10.1.0.0/24 hosts deny = *
编辑完之后执行rsync –daemon 开启守护进程
剩下的服务器都一样配置。
同步服务器的confxml.xml如下
<?xml version="1.0" encoding="ISO-8859-1"?> <head version="2.2"> <host hostip="10.1.0.2" port="8008"></host> <filter start="false"> <exclude expression="(.*)\.gz"></exclude> <exclude expression="^info/*"></exclude> </filter> <sersync> <localpath watch="/data0/web " debug="false"> <remote ip="10.1.0.4" name="web"/> <remote ip="10.1.0.5" name="web"/> <remote ip="10.1.0.6" name="web"/> <!--<remote ip="192.168.8.39" name="tongbu"/>--> </localpath> <rsyncauth start="flase" users="www" passwordfile="/etc/rsync.pas"/> <crontab start="false" schedule="600"> <crontabfilter start="false"> <exclude expression="*.php"></exclude> <exclude expression="info/*"></exclude> </crontabfilter> </crontab> </sersync> </head>
然后执行:
./sersyncphp –d 在主服务器上开启sersync守护进程,使sersync在后台运行,开启实时同步。.
./sersyncphp –r 在开启实时监控的之前对主服务器目录与远程目标机目录进行一次整体同步
扩展:
如果进行多个目录同步,复制出多个confxml.xml即可,名称根据自己来定义,不可相同。
执行
./sersync -o XXXX.xml
[/img]..