? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? day32
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?作者:黃勝
內(nèi)容概要:rsync服務(wù)的知識(shí)
介紹:Rsync:remote synchronization 是開源、高速、數(shù)據(jù)復(fù)制(拷貝)工具
用于不同機(jī)器甲献、機(jī)房之間的數(shù)據(jù)定時(shí)蜕该、實(shí)時(shí)備份。
一污淋、增量復(fù)制原理
使用quick check算法嫉晶,只對(duì)增量部分復(fù)制,根據(jù)大小屬性的變化進(jìn)行復(fù)制敛滋,可分:2.x比對(duì)差異后復(fù)制许布;3.x一邊比對(duì)一邊復(fù)制。
二绎晃、rsync三種工作模式介紹
模式一:rsync就是一個(gè)命令(命令 參數(shù) 目標(biāo) 源文件)
命令操作:
a.把數(shù)據(jù)從一個(gè)地方復(fù)制到另外一個(gè)地方蜜唾,相當(dāng)于cp
b.通過加參數(shù)實(shí)現(xiàn)刪除功能,相當(dāng)于rm命令庶艾。
c.查看屬性信息功能袁余,相當(dāng)于ls。
1. rsync --delete /null.txt /opt/hosts? #讓前面的null.txt和后面的hosts一樣
2. rsync -r --delete? /null/ /opt/ #讓后面的opt和前面的null目錄內(nèi)容保持一致
3.rsync 咱揍、etc/hosts #查看屬性
模式二:遠(yuǎn)程shell模式(借助ssh隧道傳輸數(shù)據(jù)泌霍,適合不同的機(jī)器之間復(fù)制)
pull 拉:從遠(yuǎn)端拉取到本地
例如:rsync -avz root@172.16.1.41:/opt/hosts /opt
rsync -avz -e "ssh -p 22" root@172.16.1.41:/opt/hosts /opt
push 推:從本地推到遠(yuǎn)端,格式:rsync? 參數(shù)? [USER@]HOST:SRC...? 本地路徑
例如: [root@nfs01 ~]# rsync -avz /etc/hosts root@172.16.1.41:/opt/ #加密傳輸述召。 The authenticity of host '172.16.1.41 (172.16.1.41)' can't be established. ECDSA key fingerprint is SHA256:qZSBkrmOv7xO/63qOU1uLXkPyNVHdkqvrNAcAmXqNEk. ECDSA key fingerprint is MD5:23:d0:cb:a9:f4:7c:0b:eb:2d:07:00:e1:a3:12:d8:33. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.16.1.41' (ECDSA) to the list of known hosts. root@172.16.1.41's password: sending incremental file list hosts sent 219 bytes received 35 bytes 14.51 bytes/sec total size is 332 speedup is 1.31 檢查: [root@backup ~]# cd /opt/ [root@backup /opt]# ls hosts rsync -avz /etc/hosts root@172.16.1.41:/opt/ rsync -avz /etc/hosts -e "ssh -p 22" root@172.16.1.41:/opt/ 上述命令是等價(jià)的朱转。-e 指定通道 ssh ssh服務(wù)連接客戶端 -p 22指定22端口。 [root@nfs01 ~]# rsync -avz /etc/hosts -e "ssh -p 22" root@172.16.1.41:/opt/ root@172.16.1.41's password: sending incremental file list sent 44 bytes received 12 bytes 22.40 bytes/sec total size is 332 speedup is 5.93