Redhat7安装yum源

前言:想要在服务器Redhat7 安装gcc   使用yum   install gcc  报错:

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

原因是Redhat的yum需要注册。这里想办法安装了CentOS的yum源

一、卸载原来的yum

#查看原来是否安装
rpm -qa |grep yum    

#卸载本机yum
rpm -qa|grep yum|xargs rpm -e --nodeps 

# 查看yum是否卸载干净
rpm -qa |grep yum

二、下载yum替换包

这里要说明一下,因为要替换,所以一定要是一整套,还有一个rhel-debuginfo.repo文件要配置。

我这里准备了yum包,已上传到csdn资源。在公司Redhat服务器已经安装成功。下载路径:https://download.csdn.net/download/kzdwts/10586712

可以先建一个文件夹,然后把5个安装包拷贝到 yum 这个文件下面

执行:

rpm -ivh *.rpm

 一次性执行依赖包,因为包之间会相互依赖。

第三步:新建配置 .repo文件

vim /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

第四步:执行命令

yum clear all

yum list

好了,到这里就可用了。附上我在公司Redhat安装执行的命令

Redhat7安装yum源_第1张图片

你可能感兴趣的:(VMware,服务部署,Linux)