[toc]
centos7.7搭建sersync
sersync已于2015年8月停止更新,作者推荐使用lsyncd
1.sersync简介
sersync主要用于服务器同步,web镜像等功能。基于boost1.41.0,inotify api,rsync command.开发。目前使用的比较多的同步解决方案是inotify-tools+rsync ,另外一个是google开源项目Openduckbill(依赖于inotify- tools),这两个都是基于脚本语言编写的。相比较上面两个项目,本项目优点是:
1.sersync是使用c++编写,而且对linux系统文件系统产生的临时文件和重复的文件操作进行过滤(详细见附录,这个过滤脚本程序没有实现),所以在结合rsync同步的时候,节省了运行时耗和网络资源。 因此更快。
2.相比较上面两个项目,sersync配置起来很简单,其中bin目录下 已经有基本上静态 编译的2进制文件,配合bin目录下的xml配置文件直接使用即可。
3.另外本项目相比较其他脚本开源项目,使用多线程进行同步,尤其在同步较大文件时,能够保证多个服务器实时保持同步状态。
4.本项目有出错处理机制,通过失败队列对出错的文件重新同步,如果仍旧失败,则 每10个小时对同步失败的文件重新同步。
5.本项目自带crontab功能,只需在xml配置文件中开启,即可按您的要求,隔一段时间整体同步一次。无需再额外配置crontab功能。
6.本项目socket与http插件扩展,满足您二次开发的需要。
同步原理图
2.sersync搭建过程
- sersync流程
- 安装sersync的服务器角色为客户端,实时检测在sersync中配置的共享目录文件变化,采用客户端主动推送的方式将发生变化的文件传输到服务端
- sersync负责检测文件变化,真正同步文件还是rsync
试验环境
角色 | IP | 主机名 | 安装服务 |
---|---|---|---|
rsync server | 10.0.0.10 | rsync-server | rsync |
rsync client | 10.0.0.11 | rsync-client | sersync、rsync、inotify-tools |