CentOS平臺實現搭建rsync遠程同步服務器的方法
本文實例講述了CentOS平臺實現搭建rsync遠程同步服務器的方法。分享給大家供大家參考,具體如下:
rsync(remote synchronize)是一個遠程數據同步工具,可通過LAN/WAN快速同步多臺主機間的文件,也可以使用 rsync 同步本地硬盤中的不同目錄。
rsync和scp的區(qū)別:
rsync支持增量同步,不管是文件數量的新增還是文件內容的新增,scp不行
注意事項:
1、centos默認已經安裝rsync了,輸入命令rsync查看,如果無法正常工作可參考文章最后的鏈接進行操作
2、rsync只會增量同步,從服務器如果刪除 下次同步還會有,--delete 刪除目標目錄比源目錄多余的文件
3、同步命令可用程序執(zhí)行、也可定時執(zhí)行、手動執(zhí)行
4、修改配置文件后 記得重啟service xinetd restart
5、文件很大可先tar打包壓縮后再傳輸
序號 | IP地址 | 簡稱 |
1 | 192.168.46.32 | A機器 |
2 | 192.168.46.11 | B機器 |
先看下A機器上,logs文件夾下的文件:
[root@h1 logs]# ll
總用量 4
-rw-r--r-- 1 root root 3 8月 30 02:29 a.txt [root@h1 logs]#
然后,我們在B機器上,執(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]#
然后,我們在A機器上的log文件下,新增一個b.txt,再測試同步命令:
[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ā)現如果新增一個使用rsync僅僅同步了新增的文件: 現在我們在A服務器上的log文件夾下的a.txt里面新增一行內容,再次執(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ā)現rsync命令也能很好的識別出來 最后我們在來看下,同時改動,A服務器上的a和 b文件,一個新增一行,一個刪除一行,來測下增量:
[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ā)現rsync也能很好的識別出來。 最后,我們在來看下,如何在B服務器上向A服務器上發(fā)送數據,注意,散仙剛在上面的演示,是從B服務器上下載A服務器上的數據,現在我們要演示的是如何在B服務上主動發(fā)送數據到A服務器上,原理一樣,都是以增量的方式的操作的,只不過寫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://www.dbjr.com.cn/article/138864.htm
http://www.dbjr.com.cn/article/138866.htm
希望本文所述對大家CentOS服務器配置有所幫助。
- CentOS6.5平臺上rsync服務器安裝配置方法簡述
- CentOS6.5環(huán)境下使用rsync增量同步備份文件的方法
- CentOS Rsync服務端與Windows cwRsync客戶端實現數據同步配置方法
- CentOS 6.3 Rsync客戶端與Win2003 cwRsyncServer服務端實現數據同步
- Centos rsync文件同步配置步驟分享
- CentOS5 + rsync 同步2臺服務器的文件
- centos下mysql主從同步快速設置步驟分享
- Mysql 主從數據庫同步(centos篇)
- CentOS服務器平臺搭建mysql主從復制與讀寫分離的方法
- CentOS6.5系統(tǒng)簡單安裝與配置Nginx服務器的方法
相關文章
CentOS虛擬機克隆后無法上網(網卡信息不一致)問題的解決方法
這篇文章主要為大家詳細介紹了CentOS虛擬機克隆后無法上網,即網卡信息不一致問題的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04Ubuntu18 給terminal改個漂亮的命令行提示符的方法
這篇文章主要介紹了Ubuntu18 給terminal改個漂亮的命令行提示符的方法,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-06-06