sersync2.5+rsync实现数据同步

环境
源服务器IP:192.168.1.51
目标服务器IP:192.168.1.52




目标服务器
#tar -zxvf rsync-3.0.9.tar.gz
#cd rsync-3.0.9
#./configure --prefix=/usr/local/rsync
#make && make install

#cd /usr/local/rsync/
#mkdir etc
#vim /usr/local/rsync/etc/rsyncd.conf


uid=nobody
gid=nobody
use chroot=no
max connections=200
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock

[http]
uid=root
gid=root
path=/usr/local/nginx/html/sync
comment = wwwroot
read only = no
write only = no
list = yes
ignore errors = yes
hosts allow = 192.168.1.51/24
hosts deny = *

#/usr/local/rsync/bin/rsync --daemon --config=/usr/local/rsync/etc/rsyncd.conf

#iptables -A INPUT -p tcp --dport 873 -j ACCEPT



源服务器
#tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
#mv GNU-Linux-x86/ /usr/local/sersync2.5
#cd /usr/local/sersync2.5/
# vim /usr/local/sersync2.5/confxml.xml



<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="192.168.1.51" 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="/usr/local/nginx/html/sync">
            <remote ip="192.168.1.52" name="http"/>
            <!--<remote ip="192.168.8.39" name="tongbu"/>-->
            <!--<remote ip="192.168.8.40" name="tongbu"/>-->






        <failLog path="/var/log/sersync2.log" timeToExecute="60"/>




配置完成,先做一次整体同步
#/usr/local/sersync2.5/sersync2 -r -o /usr/local/sersync2.5/confxml.xml


守护进程模式启动sersync2
#/usr/local/sersync2.5/sersync2 -d -o /usr/local/sersync2.5/confxml.xml









sersync2配置文件详解

<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="9090"></host>
    <debug start="false"/>
    <fileSystem xfs="false"/>
    <filter start="true">
     <exclude expression="^((?!original\.).*)$"></exclude>    
                    #只备份源里面文件名是original开头的,后缀名不限定的文件,?!original 代表反向选择
     <!-- <exclude expression="abc"></exclude>
     <exclude expression="image"></exclude>
     <exclude expression="txt"></exclude>
     <exclude expression="xml"></exclude>
     <exclude expression="*"></exclude>
     -->
    </filter>
    <inotify>
     <delete start="false"/>                    #不监控文件或目录的删除
     <createFolder start="true"/>    
posted @ 2013-10-29 14:03  消磨_时间  阅读(115)  评论(0)    收藏  举报