上面这种场景是一种拉模式下的数据同步。
三.C/C模式场景
client/client
这种模式比较简单,不需要配置服务器。
默认情况下rsync
走的是ssh
协议的22
端口,如果ssh
是非默认的22
端口,那么可以添加-e
选项:
3.1环境说明
现有两台主机,服务端数据同步到客户端,主机信息如下:
类型 | 主机名 | IP 地址 | 操作系统 | 目录 |
---|
服务端S | rsyncnew01 | 192.168.250.50 | CentOS 7.8 | /data |
客户端C | rsyncnew02 | 192.168.250.51 | CentOS 7.8 | /mybackup |
3.2检查并安装rsync
服务
这个过程略,相关方法请参照本文前面的内容。
3.3推模式同步
这种模式在服务端执行命令,直接将文件推送到客户端指定目录下:
[root@rsyncnew01 /]# rsync -vzrtopg --delete --progress /data/extundelete-0.2.4.tar.bz2 root@192.168.250.51:/mybackup
The authenticity of host '192.168.250.51 (192.168.250.51)' can't be established.
ECDSA key fingerprint is SHA256:vThEoRhUOECeD5jhE+m8TZA2+6OoElIoNOQ3XqtopZw.
ECDSA key fingerprint is MD5:97:40:b2:35:6e:07:5a:61:1f:73:f1:b2:6e:54:5b:7d.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.250.51' (ECDSA) to the list of known hosts.
root@192.168.250.51's password:
sending incremental file list
extundelete-0.2.4.tar.bz2
108,472 100% 14.44MB/s 0:00:00 (xfr#1, to-chk=0/1)
sent 108,599 bytes received 35 bytes 8,046.96 bytes/sec
total size is 108,472 speedup is 1.00
[root@rsyncnew01 /]#