APP02安装 rsync服务端
yum install rsync
vim /etc/rsyncd.conf
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 ### 两台服务器密码文件的权限设置为600
heron:RD18v1Fx831AIrROo
启动并设置开机自启动
systemctl start rsyncd
systemctl enable rsyncd
APP01安装rsync+sersync(代码所在服务器)
yum install rsync
vim /etc/rsyncd.secrets
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>
启动,可以配置多个文件启动
-d参数表示放到后台、-r表示先进行一次完整同步,-o表示指向某个配置文件,注意:配置文件配置了忽略文件的话,启动方式不可以带r参数
/usr/local/sersync/sersync -dro /usr/local/sersync/dict_confxml.xml