站長新書 站長開講 首頁 最新文章 站長著作及審校 FreeBSD 筆記 Linux 筆記 Windows 筆記 虛擬化筆記 網管人雜誌 遊山玩水 關於本站
站長新書 VMware vSphere ICM 團購開跑了!!

RHEL 使用 CentOS YUM

最後編輯

增加:

> 在設定以前用 yum search drbd 是找不到套件可安裝的,如下所示
> #yum search drbd
> Loaded plugins: rhnplugin, security
> This system is not registered with RHN.
> RHN support will be disabled.
> Warning: No matches found for: drbd
> No Matches found

增加:

> 下列為 centos.repo 的內容
> [base]
> name=CentOS-5.6 - Base
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=os
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/os/$basearch/
> enabled=1
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #released updates
> [updates]
> name=CentOS-5.6 - Updates
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=updates
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/updates/$basearch/
> enabled=1
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #packages used/produced in the build but not released
> [addons]
> name=CentOS-5.6 - Addons
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=addons
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/addons/$basearch/
> enabled=1
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #additional packages that may be useful
> [extras]
> name=CentOS-5.6 - Extras
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=extras
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/extras/$basearch/
> enabled=1
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-5.6 - Plus
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=centosplus
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/centosplus/$basearch/
> gpgcheck=0
> enabled=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #contrib - packages by Centos Users
> [contrib]
> name=CentOS-5.6 - Contrib
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=contrib
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/contrib/$basearch/
> gpgcheck=0
> enabled=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5me=CentOS-5.6 - Base
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=os
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/os/$basearch/
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #released updates
> [updates]
> name=CentOS-5.6 - Updates
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=updates
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/updates/$basearch/
> enabled=1
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #packages used/produced in the build but not released
> [addons]
> name=CentOS-5.6 - Addons
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=addons
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/addons/$basearch/
> enabled=1
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #additional packages that may be useful
> [extras]
> name=CentOS-5.6 - Extras
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=extras
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/extras/$basearch/
> enabled=1
> gpgcheck=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #additional packages that extend functionality of existing packages
> [centosplus]
> name=CentOS-5.6 - Plus
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=centosplus
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/centosplus/$basearch/
> gpgcheck=0
> enabled=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
> #contrib - packages by Centos Users
> [contrib]
> name=CentOS-5.6 - Contrib
> mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=contrib
> #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/contrib/$basearch/
> gpgcheck=0
> enabled=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


前言

因為某些因素 RHEL 在沒有開通 RHN 的機制時使用 CentOS YUM 來進行套件安裝或更新。警告: 此舉可能導致 RHEL 運作不正常,建議您還是購買 RHEL License 並使用 RHN 更新機制來進行套件的更新。

實作環境

安裝及設定

在設定以前用 yum search drbd 是找不到套件可安裝的,如下所示

 #yum search drbd
  Loaded plugins: rhnplugin, security
  This system is not registered with RHN.
  RHN support will be disabled.
  Warning: No matches found for: drbd
  No Matches found

請切換至 /etc/yum.repos.d 資料夾下建立一個副檔名為 .repo 的檔案,例如 centos.repo 然後將 CentOS 中 CentOS-Base.repo 內容貼進來。

  1. 對 CentOS-Base.repo 內容進行修改
    1. 將 CentOS-Base.repo 中 Mirror Site 指向至國內
    2. 把 gpgcheck 改成 =0 代表不使用下一行的那個 GPG key 來檢查是否為 RHEL5 原廠套件。 (%s,gpgcheck=1,gpgcheck=0,g)
    3. 加上或修改 enabled=1 表示啟用 (%s,enabled=0,enabled=1,g)
    4. 把 $releasever 取代為目前 RHEL 的版本 (%s,$releasever,5.6,g)
  2. 執行 yum clean all
  3. yum search drbd 便可以找到套件了

下列為 centos.repo 的內容

 [base]
 name=CentOS-5.6 - Base
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=os
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/os/$basearch/
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #released updates
 [updates]
 name=CentOS-5.6 - Updates
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=updates
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/updates/$basearch/
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #packages used/produced in the build but not released
 [addons]
 name=CentOS-5.6 - Addons
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=addons
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/addons/$basearch/
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #additional packages that may be useful
 [extras]
 name=CentOS-5.6 - Extras
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=extras
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/extras/$basearch/
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #additional packages that extend functionality of existing packages
 [centosplus]
 name=CentOS-5.6 - Plus
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=centosplus
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/centosplus/$basearch/
 gpgcheck=0
 enabled=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #contrib - packages by Centos Users
 [contrib]
 name=CentOS-5.6 - Contrib
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=contrib
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/contrib/$basearch/
 gpgcheck=0
 enabled=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5me=CentOS-5.6 - Base
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=os
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/os/$basearch/
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #released updates
 [updates]
 name=CentOS-5.6 - Updates
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=updates
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/updates/$basearch/
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #packages used/produced in the build but not released
 [addons]
 name=CentOS-5.6 - Addons
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=addons
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/addons/$basearch/
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #additional packages that may be useful
 [extras]
 name=CentOS-5.6 - Extras
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=extras
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/extras/$basearch/
 enabled=1
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #additional packages that extend functionality of existing packages
 [centosplus]
 name=CentOS-5.6 - Plus
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=centosplus
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/centosplus/$basearch/
 gpgcheck=0
 enabled=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 #contrib - packages by Centos Users
 [contrib]
 name=CentOS-5.6 - Contrib
 mirrorlist=http://mirrorlist.centos.org/?release=5.6&arch=$basearch&repo=contrib
 #baseurl=http://ftp.cse.yzu.edu.tw/pub/CentOS/5.6/contrib/$basearch/
 gpgcheck=0
 enabled=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Go To Oddmuse OrgGo To FreeBSD OrgCreative Commons 2.5 Taiwansitestates.com