028_rync和inotify实现实时备份
一、服务节点安装inotify-tools。
确保系统后以下输出=>
[root@xxxx]# ll /proc/sys/fs/inotify/
total 0
-rw-r--r-- 1 root root 0 Aug 23 20:02 max_queued_events
-rw-r--r-- 1 root root 0 Aug 23 20:02 max_user_instances
-rw-r--r-- 1 root root 0 Aug 23 20:02 max_user_watches
(1)yum -y install inotify-tools.x86_64
(2)配置server端的inotify监测脚本
<1>cat /opt/zkrsync/rsyncfile.sh
#!/bin/bash
host_pubbak=10.0.138.136 src=/data/zookeeper
dest_pubbak=zkpub
user=root /bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,delete,create,attrib $src \
| while read file
do
/bin/rsync -vzrtopg --delete --progress $src $user@$host_pubbak::$dest_pubbak
echo "${$(date +%Y%m%d_%H%M%S)} ${files} was rsynced" >> /tmp/rsync.log 2>&1
done
sh /opt/zkrsync/rsyncfile.sh &
<2>supervisord配置
cat /etc/supervisord.d/rsync.ini
[program:rsync]
command=/opt/zkrsync/rsyncfile.sh
startsecs=3
startretries=3
stopsignal=QUIT
stopasgroup=true
stopwaitsecs=10
user=root
redirect_stderr=true
stdout_logfile=/data/log/rsync/running.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stderr_logfile=/data/log/rsync/error.log
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=10
二、客户端
(1)rsync配置文件设置
cat /etc/rsyncd.conf
uid = root
gid = root
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[zkpub]
path = /tmp
comment = zk transaction log trans
read only = no
hosts allow = 10.0.138.152 #server端ip
hosts deny = *
(2)启动rsync进程服务
rsync --daemon --config=/etc/rsyncd.conf -v
三、 测试
向这个目录"/tmp/test"进行文件的增删改查操作,日志样例如下:
sending incremental file list
test/
deleting test/wuwu sent 40 bytes received 12 bytes 104.00 bytes/sec
total size is 0 speedup is 0.00
sending incremental file list
test/
test/iiii
5 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2)
测试ok没有问题。
028_rync和inotify实现实时备份的更多相关文章
- 搭建rsync+inotify实现实时备份
一.环境搭建说明 系统环境 CentOS7.5 备份节点 主机名:backup01 IP地址:172.16.2.41 数据节点 主机名:nfs-master IP地址:172.16.2.31 二.在备 ...
- rsync + inotify 数据实时同步
一.rsync介绍 rsync英文全称为Remote synchronization,从软件的名称就可以看出来,Rsync具有可是本地和远程两台主机之间的数据快速复制同步镜像.远程备份的功能,这个功能 ...
- 通过rsync+inotify实现数据的实时备份
我讲到过利用rsync实现数据的镜像和备份,但是要实现数据的实时备份,单独靠rsync还不能实现,本文就讲述下如何实现数据的实时备份. 一.rsync的优点与不足 与传统的cp.tar备份方式相比,r ...
- 全网数据实时备份方案[inotify,sersync]
环境搭建 0.环境安装 gcc yum install gcc -y 1.安装inotify(源码软件包) 文件下载:https://files.cnblogs.com/files/ftl101 ...
- 实时备份工具之inotify+rsync
1.inotify简介 inotify 是一个从 2.6.13 内核开始,对 Linux 文件系统进行高效率.细粒度.异步地监控机制, 用于通知用户空间程序的文件系统变化.可利用它对用户空间进行安全. ...
- 通过rsync+inotify实现数据的实时备份(多台备份机)
在前面的博文中,我讲到过利用rsync实现数据的镜像和备份,但是要实现数据的实时备份,单独靠rsync还不能实现,本文就讲述下如何实现数据的实时备份. 一.rsync的优点与不足 与传统的cp.ta ...
- 通过rsync+inotify实现数据实时备份
rsync的优点与不足 与传统的cp,scp,tar,备份方式相比,rsync具有安全性高备份迅速支持增量备份的优点,可以满足对实时性要求不高的需求,例如定期备份文件服务器数据到远端服务器,但是,当数 ...
- 通过rsync+inotify实现数据的实时备份 【转载】
在前面的博文中,我讲到过利用rsync实现数据的镜像和备份,但是要实现数据的实时备份,单独靠rsync还不能实现,本文就讲述下如何实现数据的实时备份. 一.rsync的优点与不足 与传统的cp ...
- 6、inotify实时备份
备份用户nfs共享文件系统,存储单点解决方案inotify+rsync(增量,无差异备份),inotify是单线程, inotify是一种强大的,细粒度的,异步的文件系统事件监控机制,通过加入了ino ...
随机推荐
- 树莓派上使用KickThemOut对局域网内的设备进行ARP欺骗
安装KickThemOut工具 $ git clone https://github.com/k4m4/kickthemout.git $ cd kickthemout/ $ sudo -H pip ...
- [SDOI2016]储能表——数位DP
挺隐蔽的数位DP.少见 其实减到0不减了挺难处理.....然后就懵了. 其实换个思路: xor小于k的哪些都没了, 只要留下(i^j)大于等于k的那些数的和以及个数, 和-个数*k就是答案 数位DP即 ...
- Redis我想入门——启动
nosql数据库出现到现在很多年了.笔者一直从事C/S模式的上开发.所以相对而言笔者只是听过却从来不知道他是什么东西.时代在变化,当年所有业务都放在一个War包的时代已经不在了.微服务已经成为了世界主 ...
- A1010. Radix
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The an ...
- 【洛谷P1072】Hankson 的趣味题
题目大意:给定四个数字 a,b,c,d,求满足 \(gcd(a,x)=b,lcm(c,x)=d\) 的 x 的个数. 题解: 解法1:根据 lcm 的性质,x 一定为 d 的约数.因此,直接枚举 d ...
- Python基础学习(四)
菜鸟咀嚼python基础之继续. 一.返回函数 第三章已经简单操作了Python的高阶函数,目前继续练手函数作为返回值的特效:通常,高阶函数除了可以接收函数作为参数外,还可以把函数作为结果值返回. 案 ...
- 洛谷P2148 [SDOI2009]E&D(博弈论)
洛谷题目传送门 先安利蒟蒻仍在施工的博弈论总结 首先根据题目,石子被两两分组了,于是根据SG定理,我们只要求出每一组的SG值再全部异或起来就好啦. 把每一对数看成一个ICG,首先,我们尝试构造游戏的状 ...
- php框架:Flight 简介
Flight是一个php的极简的有着微内核的框架,能过快速的构建RESTful的应用 官网地址: http://flightphp.com/ github地址:https://github.com/m ...
- OS + Linux RedHat 6 / redhat 6 configuration / configure / autoconf / make / make install
s These critical programs are missing or too old: as ld http://blog.csdn.net/testcs_dn/article/detai ...
- python---RabbitMQ(4)exchange中模糊匹配topic
和关键字相似 生产者: # coding:utf8 # __author: Administrator # date: // # /usr/bin/env python import pika con ...