在同步服务器上开启sersync,将监控路径中的文件同步到目标服务器,因此需要在同步服务器配置sersync,在同步目标服务器配置rsync。

一、同步目标服务器配置rsync

  1. # rpm -qa |grep rsync
  2. rsync-2.6.8-3.1
  3. # rpm -e rsync-2.6.8-3.1

unistall系统自带安装的rsync,安装3.0版的rsync

  1. # wget -c http://rsync.samba.org/ftp/rsync/rsync-3.0.8.tar.gz
  2. # tar xf rsync-3.0.8.tar.gz
  3. # ./configure --prefix=/usr && make && make install
  4. # vi /etc/rsyncd.conf

添加下面的代码到rsyncd.conf中

  1. uid = nobody
  2. gid = nobody
  3. use chroot = no
  4. strict modes = yes
  5. max connections = 200
  6. pid file = /var/run/rsyncd.pid
  7. lock file = /var/run/rsync.lock
  8. log file = /var/log/rsyncd.log
  9. [test]
  10. path = /home/
  11. comment = test
  12. read only = no
  13. write only = no
  14. ignore errors = yes
  15. list = yes
  16. uid = root
  17. gid = root

启动rsync服务

  1. # rsync --daemon

二、配置sersync2

sersync2是金山逍遥网技术支持部平台组周洋童鞋,开发的一款基于 inotify + rsync 的大量文件的多服务器自动同步程序,目前已开源,开源协议为 New BSD License,项目的下载地址:

  1. http://code.google.com/p/sersync/

这个配置超简单的,下载文件,解压即可

  1. # wget -c http://sersync.googlecode.com/files/sersync2.5_64bit_binary_stable_final.tar.gz
  2. # tar xf sersync2.5_64bit_binary_stable_final.tar.gz
  3. # cd GNU-Linux-x86
  4. # mkdir /etc/sersync2
  5. # cp confxml.xml /etc/sersync2
  6. # cp sersync2 /usr/bin

配置sersync2

  1. <sersync>
  2. <localpath watch="/data/bb">
  3. <remote ip="192.168.1.4" name="test"/>
  4. <remote ip="192.168.1.6" name="test"/>
  5. <!--<remote ip="192.168.8.40" name="tongbu"/>-->
  6. </localpath>
  7. <rsync>
  8. <commonParams params="-artuz"/>
  9. <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
  10. <userDefinedPort start="false" port="874"/><!-- port=874 -->
  11. <timeout start="false" time="100"/><!-- timeout=100 -->
  12. <ssh start="false"/>
  13. </rsync>
  14. <failLog path="/var/log/rsync_fail.log" timeToExecute="60"/><!--default every 60mins execute once-->
  15. <crontab start="false" schedule="600"><!--600mins-->
  16. <crontabfilter start="false">
  17. <exclude expression="*.php"></exclude>
  18. <exclude expression="info/*"></exclude>
  19. </crontabfilter>
  20. </crontab>
  21. <plugin start="false" name="command"/>
  22. </sersync>

表明要将同步服务器上本地的/data/bb 路径下的文件,同步到远程服务器 192.168.1.4 与 192.168.1.6上的test 模块下。

接下来,运行sersync2

#  sersync2 -r -o /etc/sersync2/confxml.xml

-r的意义

  1. -r 在开启实时监控之前对同步服务器目录与远程目标机目录进行一次整体同步

运行完了输出

  1. set the system param
  2. execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
  3. execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
  4. parse the command param
  5. option: -r      rsync all the local files to the remote servers before the sersync work
  6. option: -d      run as a daemon
  7. option: -o      config xml name:  /etc/sersync2/confxml.xml
  8. daemon thread num: 10
  9. parse xml config file
  10. host ip : localhost     host port: 8008
  11. daemon start,sersync run behind the console
  12. config xml parse success
  13. please set /etc/rsyncd.conf max connections=0 Manually
  14. sersync working thread 112  = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
  15. Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads)
  16. please according your cpu ,use -n param to adjust the cpu rate
  17. ------------------------------------------
  18. rsync the directory recursivly to the remote servers once
  19. working please wait...
  20. execute command: cd /data/bb && rsync -artuz -R --delete ./ 192.168.1.4::test >/dev/null 2>&1
  21. run the sersync:
  22. watch path is: /data/bb

sersync2的参数

  1. sersync2 -h
  2. set the system param
  3. execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
  4. execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
  5. parse the command param
  6. _______________________________________________________
  7. 参数-d:启用守护进程模式
  8. 参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍
  9. c参数-n: 指定开启守护线程的数量,默认为10个
  10. 参数-o:指定配置文件,默认使用confxml.xml文件
  11. 参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块
  12. 参数-m:单独启用其他模块,使用 -m socket 开启socket模块
  13. 参数-m:单独启用其他模块,使用 -m http 开启http模块
  14. 不加-m参数,则默认执行同步程序
  15. ________________________________________________________________

索性一次性运行

  1. #  sersync2 -r -d -o /etc/sersync2/confxml.xml

其他功能待研究中

sersync2 实时同步配置的更多相关文章

  1. Rsync结合Inotify 实时同步配置(更新之前繁琐的传输认证)

    今天一位CU的友友根据之前介绍过 通过rsync+inotify-tools+ssh实现触发式远程实时同步  配置分发系统,但是由于认证繁琐,很容易出错,我今天重新整理了下,用rsync密码文件pas ...

  2. centos6.6配置rsync+sersync实现实时同步分布式多客户端分发同步

    1.sersync项目: sersync项目利用inotify与rsync技术实现对服务器数据实时同步到解决方案,其中inotify用于监控sersync所在服务器上文件系统的事件变化,rsync是目 ...

  3. Sersync实时同步企业应用配置实战

    一.实验环境 CentOS版本: 6.6(2.6.32.-504.el6.x86_64) Rsync版本:  Rsync-3.0.6(系统自带) Sersync版本:sersync2.5.4_64bi ...

  4. 数据文件实时同步(rsync + sersync2)

    因近期项目需求,需要同步云端服务器的数据给**方做大数据分析. 思路: 起初只要数据同步,准备开放数据采集接口.但实时性较差,会有延迟. 故而寻觅各种解决方案,最终确定使用 rsync 进行文件同步, ...

  5. sersync2 文件的实时同步备份

    |——需求: 监控192.168.9.5[主]  下的 /data/vmeipai 目录  --> 同步到 192.168.12.8 [备] 下的 /data/vmeipai 目录 |——网络拓 ...

  6. Linux 下配置多机实时同步

    没钱的时候,用此方案做网站内容的负载均衡.异地备份,经济实惠又方便(仅针对网站文件做实时同步,如果数据库,则考虑mysql的多主架构) 一.机器配置及机房IP A机,位于杭州,IP: 115.33.2 ...

  7. 配置rsync+inotify实时同步

    与上一篇同步做 配置rsync+inotify实时同步 1:调整inotify内核参数 在linux内核中,默认的inotify机制提供三个调控参数:max_queue_events.max_user ...

  8. rsync简介与rsync+inotify配置实时同步数据

    rsync简介 rsync是linux系统下的数据镜像备份工具.使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSH.rsync主机同步. rsync特性 rsync ...

  9. Centos 6.5配置rsync+inotify实现文件实时同步

    1.安装rsync(两台机器执行相同的步骤)yum install gcc yum install rsyncd xinetd -y因为rsync是由xinetd启动的,所以需要修改一个配置vim / ...

随机推荐

  1. JS 代理模式

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. linux下IPTABLES配置详解

    如果你的IPTABLES基础知识还不了解,建议先去看看. 开始配置 我们来配置一个filter表的防火墙. (1)查看本机关于IPTABLES的设置情况 [root@tp ~]# iptables - ...

  3. hd oj2015

    #include "stdio.h"int main(){ int n,m,k,num,i,sum=0; while(~scanf("%d%d",&n, ...

  4. Cisco路由器的6种模式

    Cisco路由器的6种模式 -------------------------------------------------------------------------------------- ...

  5. Ubuntu安装Osmocom-BB一只猿多频点WEB脚本

    LAMP(Linux- Apache-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统,Apache网络服务器,MySQL数据 库,Perl.PHP或者Pytho ...

  6. struts2和servlet同时用(访问servlet时被struts2过滤器拦截问题的解决)

    在同一个项目中间,如果既用到servlet有用了struts2的框架,运行项目时可能无法正常使用servlet,原因是在配置struts2的核心控制器时<url-pattern>/*< ...

  7. 6、C#基础整理(for 语句经典习题--for循环嵌套、穷举)

    1.for循环嵌套----最基础题目:求阶乘的和 ; int n = int.Parse(Console.ReadLine()); ; i < n; i++) { ;//定义变量sum1,每次循 ...

  8. 对dataTable去重

    using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.T ...

  9. 开源 VS 商业,消息中间件你不知道的那些事

    11月23日,新炬网络中间件技术专家刘拓老师在DBA+社群中间件用户组进行了一次主题为“开源 VS 商业,消息中间件你不知道的那些事”的线上分享.小编特别整理出其中精华内容,供大家学习交流. 嘉宾简介 ...

  10. OpenFlow Switch学习笔记(四)——Matching

    这次我们着重详述来自于网络中的数据包在OpenFlow Switch中与Flow Entries的具体匹配过程,以及当出现Table Miss时的处理方式,下面就将从这两方面说起. 1.Matchin ...