Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8555
  • 博文数量: 5
  • 博客积分: 132
  • 博客等级: 入伍新兵
  • 技术积分: 60
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-18 16:29
文章分类

全部博文(5)

文章存档

2012年(3)

2011年(2)

我的朋友
最近访客

分类: Python/Ruby

2012-04-27 10:06:29

一、环境介绍
有IP地址末尾分别为*.*.*.3,*.*.*.4,*.*.*.5,*.*.*.6的4台主机,要求在*.*.*.6上部署一个新版本,*.*.*.3,*.*.*.4,*.*.*.5实时同步*.*.*.6上的新版本,
二、实施
1 在*.*.*.6上安装inotify
wget
tar zxvf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure
make
make install
2 后天运行实时监控脚本./.in_rsyncd.sh &
vim .in_rsyncd.sh

点击(此处)折叠或打开

  1. #!/bin/bash

  2. #---------------------------------------------------------------

  3. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

  4. export PATH

  5. auth_user=nazca

  6. remote_ip_3=*.*.*.3
  7. remote_ip_4=*.*.*.4
  8. remote_ip_5=*.*.*.5


  9. remote_module=themis

  10. local_dir=/themis/glassfish3/glassfish/domains/domain1/themis-dist/


  11. auth_file=/etc/rsyncd.pwd

  12. rsync_path=/usr/bin/rsync

  13. inotify=/usr/local/bin/inotifywait

  14. $inotify -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e modify,move,delete,create,attrib $local_dir | while read date time dir file;do
  15. FILECHANGE=${dir}${file}
  16. $rsync_path -avrop --delete $local_dir $auth_user@$remote_ip_3::$remote_module --password-file=$auth_file
  17. $rsync_path -avrop --delete $local_dir $auth_user@$remote_ip_4::$remote_module --password-file=$auth_file
  18. $rsync_path -avrop --delete $local_dir $auth_user@$remote_ip_5::$remote_module --password-file=$auth_file
  19. echo "At ${time} on ${date},file $FILECHANGE was backed up via rsync"
  20. done

3 配置rsync,分别在.3,.4,.5上配置rsync,启动rsyncd服务,
vim /etc/xinetd.d/rsync

点击(此处)折叠或打开

  1. # default: off
  2. # description: The rsync server is a good addition to an ftp server, as it \
  3. # allows crc checksumming etc.
  4. service rsync
  5. {
  6.         disable = no
  7.         socket_type = stream
  8.         wait = no
  9.         user = root
  10.         server = /usr/bin/rsync
  11.         server_args = --daemon
  12.         log_on_failure += USERID
  13. }
vim /etc/rsyncd.conf

点击(此处)折叠或打开

  1. # Global Settings
  2. uid = root
  3. gid = root
  4. use chroot = no
  5. max connections = 80
  6. secrets file=/etc/rsyncd.pwd
  7. log file=/var/log/rsyncd.log
  8. pid file=/var/run/rsyncd.pid
  9. lock file=/var/run/rsyncd.lock

  10. [themis]
  11. path = /themis/glassfish3/glassfish/domains/domain1/themis-dist
  12. read only = no
  13. ignore errors
  14. list = no
注:ignore errors可以忽略,因为在同步的时候会产生如下报错:params.c:Parameter() - Ignoring badly formed line in configuration file: ignore errors
配置完成重启/etc/init.d/xinetd restart
阅读(455) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~