inotify+rsync懂得进

搬瓦工机场JMS

inotify+rsync遇到了个问题:
一旦当文件发生变化同步后,就隔一段时间(大概一分钟不到)就自动轮询一次文件夹,造成了服务器的负载。。。

  1. /usr/bin/inotifywait -mrq –timefmt ‘%d/%m/%y %H:%M’ –format ‘%T %w%f%e’ -e modify,delete,create,attrib $src|while read files
  2. do
  3.   /usr/bin/rsync -avzP –delete –progress ${src} ${user}@${host1}::${dst} –password-file=/etc/web.passwd
  4.   echo "${file} was rsyncd"
  5. done

复制代码

如果只是启动这个脚本,暂时没有文件变化的时候,就不会隔一段时间轮询一次。。。

这个是什么问题?到底要怎么弄?
难道你是监测到文件变化后去同步完成就好了么?为啥还要隔一段时间轮询一次目录啊

  1. sent 16,559,294 bytes  received 9,062 bytes  241,873.81 bytes/sec
  2. total size is 654,649,017,020  speedup is 39,512.01
  3. was rsyncd
  4. sending incremental file list
  5. sent 16,559,302 bytes  received 9,070 bytes  241,874.04 bytes/sec
  6. total size is 654,649,017,020  speedup is 39,511.97
  7. was rsyncd
  8. sending incremental file list
  9. sent 16,559,306 bytes  received 9,074 bytes  241,874.16 bytes/sec
  10. total size is 654,649,017,020  speedup is 39,511.95
  11. was rsyncd
  12. sending incremental file list
  13. sent 16,559,298 bytes  received 9,066 bytes  241,873.93 bytes/sec
  14. total size is 654,649,017,020  speedup is 39,511.99
  15. was rsyncd
  16. sending incremental file list
  17. sent 16,559,290 bytes  received 9,058 bytes  241,873.69 bytes/sec
  18. total size is 654,649,017,020  speedup is 39,512.03
  19. was rsyncd
  20. sending incremental file list
  21. sent 16,559,302 bytes  received 9,070 bytes  241,874.04 bytes/sec
  22. total size is 654,649,017,020  speedup is 39,511.97
  23. was rsyncd
  24. sending incremental file list
  25. sent 16,559,218 bytes  received 8,986 bytes  238,391.42 bytes/sec
  26. total size is 654,649,017,020  speedup is 39,512.37
  27. was rsyncd
  28. sending incremental file list

复制代码

河北网友:用lsyncd
内蒙古网友:文件数量多的时候,用这个就不靠谱了,非常消耗资源,可以做主动同步
吉林网友:实时性不高的话建议定时任务,或者试试lsyncd

未经允许不得转载:美国VPS_搬瓦工CN2 GIA VPS » inotify+rsync懂得进

赞 (0) 打赏

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏