Red Hat Enterprise Linux yum update or CentOS yum update by ISO

2014/06/19 補充 CentOS 如何不裝 NTFS-3G 就掛載超過 4GB 的 ISO 檔

Red Hat | Red Hat Enterprise Linux: www.redhat.com/products/enterprise-linux/
Red Hat Enterprise Linux是Red Hat公司的Linux發行版,面向商業市場,包括大型電腦。紅帽公司從Red Hat Enterprise Linux 5開始對企業版LINUX的每個版本提供10年的支援[1]。而Red Hat Enterprise Linux常簡作RHEL。

CentOS | Community Enterprise Operating System: http://centos.org
CentOS(Community Enterprise Operating System)是Linux發行版之一,它是來自於Red Hat Enterprise Linux依照開放原始碼規定釋出的原始碼所編譯而成。由於出自同樣的原始碼,因此有些要求高度穩定性的伺服器以CentOS替代商業版的Red Hat Enterprise Linux使用。兩者的不同,在於CentOS並不包含封閉原始碼軟體。CentOS 對上游代碼的主要修改是為了移除不能自由使用的商標。
如果還很有興趣可以研究一下這邊:http://zh.wikipedia.org/zh-hant/CentOS 跟 http://zh.wikipedia.org/wiki/Red_Hat_Enterprise_Linux

基本上白話一點來講的話,就是 RHEL 想用是要錢的,而 CentOS 當然就不用;只有偶爾會有某些公司行號或商業軟體需要使用 RHEL ... 所以這次碰上的問題是有軟體非得要安裝於 RHEL 上的問題 ....

當然網路上有說只要修改 /etc/redhat-relese 裡的內容為下方幾種,通常可以順利偽裝 ...
Red Hat Enterprise Linux Server release 5 (Tikanga)
Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
(RHEL6 的我忘了 ! xDDDD)

好 ! 回過來說說在 Linux裡 yum 這工具,主要是在 RedHat 及其衍生版本(RHEL, CentOS, Fedora)安裝套件使用, 通常透過 yum 會自動在網路 mirror 上自動下載更新套件 rpm, 同時會判斷相依套件比起自己下載原始檔一個一個編譯可說是非常方便!

而這個就是這篇主要記載的過程了 ....


上圖就是如果您是安裝 RHEL,當你要用 yum 時就會發生沒東西可以更新的狀況,所以得先 刪除redhat原有的yum,並下載新的 (請注意版本號)

# rpm -qa | grep yum | xargs rpm -e --nodeps
# rpm -qa | grep yum

#  wget http://vault.centos.org/6.2/os/x86_64/Packages/yum-3.2.29-22.el6.centos.noarch.rpm
# wget ftp.centos.org/6.5/updates/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-17.el6_5.noarch.rpm
# wget ftp://ftp.muug.mb.ca/mirror/centos/6.5/updates/i386/Packages/yum-plugin-fastestmirror-1.1.30-17.el6_5.noarch.rpm
# wget http://vault.centos.org/6.2/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

# rpm -ivh yum-*
接著請移除舊有的 RHEL 的設定

# mv rhel-source.repo rhel-source.repo.bakup
# mv redhat.repo redhat.repo.bakup


新增 CentOS-Base.repo 於  /etc/yum.repos.d/ 並修改成像上面那樣 (注意因為是舊版所以我是使用 vault.centos.org 上的 更新源 )

把 gpgcheck 改成 =0 代表不使用
GPG key 檢查是否為 RHEL5 原廠套件。 (%s,gpgcheck=1,gpgcheck=0)
加上或修改 enabled=1 表示啟用 (%s,enabled=0,enabled=1)
把 $releasever 取代為目前 RHEL 的版本 (%s,$releasever,5.6)

執行 yum clean all,便可以使用了

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
#baseurl=http://ftp.isu.edu.tw/pub/Linux/CentOS/6.5/os/$basearch/
baseurl=http://vault.centos.org/6.2/os/x86_64/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
#baseurl=http://ftp.isu.edu.tw/pub/Linux/CentOS/6/updates/$basearch/
baseurl=http://vault.centos.org/6.2/updates/x86_64/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
#baseurl=http://ftp.isu.edu.tw/pub/Linux/CentOS/6/extras/$basearch/
baseurl=http://vault.centos.org/6.2/extras/x86_64/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
#baseurl=http://ftp.isu.edu.tw/pub/Linux/CentOS/6/centosplus/$basearch/
baseurl=http://vault.centos.org/6.2/centosplus/x86_64/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
#baseurl=http://ftp.isu.edu.tw/pub/Linux/CentOS/6/contrib/$basearch/
baseurl=http://vault.centos.org/6.2/contrib/x86_64/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


主要就是每一個的 baseurl 要修改為 http://vault.centos.org/xx/xx/x86_64/ 以及修改 gpgcheck = 0 這樣才可以 !

然而在某些環境可能無法透過網路連外(如公司內部或隔離環境), 若要自行下載所有套件上傳到CentOS上安裝,光下載所有相依套件就煩死人了。 其實大多數的套件 rpm 都已包含在 CentOS release 的光碟中,所以只要將 yum 安裝源指向光碟 (或是 ISO), 就能透過 yum 指令自動找到所需套件!

PS: 找不到較舊版本的 CentOS 光碟?其實 CentOS 官方有一個網站, 專門放舊版本 ISO 和 套件:http://vault.centos.org ....  只是有幾個版本是只放 CD 版 ... 這時可以自己用 cURL 下載合成 !

# curl -O http://vault.centos.org/XXX/isos/x86_64/CentOS-XXX-x86_64-bin-[1-8]of8.iso

然後官網這邊有教怎樣從 CD 轉成 DVD:http://wiki.centos.org/TipsAndTricks/CDtoDVDMedia

最後呢 .... 稍微修改一下這個檔案內容就可以囉 !

# cat /etc/yum.repos.d/CentOS-Media.repo
[C6-Media]
name=6.5
baseurl=file:///mnt/
mediaid=1385726732.061157
metadata_expire=-1
gpgcheck=0
cost=500
enabled=1

至於指令怎樣用勒 ? 放心 ... 裡面都有寫

# To use this repo, put in your DVD and use it with the other repos too: 
# yum --enablerepo=c6-media [command] 
# # or for ONLY the media repo, do this: 
# # yum --disablerepo=\* --enablerepo=c6-media [command]


原本天真的以為這樣就搞定了 ... 但天不從人願 ... 有時候就是會碰上沒光碟沒網路 ...
很不巧的今天就碰到了 .... 忘了帶光碟片,同時現場是不能上網 ... 好險我有帶 ISO 檔

但是 ~ 隨身碟是 FAT32 所以檔案超過 4 GB 會放不進去 .... 還好可以格式化成 NTFS ....

但是 .... 剛用 Basic Server 裝好的 CentOS6.5 x64 是沒裝 NTFS-3G 的 ~ 而且沒裝 gcc 就算你又 NTFS-3G 的 tar 檔也不能裝 !!!! Orz

於是我試著把 CentOS-6.5-x86_64.ISO 用 rar 壓縮分割成 CentOS.zip、CentOS.z01、CentOS.z02 等 3 個檔 ... 然後再放到 FAT32 的USB 插到 CentOS 上,這時就能夠抓到 ... 然後把檔案存到 CentOS 上了

接著得要用下面這樣才可以正常解壓縮 ....

# cat CentOS.z.* > CentOS_all.zip
# unzip CentOS_all.zip
嗯 ~ 搞定打完收工 !!!!

Reference:

linux下解压被分割的zip文件
http://www.niwozhi.net/demo_c86_i28684.html

yum使用CentOS光碟離線安裝套件
http://www.ewdna.com/2014/03/yum-install-via-dvdrom-repository.html