sersync

目录

sersync

  如果需要跨机房同步一些数据,sersync是非常有用的。这里我们假设从A服务器同步数据到B服务器

A服务器

安装

wget http://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz
tar xvf sersync2.5.4_64bit_binary_stable_final.tar.gz
mv GNU-Linux-x86 /usr/local/webserver/sersync

配置

cp /usr/local/webserver/sersync/confxml.xml /usr/local/webserver/sersync/myconfig.conf
vim myconfig.conf
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="false"/>
    <fileSystem xfs="false"/>
    <filter start="true">
                <exclude expression="config\.inc\.php"></exclude>
                <exclude expression="(.*)logs/in\.html"></exclude>  #不需要同步的内容
    </filter>
    <inotify>
                <delete start="true"/>
                <createFolder start="true"/>
                <createFile start="false"/>
                <closeWrite start="true"/>
                <moveFrom start="true"/>
                <moveTo start="true"/>
                <attrib start="true"/>
                <modify start="true"/>
    </inotify>

    <sersync>
        <localpath watch="/data/htdocs/web/"> #同步的目录
            <remote ip="xxx.xxx.xxx.xxx" name="user"/>   #可以写多个
        </localpath>
....

启动

/usr/local/webserver/sersync/sersync2 -n 24 -d -o /usr/local/webserver/sersync/myconfig.conf

B服务器

安装

yum install rsync -y

配置

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

[xxx_com]
path=同步到哪个目录
comment  = xxx_com
ignore errors = yes
read only = no
list = no
hosts allow = 192.168.1.4
hosts deny = *

启动

rsync --daemon

测试

在A服务器的同步目录写下新建文件,然后到B服务器上看是否产生了新建的文件

目录