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 ...
随机推荐
- hdu 2845 Beans(最大不连续子序列和)
Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled ...
- C++11新特性——range for
很多编程语言都有range for语法功能,自C++11起,终于将这个重要功能加入C++标准中.range for语句,可以方便的遍历给定序列中的每个元素并对其执行某种操作. 1.基本语法 for(d ...
- SpringCloud学习(二)---Eureka
Eureka 重点在使用,概念和源码基本不涉及 Eureka是一个基于REST(REST是HTTP协议的)的服务,主要在亚马逊网络服务(AWS)云中使用,定位服务来进行中间层服务器的均衡负载和故障转移 ...
- intent 几种用法
Intent 应该算是Android中特有的东西.你可以在Intent中指定程序 要执行的动作(比如:view,edit,dial),以及程序执行到该动作时所需要的资料.都指定好后,只要调用start ...
- Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others
Some interesting excerpts from the bash manpage:When bash is invoked as an interactive login shell, ...
- 【POJ3666】Making the Grade 离散化+DP
学到了一个引理:在满足S最小化的条件下,一定存在一种构造序列B的方案,使得序列B中的数值都来自于A中.(数学归纳法+中位数定理得证) 对于状态的表示来说,首先肯定有一个 i ,表示选到了第 i 个数时 ...
- 跟我一起使用electron搭建一个文件浏览器应用吧(三)
第二篇博客中我们可以看到我们构建的桌面应用会显示我们的文件及文件夹. In the second blog, we can see that the desktop application we bu ...
- 有趣的async
在项目的开发过程中,同步异步是一个很重要的概念.但是在js中,又会有稍微的不同. 依据微软的MSDN上的解说: (1) 同步函数:当一个函数是同步执行时,那么当该函数被调用时不会立即返回,直到该函数所 ...
- 走进JVM之一 自己编译openjdk源码
想要深入了解JVM,就必须了解其实现机制.了解JVM实现的最好方法便是自己动手编译JDK.好了,让我们开始吧! 1. 准备工作 获取OpenJDK源码 本次编译选择的是OpenJDK7u,官方源码包 ...
- Unity做AR
Unity做AR呢这里借助了高通的AR包 这里是视频教程 http://www.tudou.com/programs/view/dnvEbIubNzI/ 这里是结果演示 http://www.tu ...