RHEL 7配置CentOS yum源
因Redhat 的更新包只對註冊的用戶生效,so 我們需要將其變更一下才能使用
以下操作本人已實機操作成功。
操作步驟:
1.首先查看redhat 7.0系統本身所安裝的哪些yum 軟件包:
rpm -qa | grep yum #列出所有已安裝的yum包
2.刪除這些包:
rpm -e *.rpm --nodeps #刪除所有以前的yum包
組合命令:rpm -qa | grep yum |xargs rpm -e --nodeps
命令執行結束後再次執行:rpm -qa | grep yum
沒有結果即為刪除成功
3.下載新的yum rpm包:(以下為2017-09-07最新版本rpm,如果404 NOT FOUND錯誤,自己進去網址,換成最新的rpm包的名字)
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.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 http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-40.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-40.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
4.安裝下載的rpm包:
rpm -ivh yum-*
5.配置CentOS-Base.repo:(2017-09-07 最新源網址配置)
vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-7-Base
baseurl=http://mirrors.sohu.com/centos/7/os/x86_64/
gpgcheck=1
#released updates
name=CentOS-7- Updates
baseurl=http://mirrors.163.com/centos/7/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#packages used/produced in the build but not released
[addons]
name=CentOS-7- Addons
baseurl=http://mirrors.163.com/centos/7/sclo/x86_64/sclo/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7- Extras
baseurl=http://mirrors.163.com/centos/7/extras/x86_64/
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
baseurl=http://mirrors.163.com/centos/7/centosplus/x86_64/
gpgcheck=1
enabled=0
註意一定要頂頭編輯
如下圖所示
保存退出。
6.yum源配置完成:
yum clean all
7.測試yum是否成功:
yum update python
報錯:You have enabled checking of packages via GPG keys. This is a good thing. However, you do not have any GPG public keys installed. You need to download the keys for packages you wish to install and install them. You can do that by running the command.
rpm --import public.gpg.key
.........
經查,是key的錯誤,解決方法是:
cd /etc/pki/rpm-gpg/
ls #列出所有密鑰
導入以 release 結尾的密鑰
rpm --import RPM-GPG-KEY-redhat-legacy-release
8.經測試,yum成功:
yum update python #順利使用yum
本文出自 “學習之路” 博客,請務必保留此出處http://rhelanker.blog.51cto.com/12834161/1963343
RHEL 7配置CentOS yum源