簡介:php
192.168.16.134 sersyncexpress
192.168.16.135 rsyncdvim
192.168.16.135:服務器
安裝rsyncd:dom
tar xf rsync-3.1.1.tar.gzssh
cd rsync-3.1.1socket
./configure --prefix=/usr/local/rsyncide
make && make installsvn
ln -s /usr/local/rsync/bin/rsync /usr/bin/ui
配置rsyncd:
mkdir /etc/rsyncd
vim /etc/rsyncd/rsyncd.conf
uid=root
gid=root
use chroot=false
max connections=200
timeout=600
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
log file=/var/log/rsyncd.log
[test]
path=/data/test 文件路徑
read only=false 不僅讀
auth users=rsync認證用戶
secrets file=/etc/rsyncd/rsyncd.password 認證文件名
建立密碼:
echo 'rsync:123456' >> /etc/rsyncd/rsyncd.password <---- 建立認證文件
chmod 600 /etc/rsyncd/rsyncd.password <----不修改會一直報沒權限。
啓動:
rsync --daemon --address=192.168.16.135 --port=873 --config=/etc/rsyncd/rsyncd.conf
設置開機啓動:
echo "rsync --daemon --address=192.168.16.135 --port=873 --config=/etc/rsyncd/rsyncd.conf" >> /etc/rc.local
192.168.16.134:
安裝rsyncd:
tar xf rsync-3.1.1.tar.gz
cd rsync-3.1.1
./configure --prefix=/usr/local/rsync
make && make install
ln -s /usr/local/rsync/bin/rsync /usr/bin/
安裝sersync:
tar xf sersync2.5_32bit_binary_stable_final.tar.gz
mv GNU-Linux-x86/ /usr/local/sersync
修改配置:
vim /usr/local/sersync/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>
</filter>
<inotify>
<delete start="false"/> //取消參數--delete
<createFolder start="true"/>
<createFile start="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="true"/>
</inotify>
<sersync>
<localpath watch="/data/test">
<remote ip="192.168.16.135" name="test"/> //16.135服務器設置的rsync項目名稱。
</localpath>
<rsync>
<commonParams params="-az"/>
<auth start="true" users="rsync" passwordfile="/etc/rsyncd/rsync.password.scrt"/> //定義rsync用戶與密碼路徑。
<userDefinedPort start="true" port="873"/> //定義端口爲873。
<timeout start="false" time="100"/>
<ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.log" timeToExecute="60"/> //失敗日誌。
<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/p_w_picpaths"/>
</localpath>
</plugin>
</head>
配置按照本身的狀況修改。
建立密碼文件:
mkdir /etc/rsyncd
echo 'rsync:123456' >> /etc/rsyncd/rsync.password.scrt <---- 建立認證文件
chmod 600 /etc/rsyncd/rsync.password.scrt
配置完成,先作一次總體同:
/usr/local/sersync/sersync2 -r -o /usr/local/sersync/confxml.xml
對本地到遠程總體同步一遍後,在後臺運行實時同步:
/usr/local/sersync/sersync2 -r -d -o /usr/local/sersync/confxml.xml