鱼C论坛

 找回密码
 立即注册
查看: 193|回复: 10

GCC编译器安装报错

[复制链接]
发表于 2024-7-19 20:04:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
error was
14: curl#6 - "'Could not resolve host: mirrorlist.centos.org: Unknown error"
t use it by default. Yum
permanently enable it
One of the conf igured repositories failed (Unknow)
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. Reconf igure the baseurl/etc. for the repository, 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 will then just ignore the repository until you again or use --enablerepo for temporary usage:
yum-conf ig-manager --disable <repoid>
subscription-manager repos --disable=<repoid>
5. Conf igure 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-conf ig-manager --save --setopt=<repoid>.skip_if _unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-7-19 20:06:49 | 显示全部楼层
嘿,鱼油,别急,GCC编译器安装报错是很常见的。你这个错误主要是由于无法解析主机名,导致无法找到CentOS的软件源。我们一起来解决它。

### 1. 检查网络连接
首先确保你的网络连接是正常的。可以试试用`ping`命令测试下连接情况:
ping www.google.com
ping mirrorlist.centos.org
如果无法ping通,说明可能是网络问题,先解决网络连接。

### 2. 修改`/etc/resolv.conf`
如果是DNS解析问题,可以尝试修改DNS服务器配置。编辑`/etc/resolv.conf`文件,添加Google的公共DNS:
nameserver 8.8.8.8
nameserver 8.8.4.4
保存退出,再试试`yum`命令。

### 3. 手动配置镜像源
有时候,默认的镜像源会有问题,可以手动修改为其他镜像源。打开`/etc/yum.repos.d/CentOS-Base.repo`文件,找到`baseurl`行,把它修改为国内的镜像源,比如阿里云:
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
可以根据需要修改其他仓库的配置。

### 4. 临时禁用问题源
如果问题仓库不是必须的,可以临时禁用它们,继续其他操作:
yum --disablerepo=epel install gcc

### 5. 更新缓存
如果修改了镜像源或网络配置,最好更新一下`yum`的缓存:
yum clean all
yum makecache

这样基本上就可以解决你的问题了。如果还是不行,记得联系我,我继续帮你想办法!祝你编程愉快,顺利安装GCC!

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-7-20 11:00:56 | 显示全部楼层
请问2. 修改`/etc/resolv.conf`
如果是DNS解析问题,可以尝试修改DNS服务器配置。编辑`/etc/resolv.conf`文件,添加Google的公共DNS:
这一步的文件要怎么找到?
打开`/etc/yum.repos.d/CentOS-Base.repo`文件
这个文件又怎么找?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-7-20 11:02:06 | 显示全部楼层
TONY萌新 发表于 2024-07-20 11:00
请问2. 修改`/etc/resolv.conf`
如果是DNS解析问题, ...


哈哈,鱼油,问得好!知道文件要怎么找到,这是个非常关键的问题。别担心,我们一步步来,我会带你找到这些文件。

### 第一步:打开终端
先启动你的终端(Terminal),这是一切操作的开始。

### 第二步:检查并编辑`/etc/resolv.conf`
1. **检查文件路径**
   在终端里输入以下命令:
ls /etc/resolv.conf
   如果看到这个文件名,说明它存在。

2. **使用文本编辑器打开文件**
   你可以选择自己喜欢的文本编辑器,比如`vi`, `nano`或者`gedit`。这里我们以`vi`为例:
sudo vi /etc/resolv.conf
   编辑器打开后,按下`i`进入插入模式,然后添加Google的公共DNS:
nameserver 8.8.8.8
   nameserver 8.8.4.4
   然后按`Esc`键,再输入`:wq`保存并退出。

### 第三步:找到并编辑`/etc/yum.repos.d/CentOS-Base.repo`
1. **检查文件路径**
   在终端里输入以下命令:
ls /etc/yum.repos.d/CentOS-Base.repo
   如果看到这个文件名,说明它存在。

2. **使用文本编辑器打开文件**
   同样,这里我们以`vi`为例:
sudo vi /etc/yum.repos.d/CentOS-Base.repo
   编辑器打开后,找到类似如下内容:
[base]
   name=CentOS-$releasever - Base
   baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
   gpgcheck=1
   gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

3. **修改`baseurl`为国内的镜像源**
   把`baseurl`改成阿里云的镜像源,例如:
[base]
   name=CentOS-$releasever - Base
   baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
   gpgcheck=1
   gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
   修改完后,按`Esc`键,再输入`:wq`保存并退出。

搞定了这些,你再试试运行`yum`命令,应该能解决问题啦!祝你编程顺利,如果还有其他问题,继续找我~

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-7-20 11:22:39 | 显示全部楼层
我照做了这些步骤,但是报错
[root@localhost "J# yum -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostf ile
One of the conf igured repositories failed (Unknown).
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.
Reconf igure the baseurl/etc. for the repository, 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> ..
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-conf ig-manager --disable <repoid>
subscription-manager repos --disable=<repoid>
Conf igure 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-conf ig-manager --save --setopt=<repoid>.skip_if _unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-7-20 11:24:52 | 显示全部楼层
TONY萌新 发表于 2024-07-20 11:22
我照做了这些步骤,但是报错
[root@localhost "J# yu ...


哎呀,看样子问题还没解决呢,别担心,我们一起继续诊断和解决这个问题吧!

### 第一步:确认镜像源配置
确保你已经正确配置了镜像源。我们再三检查一遍。

在终端里运行:
cat /etc/yum.repos.d/CentOS-Base.repo
看一下输出内容是否包含类似如下配置:
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1
重要的是`baseurl`行和`enabled=1`行要确保存在且正确。

### 第二步:更新软件包缓存
确保你已经清除了之前的缓存并重新生成一遍新的缓存。
yum clean all
yum makecache

### 第三步:检查网络连接和DNS配置
确保你能访问阿里云镜像源:
ping mirrors.aliyun.com
如果能ping通,说明网络连接没问题。如果不能ping通,可能DNS配置有问题或者网络连接有问题。

再次确认你的DNS配置正确:
cat /etc/resolv.conf
确保里面有Google的公共DNS:
nameserver 8.8.8.8
nameserver 8.8.4.4

### 第四步:临时禁用有问题的仓库
尝试禁用某些有问题的仓库,看是否能够继续安装其他包:
yum --disablerepo=epel install gcc

### 第五步:检查CentOS版本
避免版本不匹配的问题,确认你的CentOS版本:
cat /etc/centos-release
比如如果是CentOS 7,`$releasever`应该替换成7。

### 第六步:使用不同的镜像源
如果阿里云也有问题,可以尝试其他的镜像源,比如清华大学的:
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1

### 第七步:最后的终极大招
如果实在搞不定,你可以尝试手动下载需要的RPM包然后本地安装,不过这只是暂时的解决方案。

希望这些步骤能够帮你解决问题!如果还有不明白的地方,随时来找我哦~ 我们一起攻克难题!

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-7-20 12:50:15 | 显示全部楼层
请问为什么编辑后按了esc,但是无法输入“:wq"
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-7-20 12:50:23 | 显示全部楼层
TONY萌新 发表于 2024-07-20 12:50
请问为什么编辑后按了esc,但是无法输入“:wq"


哈哈,鱼油,看来光有理论还是不够的,实战中总有些小问题会让人抓狂。我们来详细过一遍使用`vi`编辑器的步骤,让你变得更强大!

### 使用`vi`编辑器的详细步骤

1. **打开文件**
   在终端里输入以下命令,使用`vi`编辑器打开文件:
sudo vi /etc/resolv.conf
   或者:
sudo vi /etc/yum.repos.d/CentOS-Base.repo

2. **进入插入模式**
   在文件打开后,你会看到文件的内容。如果想要编辑其中的内容,需要进入插入模式,先按下 `i` 键。

3. **编辑文件**
   现在你可以添加或修改文件内容了,比如添加DNS服务器:
nameserver 8.8.8.8
   nameserver 8.8.4.4
   或者修改镜像源:
name=CentOS-$releasever - Base
   baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
   gpgcheck=1
   gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
   enabled=1

4. **退出插入模式**
   编辑完毕后,按 `Esc` 键退出插入模式。这时,你的光标应该已经处于普通模式。

5. **保存并退出**
   在普通模式下,输入 `:wq` 保存并退出。如果你发现你无法输入 `:wq`,可能是因为你还没有完全退出插入模式或者键盘输入有误。

   确保按下 `Esc` 键,然后输入 `:wq`(注意前面有冒号):
:wq
   **注意:** 在按下 `Esc` 键之后,输入 `:` 时应该在屏幕下方出现一个冒号提示符,这时再继续输入 `wq` 并按 `Enter` 键。

### 遇到问题时的调试技巧

如果仍然遇到问题,可以尝试以下技巧:

- **检查键盘输入**:确保键盘输入正常,没有卡键或者其他按键冲突。
- **使用其他编辑器**:如果`vi`总是搞不定,可以尝试其他文本编辑器,如`nano`:
sudo nano /etc/resolv.conf
  sudo nano /etc/yum.repos.d/CentOS-Base.repo
  `nano`编辑器更为简单直观,结束编辑后,按 `Ctrl + O` 保存,并按 `Ctrl + X` 退出。

希望这次能够顺利解决你的问题!如果还有疑惑,继续找我,我们一起搞定它!

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-7-20 14:01:55 | 显示全部楼层
还报错
[root@localhost ~]# yum -y Loaded plugins: fastestmirror Determining fastest mirrors
One of the conf igured repositories failed (Unknown).
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.Reconf igure the baseurl/etc. for the repository, 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-conf ig-manager --disable <repoid>
subscription-manager repos --disable=<repoid>
Conf igure 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-conf ig-manager --save --setopt=<repoid>.skip_if _unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-7-20 14:02:06 | 显示全部楼层
TONY萌新 发表于 2024-07-20 14:01
还报错# yum -y Loaded plugins: fastestmirror Deter ...


哎呀,看起来问题还是出现了。别急,我们继续深入解决这个问题。有可能还是DNS配置、网络连接或者源的问题。

## 步骤一:确认网络状态
首先确认一下你的网络连接是否正常。你可以通过以下命令检查:
ping -c 4 google.com

如果 `ping` 不通,说明可能有网络连接问题,需要先解决网络连接问题。

## 步骤二:检查DNS配置

如果网络正常,我们再来确认一下 DNS 配置。编辑 `/etc/resolv.conf` 文件,添加 Google 的公共 DNS:

### 打开并编辑 `/etc/resolv.conf`
vi /etc/resolv.conf

按 `i` 进入插入模式,添加以下内容:
nameserver 8.8.8.8
nameserver 8.8.4.4

然后按 `Esc` 键退出插入模式,输入 `:wq` 保存并退出。

## 步骤三:替换 YUM 源

如果 DNS 设置正确,但依旧无法连接到镜像源,我们可以尝试更换 YUM 源。

### 打开并编辑 YUM 源配置文件
vi /etc/yum.repos.d/CentOS-Base.repo

### 替换为阿里云的 YUM 源

找到类似于 `baseurl` 和 `mirrorlist` 的行,把它们注释掉(在行首加一个 `#` 号),然后在文件相应部分添加阿里云的 YUM 源:
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

### 再次尝试更新和安装

保存并退出编辑器,然后运行以下命令清理 YUM 缓存并进行更新:
yum clean all
yum makecache
yum update

如果以上步骤还是没有解决问题,请分享更多详细信息,特别是你系统的具体版本和网络连接情况,我们继续分析和解决。

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-7-28 19:50:42 | 显示全部楼层
你的是centos几啊,如果是centos7的话,官方在6.30停止维护了,镜像源可能无法使用了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-21 11:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表