Centos 6.3下rsync+inotify的安裝配置

來源:互聯網
上載者:User

什麼是inotify?

inotify是一種強大的,細粒度的,非同步檔案系統時間監控機制,它可以替代crond實現與rsync的觸發式檔案同步,從而監控檔案系統中添加,刪除,修改,移動等細粒事件,從LINUX 2.6.13起,就已加入了對inotify的支援,所以我們只需要安裝一個第三方軟體inotify-tools即可管理此服務。

之前利用的rsync+crond來觸發實現同步的瓶頸在於,rsync在同步資料時,需要先掃描所有檔案後進行比對,而後進行差異傳輸,如果檔案數量層級很大而且變化會很快,掃描所有檔案會非常耗時,而且會存在漏同步的問題,造成效率低下。

而rsync+inotify則會彌補前者先掃描後同步的效率問題,採用系統層級監控各種變化,當檔案發生任何變化,就會觸發rsync同步,解決效率與即時性問題。

LINUX作業系統:  centOS6.3 64bit

rsync:          系統內建

inotify-tools:  inotify-tools-master

www1(rsync server):192.168.7.73

www2(rsync client):192.168.7.74

拓撲圖:

(server)表示僅服務端配置

(client)表示僅用戶端配置

(server,client)表示用戶端與服務端都需配置

環境搭建:(server,client)

1.關閉iptables和SELINUX

# service iptables stop

# setenforce 0

# vi /etc/sysconfig/selinux

---------------

SELINUX=disabled

---------------

判斷LINUX系統核心是否達到2.6.13以上:

# uname -a

-------------

Linux www1.example.com 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

-------------

查看inotify目錄是否存在:

# ls -lsart /proc/sys/fs/inotify/

------------------

總用量 0

0 dr-xr-xr-x 0 root root 0 6月   4 14:04 ..

0 dr-xr-xr-x 0 root root 0 6月   4 17:35 .

0 -rw-r--r-- 1 root root 0 6月   4 17:35 max_user_watches

0 -rw-r--r-- 1 root root 0 6月   4 17:35 max_user_instances

0 -rw-r--r-- 1 root root 0 6月   4 17:35 max_queued_events

------------------

若返回以上內容,則系統支援inotify.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.