William126

Linux如何从零开始搭建rsync+serync服务器(centOS6)

一、为什么要用Rsync+sersync架构?
1、sersync是基于Inotify开发的,类似于Inotify-tools的工具
2、sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或某一个目录的名字,然后使用rsync同步的时候,只同步发生变化的这个文件或者这个目录。
二、Rsync+Inotify-tools与Rsync+sersync这两种架构有什么区别?
1、Rsync+Inotify-tools
(1):Inotify-tools只能记录下被监听的目录发生了变化(包括增加、删除、修改),并没有把具体是哪个文件或者哪个目录发生了变化记录下来;
(2):rsync在同步的时候,并不知道具体是哪个文件或者哪个目录发生了变化,每次都是对整个目录进行同步,当数据量很大时,整个目录同步非常耗时(rsync要对整个目录遍历查找对比文件),因此,效率很低。
2、Rsync+sersync
(1):sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或某一个目录的名字;
(2):rsync在同步的时候,只同步发生变化的这个文件或者这个目录(每次发生变化的数据相对整个同步目录数据来说是很小的,rsync在遍历查找比对文件时,速度很快),因此,效率很高。
小结:当同步的目录数据量不大时,建议使用Rsync+Inotify-tools;当数据量很大(几百G甚至1T以上)、文件很多时,建议使用Rsync+sersync。
 
请提前搭建好rsync服务器。
 
1.目录结构如下:

[root@nfs001 /]# tree /application/
/application/
`-- serync2.5.4
|-- bin
| `-- sersync2
|-- conf
| |-- confxml.xml
| `-- confxml.xml.ori
`-- logs
`-- rsync_fail_log.sh

 

2.编辑confxml.xml,修改如下:

<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
</inotify>

<sersync>
<localpath watch="/nfs_server/">
<remote ip="172.16.1.41" name="backup/"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-artuz"/>
<auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="true" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/application/serync2.5.4/logs/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->

3.运行serync服务。
 
4.添加开机自启动服务。
 
 
 

posted on 2017-12-24 13:43  William126  阅读(346)  评论(0编辑  收藏  举报

导航