lsyncd 全称是Live Syncing (Mirror) Daemon,它是一款能实时同步本地文件或目录到远端的机器,
它的工作原理:监视本地的目录,当源数据有文件或目录更新时,更新本地文件或目录到远端机器,
保持实时文件同步。它更新数据时需要远端机器运行rsync demon。
下面我将通过一个示例来通过lsyncd与rsync实现数据的实时同步
本示例所需要的软件是:lsyncd与rsync
在它们的官方主页上可以下载最新的源代码
lsyncd的官方主页为:http://code.google.com/p/lsyncd/
rsync的官方主页为:http://samba.anu.edu.au/rsync/
系统资源要求,对客户端要求是linux系统,对服务器端要求是linux rhel5或者是CentOS,笔者在linux rhel4上安装的过程中就遇到:
make all-am
make[1]: Entering directory `/root/lsyncd-1.25'
gcc -DHAVE_CONFIG_H -DXML_CONFIG -I. -Wall `xml2-config --cflags` -g -O2 -MT lsyncd.o -MD -MP -MF .deps/lsyncd.Tpo -c -o lsyncd.o lsyncd.c
In file included from lsyncd.c:19:
inotify-nosys.h:155:3: #error "Unsupported architecture!"
inotify-nosys.h:158:3: #error "Unsupported architecture!"
inotify-nosys.h:161:3: #error "Unsupported architecture!"
In file included from lsyncd.c:19:
inotify-nosys.h: In function `inotify_init':
inotify-nosys.h:167: error: `__NR_inotify_init' undeclared (first use in this function)
inotify-nosys.h:167: error: (Each undeclared identifier is reported only once
inotify-nosys.h:167: error: for each function it appears in.)
inotify-nosys.h: In function `inotify_add_watch':
inotify-nosys.h:172: error: `__NR_inotify_add_watch' undeclared (first use in this function)
inotify-nosys.h: In function `inotify_rm_watch':
inotify-nosys.h:177: error: `__NR_inotify_rm_watch' undeclared (first use in this function)
make[1]: *** [lsyncd.o] Error 1
make[1]: Leaving directory `/root/lsyncd-1.25'
make: *** [all] Error 2
不过最后请教张宴,发现问题是因为:
文件系统变化通知机制inotify