使用者工具

網站工具


tech:install_yum

安裝 CentOS YUM 更版主機程序

主要目標是要提供 CentOS 4.8 / CentOS 5.4 的更版主機

同步 CentOS/RPMForge 來源 YUM Server

su - root
yum install createrepo
mkdir -p /var/www/html/CentOS
 
# 以下是同步 CentOS 官方網站 rsync 主機
rsync -aqzH --delay-updates --delete msync.centos.org::CentOS/4 /var/www/html/CentOS/
rsync -aqzH --delay-updates --delete msync.centos.org::CentOS/4.8 /var/www/html/CentOS/
rsync -aqzH --delay-updates --delete msync.centos.org::CentOS/5 /var/www/html/CentOS/
rsync -aqzH --delay-updates --delete msync.centos.org::CentOS/5.4 /var/www/html/CentOS/
 
# 以下是同步 HiNet IDC 網站 rsync 主機
rsync -aqzH --delay-updates --delete mirror01.idc.hinet.net::CentOS/4 /var/www/html/CentOS/
rsync -aqzH --delay-updates --delete mirror01.idc.hinet.net::CentOS/4.8 /var/www/html/CentOS/
rsync -aqzH --delay-updates --delete mirror01.idc.hinet.net::CentOS/5 /var/www/html/CentOS/
rsync -aqzH --delay-updates --delete mirror01.idc.hinet.net::CentOS/5.4 /var/www/html/CentOS/
 
# rpmforge 
mkdir -p /var/www/html/redhat
rsync -aqzH --delay-updates --delete rsync://apt.sw.be/pub/freshrpms/pub/dag/redhat/el4 /var/www/html/redhat/
rsync -aqzH --delay-updates --delete rsync://apt.sw.be/pub/freshrpms/pub/dag/redhat/el5 /var/www/html/redhat/

自定需求 Yum Server

如果只想依照自定需求來產生 rpm update 檔案, 可以將母機安裝好, 只要執行 yum update 時, 都將 rpm 保留下來, 將這些保留的 rpm 檔案提供給其他主機使用, 這樣母機那台需要更改 /etc/yum.conf 內的 keepcache=1

:
[main]
cachedir=/var/cache/yum
keepcache=1
debuglevel=2
logfile=/var/log/yum.log
:

然後將 /var/cache/yum 當成 yum server 的 rpms 路徑, 產生 repo 資訊, 假設這台母機是安裝 CentOS 5 x86_64 只勾選 Server GUI 的預設套件, 所以建立相對應的目錄如下:

su - root
mkdir -p /var/www/html/CentOS/5/addons/x86_64/RPMS
mkdir -p /var/www/html/CentOS/5/extras/x86_64/RPMS
mkdir -p /var/www/html/CentOS/5/base/x86_64/RPMS
mkdir -p /var/www/html/CentOS/5/updates/x86_64/RPMS
mkdir -p /var/www/html/CentOS/5/rpmforge/x86_64/RPMS

之後只要執行以下程序, 就可以保持更新與安裝下載的 rpm 檔案

yum update -y
rsync -av /var/cache/yum/addons/packages/ /var/www/html/CentOS/5/addons/x86_64/RPMS/
rsync -av /var/cache/yum/extras/packages/ /var/www/html/CentOS/5/extras/x86_64/RPMS/
rsync -av /var/cache/yum/base/packages/ /var/www/html/CentOS/5/base/x86_64/RPMS/
rsync -av /var/cache/yum/updates/packages/ /var/www/html/CentOS/5/updates/x86_64/RPMS/
rsync -av /var/cache/yum/rpmforge/packages/ /var/www/html/CentOS/5/rpmforge/x86_64/RPMS/
createrepo /var/www/html/CentOS/5/addons/x86_64
createrepo /var/www/html/CentOS/5/extras/x86_64
createrepo /var/www/html/CentOS/5/base/x86_64
createrepo /var/www/html/CentOS/5/updates/x86_64
createrepo /var/www/html/CentOS/5/rpmforge/x86_64

特定需求 Yum Client

這台 Yum Client 一開始的安裝要和 Yum Server 內母機版本相同, 也就是範例的安裝 CentOS 5 x86_64 Server GUI 套件.

修改 yum conf 指定到 Yum Server (範例 192.168.122.1)

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.org
vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://192.168.122.1/CentOS/$releasever/base/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://192.168.122.1/CentOS/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
baseurl=http://192.168.122.1/CentOS/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://192.168.122.1/CentOS/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://192.168.122.1/CentOS/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://192.168.122.1/CentOS/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0

[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/rpmforge
baseurl = http://192.168.122.1/CentOS/$releasever/rpmforge/$basearch/
#mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
#gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 0

這樣在 Yum Client 執行

yum update 

就會直接連上 192.168.122.1 Yum Server 比對與下載更新 rpm 檔

參考網頁網址

tech/install_yum.txt · 上一次變更: 2010/03/30 17:54 由 jonathan