1. 程式人生 > >centos6.5下部署sersync+rsync --daemon同步數據

centos6.5下部署sersync+rsync --daemon同步數據

lse 事件 配置 p地址 erro common true ini command

rsync --daemon端配置

[root@rsync-daemon etc]# /etc/init.d/iptables stop
[root@rsync-daemon ~]# dos2unix rsyncd.conf 
dos2unix: converting file rsyncd.conf to UNIX format ...
[root@rsync-daemon ~]# cp rsyncd.conf /etc/
[root@rsync-daemon ~]# cd /etc/
[root@rsync-daemon etc]# useradd -M -s /sbin/nologin rsync
[root@rsync-daemon etc]# vi rsyncd.conf 
[root@rsync-daemon etc]# cat rsyncd.conf 
[root@rsync-daemon data]# cat /etc/rsyncd.conf
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[data]
path = /data/
ignore errors
read only = false
list = false
hosts allow = 10.0.0.0/24
#hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
#rsync_config_______________end

[root@rsync-daemon etc]# mkdir /data
[root@rsync-daemon etc]# chown -R rsync.rsync /data
[root@rsync-daemon etc]# echo "rsync_backup:123456" >>/etc/rsync.password
[root@rsync-daemon etc]# chmod 600 /etc/rsync.password 
[root@rsync-daemon etc]# echo "rsync --daemon" >>/etc/rc.local
[root@rsync-daemon data]# rsync --daemon --config=/etc/rsyncd.conf
[root@rsync-daemon etc]# netstat -lntup|grep rsync
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2821/rsync 
tcp 0 0 :::873 :::* LISTEN 2821/rsync

sersync數據推送端配置

[root@sersync tools]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz 
[root@sersync tools]# ll
total 716
drwxr-xr-x 2 root root 4096 Oct 26 2011 GNU-Linux-x86
-rw-r--r-- 1 root root 727290 Feb 26 18:34 sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@sersync tools]# cp -a GNU-Linux-x86 /usr/local/sersync
[root@sersync tools]# cd /usr/local/sersync/
[root@sersync sersync]# ll
total 1772
-rwxr-xr-x 1 root root 2214 Oct 26 2011 confxml.xml
-rwxr-xr-x 1 root root 1810128 Oct 26 2011 sersync2
[root@sersync sersync]# echo "PATH=/usr/local/sersync:$PATH" >/etc/profile.d/sersync.sh 
[root@sersync sersync]# source /etc/profile.d/sersync.sh
[root@sersync sersync]# echo "123456" >/etc/rsync.password
[root@sersync sersync]# chmod 600 /etc/rsync.password
[root@sersync sersync]# rsync -avzP /data/ [email protected]::data --password-file=/etc/rsync.password        #<===首先測試rsync同步是否成功
[root@sersync sersync]# vi confxml.xml 
[root@sersync sersync]# cat 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"/>                                                                 #<===系統是否是xfs
<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="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="true"/>
<modify start="true"/>
</inotify>

<sersync>                                                                                #<===這裏配置rsync --daemon端的ip地址,及模塊的名稱(帶!是註釋掉了的)
<localpath watch="/data">
<remote ip="10.0.0.4" name="data"/>
</localpath>
<rsync>
<commonParams params="-artuz"/>                                                #<===調用的rsync的參數
<auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>                          #<===啟用rsync及用戶及指定密碼文件
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="true" time="100"/><!-- timeout=100 -->                                                             #<===設置超時時間
<ssh start="false"/> 
</rsync>
<failLog path="/usr/local/sersync/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>

[root@sersync sersync]# sersync2 -r -d -o /usr/local/sersync/confxml.xml    #<===啟動sersync
[root@sersync sersync]# echo "sersync2 -r -d -o /usr/local/sersync/confxml.xml" >>/etc/rc.local    #<===加入開機自啟動

以上是所有配置,經測試,同步成功,速度極快.......

centos6.5下部署sersync+rsync --daemon同步數據