Centos 6.3下rsync+inotify的安装配置
|
一.安装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/ (编辑:云计算网_汕头站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

