Redhat7更换centos7的yum源方法步骤

Redhat7如果不是注册用户,则无法使用yum

解决办法:更换为centos7的yum源

1.查看系统自身安装的yum软件包

  [root@localhost ~]#  rpm -qa | grep yum

2.卸载所有自带yum软件包

使用命令:rpm -e 软件包名称 --nodeps

3.ping一下,确定能上网

[root@localhost ~]# ping www.baidu.com

4.网易163网络源地址:http://mirrors.163.com/
找到自己所需的版本下载。
centos7的yum源码地址:http://mirrors.163.com/centos/7/os/x86_64/Packages/

5.使用wget命令下载这些yum源码
使用命令:wget 源码地址
(如果发现系统没有wget命令,请移步:https://blog.csdn.net/weixin_43837883/article/details/89169255)

5.ls查看下载好的软件包
在这里插入图片描述
6.安装软件包

 [root@localhost ~]# rpm -ivh yum-*

7.新建.repo配置文件
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Base.repo

下面是该文件内容:

#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-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$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=$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=$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

8.清除缓存

 [root@localhost ~]# yum clean all

并将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度

[root@localhost ~]# yum makecache

9.开始使用yum在线安装软件吧!

(注意:Redhat的注册提示信息仍会出现,但可以正常使用yum功能)

发布了35 篇原创文章 · 获赞 43 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/weixin_43837883/article/details/89179533