首页 > 其他 > 详细

Inofity+rsync详细安装 实现实时同步

时间:2014-02-28 07:53:24      阅读:1356      评论:0      收藏:0      [点我收藏+]

需求把192.168.150.21上 /apache-tomcat-7.0.37 实时同步到192.168.150.20 的 /home/tgss/apache-tomcat-7.0.37 中

配置192.168.150.20

rpm –ivh rsync-3.0.9-1.el6.rfx.x86_64.rpm

cat /etc/xinetd.d/rsync

可以看到rsync服务是关闭的 disable=yes 把它开启 disable=no

创建配置文件 /etc/rsyncd.conf                     

uid = root

gid = root

hosts allow = 192.168.150.21

use chroot = no

max connection = 4

timeout = 50

pid file = /var/run/rsyncd.pid 

lock file = /var/run/rsync.lock 

log file = /var/log/rsyncd.log 

port = 873

[test] 

path = /home/tgss

comment = web file 

ignore errors 

read only = no

list = yes

auth users = webuser

secrets file = /etc/rsync.passwd

transfer logging = yes

log format ="%a %f %l"

创建配置文件 /etc/rsync.passwd密码文件

 

chmod 600 /etc/rsync.passwd

启动rsync进程

rsync –daemon –config=/etc/rsyncd.conf

配置192.168.150.21

安装inotify

rpm –ivh rsync-3.0.9-1.el6.rfx.x86_64.rpm

cat /etc/xinetd.d/rsync

可以看到rsync服务是关闭的 disable=yes 把它开启 disable=no

tar xvf inotify-tools-3.14.tar.gz  –C /usr/local

cd inotify-tools-3.14

./configure –prefix=/usr/local  && make && make install

创建/etc/rsyncd.conf

 

启动rsync 服务

rsync –daemon

vim inofity.sh

#!/bin/bash

host=192.168.150.20

src=/apache-tomcat-7.0.37/

dst=test

user=webuser

/usr/local/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  --password-file=/etc/rsync.passwd /apache-tomcat-7.0.37 $user@$host::$dst >/dev/null

                echo "${files} was rsynced" >>/tmp/rsync.log 2>&1

         done

 

 

chmod a+x inofity.sh

sh inofity.sh &

测试 在


 
  
  
  
  
  
  
  
  
  
  
  
  
 
 
 


Inofity+rsync详细安装 实现实时同步,布布扣,bubuko.com

Inofity+rsync详细安装 实现实时同步

原文:http://www.cnblogs.com/hmyyj/p/3571279.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!