RedHat7更换yum源

2019-10-28  本文已影响0人  粥粥zz
Centos7系统用yum安装gcc遇到的问题(报错如下),这是因为yum源的问题,所以我们可以替换下yum源。 image.png

1.检查是否安装yum软件包

rpm -qa|grep yum

2.卸载这些软件包

rpm -qa|grep yum|xargs rpm -e --nodeps
rpm -e  <软件包>  --nodeps

3.进入centos镜像网站找到自己对应系统需要的yum包

(1)查看系统的命令

 cat /etc/redhat-release
如图: image.png

(2)查看系统的位数:

file /bin/ls
如图: image.png

(3)CentOS网络源找到与自己系统对应的yum依赖包

wget http://vault.centos.org/7.6.1810/os/x86_64/Packages/PackageKit-yum-1.1.10-1.el7.centos.x86_64.rpm
wget http://vault.centos.org/7.6.1810/os/x86_64/Packages/PackageKit-yum-plugin-1.1.10-1.el7.centos.x86_64.rpm

4.安装yum依赖包

rpm -ivh yum-*

5.更新centos系统的repo文件

vi /etc/yum.repos.d/CentOS-Base.repo

在yum.repos.d/路径下新建配置文件

# 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=$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=$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=$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

6.运行yum makecache命令生成缓存。

yum clean all
yum makecache
yum update

经过上述六个步骤,新的yum源已经安装完成了

7.用yum install gcc 成功了安装gcc

注意替换了yum源会影响内核

上一篇 下一篇

猜你喜欢

热点阅读