|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!实例:
假定web01与web02是公司的网站,我们在内容公布办事器中增加数据,inotify检测到无数据更新经由过程rsync及时传输到web01与web02。
1、web设置(web01与web02设置几近分歧,寄望白色局部)
#vi/etc/rsyncd.conf
#filename:/etc/rsyncd.conf
uid=nobody
gid=nobody
usechroot=no
maxconnections=10
#setpassword
strictmodes=yes
pidfile=/var/run/rsyncd.pid
lockfile=/var/run/rsyncd.lock
logfile=/var/log/rsyncd.log
[web_01]
path=/var/www/html
comment=webdir
ignoreerrors
readonly=no
writeonly=no
hostsallow=172.16.10.0/255.255.255.0
hostsdeny=*
list=false
auth=backup
secretsfile=/etc/rsyncd.auth
#echobackup:backup>/etc/rsyncd.auth
#chmod600/etc/rsyncd.auth
2、内容公布办事器设置- //装置inotify-tool#tarzxvfinotify-tools-3.14.tar.gz#cdinotify-tools-3.14#./configure;make;makeinstall//创建rsync考证文件#echobackup:backup>/etc/rsyncd.auth#chmod600/etc/rsyncd.auth
复制代码- [root@10.1~]#viinotify_rsync.sh#!/bin/bash#Thisrsyncscriptbasedoninotify.exportPATH=/bin:/usr/bin:/usr/local/binsrc=/var/www/html/dst=/var/www/html/client1=172.16.10.101client2=172.16.10.102user=backup#passwordfilemustnotbeother-accessible.Passfiles=/etc/rsyncd.auth#Waitforchangeinotifywait-mrq--timefmt%d-%m-%y%H:%M--format%T%w%fi%e--eventmodify,delete,create,attrib$src|whilereadfilesdorsync-vzrtopg--progress--delete--password-file=$Passfiles$src$user@$client1::$dstrsync-vzrtopg--progress--delete--password-file=$Passfiles$src$user@$client2::$dstecho"${files}wasrsynced">>/var/log/inotify_web2>&1done
复制代码
背景运转以上shell剧本,并在内容公布办事器长进行文件修正等操纵
日记一览- #cat/var/log/inotify_web12-09-1414:41/var/www/htmltest_01iMODIFYwasrsynced12-09-1414:42/var/www/htmltest_01iMODIFYwasrsynced12-09-1414:43/var/www/htmlauditdiCREATEwasrsynced12-09-1414:43/var/www/htmlauditdiMODIFYwasrsynced12-09-1414:43/var/www/htmlblk-availabilityiCREATEwasrsynced12-09-1414:43/var/www/htmlblk-availabilityiMODIFYwasrsynced12-09-1414:43/var/www/htmlcgconfigiCREATEwasrsynced12-09-1414:43/var/www/htmlcgconfigiMODIFYwasrsynced12-09-1414:43/var/www/htmlcgrediCREATEwasrsynced12-09-1414:43/var/www/htmlcgrediMODIFYwasrsynced12-09-1414:43/var/www/htmlcrondiCREATEwasrsynced12-09-1414:43/var/www/htmlcrondiMODIFYwasrsynced12-09-1414:43/var/www/htmldrbdiCREATEwasrsynced12-09-1414:43/var/www/htmldrbdiMODIFYwasrsynced12-09-1414:43/var/www/htmlfcoeiCREATEwasrsynced12-09-1414:43/var/www/htmlfcoeiMODIFYwasrsynced12-09-1414:43/var/www/htmlfunctionsiCREATEwasrsynced12-09-1414:43/var/www/htmlfunctionsiMODIFYwasrsynced12-09-1414:43/var/www/htmlhaltiCREATEwasrsynced12-09-1414:43/var/www/htmlhaltiMODIFYwasrsynced12-09-1414:43/var/www/htmlhtcachecleaniCREATEwasrsynced12-09-1414:43/var/www/htmlhtcachecleaniMODIFYwasrsynced
复制代码
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|