RHEL7更换yum源

1,删除注册和订阅提示

查找subscription-manager相关组件:

 rpm -qa | grep subscription-manager 

RHEL7更换yum源_第1张图片

删除subscription-maanager相关组件:

 sudo yum remove subscription-manager 

RHEL7更换yum源_第2张图片

查找rhn相关组件

 rpm -qa | grep rhn 

RHEL7更换yum源_第3张图片

删除rhn相关组件:

 sudo yum remove rhn-check 

 RHEL7更换yum源_第4张图片

2,yum 安装

 查询当前RHEL7.0的yum安装包:

 rpm -qa |grep yum 

RHEL7更换yum源_第5张图片

强制删除当前yum:

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

再次查询yum是否删除:

 rpm -qa |grep yum 

RHEL7更换yum源_第6张图片

3.解决wget无法解析DNS问题

解决方法:

a.进入/etc/resolv.conf

b.修改或增加内容:

    nameserver 8.8.8.8

4.下载所需的安装包

http://mirrors.163.com/centos/7/os/x86_64/Packages/

ctrl + f搜索需要的 安装包

yum-plugin-fastestmirror 

yum-updateonboot 

yum-utils 

yum-metadata-parser 

yum-3.4.3-163.el7.centos.noarch.rpm

 

5.安装

1 rpm -ivh  yum-*
2 #报错,依赖包版本不符:
3     python-urlgrabber >= 3.10-8 被 yum-3.4.3-163.el7.centos.noarch 需要
4     rpm >= 0:4.11.3-22 被 yum-3.4.3-163.el7.centos.noarch 需要

RHEL7更换yum源_第7张图片

解决方法:升级

1 wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
2 wget  http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
3 #如果下载不了,链接过期了,自己去网易官网搜索,下载到本地,安装
4 #安装
5 rpm -Uvh yum-3.4.3-163.el7.centos.noarch.rpm  --nodeps
6 rpm -Uvh python-urlgrabber-3.10-9.el7.noarch.rpm

 

RHEL7更换yum源_第8张图片

RHEL7更换yum源_第9张图片

 

重新安装其他安装包

 rpm -ivh yum-* 

 

RHEL7更换yum源_第10张图片

6.更新yum源

 1 rm /etc/yum.repos.d/redhat.repo
 2 vim /etc/yum.repos.d/CentOS-Base.repo
 3 # 内容:
 4 
 5 [base]
 6 name=CentOS-$7 - Base - 163.com
 7 #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
 8 baseurl=http://mirrors.163.com/centos/7/os/$basearch/
 9 gpgcheck=1
10 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
11 #released updates
12 [updates]
13 name=CentOS-$7 - Updates - 163.com
14 #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
15 baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
16 gpgcheck=1
17 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
18 #additional packages that may be useful
19 [extras]
20 name=CentOS-$7 - Extras - 163.com
21 #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
22 baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
23 gpgcheck=1
24 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
25 #additional packages that extend functionality of existing packages
26 [centosplus]
27 name=CentOS-$7 - Plus - 163.com
28 baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
29 gpgcheck=1
30 enabled=0
31 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

清空yum缓存

 yum clean all 

生成缓存

 yum makecache 

更新成功

 1 yum install tree

 2 tree 

RHEL7更换yum源_第11张图片

 

 

 

 

 

 

你可能感兴趣的:(RHEL7更换yum源)