一、YUM Server環境建置:

Step 1) 下載mirrordir套件安裝

mirrordir:http://pkgs.repoforge.org/mirrordir/

 

Step 2) 下載yum-arch套件安裝(自動產生headers資料夾)

yum-arch:http://rpm.pbone.net/index.php3/stat/4/idpl/4852179/com/yum-arch-2.2.2-2.el5.noarch.rpm.html

 

Step3) 安裝createrepo套件(建立索引檔用)

$ yum install -y createrepo

 

Step 4) 安裝並啟動httpd套件

$ yum install -y httpd

 

二、YUM Server設定

Step 5) 建立要放置的RPM目錄

建立32-bit CentOS 5.8 packages
$ mkdir -p /var/www/html/yum/centos/5.8/os/i386
$ mkdir -p /var/www/html/yum/centos/5.8/updates/i386
$ mkdir -p /var/www/html/yum/centos/5.8/extras/i386

建立64-bit CentOS 5.8 packages
$ mkdir -p /var/www/html/yum/centos/5.8/os/x86_64
$ mkdir -p /var/www/html/yum/centos/5.8/updates/x86_64
$ mkdir -p /var/www/html/yum/centos/5.8/extras/x86_64

 

Step 6) 針對目錄mirror YUM Server更新套件 (國家高速網路與計算中心FTP)

mirror 32-bit CentOS 5.8 RPM目錄
$ mirrordir -v ftp://ftp.twaren.net/Linux/CentOS/5.8/os/i386 /var/www/html/yum/centos/5.8/os/i386
$ mirrordir -v ftp://ftp.twaren.net/Linux/CentOS/5.8/updates/i386 /var/www/html/yum/centos/5.8/updates/i386
$ mirrordir -v ftp://ftp.twaren.net/Linux/CentOS/5.8/extras/i386 /var/www/html/yum/centos/5.8/extras/i386

mirror 64-bit CentOS 5.8 RPM目錄
$ mirrordir -v ftp://ftp.twaren.net/Linux/CentOS/5.8/os/x86_64 /var/www/html/yum/centos/5.8/os/x86_64
$ mirrordir -v ftp://ftp.twaren.net/Linux/CentOS/5.8/updates/x86_64 /var/www/html/yum/centos/5.8/updates/x86_64
$ mirrordir -v ftp://ftp.twaren.net/Linux/CentOS/5.8/extras/x86_64 /var/www/html/yum/centos/5.8/extras/x86_64

 

Step 7) RPM分析,並在目錄下產生headers資料夾

對32-bit packages目錄產生headers資料夾
$ yum-arch /var/www/html/yum/centos/5.8/os/i386
$ yum-arch /var/www/html/yum/centos/5.8/updates/i386
$ yum-arch /var/www/html/yum/centos/5.8/extras/i386

對64-bit packages目錄產生headers資料夾
$ yum-arch /var/www/html/yum/centos/5.8/os/x86_64
$ yum-arch /var/www/html/yum/centos/5.8/updates/x86_64
$ yum-arch /var/www/html/yum/centos/5.8/extras/x86_64

 

Step 8) 使用createrepo套件產生XML metadata,並在目錄下產生repodata資料夾

對32-bit packages目錄產生repodata資料夾
$ createrepo /var/www/html/yum/centos/5.8/os/i386
$ createrepo /var/www/html/yum/centos/5.8/updates/i386
$ createrepo /var/www/html/yum/centos/5.8/extras/i386

對64-bit packages目錄產生repodata資料夾
$ createrepo /var/www/html/yum/centos/5.8/os/x86_64
$ createrepo /var/www/html/yum/centos/5.8/updates/x86_64
$ createrepo /var/www/html/yum/centos/5.8/extras/x86_64

 

Step 9) 建立CentOS 5.x通用的YUM Server目錄,並指向最新的CentOS 5.8 Packages.
$ mkdir /var/www/html/yum/centos/5
$ ln -s /var/www/html/yum/centos/5.8/os /var/www/html/yum/centos/5/os
$ ln -s /var/www/html/yum/centos/5.8/updates /var/www/html/yum/centos/5/updates 
$ ln -s /var/www/html/yum/centos/5.8/extras /var/www/html/yum/centos/5/extras  

 

Step 10) 若要使Step6), 7), 8)定期更新的話,可以結合crontab.

 

三、YUM Client設定

Step 10) $ cd /etc/yum.repo.d

Step 11) $ cp CentOS-Base.repo bak.CentOS-Base.repo

Step 12) $ vim CentOS-Base.repo
---------------------------------------------------------------------------
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://YUM-Server-IP/yum/centos/$releasever/os/$basearch/
gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
gpgkey=http://YUM-Server-IP/yum/centos/$releasever/os/$basearch/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://YUM-Server-IP/yum/centos/$releasever/updates/$basearch/
gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

gpgkey=http://YUM-Server-IP/yum/centos/$releasever/os/$basearch/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://YUM-Server-IP/yum/centos/$releasever/extras/$basearch/
gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

gpgkey=http://YUM-Server-IP/yum/centos/$releasever/os/$basearch/RPM-GPG-KEY-CentOS-5
--------------------------------------------------------------------------- 

http://YUM-Server-IP/ 指的是YUM伺服器的Domain Name或是IP Address.
※ 因為YUM Client為CentOS 5.5 x86_64,也就是5.x系列,故此處的$releasever會等於「5」,而$basearch會等於「x86_64」
※ 若在/etc/yum.repo.d/CentOS-Base.repo不只有[base], [updates], [extras]的話,請記得將沒有用到的,如:[addons][centosplus][contrib]的enabled參數設定為0
 

 

以上資料參考自:http://paul.pixnet.net/blog/post/10980468

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dreamtails 的頭像
    dreamtails

    雜七雜八的小筆記!

    dreamtails 發表在 痞客邦 留言(1) 人氣()