国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務器 > Web服務器 > 正文

CentOS平臺實現搭建rsync遠程同步服務器的方法

2024-09-01 13:54:42
字體:
來源:轉載
供稿:網友

本文實例講述了CentOS平臺實現搭建rsync遠程同步服務器的方法。分享給大家供大家參考,具體如下:

rsync(remote synchronize)是一個遠程數據同步工具,可通過LAN/WAN快速同步多臺主機間的文件,也可以使用 rsync 同步本地硬盤中的不同目錄。

rsync和scp的區別:

rsync支持增量同步,不管是文件數量的新增還是文件內容的新增,scp不行

注意事項:

1、centos默認已經安裝rsync了,輸入命令rsync查看,如果無法正常工作可參考文章最后的鏈接進行操作
2、rsync只會增量同步,從服務器如果刪除 下次同步還會有,--delete 刪除目標目錄比源目錄多余的文件
3、同步命令可用程序執行、也可定時執行、手動執行
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機器上,執行同步命令如下:

[root@h2 logs]# ll

總用量 0

[root@h2 logs]# rsync -av --delete 192.168.46.32:/root/logs /root/logg/receiving incremental file listlogs/logs/a.txtsent 34 bytes received 107 bytes 282.00 bytes/sectotal 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 listlogs/logs/b.txtsent 34 bytes received 125 bytes 318.00 bytes/sectotal size is 5 speedup is 0.03[root@h2 logs]#

通過日志,我們發現如果新增一個使用rsync僅僅同步了新增的文件: 現在我們在A服務器上的log文件夾下的a.txt里面新增一行內容,再次執行同步命令:

[root@h2 logs]# rsync -av --delete 192.168.46.32:/root/logs /root/logg/receiving incremental file listlogs/a.txtsent 37 bytes received 128 bytes 330.00 bytes/sectotal size is 9 speedup is 0.05[root@h2 logs]#

我們發現rsync命令也能很好的識別出來 最后我們在來看下,同時改動,A服務器上的a和 b文件,一個新增一行,一個刪除一行,來測下增量:

[root@h2 logs]# rsync -av --delete 192.168.46.32:/root/logs /root/logg/receiving incremental file listlogs/logs/a.txtlogs/b.txtsent 65 bytes received 174 bytes 478.00 bytes/sectotal size is 10 speedup is 0.04[root@h2 logs]#

我們發現rsync也能很好的識別出來。 最后,我們在來看下,如何在B服務器上向A服務器上發送數據,注意,散仙剛在上面的演示,是從B服務器上下載A服務器上的數據,現在我們要演示的是如何在B服務上主動發送數據到A服務器上,原理一樣,都是以增量的方式的操作的,只不過寫IP的方式,變換了一下位置:

[root@h2 logs]# rsync -av --delete /root/logg/logs/b.txt 192.168.46.32:/root/sending incremental file listb.txtsent 87 bytes received 37 bytes 248.00 bytes/sectotal size is 10 speedup is 0.08[root@h2 logs]#

希望本文所述對大家CentOS服務器配置有所幫助。


注:相關教程知識閱讀請移步到服務器教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 肃南| 保山市| 敦煌市| 武安市| 山东| 恩施市| 江北区| 南木林县| 宁国市| 南丰县| 松江区| 鄂托克旗| 金山区| 金阳县| 山东省| 叙永县| 阳新县| 石景山区| 龙游县| 抚松县| 丘北县| 鄂温| 石河子市| 高邑县| 密山市| 巴彦县| 甘孜县| 深州市| 和平县| 库车县| 青龙| 汉沽区| 麻阳| 韶山市| 阿克| 中卫市| 湘乡市| 林西县| 称多县| 尤溪县| 望谟县|