服务器 | IP地址 | 文件路径 |
files | 172.16.2.1 | /www/webpages |
web01 | 172.16.2.2 | /www/webpages |
-
files配置:
-
12345678910111213141516171819202122232425
1、安装inotify:
# tar xf inotify-tools-3.14.tar.gz
# cd inotify-tools-3.14
# ./configure && make && make install
# mkdir /root/scripts
# vim /root/scripts/in_rsync.sh 编写脚本内容如下:
#!/bin/bash
host1=172.16.2.2
src=
/www/webpages
dst1=web01
user1=root
/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
-zrtopg --delete --password-
file
=
/etc/rsyncd
.pass $src $user1@$host1::$dst1 >
/dev/null
2>&1
echo
"${files} was rsynced"
>>
/tmp/rsync
.log 2>&1 >
/dev/null
done
# chmod +x /root/scripts/in_rsync.sh
# setenforce 0
# service iptables stop
# vim /etc/rsyncd.pass
rsync
# chmod 600 /etc/rsyncd.pass
# nohup /root/scripts/in_rsync.sh & //挂载到后台执行同步
# echo “nohup /root/scripts/in_rsync.sh &” >>/etc/rc.local //添加到开机启动中
web服务器配置
1234567891011121314151617181920212223242526272829# yum install xinetd rsync –y
# vim /etc/rsyncd.conf //添加以下内容
#Global Settings
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
[web01]
path =
/www
auth
users
= root
read
only = no
hosts allow =172.16.2.0
/24
list = no
uid = root
gid = root
secrets
file
=
/etc/rsyncd
.pass
ignore errors =
yes
# vim /etc/rsyncd.pass //添加以下内容:
root:
rsync
# chmod 600 /etc/rsyncd.pass //设置600权限。
# setenforce 0
# service iptables stop
# /usr/bin/rsync –daemon //启动rsync
# echo “/usr/bin/rsync --daemon” >>/etc/rc.local //添加开机自动启动
-
安装apache