概述

sersync是基于inotify开发的,类似于inotify-tools的工具

sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或者某一个目录的名字,然后使用rsync同步的时候,只同步发生变化的文件或者目录

rsync+inotify-tools与rsync+sersync架构的区别?

1.rsync+inotify-tools

  • inotify只能记录下被监听的目录发生了变化(增,删,改)并没有把具体是哪个文件或者哪个目录发生了变化记录下来;
  • rsync在同步的时候,并不知道具体是哪个文件或目录发生了变化,每次都是对整个目录进行同步,当数据量很大时,整个目录同步非常耗时(rsync要对整个目录遍历查找对比文件),因此效率很低

2.rsync+sersync

  • sersync可以记录被监听目录中发生变化的(增,删,改)具体某个文件或目录的名字;
  • rsync在同步时,只同步发生变化的文件或目录(每次发生变化的数据相对整个同步目录数据来说很小,rsync在遍历查找对比文件时,速度很快),因此效率很高。

总结:

当同步的目录数据量不大时,建议使用rsync+inotify

当同步的目录数据量很大时(几百G甚至1T以上)文件很多时,建议使用rsync+sersync

安装sersync

  sersync 下载地址,验证码【 eh2b 】

安装步骤

  1. [root@nfs01 ~]# unzip sersync_installdir_64bit.zip
  2.  
  3. [root@nfs01 ~]# ls
  4. anaconda-ks.cfg sersync_installdir_64bit sersync_installdir_64bit.zip
  5.  
  6. [root@nfs01 ~]# mv sersync_installdir_64bit/sersync/ /usr/local/sersync

配置文件修改

  1. [root@nfs01 sersync]# ls
  2. bin conf logs
  3.  
  4. [root@nfs01 sersync]# vim conf/confxml.xml
  5. <?xml version="1.0" encoding="ISO-8859-1"?>
  6. <head version="2.5">
  7. <host hostip="localhost" port=""></host>
  8. #开启调试模式
  9. <debug start="true"/>
  10. <fileSystem xfs="false"/>
  11. #指定排除数据信息, 不进行实时同步
  12. <filter start="false">
  13. <exclude expression="(.*)\.svn"></exclude>
  14. <exclude expression="(.*)\.gz"></exclude>
  15. <exclude expression="^info/*"></exclude>
  16. <exclude expression="^static/*"></exclude>
  17. </filter>
  18. <inotify>
  19. # 指定inotify程序监控事件信息
  20. <delete start="true"/>
  21. <createFolder start="true"/>
  22. <createFile start="false"/>
  23. <closeWrite start="true"/>
  24. <moveFrom start="true"/>
  25. <moveTo start="true"/>
  26. <attrib start="false"/>
  27. <modify start="false"/>
  28. </inotify>
  29.  
  30. <sersync>
  31. <localpath watch="/opt/tongbu"> #备份文件位置
  32. <remote ip="127.0.0.1" name="tongbu1"/> #IP地址,模块名称
  33. <!--<remote ip="192.168.8.39" name="tongbu"/>-->
  34. <!--<remote ip="192.168.8.40" name="tongbu"/>-->
  35. </localpath>
  36. <rsync>
  37. <commonParams params="-artuz"/> #rsync选项
  38. <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/> #auth users 位置 | 密码文件位置
  39. <userDefinedPort start="false" port=""/><!-- port= -->
  40. <timeout start="false" time=""/><!-- timeout= -->
  41. <ssh start="false"/>
  42. </rsync>
  43. <failLog path="/tmp/rsync_fail_log.sh" timeToExecute=""/><!--default every 60mins execute once-->
  44. <crontab start="false" schedule=""><!--600mins-->
  45. <crontabfilter start="false">
  46. <exclude expression="*.php"></exclude>
  47. <exclude expression="info/*"></exclude>
  48. </crontabfilter>
  49. </crontab>
  50. <plugin start="false" name="command"/>
  51. </sersync>
  52.  
  53. <plugin name="command">
  54. <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
  55. <filter start="false">
  56. <include expression="(.*)\.php"/>
  57. <include expression="(.*)\.sh"/>
  58. </filter>
  59. </plugin>
  60.  
  61. <plugin name="socket">
  62. <localpath watch="/opt/tongbu">
  63. <deshost ip="192.168.138.20" port=""/>
  64. </localpath>
  65. </plugin>
  66. <plugin name="refreshCDN">
  67. <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
  68. <cdninfo domainname="ccms.chinacache.com" port="" username="xxxx" passwd="xxxx"/>
  69. <sendurl base="http://pic.xoyo.com/cms"/>
  70. <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
  71. </localpath>
  72. </plugin>
  73. </head>

启动服务程序

  1. [root@nfs01 sersync]# chmod +x /usr/local/sersync/bin/sersync 添加执行权限
  2.  
  3. [root@nfs01 sersync]# vim /etc/profile
  4. export PATH="$PATH:/usr/local/sersync/bin/" #/etc/profile 最下面添加全局环境变量
  5.  
  6. [root@nfs01 sersync]# sersync -dro /usr/local/sersync/conf/confxml.xml

命令执行结果

  1. root@web01 ~]# sersync -dro /usr/local/sersync/conf/confxml.xml
  2. set the system param
  3. executeecho > /proc/sys/fs/inotify/max_user_watches
  4. executeecho > /proc/sys/fs/inotify/max_queued_events
  5. parse the command param
  6. option: -d run as a daemon
  7. option: -r rsync all the local files to the remote servers before the sersync work
  8. option: -o config xml name /usr/local/sersync/conf/confxml.xml
  9. daemon thread num:
  10. parse xml config file
  11. host ip : localhost host port:
  12. daemon startsersync run behind the console
  13. use rsync password-file :
  14. user is rsync_backup
  15. passwordfile is /etc/rsync.password
  16. config xml parse success
  17. please set /etc/rsyncd.conf max connections= Manually
  18. sersync working thread = (primary thread) + (fail retry thread) + (daemon sub threads)
  19. Max threads numbers is: = (Thread pool nums) + (Sub threads)
  20. please according your cpu use -n param to adjust the cpu rate
  21. ------------------------------------------
  22. rsync the directory recursivly to the remote servers once
  23. working please wait...
  24. execute command: cd /backup && rsync -az -R --delete ./ rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.password >/dev/null >&
  25. run the sersync:
  26. watch path is: /backup

二进制sersync部署安装的更多相关文章

  1. MariaDB二进制包简单安装部署

    一.简介: MySQL最早是由Michael Widenius在所研发,而在后来Michael先生以10亿美元的价格把MySQL卖给了SUN以后不久SUN就被Oracle公司给收购了,在Oracle收 ...

  2. Kubernetes全栈架构师(二进制高可用安装k8s集群部署篇)--学习笔记

    目录 二进制高可用基本配置 二进制系统和内核升级 二进制基本组件安装 二进制生成证书详解 二进制高可用及etcd配置 二进制K8s组件配置 二进制使用Bootstrapping自动颁发证书 二进制No ...

  3. Docker+Redis镜像的原理以及部署安装(超详解附截图)

    文章来源:公众号-智能化IT系统. 一. DOCKER介绍 Docker简介 (1)Docker 是一个开源的应用容器引擎,基于 Go 语言,并遵从Apache2.0协议开源. (2)Docker 可 ...

  4. Elastic Stack之ElasticSearch分布式集群二进制方式部署

    Elastic Stack之ElasticSearch分布式集群二进制方式部署 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 想必大家都知道ELK其实就是Elasticsearc ...

  5. Apache Ignite 学习笔记(一): Ignite介绍、部署安装和REST/SQL客户端使用

    Apache Ignite 介绍 Ignite是什么呢?先引用一段官网关于Ignite的描述: Ignite is memory-centric distributed database, cachi ...

  6. sersync部署

    rsync :  wget  http://rsync.samba.org/ftp/rsync/src/rsync-3.1.1.tar.gz Sersync: wget https://raw.git ...

  7. 二进制包部署Kubernetes集群

    今天这篇文章教给大家如何快速部署一套Kubernetes集群.K8S集群部署有几种方式:kubeadm.minikube和二进制包.前两者属于自动部署,简化部署操作,我们这里强烈推荐初学者使用二进制包 ...

  8. 二进制方法-部署k8s集群部署1.18版本

    二进制方法-部署k8s集群部署1.18版本 1. 前置知识点 1.1 生产环境可部署kubernetes集群的两种方式 目前生产部署Kubernetes集群主要有两种方式 kuberadm Kubea ...

  9. Kubernetes全栈架构师(二进制高可用安装k8s集群扩展篇)--学习笔记

    目录 二进制Metrics&Dashboard安装 二进制高可用集群可用性验证 生产环境k8s集群关键性配置 Bootstrapping: Kubelet启动过程 Bootstrapping: ...

随机推荐

  1. Maven中的dependency详解

    <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> & ...

  2. 1. JDK 、 JRE 、JVM有什么区别和联系?

    首先,我们分别对这三者进行阐述. JVM :英文名称(Java Virtual Machine),就是我们耳熟能详的 Java 虚拟机.它只认识 xxx.class 这种类型的文件,它能够将 clas ...

  3. VBA通过C#以API方式调用JS脚本函数

    http://www.cnblogs.com/Charltsing/p/JSDotNetAPI.html 在网页采集中,很多时候需要运行网站下载的某个js文件中的函数,以计算Request参数.VBA ...

  4. flask环境布署--废弃不用,只留作备份

    [前置条件] 创建1个flask-demo,生成requirement.txt文件(下载好gunicorn),上传至git.创建demo参照:创建一个flask api-demo(响应体显示中文) g ...

  5. 在VSCode中开启ESLint风格审查

    最近一直在学习开发一个VUE项目,几乎没有前端基础摸爬滚打,就一边摸索HTML,JS,CSS一边模仿着已有代码开发,也还算能学到东西. VSCode确实还不错,很轻量.在刚开始学写vue的时候,后台总 ...

  6. jmeter的cookie跨线程传递

    测试计划需要设置成独立运行每个线程组获取cookie需要先执行才能使接下来的cookie使用正确执行 登录线程组登录,使用正则表达式提取器提取所需cookie然后使用BeanShellPostProc ...

  7. 【MM系列】SAP MB5B中FI凭证摘要是激活的/结果可能不正确 的错误

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MB5B中FI凭证摘要是激活 ...

  8. 递归算法之排列组合-求一个集合S的m个元素的组合和所有可能的组合情况

    求一个集合S的m个元素组合的所有情况,并打印出来,非常适合采用递归的思路进行求解.因为集合的公式,本身就是递归推导的: C(n,m) = C(n-1,m-1) + C(n-1,m). 根据该公式,每次 ...

  9. 【Go语言】map在goroutine通信中的使用问题

    简介 本篇文章的主要内容是解决go语言map在使用中遇到的两个问题,对于初学者是不可避免的坑 一.cannot assign to struct field 当map中存在struct类型的成员,如果 ...

  10. docker--docker 的web可视化管理工具

    12 docker 的web可视化管理工具 12.1 常用工具介绍 当 Docker 部署规模逐步变大后,可视化监控容器环境的性能和健康状态将会变得越来越 重要. Docker的图形化管理工具,提供状 ...