今天在我做实验时要用到gcc,发现用不了然后我用yum去安装,但是报了如下错误:
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
后来才知道,如果使用redhat的yum源是需要注册付费的。因此咱们就要更改yum源来使它免费,咱们来使用163的源。
大致思路如下:
1、删除red hat自带的yum包
2、下载新的centos的yum包(因为centos就是基于red hat写的,所以他们本质上一样的)
3、更换yum源
1、删除red hat自带的yum包
rpm -qa | grep yum #查找yum包
rpm -qa|grep yum|xargs rpm -e --nodeps #删除yum包
rpm -qa |grep yum #再查看发现无输出,即代表yum包删除干净
如图:
2、下载新的centos的yum包
进入http://mirrors.163.com/centos/7/os/x86_64/Packages/
找到如下四个包进行安装:
yum-3.4.3-168.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
python-urlgrabber-3.10-10.el7.noarch.rpm
然后对这些包进行安装
首先安装yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
命令如下:
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
然后安装python-urlgrabber-3.10-10.el7.noarch.rpm
命令如下:
rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm
最后安装yum-3.4.3-168.el7.centos.noarch.rpm和yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm(两个有依赖关系,所以要一起安装)
命令如下:
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm --force --nodeps yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm #千万不能错,不然会失败
3、更换yum源
(1)进入到系统yum源的目录下:
cd /etc/yum.repos.d
进入:http://mirrors.163.com/.help/centos.html里面有下载对应版本repo文件
然后按照网站给的步骤进行备份,并下载对应版本的repo文件,将下载好的repo文件放入/etc/yum.repos.d
修改刚下载的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=KaTeX parse error: Expected 'EOF', got '&' at position 11: releasever&̲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=KaTeX parse error: Expected 'EOF', got '&' at position 11: releasever&̲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=KaTeX parse error: Expected 'EOF', got '&' at position 11: releasever&̲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
运行makecache 生成缓存:
yum makecache
11、运行yum clean all
yum clean all
12、更新yum文件
yum update
13、是否安装成功
yum install dhcp -y
提示安装,即成功!!!