yum install rsync
vim /etc/rsyncd.confphp
pid file=/var/rsynclog/rsyncd.pid log file=/var/rsynclog/rsyncd.log lock file=/var/rsynclog/rsync.lock motd file=/etc/rsyncd.motd port=873 address=10.10.1.56 hosts allow=10.10.1.35 #hosts deny=0.0.0.0/0 uid=heron gid=heron max connections=10 read only=no list=yes ###密碼文件 secrets file=/etc/rsyncd.secrets ### 有須要能夠添加多個目錄 [dist] comment=rsync dist directory path=/home/heron/www/dist [yadmin] comment=rsync yadmin directory path=/home/heron/www/yadmin [miniapp] comment=rsync miniapp directory path=/home/heron/www/miniapp
cat /etc/rsyncd.secrets ### 兩臺服務器密碼文件的權限設置爲600git
heron:RD18v1Fx831AIrROo
啓動並設置開機自啓動express
systemctl start rsyncd systemctl enable rsyncd
yum install rsync
vim /etc/rsyncd.secretsvim
heron:RD18v1Fx831AIrROo
安裝sersync並配置服務器
tar fxzsersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/local/ cd /usr/local/ mv GNU-Linux-x86 sersync vim sersync/confxm.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="true"> <exclude expression="(.*)\.git"></exclude> <exclude expression="(.*)\.log"></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="/home/heron/www/dist"> <remote ip="10.10.1.56" name="dist"/> <!--<remote ip="192.168.8.39" name="tongbu"/>--> <!--<remote ip="192.168.8.40" name="tongbu"/>--> </localpath> <rsync> <commonParams params="-auz"/> <auth start="true" users="heron" passwordfile="/etc/rsync.secrets"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="true" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/usr/local/sersync/logs/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>
啓動,能夠配置多個文件啓動app
-d參數表示放到後臺、-r表示先進行一次完整同步,-o表示指向某個配置文件,注意:配置文件配置了忽略文件的話,啓動方式不能夠帶r參數dom
/usr/local/sersync/sersync -dro /usr/local/sersync/dict_confxml.xml