
我想在本機網路上為 Fedora 軟體包建立一個 RPM 儲存庫。由於存儲限制,我希望存儲庫最初為空,並在訪問包後下載它們。
背景
我經常使用本地虛擬機器。每當我創建一個新的VM並安裝Fedora時,都會從互聯網上下載很多軟體包,並且大多數下載的軟體包都是相同的。為了加快這個過程,我希望將 RPM 快取在位於同一網路的伺服器上。
createrepo
類似的問題已透過&的組合得到了答案reposync
。我不喜歡這一reposync
部分,因為當我只需要一些包時,我不想預先克隆整個存儲庫。
理想的解決方案
我希望本地網路上的伺服器充當我的 Fedora 安裝的 RPM 儲存庫。它應該傳遞來自 .config 中配置的任何元資料/etc/yum.repo.d/*
。如果本機快取中存在所請求的 RPM,伺服器應傳送該 RPM,否則下載並傳送它。
一種較不雄心勃勃的方法是配置單一 RPM 儲存庫,而不是https://mirrors.fedoraproject.org/...
僅使用 http 代理程式。
更新:2015 年 11 月 2 日
我已經在網路上運行了 nginx,因此我嘗試了proxy_pass
和的組合proxy_cache
。它有點有效,但恕我直言,它的缺點多於優點:
- 為 中配置的每個儲存庫進行單獨的配置
/etc/yum.repo.d/*
。 - 由於備用鏡像而無法使用
metadata
from 。https://mirrors.fedoraproject.org/
我按照評論中的建議刪除了 nginx 並安裝了squid
。squid
對我來說效果很好。透過store_id_program
配置,我甚至可以使用備用鏡像並仍然命中緩存,無論 RPM 最初來自何處。
答案1
在這裡您可以找到針對 rpm 快取進行微調的squid.conf:
https://github.com/spacewalkproject/spacewalk/blob/master/proxy/installer/squid.conf
您只需修改記憶體和連接埠設定即可。
答案2
我不確定你是否找到了一個好的解決方案,但我最終編寫了一個快速的小 Go 程式。它充當快取代理並保留 RPM,但代理上游到資料庫文件,因此它始終是正確的。目前它已針對 CentOS、Fedora EPEL 和 Arch Linux 進行配置。
你可以在以下位置看到它:https://github.com/yobert/remirror
答案3
apt-cacher-ng
效果很好。我們已經使用它一段時間了,效果很好。並且記住在使用它時只使用 http 鏡像(而不是 https 鏡像)以提高效率(當然,它無法查看和快取 https 流量):
要將 fedora 官方存儲庫配置為僅使用 http 鏡像,您可以&protocol=http
在配置 url 末尾添加metalink
,例如對於fedora
存儲庫,它將變為:
metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch&protocol=http
https://www.unix-ag.uni-kl.de/~bloch/acng/
緩存代理。專門用於來自 Linux 發行商的軟體包文件,主要用於 Debian(以及基於 Debian 的)發行版,但不限於這些發行版。請參閱 Apt-Cacher 的文檔以了解它的用途。
答案4
Yum wiki 包含頁面快取解決方案回顧
其中一些與主題相關的內容:
-
Pros Zero configuration, on the client side. Post setup it mostly just works and everything should be immediate. Only downloads what is required by the users. Fully automated server side, once setup/working. Cons Requires setting up a local Squid + Apache-httpd + IntelligentMirror to serve the data. If the server is down then metalinks/MM will route you to an external mirror. Only intelligently caches packages, not metadata.
(測試版)avahi-packages-server.py 和 yum avahi 支援(請參閱:http://james.fedorapeople.org/yum/avahi)
Pros Zero configuration client. Zero configuration server. Only downloads what is required by the users. Cons Not upstream yet (still beta). A client that doesn't run the avahi server side doesn't share it's downloads (so all clients need to run the "server"). Requires working avahi on the network.