我们使用 yum 存储库将软件分发到生产实例。不幸的是,createrepo 正在成为瓶颈,存储库中只有 469 个软件包。
$ time createrepo /opt/tm-yum-repo
Spawning worker 0 with 469 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
real 0m43.188s
user 0m37.798s
sys 0m1.296s
我该怎么做才能让它更快?
答案1
--cachedir
dmourati 在他的回答中给出的选项会对您有所帮助,但您也应该使用,--update
特别是当您不想一次替换所有 469 个包时。
--update
If metadata already exists in the outputdir and an rpm is
unchanged (based on file size and mtime) since the metadata was
generated, reuse the existing metadata rather than recalculating
it. In the case of a large repository with only a few new or
modified rpms this can significantly reduce I/O and processing
time.
此外,如果以这种方式部署确实对时间敏感并且--update
帮助不够,请考虑为该包创建一个单独的 repo。
答案2
从 createrepo 手册页中,您将看到一个 cachedir 选项。
-c --cachedir <path>
Specify a directory to use as a cachedir. This allows createrepo
to create a cache of checksums of packages in the repository. In
consecutive runs of createrepo over the same repository of files
that do not have a complete change out of all packages this
decreases the processing time dramatically.
我会从那里开始。
如果这还不能充分提高 createrepo 的速度,我会考虑 SSD 或临时文件。
答案3
您是否尝试过使用 --workers 来实现多核 CPU?通常我使用 --workers 4 来生成 4 个 createrepo 线程
答案4
使用创建repo_c,createrepo 的 C 实现