一、环境:
主机1:youzhuan-bak centos 7.2
主机2:youzhuan-online centos 7.2
二、部署过程:
youzhuan-bak :
[root@youzhuan-bak ~]# yum install rsync -y
[root@youzhuan-bak ~]# rsync --daemon
[root@youzhuan-bak ~]# netstat -an | grep 873
[root@youzhuan-bak ~]# cat /etc/rsyncd.conf rsync配置文件修改
uid = nobody
gid = nobody
use chroot = yes
address = 0.0.0.0
port 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
hosts allow = 172.24.119.202
[backup]
path = /data/www
comment = backup
read only = false
auth users = liang
secrets file = /etc/rsyncd.pwd
[root@youzhuan-bak ~]# cat /etc/rsyncd.pwd 增加秘钥文件
liang:m2i3sc
[root@youzhuan-bak ~]# chmod 600 /etc/rsyncd.pwd 权限必须为 600
[root@youzhuan-bak ~]# ll /etc/rsyncd.pwd
-rw------- 1 root root 13 Mar 29 21:18 /etc/rsyncd.pwd
****************当连接不上时候用这样配置 root *******************************
youzhuan-online : 配置 sersync
下载安装包: sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@youzhuan-online local]# tar -xf sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@youzhuan-online localt]# mv GNU-Linux-x86/ sersync
[root@youzhuan-online local]# cd sersync
[root@youzhuan-online sersync]# cp confxml.xml confxml.xml.bak
[root@youzhuan-online sersync]# vim confxml.xml
[root@youzhuan-online sersync]# cat /etc/liang.passwd
m2i3sc
[root@youzhuan-online sersync]# chmod 600 /etc/liang.passwd
[root@youzhuan-online sersync]# ll /etc/liang.passwd
-rw------- 1 root root 7 Mar 29 21:19 /etc/liang.passwd
[root@youzhuan-online sersync]# /usr/local/sersync/sersync2 -d -r -o /usr/local/sersync/confxml.xml
测试 :
[root@youzhuan-online sersync]# cd /data/www/
[root@youzhuan-online www]# mkdir 999
在 youzhuan-bak上验证:
删除后也会实时同步,验证成功。