加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_汕头站长网 (https://www.0754zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Centos 6.3下rsync+inotify的安装配置

发布时间:2016-09-15 07:28:51 所属栏目:Linux 来源:站长网
导读:什么是inotify? inotify是一种强大的,细粒度的,异步文件系统时间监控机制,它可以替代crond实现与rsync的触发式文件同步,从而监控文件系统中添加,删除,修

一.安装rsync:(server,client)

传送门:http://showerlee.blog.51cto.com/2047005/1132724

配置:(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

二.安装inotify-tools:(server,client)

可以到https://github.com/rvoicilas/inotify-tools/下载zip包,然后传到系统进行编译安装:

# unzip inotify-tools-master.zip

# cd inotify-tools-master

# ./autogen.sh

# ./configure --prefix=/usr/local/inotify

# make && make install

配置client端的inotify:(client)

# vi /etc/rc.d/inotify.sh

该脚本在做客户端目录下文件若发生变化,则向服务端做同步上传操作,也就是保持客户端目录文件发生变化,服务端也相应改变。

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

#!/bin/bash

src=/test

des=test

ip=192.168.7.73

/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y/%H:%M' --format '%T%w%f' -e modify,delete,create,attrib $src | while read file

  do

       rsync -vzrtopg --delete --progress $src user@$ip::$des --password-file=/etc/rsync.pas &&

   echo "$src has been resynced"

  done

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

查看本栏目更多精彩内容:http://www.bianceng.cn/OS/Linux/

(编辑:云计算网_汕头站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!