rsync 挂起并指定了许多远程文件
当远程计算机使用 rsyncd 时,使用以下 rsync 命令将允许您将大量远程文件复制到本地计算机:
rsync -R hostname::'module/path1/file1 module/path2/file2 module/path3/file3 module/path4 /file4' /local/path
但是,如果文件数量太多,rsync 会挂起,不会在目标位置创建文件。 我正在测试的环境中的限制是 22。如果有 22 个文件,它会在几秒钟内完成; 如果有 23 个或更多文件,它会无限期挂起。
任何人都可以提供为什么会发生这种情况的原因吗? 以下是我检查过的一些内容:
- 两台机器都没有耗尽磁盘空间或内存。
- 所有文件都可以传输,只要我一次不超过22个即可。 (换句话说,位置 23 及以上的特定文件并没有什么特殊之处。)
- 不存在权限问题; 我能够读取远程计算机上的所有文件,并且可以写入目标目的地。 (此外,正如我在上一项中指出的,只要我一次不执行超过 22 个文件,就可以传输整个列表中的所有约 50 个文件。)
- 如果我使用 -n (干),则不会发生任何变化运行)选项。
Using the following rsync command will let you copy numerous remote files to your local machine, when the remote machine is using rsyncd:
rsync -R hostname::'module/path1/file1 module/path2/file2 module/path3/file3 module/path4/file4' /local/path
If the number of files is too great, however, rsync hangs, not creating the files in the target location. The limit in the environment I'm testing on is 22. With 22 files it finishes in a few seconds; with 23 or more files, it hangs indefinitely.
Can anyone provide a reason why this might happen? Here's some things I've checked:
- Neither machine is running out of disk space or memory.
- All the files can be transferred, as long as I don't do more than 22 at a time. (In other words, it's not something special about the specific files at position 23 and above.)
- There are no permissions issues; I have the ability to read all files on the remote machine, and can write to the target destination. (Also, as I noted in the previous item, all of the ~50 files in my overall list can be transferred as long as I don't do more than 22 at a time.)
- Nothing changes if I use the -n (dry run) option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
没有解释为什么要指定单个文件。 最简单的方法是递归地 rsync 整个目录,如果您需要更多,请使用
--include
或--exclude
标志以及您想要匹配的适当模式控制。如果您的使用确实需要显式指定要备份的每个文件,请使用列出这些文件的单独文本文件,并使用
--files-from
标志调用 rsync。我使用了
--files-from
选项。 效果很好。 rsync 非常可靠 - 但许多配置选项可能会让学习变得混乱。 例如,有一个--cvs-exclude
标志可以从备份中排除所有元数据文件,不仅适用于 CVS,也适用于 SVN。 非常有用,但绝对不容易发现。所有这些选项均在此处的 rsync 文档中详细介绍。
There's no explanation of why you're specifying individual files. The simplest approach is to rsync an entire directory recursively, and use either the
--include
or--exclude
flags with the appropriate patterns you want to match on if you need more control.If your usage really does require explicitly specifying every single file to be backed up, then use a separate text file that lists those files and call rsync with the
--files-from
flag.I've used the
--files-from
option. It works well. rsync is very solid - but the many configuration options can make it confusing to learn. For example, there's a--cvs-exclude
flag to exclude all the metadata files from backup not only for CVS but also for SVN. Extremely useful, but definitely not easily discoverable.All of these options are detailed in the rsync documentation here.
好吧,经过进一步测试,这似乎与参数长度有关。 我还没有计算出确切的长度,但我尝试了另一组 25 个文件,路径/文件名更短,并且工作正常。 所以我想我只需要限制命令的长度。 屁股。 :\
Okay, after further testing, it appears to have to do with argument length. I haven't worked out the exact length, but I tried a different set of 25 files, with shorter path/filenames, and it worked normally. So I guess I just have to limit the length of the command. Arse. :\
strace 客户端和服务器,看看是谁造成了问题。 听起来像是 rsync 中的某种错误。
strace the client and server, see who's causing the problem. It smells like a bug of some sort in rsync.
让我们假设这是一个错误而不是预期的行为。
由于 Rsync 是一个开源项目。 您可以下载源代码,找到错误并为每个人上传修复程序。 您应该首先检查您是否使用的是最新版本。
Let's assuming this is a bug rather than an expected behavior.
Since Rsync is an open source project. you could download the source, find the bug and upload a fix for everyone. You should check if you're using the latest version first.