需要同步的机器我们搭建RSYNC服务器 yum -y install rsync yum -y install xinetd vim /etc/xinetd.d/rsync disabled=no 创建rsync配置文件 vim /etc/rsyncd.conf uid = root gid = root max connections = 200 timeout = 600 use chroot = no read only = no [etc] path = /etc/ ignore errors write only = no hosts allow = 192.168.0.2 hosts deny=* list = false 启动服务 service xinetd restart 在主服务器上安装inotify和rsync yum -y install rsync yum -y install inotify-tools 编写脚本用来监控 vim tongbu.sh #!/bin/bash host=192.168.0.3 src=/etc/nginx dst=etc user=root /usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src \ | while read files do /usr/bin/rsync -vzrtopg --delete --progress $src $user@$host::$dst echo "${file} was rsynced" >> /tmp/rsync.log 2>&1 done 赋予脚本执行权限 chmod +x tongbu.sh 运行脚本即可 ./tongbu.sh 添加到启动项中 vim /etc/rc.local /root/tongbu.sh
linux实时同步文件系统
原创
©著作权归作者所有:来自51CTO博客作者woai2607的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章