千家信息网

sersync如何实现数据实时同步

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,小编给大家分享一下sersync如何实现数据实时同步,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!1.1 第一个里程碑:安
千家信息网最后更新 2026年11月01日sersync如何实现数据实时同步

小编给大家分享一下sersync如何实现数据实时同步,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

1.1 第一个里程碑:安装sersync软件

1.1.1 将软件上传到服务器当中并解压

1、上传软件到服务器上 rz -E

为了便于管理上传位置统一设置为 /server/tools 中

2、解压软件包

[root@backup sersync_installdir_64bit]# tree.└── sersync ├── bin │ └── sersync ├── conf │ └── confxml.xml └── logs

1.1.2 二进制包安装方法

二进制包安装软件方法(绿色软件安装方法):

直接解压就可以使用

[root@nfs01 sersync_installdir_64bit]# mv sersync/ /usr/local/[root@nfs01 tools]# tree /usr/local/sersync/ /usr/local/sersync/ ├── bin │ └── sersync ├── conf │ └── confxml.xml └── logsdirectories, 2 files

1.2 第二个里程碑:编写sersync配置文件

1.2.1 常见的语法格式

rsync 配置文件编写:ini语法

sersync配置文件编写:xml语法

ansible配置文件编写:yml 语法

1.2.2 修改配置文件

编写前备份

[root@backup conf]# lltotal 4-rw-r--r-- 1 root root 2214 Oct 26 2011 confxml.xml[root@backup conf]# cp confxml.xml{,.bak}

6-11行表示排除同步的数据,等价于 --exclude 功能,表示排除

     

12-21行是利用inotify的功能监控指定的事件,等价与 -e create,delete…… 表示指定监控事件信息

         

24-28行:推送到哪里 name=模块 是rsync服务器的地址

  #监控那个目录    

29-35行 定义rsync推送时的参数信息。

注意:不要有单词拼写错误 (true),否则程序不能正常启动,卡死

     

配置文件最终内容:

[root@nfs01 tools]# cat /usr/local/sersync/conf/confxml.xml                                                                

1.3 第三里程碑: 启动sersync

1.3.1 修改文件的权限(可执行)

首先让程序让文件有执行权限

[root@nfs01 bin]# chmod a+x sersync [root@nfs01 bin]# lltotal 1768-rwxr-xr-x 1 root root 1810128 Oct 26 2011 sersync

1.3.2 查看软件的帮助信息

[root@nfs01 bin]# ./sersync -hset the system paramexecute:echo 50000000 > /proc/sys/fs/inotify/max_user_watchesexecute:echo 327679 > /proc/sys/fs/inotify/max_queued_eventsparse the command param_______________________________________________________重要参数-d:启用守护进程模式重要参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍 参数-n: 指定开启守护线程的数量,默认为10个重要参数-o:指定配置文件,默认使用confxml.xml文件 参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块 参数-m:单独启用其他模块,使用 -m socket 开启socket模块 参数-m:单独启用其他模块,使用 -m http 开启http模块不加-m参数,则默认执行同步程序________________________________________________________________

1.3.3 在程序的bin目录下启动程序

./sersync -dro /usr/local/sersync/conf/confxml.xml

1.3.4 启动方法二

将/usr/local/sersync/bin/程序的bin目录添加到PATH中

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/sersync/bin/

然后sersync命令就能直接使用

[root@nfs01 scripts]# sersync -dro /usr/local/sersync/conf/confxml.xml set the system paramexecute:echo 50000000 > /proc/sys/fs/inotify/max_user_watchesexecute:echo 327679 > /proc/sys/fs/inotify/max_queued_eventsparse the command paramoption: -d run as a daemonoption: -r rsync all the local files to the remote servers before the sersync workoption: -o config xml name: /usr/local/sersync/conf/confxml.xmldaemon thread num: 10parse xml config filehost ip : localhost host port: 8008daemon start,sersync run behind the console use rsync password-file :user is rsync_backuppasswordfile is /etc/rsync.passwordconfig xml parse successplease set /etc/rsyncd.conf max connections=0 Manuallysersync 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 onceworking please wait...execute command: cd /data && rsync -az -R --delete ./ rsync_backup@172.16.1.41::nfsbackup --password-file=/etc/rsync.password >/dev/null 2>&1 run the sersync: watch path is: /data

1.4 Inotify与 sersync总结对比

1.4.1 Inotify实时并发:

结论:经过测试,每秒200文件并发,数据同步几乎无延迟(小于1秒)

1.4.2 inotify 优点:

1)监控文件系统事件变化,通过同步工具实现实时数据同步。

1.4.3 inotify 缺点

1)并发如果大于200个文件(10-100k),同步就会有延迟

2)我们前面写的脚本,每次都是全部推送一次,但确实是增量的。也可以只同步变化的文件,不变化的不理。

3)监控到事件后,调用rsync同步是单进程的,而sersync为多进程同步。既然有了inotify-tools,为什么还要开发sersync?

1.4.4 serysync功能多:(inotify+rsync命令)

1)支持通过配置文件管理

2)真正的守护进程socket

3)可以对失败文件定时重传(定时任务功能)

4)第三方的HTTP接口(例如:更新cdn缓存)

5)默认多进程rsync同步

1.4.5 高并发数据实时同步方案小结:

1)inotify(sersync)+ rsync,是文件级别的。

2)drbd文件系统级别,文件系统级别,基于block块同步,缺点:备节点数据不可用

3)第三方软件的同步功能:mysql同步(主从复制),oracle,mongodb

4)程序双写,直接写两台服务器。

5)利用产品业务逻辑解决(读写分离,备份读不到,读主)

2.1 man命令的级别

centos6

[root@nfs01 ~]# man man The standard sections of the manual include: User Commands     #用户命令 System Calls     #系统调用 C Library Functions    # Ç库函数 Devices and Special Files   #设备和特殊文件 File Formats and Conventions  #文件格式和约定 Games et. Al.     #游戏等。 Miscellanea     #杂记 System Administration tools and Daemons #系统管理工具和程序 Distributions customize the manual section to their specifics, which often include additional sections.

centos7

[root@clsn tuichu]# man ~ Executable programs or shell commands System calls (functions provided by the kernel) Library calls (functions within program libraries) Special files (usually found in /dev) File formats and conventions eg /etc/passwd Games Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) System administration commands (usually only for root) Kernel routines [Non standard]

以上是"sersync如何实现数据实时同步"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

文件 同步 参数 程序 软件 配置 数据 模块 监控 实时 功能 命令 系统 进程 事件 方法 服务器 目录 级别 语法 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 广州紫鲸互联网科技有限公司 狮子座互联网科技 唐信互联网科技 西藏七维空间互联网科技有限公司 汽车互联网创新科技园 科技与互联网哪个更好 互联网金融科技公司干啥的 湖南诚度互联网科技有限公司 黑科技闪耀互联网之光 中国航天科技大学国际工业互联网 阿大互联网科技有限公司 宜昌元轩互联网科技有限公司 注册互联网科技公司经营范围大全 上海钢联属于互联网科技股吗 皮皮虾互联网科技有限公司 广州百诚互联网科技有限公司官网 美国互联网科技公司 上海乐五互联网科技有限公司 河南商务圈互联网科技有限公司 互联网科技企业文化 河南云网互联网络科技有限公司 新浪科技互联网 广州优美互联网科技 湖南一路畅行互联网科技 互联网与医疗科技 浙南科技城互联网大厦建设工程 深圳市罗太互联网科技有限公司 烟台灵鸽互联网科技有限公司 互联网科技包装股份有限公司上市 互联网界的黑科技
0