sersync+rsync   實時同步

 1客戶端 192.168.0.153   服務端  115.182.10.144

客戶端操作
http://code.google.com/p/sersync/downloads/list    sersync 下載地址
tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/bin
cd /usr/bin/GNU-Linux-x86/
[root@wlmachine GNU-Linux-x86]# ls
confxml.xml  sersync2
有這兩個文件是對的
 
 
vim confxml.xml  
[root@wlmachine GNU-Linux-x86]# vim 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>
        <exclude expression="(.*)\.gz"></exclude>
        <exclude expression="^info/*"></exclude>
        <exclude expression="^static/*"></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="/opt/test">
            <remote ip="192.168.1.55" name="test"/>
            <!--<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"/>
            <userDefinedPort start="false" port="874"/><!-- port=874 -->
            <timeout start="false" time="100"/><!-- timeout=100 -->
            <ssh start="false"/>
        </rsync>
        <failLog path="/tmp/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">
加粗部分是更改的部分                                                                        
更改共享目錄
 
保存退出
 
檢查rsync是否安裝  如果沒有 yum安裝
服務端  也安裝rsync
安裝完成後 配置主配置文件,如果沒有就創建一個
vim /etc/rsyncd.conf 
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
 
[test]#此處要和sersync配置目錄相同
path=/opt/test#本地同步存放目錄
comment = http file
ignore errors = yes
read only = no
其他配置不用改
服務端啓動   rsync --daemon
客戶端啓動   cd /usr/bin/GNU-Linux-x86/
執行如下命令  啓動守護進城及第一次同步
[root@wlmachine GNU-Linux-x86]# ./sersync2 -rd
現在可以測試了。。
如果有/var/run/pid 之類的錯誤 直接rm -fr  刪除即可
####如果有防火牆    iptables -A INPUT -p tcp --dport 803 -j ACCEPT
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章