博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
028_rync和inotify实现实时备份
阅读量:6941 次
发布时间:2019-06-27

本文共 1774 字,大约阅读时间需要 5 分钟。

一、服务节点安装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/bashhost_pubbak=10.0.138.136src=/data/zookeeperdest_pubbak=zkpubuser=root/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,delete,create,attrib $src \| while read filedo/bin/rsync -vzrtopg --delete --progress $src $user@$host_pubbak::$dest_pubbakecho "${$(date +%Y%m%d_%H%M%S)} ${files} was rsynced" >> /tmp/rsync.log 2>&1done

sh /opt/zkrsync/rsyncfile.sh &

<2>supervisord配置

cat /etc/supervisord.d/rsync.ini

[program:rsync]command=/opt/zkrsync/rsyncfile.shstartsecs=3startretries=3stopsignal=QUITstopasgroup=truestopwaitsecs=10user=rootredirect_stderr=truestdout_logfile=/data/log/rsync/running.logstdout_logfile_maxbytes=50MBstdout_logfile_backups=10stderr_logfile=/data/log/rsync/error.logstderr_logfile_maxbytes=50MBstderr_logfile_backups=10

二、客户端

(1)rsync配置文件设置

cat /etc/rsyncd.confuid = rootgid = rootpid file = /var/run/rsyncd.pidlock file = /var/run/rsync.locklog 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 listtest/deleting test/wuwusent 40 bytes received 12 bytes 104.00 bytes/sectotal size is 0 speedup is 0.00sending incremental file listtest/test/iiii5 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2)

测试ok没有问题。

转载地址:http://rjinl.baihongyu.com/

你可能感兴趣的文章
2018年Github最受欢迎机器学习语言Python稳坐冠军,numpy、scipy是最受欢迎软件包...
查看>>
GitHub 重磅更新:无限私有仓库免费使用
查看>>
“10%时间”:优点和缺点——敏捷海滩会议上Elizabeth Pope的报告
查看>>
Rico Mariani对Visual Studio不是64位的解释
查看>>
破译密码、设计飞机和建设团队:Randy Shoup谈高绩效团队
查看>>
缓存分享会小记
查看>>
正则匹配常见链接地址
查看>>
Yii2.0 框架中如何创建自定义小部件
查看>>
亚马逊DevOps的实践指南
查看>>
PHP|关于对象复制的一些事
查看>>
Python 性能分析大全
查看>>
GoJS 绘图 (十) :链接(完结)
查看>>
PHP|什么是CGI, FastCGI, PHP-CGI, PHP-FPM, Spawn-FCGI?
查看>>
【算法】递归算法之n阶矩阵行列式求解
查看>>
React Native 的默认单位和自适应布局方案
查看>>
ReactNative安卓首屏白屏优化
查看>>
设计模式(Design Pattern)系列之.NET专题
查看>>
为 Nginx 添加 HTTP 基本认证(HTTP Basic Authentication)
查看>>
gulp使用ES6
查看>>
ECUG Con 邀您共议服务端开发最深度实践
查看>>