安装环境 192.168.1.124 sersync服务器 192.168.1.127 客户端 centos6 64bit 192.168.1.124 sersync服务器执行以下操作 下载地址http://code.google.com/p/sersync/downloads/list tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/bin [root@localhost ~]# cd /usr/bin/GNU-Linux-x86/ [root@localhost GNU-Linux-x86]# ls confxml.xml sersync2 vim 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> <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> #############################add 20120309############################### 对于大多数应用,可以尝试把createFile(监控文件事件选项)设置为false来提高性能,减少 rsync通讯。因为拷贝文件到监控目录会产生create事件与close_write事件,所以如果关闭create事件,只监控文件拷贝结束时的事 件close_write,同样可以实现文件完整同步。 注意:强将createFolder保持为true,如果将createFolder设为false,则不会对产生的目录进行监控,该目录下的子文件与子目录也不会被监控。所以除非特殊需要,请开启。 默认情况下对创建文件(目录)事件与删除文件(目录)事件都进行监控,如果项目中不需要删除远程目标服务器的文件(目录),则可以将delete 参数设置为false,则不对删除事件进行监控。 补充参考http://lihuipeng.blog.51cto.com/3064864/563291 ###############################add 20120309############################## <sersync> #以下部分是我做的改动,其余没变要和客户端对应 <localpath watch="/opt/test"> <remote ip="192.168.1.127" name="test"/> <!--<remote ip="192.168.8.39" name="tongbu"/>--> <!--<remote ip="192.168.8.40" name="tongbu"/>--> </localpath> # <rsync> <commonParams params="-artuz"/> <auth start="false" users="root" passwordfile="/etc/rsync.pas"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <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="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> 安装 yum install rsync(sersync调用) 192.168.1.127客户端 yum install rsync [root@localhost test]# rpm -qa | grep rsync rsync-3.0.6-5.el6_0.1.x86_64 vi /etc/rsyncd.conf uid=root gid=root max connections=100 use chroot=no log file=/var/log/rsyncd.log pid file=/var/run/rsyncd.pid lock file=/var/run/rsyncd.lock [test] #和sersync相关内容对应 path=/opt/test #uid = root comment = test ignore errors = yes read only = no hosts allow = 192.168.1.124 192.168.1.127 启动服务 rsync --daemon [root@localhost test]# ps -ef | grep rsync root 1873 1 0 Dec06 ? 00:00:00 rsync --daemon root 2818 1855 0 00:07 pts/0 00:00:00 grep rsync [root@localhost test]# lsof -i:873 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME rsync 1873 root 4u IPv4 11195 0t0 TCP *:rsync (LISTEN) rsync 1873 root 5u IPv6 11196 0t0 TCP *:rsync (LISTEN) 然后 192.168.1.124 sersync服务器执行以下操作启动服务 /usr/bin/GNU-Linux-x86/sersync2 -d -o /usr/bin/GNU-Linux-x86/confxml.xml rsync --daemon [root@localhost GNU-Linux-x86]# ps -ef | grep rsync root 1878 1 0 Dec06 ? 00:00:00 /usr/bin/GNU-Linux-x86/sersync2 -d -o /usr/bin/GNU-Linux-x86/confxml.xml root 2543 1860 0 00:09 pts/0 00:00:00 grep rsync 然后说说我这两边的其他操作 我把selinux关了 iptables也关了 好了 现在可以测试去试试了
sersync 同步站点文件配置
最新推荐文章于 2025-05-01 22:33:20 发布