1.服务器配置(提供文件)
yum install -y rsync
echo "root:password" > /etc/rsyncd.secrets
#授权
chown root.root /etc/rsyncd.secrets
#一定要给这个文件600权限
chmod 600 /etc/rsyncd.secrets
配置文件
vim /etc/rsyncd.conf
启动服务
rsync --daemon
2.客户端配置(获取文件)
yum install -y rsync
echo "password" > /etc/rsyncd.secrets
chmod 600 /etc/rsyncd.secrets
rsync --list-only --password-file=/etc/rsyncd.secrets X.X.X.X::test1
杀死服务:rm -rf /var/run/rsyncd.pid
重启 rsync
# 要 Kill rsync 进程,不要用 kill -HUP {PID} 的方式重启进程。
ps -ef|grep rsync|grep -v grep|awk '{print $2}'|xargs kill -9
#也可以用
cat /var/run/rsyncd.pid | xargs kill -9
rm -rf /var/run/rsyncd.pid
/usr/bin/rsync --daemon
rsync注意:在vim /etc/rsyncd.conf中,一定要配置好
hosts allow = 0.0.0.0/0(允许的IP段)
hosts deny = 0.0.0.0/32(拒绝的IP段)