1.sersync介绍
sersync
的实时数据同步:
sersync
监控指定的目录,对监控路径下变化的文件进行实时同步到rsync的服务端。
- 整个过程相当于
rsync+inotify
,并且推送是通过rsync --delete
的,所以使用的时候要谨慎。
2.下载安装
部署前需要在被同步端(rsync服务端)开启响应的ip allow权限,以及增加rsync demon模式的区块配置。一个区块配置对应一个sersync的进程。
1 2 3 4
| cd /usr/local/src wget -S http://nagios.bytech.boyihuyu.com/linux/tools/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz tar xvf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/local/ ln -s /usr/local/sersync2.5.4 /usr/local/sersync
|
3.配置文件
如果想要监控多个目录,拷贝多个配置文件对应起多个进程来实时监控。
1 2
| cd /usr/local/sersync/conf/ cp confxml.xml yd_vhosts.xml
|
只需要配置配置文件yd_vhosts.xml
下的<sersync>
区块
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <sersync> <localpath watch="/usr/local/nginx/conf/vhosts/"> <remote ip="x.x.x.x" name="yd_web_nginx_config"/> # rsync服务端ip,区块名 <!--<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"/> # 如果需要密码,改成true,对应密码文件600 <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="true" time="100"/><!-- timeout=100 --> # 超时时间,可开可不开。 <ssh start="false"/> </rsync> # 错误日志路径 <failLog path="/usr/local/sersync/log/yd_vhosts_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>
|
4.启动
1 2 3 4 5
| /usr/local/sersync/bin/sersync2 -r -d -o /usr/local/sersync/conf/yd_vhosts.xml
# -r 第一次启动进行一次推送 # -d 守护进程 # -o 指定配置文件
|