以往同步檔案的時候通常client無法得知source有哪些檔案備異動過
所以透過rsync跟source端要資料時,需要將一整個目錄重新比對過,然後將有異動的部分複製到目的端
透過lsyncd+rsync則是在source端有異動資料的時候,主動透過rsync將異動的部分丟到目的端

測試平台 CentOS 5.5

來源端 10.0.0.1
安裝rsync+lsyncd
yum -y install lsyncd

啟動lsyncd
lsyncd /home/mirror/ 10.0.0.2::mirror/
/home/mirror 為要監控的來源目錄,10.0.0.2::mirror 則是遠端要更新的路徑


目的端 10.0.0.2
編輯 /etc/rsyncd.conf
[mirror]
   path = /home/mirror
   hosts allow = 10.0.0.1
   read only = no
   commect = mirror from 10.0.0.1

安裝xinetd並讓rsync可以透過xinetd可以被呼叫
yum -y install xinetd
vi /etc/inetd.d/rsync
disable = yes 改成 disable = no
service xinetd restart

這樣就可以運作了,試著將source的目錄做一些異動看看唄

可以觀察到SRC端的process,會針對有異動的目錄進行同步到DEST端,不會把一個目錄全部比對一次
/usr/bin/rsync --delete -ltd /home/mirror//test1/ 10.0.0.2::mirror//test1/

以及DEST端的process
rsync --daemon


arrow
arrow
    全站熱搜

    helloworld 發表在 痞客邦 留言(0) 人氣()