实时同步---------sersync

sersync是基于inotify,rsync开发的工具,不仅保留了优点同时还强化了实时监控,文件过滤,简化配置等功能,帮助用户提高运行效率,节省时间和网络资源。

Sersync项目利用Inotify和Rsync工具技术实现对服务器数据实时复制。

当事件发生变化后,利用rsync命令把变化的数据复制到远端服务器上。

Sersync特点

  • 使用C++编写,支持对监控事件的过滤
  • Sersync采用xml配置文件,由守护进程启动,配置起来比起简易的inotify+rsync更简单
  • 使用多线程复制,可以并发复制多个不同文件,效率更高
  • Sersync自带异常检测机制,可以通过失败队列对出错的文件重新复制
  • 自带crontab功能,实现对失败队列中的文件定时整体复制
  • 自带socket和HTTP协议扩展,定制特殊需求,二次开发

 sersync的部署

1、下载安装
[root@nfs-31 /opt]#wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz

2、解压下载的压缩包
[root@nfs-31 /opt]#tar -xvf sersync2.5.4_64bit_binary_stable_final.tar.gz 

3、配置文件修改
在修改配置文件的时候需要查看你在备份服务器设置的配置文件信息
[root@rsync-41 ~]#cat /etc/rsyncd.conf
uid = www 
gid = www 
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 600
ignore errors
read only = false
list = false
auth users = rsync_backup
secrets file = /etc/rsync.passwd 
log file = /var/log/rsyncd.log
#####################################
[backup]
comment = 172.16.1.31 about rsync
path = /backup

[data]
comment = this is secord backup dir,to website data..
path = /data

修改sersync的配置文件
[root@nfs-31 /opt]#cat ./sersync254/confxml.xml
<sersync>
	<localpath watch="/nfs-data">
	    <remote ip="172.16.1.41" name="data"/>
	    <!--<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.pwd"/>

 sersync服务的启动

[root@nfs-31 ~]#/opt/sersync254/sersync2  -r -d -o  /opt/sersync254/confxml.xml 
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:  /opt/sersync254/confxml.xml
daemon thread num: 10
parse xml config file
host ip : localhost	host port: 8008
daemon start,sersync run behind the console 
use rsync password-file :
user is	rsync_backup
passwordfile is 	/etc/rsync.pwd
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12  = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads) 
Max threads numbers is: 22 = 12(Thread pool nums) + 10(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 /nfs-data && rsync -az -R --delete ./ rsync_backup@172.16.1.41::data --password-file=/etc/rsync.pwd >/dev/null 2>&1 
run the sersync: 
watch path is: /nfs-data

[相关参数解释]

参数-d:启用守护进程模式

参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍

c参数-n: 指定开启守护线程的数量,默认为10个

参数-o:指定配置文件,默认使用confxml.xml文件

参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块

参数-m:单独启用其他模块,使用 -m socket 开启socket模块

参数-m:单独启用其他模块,使用 -m http 开启http模块

不加-m参数,则默认执行同步程序
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值