sersync+rsync做实时同步
(1).实验环境
源主机:youxi1 192.168.5.101
目的主机:youxi2 192.168.5.102
目的:实时同步数据
sersync默认端口874,rsync默认端口873
(2).实验
1)下载sersync
wegt https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz
或者Windows下载再上传源主机youxi1。
2)解压
[root@youxi1 ~]# ls
anaconda-ks.cfg sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@youxi1 ~]# tar xvf sersync2.5.4_64bit_binary_stable_final.tar.gz //解压
GNU-Linux-x86/
GNU-Linux-x86/sersync2
GNU-Linux-x86/confxml.xml
[root@youxi1 ~]# ls
anaconda-ks.cfg GNU-Linux-x86 sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@youxi1 ~]# mv GNU-Linux-x86 sersync 改名
[root@youxi1 ~]# ls
anaconda-ks.cfg sersync sersync2.5.4_64bit_binary_stable_final.tar.gz
3)在目标主机youxi2上修改/etc/rsyncd.conf配置文件,以及密码文件
[root@youxi2 ~]# cat /etc/rsyncd.conf
uid = root
gid = root
address = 192.168.5.102
port = 873
hosts allow = 192.168.5.101/24
use chroot = yes
max connections = 5
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
motd file = /etc/rsyncd.motd
[backupwwwhtml]
path = /backup/www/html
comment = backup /www/html/
read only = false
list = yes
auth users = rsync2
secrets file = /etc/rsync.passwd
[root@youxi2 ~]# cat /etc/rsync.passwd
rsync2:102102
[root@youxi2 ~]# chmod 600 /etc/rsync.passwd
启动指定配置文件的rsync的守护进程
[root@youxi2 ~]# rsync --daemon --config=/etc/rsyncd.conf
[root@youxi2 ~]# ps aux | grep rsync
root 1478 0.0 0.0 114740 564 ? Ss 11:10 0:00 rsync --daemon --config=/etc/rsyncd.conf
root 1485 0.0 0.0 112720 980 pts/0 R+ 11:12 0:00 grep --color=auto rsync
4)源主机youxi1上修改sersync的配置文件
[root@youxi1 sersync]# vim confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false">
<exclude expression="(.*)\.svn"></exclude>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
<inotify>
<createFile start="false"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
</inotify> <sersync>
<localpath watch="/www/html">
<remote ip="192.168.5.102" name="backupwwwhtml"/> //修改为目标主机IP地址和模块名
</localpath>
<rsync>
<commonParams params="-artuz"/>
<auth start="true" users="rsync2" passwordfile="/etc/rsync.passwd"/> //开启,修改用户名和密码文件地址
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default e
very 60mins execute once-->
<crontab start="false" schedule="600"><!--600mins-->
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command"/>
</sersync>
添加密码文件
[root@youxi1 sersync]# vim /etc/rsync.passwd
102102
[root@youxi1 html]# chmod 600 /etc/rsync.passwd
5)开启源主机youxi1的sersync的守护进程
[root@youxi1 sersync]# /root/sersync/sersync2 -dro /root/sersync/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: -d run as a daemon
option: -r rsync all the local files to the remote servers before the sersync work
option: -o config xml name: /root/sersync/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 rsync2
passwordfile is /etc/rsync.passwd
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 /www/html && rsync -artuz -R --delete ./ rsync2@192.168.5.102::backupwwwhtml --password-file=/etc/rsync.passwd >/dev/null 2>&1
run the sersync:
watch path is: /www/html
6)测试
现在的目的主机youxi2情况如下
[root@youxi2 ~]# ls /backup/www/html/
adm crash empty gopher lib lock mail opt run tmp
cache db games kerberos local log nis preserve spool yp
对源主机youxi1的/www/html/目录下文件进行操作
[root@youxi1 sersync]# cd /www/html/
[root@youxi1 html]# ls
adm crash empty gopher lib lock mail opt run tmp
cache db games kerberos local log nis preserve spool yp
[root@youxi1 html]# rm -rf adm/
[root@youxi1 html]# touch 1.txt
[root@youxi1 html]# ls
1.txt crash empty gopher lib lock mail opt run tmp
cache db games kerberos local log nis preserve spool yp
回到目的主机查看情况
[root@youxi2 ~]# ls /backup/www/html/
1.txt crash empty gopher lib lock mail opt run tmp
cache db games kerberos local log nis preserve spool yp
sersync+rsync做实时同步的更多相关文章
- Linux下Rsync+sersync实现数据实时同步
inotify 的同步备份机制有着缺点,于是看了sersync同步,弥补了rsync的缺点.以下转自:http://www.osyunwei.com/archives/7447.html 前言: 一. ...
- rsync+sersync实现文件实时同步
前言: 一.为什么要用Rsync+sersync架构? 1.sersync是基于Inotify开发的,类似于Inotify-tools的工具 2.sersync可以记录下被监听目录中发生变化的(包括增 ...
- Rsync+sersync实现数据实时同步
前言: 一.为什么要用Rsync+sersync架构? 1.sersync是基于Inotify开发的,类似于Inotify-tools的工具 2.sersync可以记录下被监听目录中发生变化的(包括增 ...
- CentOS7下Rsync+sersync实现数据实时同步
近期公司要上线新项目,后台框架选型我选择当前较为流行的laravel,运行环境使用lnmp. 之前我这边项目tp32+apache,开发工具使用phpstorm. 新建/编辑文件通过phpstorm配 ...
- centos7服务搭建常用服务配置之二:Rsync+sersync实现数据实时同步
目录 1.RSYNC数据备份 1.1 rsync服务简介 1.2 rsync特点和优势 1.3 rysnc运行模式简介 1.4 数据同步方式 2 Rsync实验测试 2.1 实验环境说明 2.2 服务 ...
- inotify+rsync实现实时同步
第1章 数据实时同步介绍 1.1 什么是实时同步:如何实现实时同步 A. 要利用监控服务(inotify),监控同步数据服务器目录中信息的变化 B. 发现目录中数据产生变化,就利用rsync服务推送到 ...
- 【转】inotify+rsync实现实时同步
[转]inotify+rsync实现实时同步 1.1 什么是实时同步:如何实现实时同步 要利用监控服务(inotify),监控同步数据服务器目录中信息的变化 发现目录中数据产生变化,就利用rsync服 ...
- rsync+inotify实时同步环境部署记录
随着应用系统规模的不断扩大,对数据的安全性和可靠性也提出的更好的要求,rsync在高端业务系统中也逐渐暴露出了很多不足.首先,rsync在同步数据时,需要扫描所有文件后进行比对,进行差量传输.如果文件 ...
- CentOS6.5实现rsync+inotify实时同步
参考博文: 参考1:CentOS6.5实现rsync+inotify实时同步 参考2:inotify-tools+rsync实时同步文件安装和配置 CentOS 6.3下rsync服务器的安装与配置 ...
随机推荐
- Vs2017 NetCode Mvc EF Mysql 整合2
1 NetCode EF整合 代码 3 源代码 https://github.com/chxl800/EFMysqlDemo 1.1 项目文件结构 1.2 NuGet MySql.Data.Ent ...
- markdown编辑器抉择经历(做笔记\多系统用户)
之前一段时间,为了找到一款合适的md编辑器可谓是费尽了心思,用了我不少时间才找到一款合适的跨平台的又美观方便的编辑器----马克飞象. 感觉虽然有些编辑器功能很强大,对于使用性单一的用户,比如像我这种 ...
- 《JavaScript DOM编程艺术》(第二版)学习笔记(一)
这本书去年就买了但一直没看,闲暇的时候看了下,发现里面写的内容还真是不错,所以决定一边在博客上记录些学习的笔记,以便以后观看及查找方便. js文件最好的做法是放在< body>标签里,这样 ...
- gcc的作用
把代码编译成二进制文件 预处理----头文件,宏定义展开,条件编译 干掉注释代码 编译成汇编代码 生成目标代码.o (还不能执行) 链接(动态库)生成可执行程序 xxx.out 运行前,内存已经存在分 ...
- 多次读取HttpServletRequest的inputstream方法 问题解决
原因:我要收集所有来自前台请求的参数信息,无论在任何地方的.当前请求参数都是json格式,都写在httpservlet的body中.这个只能通过流进行获取.然后问题来了,HttpServletRequ ...
- VUE cli 4.x下配置多页面以及同时配置支持element-ui及mint-ui并且优化首页文件大小。
场景,公司的一个小型项目,需同时支持移动端和PC端.最开始考虑做两个独立的项目.但后来考虑到总共只有4个功能页面,布署起来相对麻烦.所以决定做在一个项目里. 1.升级vue-cli到4.x npm i ...
- 013_Linux驱动之_poll机制
1. 功能:poll的机制与select相似,与select在本质上没有多大差别.管理多个描写叙述符也是进行轮询,依据描写叙述符的状态进行处理,可是poll没有最大文件描写叙述符数量的限制. 2. 技 ...
- fckeditor实现ctrl+v粘贴word图片并上传
tinymce是很优秀的一款富文本编辑器,可以去官网下载.https://www.tiny.cloud 这里分享的是它官网的一个收费插件powerpaste的旧版本源码,但也不影响功能使用. http ...
- ckeditor实现ctrl+v粘贴word图片并上传
官网地址http://ueditor.baidu.com Git 地址 https://github.com/fex-team/ueditor 参考博客地址 http://blog.ncmem.com ...
- 牛客小白月赛11 Rinne Loves Xor
题目链接:https://ac.nowcoder.com/acm/contest/370/I code: #include<bits/stdc++.h> using namespace s ...