php新手网站开发,wordpress 对象存储插件,小蝌蚪福导福航app,闵行网站建设哪家好一、Rsync概述 rsync英文称为 remote synchronizetion#xff0c;rsync具有可使本地和远程两台主机之间的数据快速复制同步镜像、远程备份的功能#xff0c;功能类似于ssh带的scp命令#xff0c;优于scp命令的功能#xff0c;scp每次都是全量拷贝#xff0c;而rsync可以增…一、Rsync概述 rsync英文称为 remote synchronizetionrsync具有可使本地和远程两台主机之间的数据快速复制同步镜像、远程备份的功能功能类似于ssh带的scp命令优于scp命令的功能scp每次都是全量拷贝而rsync可以增量拷贝。
二、实验准备 本实验模拟Rsync的远程模式ssh隧道模式模拟过程中需要两台虚拟机一台充当服务端另一台充当客户端。
三、实验步骤
3.1 基础操作
①安装rsync服务的包
[rootopenEuler1 ~]# dnf install -y rsync
[rootopenEuler2 ~]# dnf install -y rsync
②push推操作
#先创建一个文件
[rootopenEuler1 ~]# echo iyuyi.xyzaliyun.com /opt/xyz.txt
[rootopenEuler1 ~]# ll /opt/
total 4
-rw-r--r-- 1 root root 23 Jan 25 16:17 xyz.txt
#进行push推操作相当于上传由于我配置了免密钥登录所有在此没有要密码
[rootopenEuler1 ~]# rsync -avz /opt/xyz.txt 192.168.126.141:/opt/ #-a表示递归传输数据保持文件属性和权限-v表示显示详细信息-z表示传输是进行压缩提高传输效率
Authorized users only. All activities may be monitored and reported.
sending incremental file list
xyz.txtsent 131 bytes received 35 bytes 110.67 bytes/sec
total size is 23 speedup is 0.14
#查看结果
[rootopenEuler2 ~]# ll /opt/
total 4
-rw-r--r-- 1 root root 23 Jan 25 16:17 xyz.txt
③pull拉操作
#与push是相反的操作
[rootopenEuler1 ~]# rsync -avz 192.168.126.141:/opt/xyz.txt /root/Authorized users only. All activities may be monitored and reported.
receiving incremental file list
xyz.txtsent 43 bytes received 131 bytes 116.00 bytes/sec
total size is 23 speedup is 0.13
#查看结果
[rootopenEuler1 ~]# ll /root/
total 12
-rw-------. 1 root root 706 Jan 23 21:05 anaconda-ks.cfg
drwxr-xr-x 3 root root 4096 Jan 23 22:20 findfiles
-rw-r--r-- 1 root root 23 Jan 25 16:17 xyz.txt
3.2 守护进程
3.2.1 服务端配置
①创建需要传输的目录
[rootopenEuler1 ~]# mkdir /backup ②配置文件
[rootopenEuler1 ~]# vim /etc/rsyncd.conf
#全局配置
uid rsync
gid rsync
use chroot no
max connections 100
timeout 300
pid file /var/run/rsyncd.pid
lock file /var/run/rsyncd.lock
log file /var/log/rsyncd.log
ignore errors
dont compress *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
hosts allow 192.168.126.0/24
fake super yes #这个必须写不写服务无法启动
auth users rsync_backup
secrets file /etc/rsync.passwd
#局部配置
[bak] #共享的目的地名字comment my backup #描述信息path /backup #这台机器的哪一个目录让它进行传文件read only false #权限设置list false #权限设置③创建用户与配置文件指定的要一致
[rootopenEuler1 ~]# useradd rsync -s /sbin/nologin -M #-s /sbin/nologin 不需要登录 -M没有家目录
[rootopenEuler1 ~]# cat /etc/rsync.passwd EOFrsync_backup:123456EOF ④修改文件和目录权限
[rootopenEuler1 ~]# chmod 600 /etc/rsync.passwd
[rootopenEuler1 ~]# chown -R rsync:rsync /backup
⑤启动服务
[rootopenEuler1 ~]# systemctl start rsyncd
3.2.2 客户端测试
[rootopenEuler2 ~]# rsync -avz /opt/xyz.txt rsync_backup192.168.126.140::bak
Password:
sending incremental file list
xyz.txtsent 125 bytes received 43 bytes 48.00 bytes/sec
total size is 13 speedup is 0.08
3.2.3 客户端免密登录
[rootopenEuler2 ~]# rsync -avz /opt/xyz.txt rsync_backup192.168.126.140::bak --password-file/etc/rsync.passwd
sending incremental file list
xyz.txtsent 132 bytes received 49 bytes 362.00 bytes/sec
total size is 20 speedup is 0.11
[rootopenEuler2 ~]# more /opt/xyz.txt
娇小赤雅
123456