Centos7安装gcc编辑器报Could not retrieve mirrorlist http:....... Could not resolve host:.....错
程序员文章站
2022-07-03 18:12:45
...
错误详情:
在Linux系统终端中输入gcc安装命令:yum -y install gcc gcc-c++ kernel-devel报错
示例:
[aaa@qq.com fei]# yum -y install gcc gcc-c++ kernel-devel
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7& arch=x86_64& repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the rep`在这里插入代码片`ository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
原因:
出现这种情况一般是因为你所在的Centos 7没有联网。
解决方法:
1.在终端输入命令 "nmcli d"查看网卡详情
示例:
[aaa@qq.com fei]# nmcli d
DEVICE TYPE STATE CONNECTION
virbr0 bridge 已连接 virbr0
ens33 ethernet 已断开 --
lo loopback 未托管 --
virbr0-nic tun 未托管 --
会看到第四行是"ens33 ethernet 已断开 – "
2.输入命令"cd /etc/sysconfig/network-scripts/"进入network-scripts
[aaa@qq.com 你的计算机名]# 会变成 [aaa@qq.com network-scripts]#
之后输入命令:“vim ifcfg-ens33”
示例:
[aaa@qq.com network-scripts]# vim ifcfg-ens33
进入以下界面
把最后一行的"ONBOOT=no"改成"ONBOOT=yes",保存退出
再依此输入一下命令:
“systemctl restart network”(重启网络)
“yum -y install gcc gcc-c++ kernel-devel”(安装gcc)
示例:
[aaa@qq.com network-scripts]# vim ifcfg-ens33
[aaa@qq.com network-scripts]# systemctl restart network
[aaa@qq.com network-scripts]# yum -y install gcc gcc-c++ kernel- devel
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.ustc.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/7/x86_64/primary_db | 194 kB 00:00:00
(3/4): base/7/x86_64/primary_db | 6.1 MB 00:00:06
(4/4): updates/7/x86_64/primary_db | 2.1 MB 00:00:07
正在解决依赖关系
--> 正在检查事务
---> 软件包 gcc.x86_64.0.4.8.5-39.el7 将被 安装
(内容太多,省略)
安装完成
上一篇: brew info python
下一篇: Mac安装Homebrew 及 pip