集群05-sersync工具实现实时复制到backup备份服务器

集群05-sersync工具实现实时复制到backup备份服务器

1、下载sersync

[root@nfs01 ~]# cd/usr/local/src/

[root@nfs01 src]# wget https://raw.githubusercontent.com/orangle/sersync/master/release/sersync2.5.4_64bit_binary_stable_final.tar.gz

2、解压并重命名

[root@nfs01 src]# tar -zxvfsersync2.5.4_64bit_binary_stable_final.tar.gz

[root@nfs01 src]# mv GNU-Linux-x86/ sersync

首先进行目录规划

[root@nfs01 src]# tree sersync

sersync

├── bin

│   └── sersync2

├── conf

│   └── confxml.xml

├── confxml.xml.bak

└── log

    └──rsync_fail_log.sh(根据配置文件自动生成的

 

3、配置sersync

[root@nfs01 src]# cd sersync

[root@nfs01 sersync]# cp confxml.xml confxml.xml.bak

[root@nfs01 sersync]# vim confxml.xml

<?xml version="1.0"encoding="ISO-8859-1"?>

<head version="2.5">

    <hosthostip="localhost" port="8008"></host>

    <debugstart="false"/>

    <fileSystemxfs="false"/>

    <filterstart="false">   #过滤规则,默认false不开启

        <excludeexpression="(.*)\.svn"></exclude>

        <excludeexpression="(.*)\.gz"></exclude>

        <exclude expression="^info/*"></exclude>

        <excludeexpression="^static/*"></exclude>

    </filter>

    <inotify>    #inotify事件监控

        <deletestart="true"/>

        <createFolderstart="true"/>

        <createFilestart="false"/>

        <closeWritestart="true"/>

        <moveFromstart="true"/>

        <moveTostart="true"/>

        <attribstart="false"/>

        <modifystart="false"/>

    </inotify>

 

    <sersync>    #sersync配置

        <localpathwatch="/data/">#同步目录

            <remote ip="172.16.1.41" name="backup"/>#rsync服务器ip,name为模块

            <!--<remoteip="192.168.8.39" name="tongbu"/>-->

            <!--<remoteip="192.168.8.40" name="tongbu"/>-->

        </localpath>

        <rsync> #rsync配置

            <commonParams params="-artuz"/>#rsync参数,如可改为-avz

            <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>  #rsync用户名和密码文件

            <userDefinedPort start="false"port="874"/><!-- port=874 --> #rsync端口

            <timeout start="true"time="100"/><!-- timeout=100 --> #rsync超时时间

            <ssh start="false"/>

        </rsync>

        <failLogpath="/tmp/rsync_fail_log.sh"timeToExecute="60"/><!--default every 60mins execute once--> #日志存放位置

        <crontabstart="true"schedule="600"><!--600mins--> #定时任务

            <crontabfilterstart="false">

            <excludeexpression="*.php"></exclude>

            <excludeexpression="info/*"></exclude>

            </crontabfilter>

        </crontab>

        <pluginstart="false" name="command"/>

    </sersync>

 

    <pluginname="command">

        <paramprefix="/bin/sh" suffix=""ignoreError="true"/>  <!--prefix/opt/tongbu/mmm.sh suffix-->

        <filterstart="false">

            <includeexpression="(.*)\.php"/>

            <includeexpression="(.*)\.sh"/>

        </filter>

    </plugin>

 

    <pluginname="socket">

        <localpathwatch="/opt/tongbu">

            <deshost ip="192.168.138.20"port="8009"/>

        </localpath>

    </plugin>

    <pluginname="refreshCDN">

        <localpathwatch="/data0/htdocs/cms.xoyo.com/site/">

            <cdninfodomainname="ccms.chinacache.com" port="80"username="xxxx" passwd="xxxx"/>

            <sendurlbase="http://pic.xoyo.com/cms"/>

            <regexurl regex="false"match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>

        </localpath>

    </plugin>

</head>

4、启动sersync2

[root@nfs01 sersync]# bin/sersync2 -d -r -n 8 -oconf/confxml.xml

-d:后台运行

-r:启动时,同步一次

-n:进程数

-o:指定配置文件

5、开机启动

[root@nfs01 /]# vim /etc/rc.local

添加内容:

/usr/local/src/sersync/bin/sersync2 -d -r -n 8 -o/usr/local/src/sersync/conf/confxml.xml

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值