基于Lsync+sync实现实时文件同步

lsyncd 全称是Live Syncing (Mirror) Daemon,它是一款能实时同步本地文件或目录到远端的机器,

 

它的工作原理:监视本地的目录,当源数据有文件或目录更新时,更新本地文件或目录到远端机器,

保持实时文件同步。它更新数据时需要远端机器运行rsync demon

 

下面我将通过一个示例来通过lsyncdrsync实现数据的实时同步

本示例所需要的软件是:lsyncdrsync

在它们的官方主页上可以下载最新的源代码

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值