首先決定你要使用 yum server 的協定, 有HTTP and FTP. 而我用的是HTTP 來架設.
Require packages: httpd, createrepo, rsync
我使用rsync 來同步資料, 台灣有支援rsync 的yum mirror site 有:
義守大學 rsync://ftp.isu.edu.tw::centos
暨南大學 rsync://ftp.ncnu.edu.tw/centos-incdvd/
可以使用shell script 來做定期的更新, 程式碼如下:
mirror.sh
#!/bin/sh之後修改/etc/yum.repos.d/CentOS-Base.repo, 將[base] 和 [update] 中的baseurl 改成
rsync="/usr/bin/rsync -aqHz --delete --delay-updates --bwlimit=256"
# this should be auto-selected, but the centos mirror script doesn't
# support selection by a specific protocol (i.e., rsync)
mirror=ftp.isu.edu.tw::centos
#mirror=mirror.stanford.edu::mirrors/centos
#mirror=centos.cs.wisc.edu::centos
#mirror=mirrors.usc.edu::centos
ver=5
#archlist="i386 x86_64"
archlist="x86_64"
baselist="os updates"
#local=/usr/local/src/repos/centos
local=/home/html/yum/CentOS
for arch in $archlist
do
for base in $baselist
do
remote=$mirror/$ver/$base/$arch/
if [ ! -d $local/$ver/$base/$arch ]; then
mkdir -p $local/$ver/$base/$arch
fi
#$rsync $remote $local/$ver/$base/$arch/
$rsync $remote $local/$ver/$base/
createrepo -q $local/$ver/$base/
done
done
baseurl=http://IP/yum/CentOS/$releasever/os/$basearch/
Reference:
鳥哥-簡易 APT/YUM 伺服器設定
http://linux.vbird.org/linux_server/0450apt.php#yum_setup
CentOS Mirroring HowTo
http://www.centos.org/modules/tinycontent/index.php?id=22
架設 yum 伺服器
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=8951
Converting Red Hat Network channels to yum repos
http://www.brandonhutchinson.com/Converting_Red_Hat_Network_channels_to_yum_repos.html
YUM: Setup and Usage
http://sial.org/howto/yum/