第一个里程: 下载安装 sersync 软件
先进行软件下载, 把软件包上传到系统中
- unzip sersync_installdir_64bit.zip
- cd sersync_installdir_64bit
- mv sersync /usr/local/
- tree
第二个里程: 编写 sersync 配置文件
- [root@nfs01 sersync]# cd /usr/local/sersync/conf/
- [root@nfs01 conf]# ll
总用量 4
- -rw-r--r-- 1 root root 2214 2011-10-26 11:54 confxml.xml
- 6 <filter start="false">
- 7 <exclude expression="(.*)\.svn"></exclude>
- 8 <exclude expression="(.*)\.gz"></exclude>
- 9 <exclude expression="^info/*"></exclude>
- 10 <exclude expression="^static/*"></exclude>
- 11 </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>
说明: 类似于 inotify 的 - e 参数功能, 指定监控的事件信息
- <sersync>
- <localpath watch="/data">
- <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="-az"/>
- <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
- <userDefinedPort start="false" port="874"/><!-- port=874 -->
- <timeout start="false" time="100"/><!-- timeout=100 -->
- <ssh start="false"/>
- </rsync>
说明: 以上内容是数据相关的配置信息, 是必须进行修改调整配置
第三个里程: 应用 sersync 软件, 实现实时同步
- [root@nfs01 conf]# cd /usr/local/sersync/
- [root@nfs01 sersync]# cd bin/
- [root@nfs01 bin]# ll
总用量 1768
-rw-r--r-- 1 root root 1810128 2011-10-26 14:19 sersync
sersync 命令参数:
参数 - d: 启用守护进程模式
参数 - r: 在监控前, 将监控目录与远程主机用 rsync 命令推送一遍 (测试)
参数 - n: 指定开启守护线程的数量, 默认为 10 个
参数 - o: 指定配置文件, 默认使用 confxml.xml 文件
./sersync -dro /usr/local/sersync/conf/confxml.xml
来源: http://www.bubuko.com/infodetail-2631418.html