notify + rsync实现web镜像实时同步
来源:互联网 发布:有密软件 编辑:程序博客网 时间:2024/04/29 17:27
notify + rsync实现web镜像实时同步
[日期:2012-06-03]来源:Linux社区 作者:navyaijm[字体:大 中 小]四、配置
1.在web1和web2上配置rsync
a. vi /etc/xinetd.d/rsync
将disable = yes 改为no,
b.新建rsyncd.conf
vi /etc/rsyncd.conf
web1的内容如下:
uid = nobody
gid = nobody
use chroot = no
max connections = 10
strict modes = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[web1]
path = /data/www/
comment = web1 file
ignore errors
read only = no
write only = no
hosts allow = 119.147.146.246
hosts deny = *
list = false
uid = root
gid = root
auth users = web1
secrets file = /etc/web1.pass
web2的内容如下:
uid = nobody
gid = nobody
use chroot = no
max connections = 10
strict modes = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[web2]
path = /data/www/
comment = web1 file
ignore errors
read only = no
write only = no
hosts allow = 119.147.146.246
hosts deny = *
list = false
uid = root
gid = root
auth users = web2
secrets file = /etc/web2.pass
c.新建web1、web2的密码文件
vi /etc/web1.pass
vi /etc/web2.pass
内容格式:
用户名:密码,如:
web1:123456
d.web1、web2上配置好rsync后,依次启动rsync守护进程,将rsync加入开机启动文件中
echo “/usr/local/rsync/bin/rsync --daemon” >> /etc/rc.loacl
2.配置web节点
a.编写shell脚本
vi inotifyrsync.sh
#!/bin/bash
host1=119.147.146.248
host2=119.147.146.249
src=/data/www/
dst1=web1
dst2=web2
user1=web1
user2=web2
/usr/local/bin/inotifywart -mrq --timefmt `%d/%m/%y %H:%M` --format `%T %w%f%e` -e modify,delte,create,attrib $src \
| while read files
do
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/web1.pass
pass $src $user1@$host1::$dst1
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/web2.pass
pass $src $user2@$host2::$dst2
echo "${files} was rsynced" >> /tmp/rsync.log 2 >&1
done
b.在/etc目录下新建web1.pass和web2.pass密码文件,内容分别是web1和web2用户的密码,更改这两个文件的权限为600
c.把inotifyrsync.sh放到/data/www目录下,放到后台用行:
# chmod 755 /data/www/inotifyrsync.sh
# /data/www/inotifyrsync.sh &
d.最后将此脚本加入开机启动文件中
echo “/data/www/inotifyrsync.sh &” >> /etc/rc.local
五、测试:
在web节点/data/www目录下添加、删除或者修改文件,然后到web1、web2对应目录下查看文件是否随着web中/data/www目录下文件的变化而变化,如果是那边就配置成功了。
如果出现这个错误“/usr/local/bin/inotifywait: error while loading shared libraries: libinotifytools.so.0”可以采用以下办法解决:
ln -sv /usr/local/lib/libinotify* /usr/lib/
ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib64/libinotifytools.so.0
cp /usr/lib/libinotifytools.so.0 /usr/local/lib/
- notify + rsync实现web镜像实时同步
- inotify + rsync实现web镜像实时同步
- rsync数据镜像备份+inotify实时同步的简单实现
- rsync实现自动同步镜像备份
- rsync+inotify实现实时同步
- rsync+inotify 实现实时同步
- rsync+inotify实现实时同步
- rsync+inotify实现实时同步
- rsync+inotify实现实时同步
- inotify+rsync实现实时同步
- rsync命令实现:多服务器镜像同步
- lsyncd+rsync实现实时自动同步
- inotify + rsync实现linux文件实时同步
- inotify + rsync 实现 linux 文件实时同步
- rsync+inotify实现文件实时同步
- sersync+rsync实现文件实时同步
- inotify+rsync实现文件实时同步
- rsync+inotify实现实时同步案例
- 第一篇博客,个人总结
- bzoj2326&CodeVS2314 数学作业
- 在PHP5.3以上版本运行ecshop出现的问题及解决方案
- iOS本地推送(本地通知)
- 指定Webbrowser控件所用IE内核版本
- notify + rsync实现web镜像实时同步
- 野鸟装备3.0问题汇总
- 操纵持久化对象
- hadoop集群环境搭建的血泪史
- POJ 1222 EXTENDED LIGHTS OUT(矩阵反转问题——枚举or高斯消元)
- Self summary: Ruby(RVM, gem, bundle)
- Java注解@Retention&@Inherited@Target@IntDef@Documented
- 81. Search in Rotated Sorted Array II LeetCode
- HttpURLConnection对象相关方法操作