Inotifywait解決監控子目錄樹的情況
inotifywait是一個可以實時監控文件變動的工具。它利用linux內核中的inotify機制實現監控功能,在內核高於2.6.13的版本中,據說不需要軟件的安裝包。(本實驗採用centos7.3)
○前提:系統支持inotify
inotifywait 命令的常用參數包括:
-m, --monitor 保持一直監聽
-r, --recursive 若有多級目錄循環遞歸每一層。
-q, --quiet 靜默式運行
-e<event>, --event <event> create,move,delete,modify
安裝inotify-tools安裝包
1、安裝gcc、make編譯包;
2、下載inotify
http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
3、解壓縮
4、編譯
5、驗證
在主控制器上操作
1、備份rsync腳本
2、執行腳本
3、出現錯誤
出現錯誤之一:
如果是32位系統
ln -s /usr/local/lib/libinotifytools.so.0/usr/lib/libinotifytools.so.0
如果是64位系統
ln -s /usr/local/lib/libinotifytools.so.0/usr/lib64/libinotifytools.so.0
出現錯誤之二:
實時複製備份
1、主服務器:
2、兩個節點上: