sersync2 实时同步配置
在同步服务器上开启sersync,将监控路径中的文件同步到目标服务器,因此需要在同步服务器配置sersync,在同步目标服务器配置rsync。
一、同步目标服务器配置rsync
- # rpm -qa |grep rsync
- rsync-2.6.8-3.1
- # rpm -e rsync-2.6.8-3.1
unistall系统自带安装的rsync,安装3.0版的rsync
- # wget -c http://rsync.samba.org/ftp/rsync/rsync-3.0.8.tar.gz
- # tar xf rsync-3.0.8.tar.gz
- # ./configure --prefix=/usr && make && make install
- # vi /etc/rsyncd.conf
添加下面的代码到rsyncd.conf中
- uid = nobody
- gid = nobody
- use chroot = no
- strict modes = yes
- max connections = 200
- pid file = /var/run/rsyncd.pid
- lock file = /var/run/rsync.lock
- log file = /var/log/rsyncd.log
- [test]
- path = /home/
- comment = test
- read only = no
- write only = no
- ignore errors = yes
- list = yes
- uid = root
- gid = root
启动rsync服务
- # rsync --daemon
二、配置sersync2
sersync2是金山逍遥网技术支持部平台组周洋童鞋,开发的一款基于 inotify + rsync 的大量文件的多服务器自动同步程序,目前已开源,开源协议为 New BSD License,项目的下载地址:
- http://code.google.com/p/sersync/
这个配置超简单的,下载文件,解压即可
- # wget -c http://sersync.googlecode.com/files/sersync2.5_64bit_binary_stable_final.tar.gz
- # tar xf sersync2.5_64bit_binary_stable_final.tar.gz
- # cd GNU-Linux-x86
- # mkdir /etc/sersync2
- # cp confxml.xml /etc/sersync2
- # cp sersync2 /usr/bin
配置sersync2
- <sersync>
- <localpath watch="/data/bb">
- <remote ip="192.168.1.4" name="test"/>
- <remote ip="192.168.1.6" name="test"/>
- <!--<remote ip="192.168.8.40" name="tongbu"/>-->
- </localpath>
- <rsync>
- <commonParams params="-artuz"/>
- <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
- <userDefinedPort start="false" port="874"/><!-- port=874 -->
- <timeout start="false" time="100"/><!-- timeout=100 -->
- <ssh start="false"/>
- </rsync>
- <failLog path="/var/log/rsync_fail.log" timeToExecute="60"/><!--default every 60mins execute once-->
- <crontab start="false" schedule="600"><!--600mins-->
- <crontabfilter start="false">
- <exclude expression="*.php"></exclude>
- <exclude expression="info/*"></exclude>
- </crontabfilter>
- </crontab>
- <plugin start="false" name="command"/>
- </sersync>
表明要将同步服务器上本地的/data/bb 路径下的文件,同步到远程服务器 192.168.1.4 与 192.168.1.6上的test 模块下。
接下来,运行sersync2
# sersync2 -r -o /etc/sersync2/confxml.xml
-r的意义
- -r 在开启实时监控之前对同步服务器目录与远程目标机目录进行一次整体同步
运行完了输出
- set the system param
- execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
- execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
- parse the command param
- option: -r rsync all the local files to the remote servers before the sersync work
- option: -d run as a daemon
- option: -o config xml name: /etc/sersync2/confxml.xml
- daemon thread num: 10
- parse xml config file
- host ip : localhost host port: 8008
- daemon start,sersync run behind the console
- config xml parse success
- please set /etc/rsyncd.conf max connections=0 Manually
- sersync working thread 112 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
- Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads)
- please according your cpu ,use -n param to adjust the cpu rate
- ------------------------------------------
- rsync the directory recursivly to the remote servers once
- working please wait...
- execute command: cd /data/bb && rsync -artuz -R --delete ./ 192.168.1.4::test >/dev/null 2>&1
- run the sersync:
- watch path is: /data/bb
sersync2的参数
- sersync2 -h
- set the system param
- execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
- execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
- parse the command param
- _______________________________________________________
- 参数-d:启用守护进程模式
- 参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍
- c参数-n: 指定开启守护线程的数量,默认为10个
- 参数-o:指定配置文件,默认使用confxml.xml文件
- 参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块
- 参数-m:单独启用其他模块,使用 -m socket 开启socket模块
- 参数-m:单独启用其他模块,使用 -m http 开启http模块
- 不加-m参数,则默认执行同步程序
- ________________________________________________________________
索性一次性运行
- # sersync2 -r -d -o /etc/sersync2/confxml.xml
其他功能待研究中
sersync2 实时同步配置的更多相关文章
- Rsync结合Inotify 实时同步配置(更新之前繁琐的传输认证)
今天一位CU的友友根据之前介绍过 通过rsync+inotify-tools+ssh实现触发式远程实时同步 配置分发系统,但是由于认证繁琐,很容易出错,我今天重新整理了下,用rsync密码文件pas ...
- centos6.6配置rsync+sersync实现实时同步分布式多客户端分发同步
1.sersync项目: sersync项目利用inotify与rsync技术实现对服务器数据实时同步到解决方案,其中inotify用于监控sersync所在服务器上文件系统的事件变化,rsync是目 ...
- Sersync实时同步企业应用配置实战
一.实验环境 CentOS版本: 6.6(2.6.32.-504.el6.x86_64) Rsync版本: Rsync-3.0.6(系统自带) Sersync版本:sersync2.5.4_64bi ...
- 数据文件实时同步(rsync + sersync2)
因近期项目需求,需要同步云端服务器的数据给**方做大数据分析. 思路: 起初只要数据同步,准备开放数据采集接口.但实时性较差,会有延迟. 故而寻觅各种解决方案,最终确定使用 rsync 进行文件同步, ...
- sersync2 文件的实时同步备份
|——需求: 监控192.168.9.5[主] 下的 /data/vmeipai 目录 --> 同步到 192.168.12.8 [备] 下的 /data/vmeipai 目录 |——网络拓 ...
- Linux 下配置多机实时同步
没钱的时候,用此方案做网站内容的负载均衡.异地备份,经济实惠又方便(仅针对网站文件做实时同步,如果数据库,则考虑mysql的多主架构) 一.机器配置及机房IP A机,位于杭州,IP: 115.33.2 ...
- 配置rsync+inotify实时同步
与上一篇同步做 配置rsync+inotify实时同步 1:调整inotify内核参数 在linux内核中,默认的inotify机制提供三个调控参数:max_queue_events.max_user ...
- rsync简介与rsync+inotify配置实时同步数据
rsync简介 rsync是linux系统下的数据镜像备份工具.使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSH.rsync主机同步. rsync特性 rsync ...
- Centos 6.5配置rsync+inotify实现文件实时同步
1.安装rsync(两台机器执行相同的步骤)yum install gcc yum install rsyncd xinetd -y因为rsync是由xinetd启动的,所以需要修改一个配置vim / ...
随机推荐
- JavaScript基础--超级玛丽(七)(上下左右控制)
相信大家都玩过超级玛丽,下面实现控制玛丽的上.下.左.右等基本功能,本篇只是在练习JavaScript的用法 1.创建一个HTML页面 <!doctype html> <html l ...
- Spark的编译
由于Spark的运行环境的多样性,如可以运行在hadoop的yarn上,这样就必须要对Spark的源码进行编译.下面介绍一下Spark源码编译的详细步骤: 1.Spark的编译方式:编译的方式可以参考 ...
- <转>用thinkPHP实现验证码的功能
许多系统的登录都有验证码,而如果使用thinkPHP框架搭建网站的话,验证码的生成和验证就比较容易了 1.生成验证码 thinkPHP有对应生成验证码的方法 要使用验证码,需要导入扩展类库中的ORG. ...
- python黑帽子源码
https://www.nostarch.com/download/BHP-Code.zip https://yunpan.cn/cPvLPWMTdWJRu 访问密码 4243
- SVG 2D入门6 - 坐标与变换
坐标系统 SVG存在两套坐标系统:视窗坐标系与用户坐标系.默认情况下,用户坐标系与视窗坐标系的点是一一对应的,都为原点在视窗的左上角,x轴水平向右,y轴竖直向下:如下图所示: SVG的视窗位置一般是由 ...
- mongo db 分享 ppt
在公司内部的mongo db的ppt.初步进阶 http://files.cnblogs.com/files/yuhan-TB/mongoDB.pptx
- Python mix-in 组合 ~ 将类组合起来 .
在一个池塘中有10个乌龟 1 条鱼 . class Turtle: def __init__(self,x): # 在生命对象的时候 说明对象的 数量 . (还是一个对象 . 数量只是该对象的一个属性 ...
- PB常用日期
用一条语句写成的有关日期函数 //1.生肖(年份参数:int ls_year 返回参数:string): mid(fill('鼠牛虎兔龙蛇马羊猴鸡狗猪',48),(mod(ls_year -1900 ...
- cocos2dx 搭建 android 平台 -2
1.配置Cocos2d-x for Xcode. 这一块比较简单, 可以参见其他文章. 重点:install-templates-xcode.sh 2.配置普通Android开发环境 这一块包括JDK ...
- 重学STM32---(八)----SDIO
1. SDIO(SD/SDIO MMC卡主机模块)在AHB外设总线和多媒体卡(MMC).SD存储卡.SDIO卡和CE-ATA设备间提供了操作接口.(SDIO没有SPI兼容的通信模式 ) 1.1.什么是 ...