sersync2 实时同步配置

简介:

在同步服务器上开启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.  
  10. [test] 
  11. path = /home/
  12. comment = test 
  13. read only = no 
  14. write only = no 
  15. ignore errors = yes 
  16. list = yes 
  17. uid = root 
  18. 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

其他功能待研究中



本文转自dongfang_09859 51CTO博客,原文链接:http://blog.51cto.com/hellosa/586164,如需转载请自行联系原作者

相关文章
|
负载均衡 Ubuntu 应用服务中间件
|
缓存 Linux 开发工具
CentOS 7- 配置阿里镜像源
阿里镜像官方地址http://mirrors.aliyun.com/ 1、点击官方提供的相应系统的帮助 :2、查看不同版本的系统操作: 下载源1、安装wget yum install -y wget2、下载CentOS 7的repo文件wget -O /etc/yum.
263031 0
|
3月前
|
Web App开发 缓存 监控
商品销量详情接口(item_get_sales)深度分析及 Python 实现
item_get_sales接口用于获取商品销量数据,包括历史趋势、时段分布、规格占比等,助力销售策略优化、库存管理与竞品分析。支持多平台调用,提供Python示例代码,适用于电商运营与市场分析场景。
|
5月前
|
存储 前端开发 应用服务中间件
Django 实战:静态文件与媒体文件从开发配置到生产部署
Django项目中,静态文件(Static Files)和媒体文件(Media Files)是两类不同用途的文件。本文详细介绍了它们的区别、配置方法以及在开发与生产环境中的处理方式,并结合用户头像上传功能进行实战演示,最后讲解了如何通过Nginx或OpenResty部署静态与媒体文件服务。
276 1
【恶意代码系列】五、处理恶意代码主要步骤及总结
【恶意代码系列】五、处理恶意代码主要步骤及总结
|
PHP
php 使用phpize报错Cannot find config.m4. Make sure that you run ‘/usr/bin/phpize‘ in the top l
php 使用phpize报错Cannot find config.m4. Make sure that you run ‘/usr/bin/phpize‘ in the top l
724 1
|
数据可视化 前端开发 数据管理
电商项目之项目背景介绍|学习笔记
快速学习电商项目之项目背景介绍
电商项目之项目背景介绍|学习笔记
|
存储 弹性计算 固态存储
阿里云服务器NVMe SSD本地盘和SATA HDD本地盘详解
阿里云本地盘是ECS实例物理机上的硬盘,提供低延迟、高IOPS和高吞吐量的存储选项。分为NVMe SSD和SATA HDD两种类型。NVMe SSD适合I/O密集型应用,如在线业务和NoSQL数据库,支持多种ECS实例规格。SATA HDD适合大数据存储和离线计算,适用于金融和互联网行业的Hadoop计算。欲了解更多详情,可参阅阿里云块存储页面。
1200 9
|
存储 运维 监控
【运维知识进阶篇】Sersync实时同步详解
【运维知识进阶篇】Sersync实时同步详解
534 0