2021-05-12 14:32:11
Red Hat Enterprise Linux 7.3更換CentOS 7 yum源
RedHat yum源是收費的,沒有註冊的Redhat機器是不能使用yum源的。
1、當前系統環境:
系統版本:Red Hat Enterprise Linux Server release 7.3 (Maipo)
軟體環境:系統預設是自帶了yum程式的,需要解除安裝,安裝CentOS的
2、更換yum源:
1) 解除安裝本地yum:
# rpm -qa|grep yum #檢視本地yum
# rpm -qa|grep yum|xargs rpm -e --nodeps #解除安裝本地yum,不檢查依賴性,解除安裝yum程式
# rpm -qa | grep Python-urlgrabber | xargs rpm -e --nodeps
2) 下載CentOS yum程式
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
使用wget命令下載,也可以用瀏覽器下載。rpm包下載地址http://mirrors.163.com/centos/7/os/x86_64/Packages/ ,包的版本會有更新,選擇最新版本下載
安裝CentOS yum程式
為避免他們之間互相依賴,三個程式一起安裝
# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
安裝報錯,依賴軟體版本不相容,
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 頭V3 RSA/SHA256 Signature, 金鑰 ID f4a80eb5: NOKEY
錯誤:依賴檢測失敗:
python-urlgrabber >= 3.10-8 被 yum-3.4.3-161.el7.centos.noarch 需要
rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
重新下載新版本的依賴軟體,安裝更新
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-libs-4.11.3-35.el7.x86_64.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-35.el7.x86_64.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-35.el7.x86_64.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-sign-4.11.3-35.el7.x86_64.rpm
# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-build-4.11.3-35.el7.x86_64.rpm
更新依賴軟體:
# rpm –ivh python-*
# rpm -ivh libxml*
# rpm –Uvh rpm*
再次安裝yum程式
# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
安裝報錯:
錯誤:依賴檢測失敗:
python-urlgrabber >= 3.10-8 被 yum-3.4.3-161.el7.centos.noarch 需要
Python-urlgrabber版本不相容,下載對應的版本。
# wget ftp://ftp.icm.edu.pl/vol/rzm3/linux-centos-altarch/7.5.1804/os/armhfp/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
安裝:
# rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm
再次安裝yum程式
# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
安裝成功。
3) repo 組態檔
下載組態檔
# cd /etc/yum.repos.d/ #進入到yum組態檔目錄
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo #下載組態檔
設定組態檔
# sed -i "s;$releasever;7;g" CentOS7-Base-163.repo
替換新的repo檔案
# mv redhat.repo redhat.repo.bak
組態檔內容如下:
[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
更新yum快取
# yum clean all #清除yum快取
# yum makecache #更新yum快取
執行yumrepolist檢視,如果顯示出repo倉庫列表,並顯示軟體包數量則OK。
# yum repolist
至此yum源更換完成。
相關文章