安裝環境 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 同步站點文件配置
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.