rsync+inotify
来源:互联网 发布:mpii数据集介绍 编辑:程序博客网 时间:2024/06/11 00:32
系统:ubuntu12.04
源端:192.168.88.145
节点端:192.168.88.155
应用:数据的实时同步
应用:数据的实时同步
rsync节点端:
sudo apt-get install rsync
#/usr/share/doc/rsync/examples/rsyncd.conf 参考配置文件
sudo vim /etc/rsync.conf 需自行创建
-->
uid=root
gid=root
use chroot = no
max connections = 20
strict modes = yes
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log format = %t %a %m %f %b
hosts allow = 192.168.88.0/24
hosts_deny= *
[test]
path = /app/webapps
auth users = xxx ---用户
ignore errors = yes
read only = no
write only = no
list = no
secrets file = /etc/rsync.passwd
mkdir /app/webapps -p
chown xxx.xxx /app/webapps -R
sudo vim /etc/rsync.passwd
格式 用户:密码
eg--> xxx:pass
sudo chmod 600 /etc/rsync.passwd
启动daemon:sudo rsync --daemon --config=/etc/rsync.conf
写入开机自启动:vim /etc/rc.local
-->rsync --daemon --config=/etc/rsync.conf
源端:
sudo apt-get install rsync inotify-tools
sudo vim /etc/rsync.passwd
-->这里只需密码 如:pass
sudo chmod 600 /etc/rsync.passwd
sudo chown xxx.xxx /etc/rsync.passwd
mkdir /app/webapps -p
chown xxx.xxx /app/webapps -R
编写rsync同步脚本rsync.sh
-->
#!/bin/sh
SRC=/app/webapps
#DES=root
#USER=root
media1=192.168.88.155
#media2=192.168.88.130
#media3=192.168.88.131
#/usr/bin/inotifywait -mrq -e create,move,delete,modify $SRC | while read files
/usr/bin/inotifywait -mrq -e create,move,delete,modify $SRC | while read D E F
do
rsync -avzxPl --delete --password-file=/etc/rsync.passwd /app/webapps/ xxx@$media1::test
rsync -avzxPl --delete --password-file=/etc/rsync.passwd /app/webapps/ xxx@$media2::test
if [ $? -eq 0 ];then
echo "${file} ok" >>/tmp/rsync.log 2>&1
fi
done
启动脚本:nohup /etc/rsync.sh &
注:用nohup后台启动,当终端关闭后进程不结束
写入开机自启动:vim /etc/rc.local
--->nohup /etc/rsync.sh &
测试:略
0 0
- rsync+inotify
- rsync + inotify
- rsync+inotify
- inotify+rsync
- rsync+inotify
- ubuntu rsync inotify 配置
- rsync inotify 实时同步
- rsync+inotify实时同步
- rsync+ inotify实时同步
- rsync+inotify实现同步
- 部署inotify 结合rsync
- rsync+inotify配置
- Rsync+Inotify实时同步
- inotify+rsync安装配置
- inotify+rsync安装配置
- inotify+rsync安装配置
- rsync+inotify配置
- rsync+inotify实时同步
- JSON.stringify的理解和使用
- Synchronized & Lock distinguish
- 实现字符数组中的单词倒序输出
- 替换SQL字段中的换行符,回车符
- 和菜鸟一起学linux总线驱动之i2c死锁问题
- rsync+inotify
- 在VMware vCenter Server上创建虚拟机共享磁盘
- block
- Opencv静态库的附加库
- 指针和引用的比较
- 【Android】软键盘弹出button与edittext一起上移
- 使用OpenCV官方提供文件配置、静态编译并运行OpenCV-2.3.x/2.4.x实例
- Devexpress Gridcontrol各种记录
- 搭建oauth-server