【服务器端】
1、首先安装rsync 服务
yum install rsync
2、在etc下创建 rsyncd.conf 配置文件
vim /etc/rsyncd.conf
【模板】
secrets file = /etc/rsyncd.pass
motd file = /etc/rsyncd.motd
read only = yes
list = no
uid = root
gid = root
hosts allow = * #这里不限制哪个IP同步,也可以是 192.168.163.30
#max connections = 5
log file = /etc/rsyncd.log
#pid file = /var/run/rsyncd.pid
#lock file = /var/run/rsync.lock
ignore errors
slp refresh = 300
[web]
comment = web
path = /data/
auth users = root
3、在etc下创建 rsyncd.pass 密码文件
vim /etc/rsyncd.pass
【模板】
root:123456
4、给密码文件 600的权限
chmod 600 rsyncd.pass
5、防火墙添加873 端口用于同步
iptables -I INPUT -p tcp --dport 873 -j ACCEPT
service iptables save
service iptables restart
查看端口占用情况
[root@localhost test]# lsof -i:873
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
xinetd 2070 root 5u IPv6 11563 0t0 TCP *:rsync (LISTEN)
[root@localhost test]# kill -9 2070
[root@localhost test]# /usr/bin/rsync --daemon --port=873 --config=/etc/rsyncd.conf
[root@localhost test]# lsof -i:873
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 31008 root 3u IPv4 1053416 0t0 TCP *:rsync (LISTEN)
rsync 31008 root 5u IPv6 1053417 0t0 TCP *:rsync (LISTEN)
/usr/bin/rsync --daemon --port=873 --config=/etc/rsyncd.conf
查看 rsync 服务目录 which rsync
【客户端】
直接运行语句
rsync -rvlHpogDtS --progress --delete root@192.168.163.128::web /data