Centos 7.0 通过rsync和inotify实现实时同步

以前写过博文通过rsync实现定时备份: windows2008和Centos7.0通过Rsync来实现通过更新(备份),而现在的需求是通过rsync和inotify实现实时同步备份。

第一步: 准备工作

1.   inotify介绍

Inotify 是一个 Linux特性,它监控文件系统操作,比如读取、写入和创建。Inotify 反应灵敏,用法非常简单,并且比 cron 任务的繁忙轮询高效得多。学习如何将 inotify 集成到您的应用程序中,并发现一组可用来进一步自动化系统治理的命令行工具。(来自百度百科)

20160227122900

2.  rsync介绍

rsync是类unix系统下的数据镜像备份工具——remote sync。一款快速增量备份工具 Remote Sync,远程同步 支持本地复制,或者与其他SSH、rsync主机同步。(来自百度百科)

15174305_TVqG

3. rsync和inotify实时同步原理图20160227123730
4. 环境部署

(1) 数据库服务器(inotify-master) IP: 192.168.221.131

20160227124122

(2)  备份服务器(inotify-slave) IP:  192.168.221.136

20160227124224

第二步: 部署备份服务器inotify-slave

这里是部署inotify-slave环境,配置rsync daemon工作方式

1. 检查是否安装rsync
1 rpm -qa|grep rsync

20160227131930

2. 添加rsync用户以及模块目录并更改其用户组
1 useradd rsync -s /sbin/nologin  -M #添加rsync用户
1 grep rsync /etc/passwd
1 mkdir /jhonse/back   #创建rsync daemon工作模式的模块目录
1 chown rsync.rsync /jhonse/back   #更改模块目录的用户组

20160227132654

3.  配置rsync的配置文件/etc/rsyncd.conf
01 # /etc/rsyncd: configuration file for rsync daemon mode
02  
03 # See rsyncd.conf man page for more options.
04  
05 # configuration example:
06  
07 # uid = nobody
08 # gid = nobody
09 # use chroot = yes
10 # max connections = 4
11 # pid file = /var/run/rsyncd.pid
12 # exclude = lost+found/
13 # transfer logging = yes
14 # timeout = 900
15 # ignore nonreadable = yes
16 # dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
17  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值