RedHat7安装centos7.0的yum

   

Redhat默认自带的yum源需要注册,才能使用,报错: This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.可替换为Centos对应的源,CentOS和redhat 几乎是一样的。

1、首先查看redhat 7.0系统本身所安装的那些yum 软件包:

# rpm -qa | grep yum
yum-utils-1.1.31-24.el7.noarch
yum-langpacks-0.4.2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-rhn-plugin-2.0.1-4.el7.noarch
PackageKit-yum-0.8.9-11.el7.x86_64
yum-3.4.3-118.el7.noarch

2、删除这些软件包:

# rpm -e yum-3.4.3-118.el7.noarch --nodeps
# rpm -e yum-utils-1.1.31-24.el7.noarch --nodeps
# rpm -e yum-rhn-plugin-2.0.1-4.el7.noarch --nodeps
# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
# rpm -e yum-langpacks-0.4.2-3.el7.noarch --nodeps
# rpm -e PackageKit-yum-0.8.9-11.el7.x86_64 --nodeps

3、进入以下网站上面查看软件包的版本是否升级或者找到自己系统所对应的文件包版本更新;
网易163网络源地址:http://mirrors.163.com/
CentOS网络源地址:http://centos.ustc.edu.cn/centos
我使用的版本百度云pan.baidu.com/s/12UvRGfkHxdJ2l4oYUUIpaA 提取码ub2i
找到自己所需要的版本下载可以使用如下命令(请自行更该版本),但是会遇到安装的python-urlgrabber版本不符合您尝试安装的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 -ivh yum-* 
警告:yum-3.4.3-132.el7.centos.0.1.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 20%]
   2:yum-plugin-fastestmirror-1.1.31-3################################# [ 40%]
   3:yum-3.4.3-132.el7.centos.0.1     ################################# [ 60%]
   4:yum-updateonboot-1.1.31-34.el7   ################################# [ 80%]
   5:yum-utils-1.1.31-34.el7          ################################# [100%]

5、新建repo 配置文件

# vim /etc/yum.repos.d/CentOS-Base.repo
[base] 
name=CentOS-$7 - Base - 163.com 
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=7&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=7&arch=7&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=7&arch=7&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

6、清除缓存

# yum clean all 
已加载插件:fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
正在清理软件源: base extras updates
Cleaning up everything

7、重建缓存

# yum makecache
 已加载插件:fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                            | 3.6 kB  00:00:00     
extras                                                          | 3.4 kB  00:00:00     
updates                                                         | 3.4 kB  00:00:00     
(1/12): base/x86_64/group_gz                                    | 166 kB  00:00:00     
(2/12): base/x86_64/filelists_db                                | 7.1 MB  00:00:04     
(3/12): base/x86_64/primary_db                                  | 6.0 MB  00:00:04     
(4/12): extras/x86_64/prestodelta                               |  62 kB  00:00:00     
(5/12): extras/x86_64/primary_db                                | 201 kB  00:00:00     
(6/12): extras/x86_64/filelists_db                              | 243 kB  00:00:00     
(7/12): extras/x86_64/other_db                                  | 126 kB  00:00:00     
(8/12): base/x86_64/other_db                                    | 2.6 MB  00:00:02     
(9/12): updates/x86_64/prestodelta                              | 681 kB  00:00:01     
(10/12): updates/x86_64/filelists_db                            | 3.7 MB  00:00:04     
(11/12): updates/x86_64/other_db                                | 588 kB  00:00:00     
(12/12): updates/x86_64/primary_db                              | 5.0 MB  00:00:04     
Determining fastest mirrors
元数据缓存已建立

8、更新系统:

# yum update

好的切换完成了,你可以快乐的使用新的yum了!

发表评论