redhat linux7 yum源的配置以及gcc的安装

redhat linux7 yum源的配置以及gcc的安装

1.安装前卸载系统的yum。

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

2.注意:请先切换到root权限,不然会有如下报错(用sudo也不行!)。

错误:can’t create 事务 lock on /var/lib/rpm/.rpm.lock (权限不够) xargs:
rpm:以状态 255 退出;中止

用一下命令查看是否清除 rpm -qa |grep yum
在这里插入图片描述

3.使用网易的镜像网站:http://mirrors.163.com/ ,访问http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/
找到以下需要下载的文件:

python-iniparse-0.4-9.el7.noarch.rpm
python-urlgrabber-3.10-9.el7.noarch.rpm
yum-3.4.3-163.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
rpm-4.11.3-40.el7.x86_64.rpm

使用Xftp将上述文件传输至虚拟机:
在这里插入图片描述

4.先安装新版rpm,注意,直接使用命令rpm -ivh无法成功安装,因为老版本的rpm与许多其他程序有着依赖,会导致无法安装新版本。这里使用 rpm -Uvh rpm-4.11.3-40.el7.x86_64.rpm --nodeps 进行升级安装。
在这里插入图片描述
同理,下载的两个python文件的也这样进行升级安装。
在这里插入图片描述
再来尝试安装那三个yum相关文件(由于yum原来的版本被卸载了,所以可以直接rpm -ivh)。
在这里插入图片描述
(注意,yum-3.4.3-161.el7.centos.noarch.rpm 和yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm相互依赖,一定要同时安装)。

输入yum看有没反应,正常反应如下图:
在这里插入图片描述
5.这时,回头再依次 rpm -ivh yum相关的文件:

rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm

在这里插入图片描述
6.新建配置.repo文件。
输入 vim /etc/yum.repos.d/CentOS-Base.repo 进入Vi编辑模式,复制下列代码内容进去:

#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

一定要复制完整,之后按esc进入命令模式,输入:wq!保存并退出,之后 yum clean all 清除缓存,就可以使用yum了。
在这里插入图片描述
7.安装gcc

yum install gcc

在这里插入图片描述
选择yes直到安装完毕。
在这里插入图片描述
使用yum安装的好处,就是可以将你所需要的工具和工具依赖的文件都一并下载或者更新,如下所示:
在这里插入图片描述
8.测试一下

gcc -v

在这里插入图片描述
安装成功!

参考链接:https://www.cnblogs.com/slothph/p/11519191.html

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值