CentOS平臺(tái)實(shí)現(xiàn)搭建rsync遠(yuǎn)程同步服務(wù)器的方法
本文實(shí)例講述了CentOS平臺(tái)實(shí)現(xiàn)搭建rsync遠(yuǎn)程同步服務(wù)器的方法。分享給大家供大家參考,具體如下:
rsync(remote synchronize)是一個(gè)遠(yuǎn)程數(shù)據(jù)同步工具,可通過LAN/WAN快速同步多臺(tái)主機(jī)間的文件,也可以使用 rsync 同步本地硬盤中的不同目錄。
rsync和scp的區(qū)別:
rsync支持增量同步,不管是文件數(shù)量的新增還是文件內(nèi)容的新增,scp不行
注意事項(xiàng):
1、centos默認(rèn)已經(jīng)安裝rsync了,輸入命令rsync查看,如果無法正常工作可參考文章最后的鏈接進(jìn)行操作
2、rsync只會(huì)增量同步,從服務(wù)器如果刪除 下次同步還會(huì)有,--delete 刪除目標(biāo)目錄比源目錄多余的文件
3、同步命令可用程序執(zhí)行、也可定時(shí)執(zhí)行、手動(dòng)執(zhí)行
4、修改配置文件后 記得重啟service xinetd restart
5、文件很大可先tar打包壓縮后再傳輸
序號(hào) | IP地址 | 簡稱 |
1 | 192.168.46.32 | A機(jī)器 |
2 | 192.168.46.11 | B機(jī)器 |
先看下A機(jī)器上,logs文件夾下的文件:
[root@h1 logs]# ll
總用量 4
-rw-r--r-- 1 root root 3 8月 30 02:29 a.txt [root@h1 logs]#
然后,我們?cè)贐機(jī)器上,執(zhí)行同步命令如下:
[root@h2 logs]# ll
總用量 0
[root@h2 logs]# rsync -av --delete 192.168.46.32:/root/logs /root/logg/ receiving incremental file list logs/ logs/a.txt sent 34 bytes received 107 bytes 282.00 bytes/sec total size is 3 speedup is 0.02 [root@h2 logs]# ll
總用量 4
-rw-r--r-- 1 root root 3 8月 30 02:29 a.txt [root@h2 logs]#
然后,我們?cè)贏機(jī)器上的log文件下,新增一個(gè)b.txt,再測(cè)試同步命令:
[root@h2 logs]# rsync -av --delete 192.168.46.32:/root/logs /root/logg/ receiving incremental file list logs/ logs/b.txt sent 34 bytes received 125 bytes 318.00 bytes/sec total size is 5 speedup is 0.03 [root@h2 logs]#
通過日志,我們發(fā)現(xiàn)如果新增一個(gè)使用rsync僅僅同步了新增的文件: 現(xiàn)在我們?cè)贏服務(wù)器上的log文件夾下的a.txt里面新增一行內(nèi)容,再次執(zhí)行同步命令:
[root@h2 logs]# rsync -av --delete 192.168.46.32:/root/logs /root/logg/ receiving incremental file list logs/a.txt sent 37 bytes received 128 bytes 330.00 bytes/sec total size is 9 speedup is 0.05 [root@h2 logs]#
我們發(fā)現(xiàn)rsync命令也能很好的識(shí)別出來 最后我們?cè)趤砜聪?,同時(shí)改動(dòng),A服務(wù)器上的a和 b文件,一個(gè)新增一行,一個(gè)刪除一行,來測(cè)下增量:
[root@h2 logs]# rsync -av --delete 192.168.46.32:/root/logs /root/logg/ receiving incremental file list logs/ logs/a.txt logs/b.txt sent 65 bytes received 174 bytes 478.00 bytes/sec total size is 10 speedup is 0.04 [root@h2 logs]#
我們發(fā)現(xiàn)rsync也能很好的識(shí)別出來。 最后,我們?cè)趤砜聪拢绾卧贐服務(wù)器上向A服務(wù)器上發(fā)送數(shù)據(jù),注意,散仙剛在上面的演示,是從B服務(wù)器上下載A服務(wù)器上的數(shù)據(jù),現(xiàn)在我們要演示的是如何在B服務(wù)上主動(dòng)發(fā)送數(shù)據(jù)到A服務(wù)器上,原理一樣,都是以增量的方式的操作的,只不過寫IP的方式,變換了一下位置:
[root@h2 logs]# rsync -av --delete /root/logg/logs/b.txt 192.168.46.32:/root/ sending incremental file list b.txt sent 87 bytes received 37 bytes 248.00 bytes/sec total size is 10 speedup is 0.08 [root@h2 logs]#
參考文章:
http://chabaoo.cn/article/138864.htm
http://chabaoo.cn/article/138866.htm
希望本文所述對(duì)大家CentOS服務(wù)器配置有所幫助。
- CentOS6.5平臺(tái)上rsync服務(wù)器安裝配置方法簡述
- CentOS6.5環(huán)境下使用rsync增量同步備份文件的方法
- CentOS Rsync服務(wù)端與Windows cwRsync客戶端實(shí)現(xiàn)數(shù)據(jù)同步配置方法
- CentOS 6.3 Rsync客戶端與Win2003 cwRsyncServer服務(wù)端實(shí)現(xiàn)數(shù)據(jù)同步
- Centos rsync文件同步配置步驟分享
- CentOS5 + rsync 同步2臺(tái)服務(wù)器的文件
- centos下mysql主從同步快速設(shè)置步驟分享
- Mysql 主從數(shù)據(jù)庫同步(centos篇)
- CentOS服務(wù)器平臺(tái)搭建mysql主從復(fù)制與讀寫分離的方法
- CentOS6.5系統(tǒng)簡單安裝與配置Nginx服務(wù)器的方法
相關(guān)文章
CentOS虛擬機(jī)克隆后無法上網(wǎng)(網(wǎng)卡信息不一致)問題的解決方法
這篇文章主要為大家詳細(xì)介紹了CentOS虛擬機(jī)克隆后無法上網(wǎng),即網(wǎng)卡信息不一致問題的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04Ubuntu18 給terminal改個(gè)漂亮的命令行提示符的方法
這篇文章主要介紹了Ubuntu18 給terminal改個(gè)漂亮的命令行提示符的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-06-06Linux系統(tǒng)下如何運(yùn)行.sh文件的實(shí)現(xiàn)
這篇文章主要介紹了Linux系統(tǒng)下如何運(yùn)行.sh文件的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12