实现从客户服务器去同步资源服务器
1、解压
# tar -xzpvf rsync-2.5.6.tar.gz
编译安装
# cd rsync-2.5.6/
# ./configure --prefix=/usr/local/rsync
# make
# make install
2、配置/etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 4
strict modes =yes
port = 873
[backup]
path = /etc/test
comment = This is a test
read only = yes
list = no
auth users = hadoop
secrets file = /etc/rsync.pas
hosts allow = 192.168.200.89
#transfer logging = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
3、启动RSYNC
#vi /etc/xinetd.d/rsync
把原来的YES改成NO
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
随系统启动RSYNC
#chkconfig rsync on
4、配置rsync密码
#vi /etc/rsync.pas
hadoop:12345
#cd /etc
#chown root.root rsync.pas
#chmod 600 rsync.pas
5、让配置生效
#service xinetd restart
6、启动rsync server
# /etc/rc.d/init.d/xinetd reload
7、加入rc.local
在各种操作系统中,rc文件存放位置不尽相同,可以修改使系统启动时把rsync --daemon加载进去。
#vi /etc/rc.local
加入一行/usr/bin/rsync --daemon
8、检查rsync是否启动
[root@test home]# lsof -i :873
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
xinetd 4396 root 5u IPv4 633387 TCP *:rsync (LISTEN)
9、配置客户服务器
只需要安装rsync,无需配置
(1)、设定密码
#vi /etc/rsync.pas
12345
修改权限
#cd /etc
#chown root.root rsync.pas
#chmod 600 rsync.pas
(2)、client连接SERVER
从SERVER端取文件
/usr/bin/rsync -vzrtopg --progress --delete hadoop@192.168.200.95::backup /var/testrsync --password-file=/etc/rsync.pas
rsync -avz --password-file=/etc/rsync.pas hadoop@192.168.200.95::backup /etc/test
客户端脚本
#!/bin/bash
/usr/bin/rsync -avz --password-file=/etc/rsync.pas hadoop@192.168.200.95::backup /etc/test
添加定时更新功能
crontab -e
30 * * * * /etc/autorsync.sh