Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1815
  • 博文数量: 1
  • 博客积分: 80
  • 博客等级: 民兵
  • 技术积分: 20
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-15 00:39
文章分类

全部博文(1)

文章存档

2012年(1)

我的朋友
最近访客

分类: LINUX

2012-11-21 12:26:50

1.  centos5.8  server: 192.168.1.201   hostname:centos001
    centos5.8  client: 192.168.1.202   hostname:centos002
 
    install package:
  (server):
  1. yum install rsync -y 
  2. mkdir -p /data/html #如果要同步的不是此目录,可以根据实际需要添加目录
  3. #wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz 
  4. tar xzvf inotify-tools-3.14.tar.gz 
  5. cd inotify-tools-3.14 
  6. ./configure 
  7. make 
  8. make install 
  (client):
  1. yum install rsync -y 
  2. mkdir -p /data/html 
 
2. server shell:
 
[root@centos001 html]# cat /etc/rsyncd.conf
uid = root
gid = root
user chroot = no
max connecton = 200
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
[backup]
path =/script/
ignore errors
read only = no
list = no
hosts allow =192.168.1.0/255.255.255.0
auth users = root
secrets file = /etc/rsyncd.password
[root@centos001 html]#
 
[root@centos001 home]# cat /etc/rsyncd.secrets
123456789
root:123456789
[root@centos001 home]#
 
 
[root@centos001 home]# cat rsync.sh
#!/bin/bash
src=/data/html/
des=www
host="192.168.1.202"
/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e modify,delete,create,attrib $src | while read files
do
for hostip in $host
do
rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.secrets $src root@$hostip::$des
done
echo "${files} was rsynced" >>/tmp/rsync.log 2>&1
done
[root@centos001 home]#
 
 
 
3.client shell
 
[root@centos002 html]# cat /etc/rsyncd.conf
uid = root
gid = root
user chroot = no
max connecton = 200
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
[www]
path =/data/html/
ignore errors
read only = no
list = no
hosts allow =192.168.1.0/255.255.255.0
auth users = root
uid = root
gid = root
secrets file = /etc/rsyncd.secrets
[root@centos002 html]#
[root@centos002 html]# cat /etc/rsyncd.secrets
123456789
root:123456789
[root@centos002 html]#
 
4.check
 
 
 
 
 
 
阅读(106) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:没有了

给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册