centos7配置rsync+inotify数据实时共享
关于centos7版本上面搭建rsync服务并且实现实时同步
之前一直是在6版本上面搭建rsync服务,在7版本上面折腾了半天。此处总结下
inotify下载地址:http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
环境说明:
centos7版本上面已经默认安装了rsync和xinetd服务
[ root@rh6 ~ ]# rpm -ql rsync --在6版本上面执行此命令可以看到xinetd服务配置文件下面有rsync的子配置文件
/etc/xinetd.d/rsync
[ root@rh6 ~ ]# ls /etc/xinetd.d/sync
/etc/xinetd.d/rsync
[ root@centos7_3 ~ ]# rpm -ql rsync --在7版本上面执行此命令却找不到这样的配置文件,ls查看提示没有此文件
[ root@centos7_3 ~ ]# ls /etc/xinetd.d/sync
ls: cannot access /etc/xinetd.d/rsync: No such file or directory
————————————————————————————————————————————————————————
实验环境:两台centos7版本的宿主机
客户端:172.16.27.25
服务端:172.16.27.26
具体步骤:
服务端
[root@cc4 ~]# rpm -aq |grep xinetd
xinetd-2.3.15-13.el7.x86_64
[root@cc4 ~]# rpm -aq |grep rsync
rsync-3.0.9-17.el7.x86_64
[root@cc4 ~]# vim /etc/xinetd.d/rsync --说明:修改xinetd服务下面的配置文件,将rsync交给xinetd管理。此配置文件在7版本默认上面是没有的,我是直接从6版本复制过来的,也可以手写下面内容
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no --将原来的yes改为no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root@cc4 ~]# vim /etc/rsyncd.conf --修改配置文件发布共享目录
[test]
path = /test --本地共享目录
auth user = user1 --指定用户同步
secrets file = /etc/rsyncd.secrets --指定保存用户密码文件
[root@cc4 ~]# systemctl restart xinetd --启动服务
[root@cc4 ~]# vim /etc/rsyncd.secrets --创建安全用户
user1:123
[root@cc4 ~]# chmod 600 /etc/rsyncd.secrets --设置安全用户文件的权限,不能被其他人查看
[root@cc4 ~]# mkdir /test --创建共享目录
[root@cc4 ~]# touch /test/file{1..10} --此处为了测试,创建几个文件
[root@cc4 ~]# ls /test/
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9
客户端测试:
[root@cc3 ~]# rsync -a 172.16.27.26::
test
[root@cc3 date]# ls
[root@cc3 date]# rsync -av user1@172.16.27.26::test /date
receiving incremental file list
./
file1
file10
file2
file3
file4
file5
file6
file7
file8
file9
sent 219 bytes received 524 bytes 1486.00 bytes/sec
total size is 0 speedup is 0.00
[root@cc3 date]# ls --可以看见成功从上面同步过来了。
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9
通过inotify+rsync架构实现实时同步
环境说明:要求node1主机上面的/node1目录发生新的创建,删除,移动,以及文件属性信息改变时,自动同不到node2主机的/node2目录
node1主机: IP 172.16.27.25
node2主机: IP 172.16.27.26
具体步骤:
node1端:
[root@cc3 tmp]# ls /tmp/inotify-tools-3.14.tar.gz
/tmp/inotify-tools-3.14.tar.gz
[root@cc3 tmp]# tar -xf inotify-tools-3.14.tar.gz
[root@cc3 tmp]# cd inotify-tools-3.14/
[root@cc3 inotify-tools-3.14]# ls
aclocal.m4 ChangeLog config.h.in configure COPYING INSTALL libinotifytools Makefile.am man NEWS src
AUTHORS config.guess config.sub configure.ac depcomp install-sh ltmain.sh Makefile.in missing README
[root@cc3 ~]# ./configure && make && make install --安装软件
[root@cc3 ~]# vim /tmp/1.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,create,move,delete,attrib /node1 |while read events
do
rsync -a --delete /node1 172.16.27.26::test
echo "`date +'%F %T'` 出现事件 $events" >>/tmp/rsync.log 2>&1
done
[root@cc3 ~]#mkdir /node1
[root@cc3 ~]# touch /node1/testa{1..5}
node2端:
[root@cc4 ~]# vim /etc/rsyncd.conf
[test]
path = /node2/
read only = false
uid = root
gid = root
[root@cc4 ~]# mkdir /node2
[root@cc4 ~]# ls /node2/ --此时查看,该目录里面什么文件都没有
[root@cc4 ~]# systemctl restart xinetd
测试验证:
在node1端执行脚本并且放在后台执行,并且创建文件,再看tmp下面是否有创建文件后脚本执行报的日志信息
[root@cc3 ~]# nohup sh /tmp/1.sh &
[1] 14720
[root@cc3 ~]# nohup: ignoring input and appending output to ‘nohup.out’ --此处直接回车
[root@cc3 ~]# echo haha >>/node1/file1
[root@cc3 ~]# ls /tmp/rsync.log
/tmp/rsync.log
[root@cc3 ~]# cat /tmp/rsync.log
2017-10-10 15:55:01 出现事件 /node1/ CREATE file1
2017-10-10 15:55:01 出现事件 /node1/ MODIFY file1
在node2端检查验证
[root@cc4 ~]# ls /node2/
file1 testa1 testa2 testa3 testa4 testa5
[root@cc4 ~]# cat /node2/file1
haha
---------测试发现在node1端创建的文件实时同步过来到node2上面了。
总结:其实在6系统和7系统上面搭建rsync服务是一样的,只是在7上面改版了,系统默认没有/etc/xinetd.d/rsync配置文件,需要自己手动创建。其余配置完全一样
centos7配置rsync+inotify数据实时共享的更多相关文章
- centos 配置rsync+inotify数据实时同步2
一.Rsync服务简介 1. 什么是Rsync 它是一个远程数据同步工具,它在同步文件的同时,可通过LAN/WAN快速同步多台主机间的文件.Rsync使用所谓的“rsync算法”来使本地和远程两个主机 ...
- centos 配置rsync+inotify数据实时同步
何为rsync? 定义: rsync是一个开源的快速备份工具,可以在不同主机之间镜像同步整个目录树,支持增量备份,保持链接和权限,非常适用于异地备份 何为源端和发起端? 在远程同步过程中,负责发起rs ...
- rsync + inotify 数据实时同步
一.rsync介绍 rsync英文全称为Remote synchronization,从软件的名称就可以看出来,Rsync具有可是本地和远程两台主机之间的数据快速复制同步镜像.远程备份的功能,这个功能 ...
- linux rsync +inotify 实现 实时同步
前言: rsync可以实现触发式的文件同步,但是通过crontab守护进程方式进行触发,同步的数据和实际数据会有差异,而inotify可以监控文件系统的各种变化,当文件有任何变动时,就触发rs ...
- 配置rsync+inotify实时同步
与上一篇同步做 配置rsync+inotify实时同步 1:调整inotify内核参数 在linux内核中,默认的inotify机制提供三个调控参数:max_queue_events.max_user ...
- Rsync+Sersync数据实时同步(双向)
Rsync+Sersync数据实时同步(双向) 服务介绍 一.为什么要用rsync+sersync架构? 1.sersync是基于inotify开发的,类似于inotify-tools的工具 2.se ...
- inotify和rsync实现数据实时同步
数据的实时同步 实现实时同步 要利用监控服务(inotify),监控同步数据服务器目录中信息的变化 发现目录中数据产生变化,就利用rsync服务推送到备份服务器上 实现实时同步的方法 ino ...
- CentOS7安装和配置rsync+inotify
(1)rsync介绍 1.rsync介绍 开源,实现全量及增量的本地或远程数据同步备份工具 2.工作场景: 存储实时备份:rsync+inotify 定时备份:rsync+crond 3.rsync工 ...
- 搭建rsync+inotify实现实时备份
一.环境搭建说明 系统环境 CentOS7.5 备份节点 主机名:backup01 IP地址:172.16.2.41 数据节点 主机名:nfs-master IP地址:172.16.2.31 二.在备 ...
随机推荐
- Flutter移动电商实战 --(9)移动商城数据请求实战
1.URL接口管理文件建立 第一步需要在建立一个URL的管理文件,因为课程的接口会一直进行变化,所以单独拿出来会非常方便变化接口.当然工作中的URL管理也是需要这样配置的,以为我们会不断的切换好几个服 ...
- npm 权限
将npm默认目录定向到其他你具有读写权限的目录 很多时候你可能并不想改变npm所用的默认目录(如/usr)的拥有者,因为这可能会导致一些问题,比如你在与其他用户共用此系统时. 这时,你可以设置npm整 ...
- linux下如何查看某个容器的详细信息?
答: 使用docker inspect <CONTAINER ID>即可
- xshell链接vbox 上 nat 方式链接虚拟机 - 端口转发
使用场景 某些不可解原因导致 centos7通过桥接方式进行外网资源访问无法实现, 但是 nat 方式是没问题的, 因此考虑直接基于这个的方式进行操作, 但是xshell 的链接需要ip地址, 因此提 ...
- 小D课堂 - 新版本微服务springcloud+Docker教程_3-05 服务注册和发现Eureka Server搭建实战
笔记 5.服务注册和发现Eureka Server搭建实战 简介:使用IDEA搭建Eureka服务中心Server端并启动,项目基本骨架介绍 官方文档:http://clou ...
- ubuntu---ssh连接
17.04版本或其他版本: 1.第一步是.(这个必须先安装) apt-get install openssh-server 2.第二步: 当在这段输入ifconfig提示安装.再最后安装这个. 终端会 ...
- 一百一十五:CMS系统之实现点击更换图形验证码功能
把验证码渲染到到页面上 访问,显然,是标签有个内边距 去掉内边距 加一个class 如果放大看的话,还有问题 用js实现点击更换图形验证码:生成查询字符串的形式访问图形验证码接口的url,放到img标 ...
- Linux系统管理_主题01 :初识Linux_1.7 关闭和重启Linux_shutdown
shutdown [选项] 时间 [警告消息] 系统关机 -c 取消前一个 shutdown 命令.值得注意的是,当执行一个如 “shutdown -h 11:10”的命令时,只要按“Ctrl+C ...
- uni-app 封装 http promise请求,仅提供 post,all,spread 方法
简单封装一下 uni-app 的请求,因为项目中只用 post 请求,所以只封装了 post 和 all 方法. 更新,新增 spread 方法 2019-11-22 10:37:21 global. ...
- web代码审计题
@题名:code i春秋https://www.ichunqiu.com/battalion wp:https://www.ichunqiu.com/writeup/detail/4139