全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 861|回复: 4
打印 上一主题 下一主题

inotify+rsync懂得进

[复制链接]
跳转到指定楼层
1#
发表于 2019-8-21 00:05:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Apian 于 2019-8-21 00:07 编辑

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
复制代码

3#
发表于 2019-8-21 00:16:23 来自手机 | 只看该作者
文件数量多的时候,用这个就不靠谱了,非常消耗资源,可以做主动同步
4#
发表于 2019-8-21 12:56:22 来自手机 | 只看该作者
实时性不高的话建议定时任务,或者试试lsyncd
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-6 04:24 , Processed in 0.063614 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表