手机版
你好,游客 登录 注册
背景:
阅读新闻

CentOS 6.3下rsync+inotify安装配置笔记

[日期:2013-06-07] 来源:Linux社区  作者:showerlee [字体:大 中 小]

inotify是一种强大的,细粒度的,异步文件系统时间监控机制,它可以替代crond实现与rsync的触发式文件同步,从而监控文件系统中添加,删除,修改,移动等细粒事件,从LINUX 2.6.13起,就已加入了对inotify的支持,所以我们只需要安装一个第三方软件inotify-tools即可管理此服务。

之前利用的rsync+crond来触发实现同步的瓶颈在于,rsync在同步数据时,需要先扫描所有文件后进行比对,而后进行差异传输,如果文件数量级别很大而且变化会很快,扫描所有文件会非常耗时,而且会存在漏同步的问题,造成效率低下。

而rsync+inotify则会弥补前者先扫描后同步的效率问题,采用系统级别监控各种变化,当文件发生任何变化,就会触发rsync同步,解决效率与实时性问题。 

Linux操作系统: CentOS6.3 64bit

rsync: 系统自带

inotify-tools: inotify-tools-master 

www1(rsync server):192.168.7.73

www2(rsync client):192.168.7.74

 

(server)表示仅服务端配置

(client)表示仅客户端配置

(server,client)表示客户端与服务端都需配置 

环境搭建:(server,client) 

1.关闭iptables和SELINUX

# service iptables stop

# setenforce 0

# vi /etc/sysconfig/selinux

---------------

SELINUX=disabled

--------------- 

判断Linux系统内核是否达到2.6.13以上:

# uname -a

-------------

Linux www1.example.com 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

-------------

 

查看inotify目录是否存在:

# ls -lsart /proc/sys/fs/inotify/

------------------

总用量 0

0 dr-xr-xr-x 0 root root 0 6月 4 14:04 ..

0 dr-xr-xr-x 0 root root 0 6月 4 17:35 .

0 -rw-r--r-- 1 root root 0 6月 4 17:35 max_user_watches

0 -rw-r--r-- 1 root root 0 6月 4 17:35 max_user_instances

0 -rw-r--r-- 1 root root 0 6月 4 17:35 max_queued_events

------------------

若返回以上内容,则系统支持inotify. 

一.安装rsync:(server,client)

传送门:http://www.linuxidc.com/Linux/2012-10/71704.htm

 

配置:(server)

# vi /etc/rsyncd.conf

--------------------

uid = root

gid = root

use chroot = no

max connections = 10

strict modes = yes

port = 873

address = 192.168.7.73

[test]

path = /test

comment = mirror for test

ignore errors

read only = no

list = no

auth users = user

secrets file = /etc/rsync.pas

hosts allow = *

# hosts deny = 0.0.0.0/0

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

--------------------

启动rsync

# rsync --daemon --config=/etc/rsyncd.conf

重启xinetd使其配置生效:

# /etc/init.d/xinetd restart

linux
相关资讯       rsync  CentOS 6.3  rsync inotify 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款