Fedora Core 8 安裝完成後,首要任務是使用 yum 更新系統。但官方遠端鏡像站速度往往極慢,甚至無法完成下載。本文介紹如何透過 HTTP 搭建本地 YUM 更新源,大幅提升更新效率。
先安裝 httpd 與 createrepo:
# yum install httpd
# chkconfig httpd on
# service httpd start
# yum install createrepo
建立儲存 Fedora 8 基礎套件與更新套件的目錄:
# mkdir -p /var/www/html/yum/base/8/i386
# mkdir -p /var/www/html/yum/updates/8/i386
若有 Fedora 8 安裝光碟,可將所有 RPM 複製至本地目錄:
# cd /misc/cd/Packages
# cp -V * /var/www/html/yum/base/8/i386
# cd
從 Fedora 官方鏡像站同步下載,以 rsync 為例:
rsync -avrt rsync://ftp-stud.hs-esslingen.de/fedora/linux/releases/8/Everything/i386/os/Packages/ /var/www/html/yum/base/8/i386
注意:路徑結尾必須保留 / 斜線。
對基礎套件目錄執行 createrepo,系統自動建立 repodata 目錄與索引檔:
# createrepo /var/www/html/yum/base/8/i386
執行後可用以下指令確認:
# ls -l /var/www/html/yum/base/8/i386/repodata/
應會看到 filelists.xml.gz、other.xml.gz、primary.xml.gz、repomd.xml 等檔案。
同步 Fedora 8 更新套件至對應目錄:
rsync -avrt rsync://ftp-stud.hs-esslingen.de/fedora/linux/updates/8/i386/ --exclude=debug/ /var/www/html/yum/updates/8/i386
為確保本地源保持最新,透過 crontab 設定定期自動同步:
23 4 */2 * * /usr/bin/rsync -avrt rsync://ftp-stud.hs-esslingen.de/fedora/linux/updates/8/i386/ --exclude=debug/ /var/www/html/yum/updates/8/i386
表示每兩天凌晨 4:23 自動執行一次 rsync 同步。
進入 /etc/yum.repos.d/ 目錄,建立 .repo 結尾的新檔案(如 local.repo),內容如下:
[base-local]
name=Fedora $releasever - $basearch
failovermethod=priority
baseurl=https://192.168.0.100/yum/base/$releasever/$basearch
enabled=1
gpgcheck=0
[updates-local]
name=Fedora $releasever - $basearch - Updates
failovermethod=priority
baseurl=https://192.168.0.100/yum/updates/$releasever/$basearch/
enabled=1
gpgcheck=0
將 192.168.0.100 替換為本地伺服器實際 IP。完成後即可用 yum update 快速從本地源更新系統。