CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org;"之解决办法(换源)

简介: CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org; Name or service not known“之解决办法(换源)

文章目录

CentOS7 更换镜像源

  • 1.先安装wget
  • 2.下载CentOS 7的对应的repo文件
  • 3.更新镜像源

使用yum install -y xxx 或者 yum makecache时,报错Could not resolve host: mirrorlist.centos.org

1-1.png

1-2.png

解决方法:看到报错日志中加粗的字体,命令行ping mirrorlist.centos.org 不通。试着ping www.baidu.com是正常的,说明DNS解析没问题。基本确认是yum源的问题

CentOS7 更换镜像源

1.先安装wget

wget --version    #如果已有wget,则跳过安装、直接进行第二步
yum install -y wget
wget --version

2.下载CentOS 7的对应的repo文件

#先备份CentOS-Base.repo
mv CentOS-Base.repo CentOS-Base.repo.backup


#下载CentOS 7的对应的repo文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

如果wget提示报错,wget: unable to resolve host address ‘mirrors.aliyun.com’,(此时/etc/yum.repos.d/CentOS-Base.repo文件内容为空)

2-1.png

直接在浏览器通过http://mirrors.aliyun.com/repo/Centos-7.repo 下载Centos-7.repo,然后将其传到/etc/yum.repos.d目录下,重命名为CentOS-Base.repo

cd /etc/yum.repos.d
mv Centos-7.repo CentOS-Base.repo
cat CentOS-Base.repo

2-2.png

3.更新镜像源

yum clean all
yum makecache
yum -y update

执行完上面三行命令,便可通过yum下载其他软件了。

相关文章
|
28天前
|
关系型数据库 MySQL Linux
Linux 安装 mysql【使用yum源进行安装】
这篇文章介绍了在Linux系统中使用yum源安装MySQL数据库的步骤,包括配置yum源、安装MySQL服务、启动服务以及修改root用户的默认密码。
Linux 安装 mysql【使用yum源进行安装】
|
12天前
|
缓存 Linux 编译器
【C++】CentOS环境搭建-安装log4cplus日志组件包及报错解决方案
通过上述步骤,您应该能够在CentOS环境中成功安装并使用log4cplus日志组件。面对任何安装或使用过程中出现的问题,仔细检查错误信息,对照提供的解决方案进行调整,通常都能找到合适的解决之道。log4cplus的强大功能将为您的项目提供灵活、高效的日志管理方案,助力软件开发与维护。
29 0
|
14天前
|
Unix Linux Go
Linux 使用Yum安装Go和配置环境
Linux 使用Yum安装Go和配置环境
|
25天前
|
缓存 Linux 开发工具
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
77 0
|
25天前
|
Linux 开发工具 数据安全/隐私保护
CentOS7报错:“xxx is not in the sudoers file. This incident will be reported“解决方法
CentOS7报错:“xxx is not in the sudoers file. This incident will be reported“解决方法
26 0
|
28天前
|
Linux Shell Python
centos执行pip3 install etcd3报错
centos执行pip3 install etcd3报错
|
2月前
|
Oracle Java 关系型数据库
yum安装指定版本的openJDK
yum安装指定版本的openJDK
|
4月前
yum 可以安装rpm包
【6月更文挑战第18天】yum 可以安装rpm包
531 0
|
2月前
|
关系型数据库 MySQL Linux
在CentOS上使用yum安装与使用MySQL
在CentOS操作系统上使用yum包管理器安装和配置MySQL数据库的详细步骤,包括下载MySQL的yum源配置、安装MySQL服务、启动和停止服务、设置开机自启动、获取临时密码、修改root用户密码、授权用户以及处理相关问题。同时,文章还包含了一些操作的截图,帮助用户更直观地理解安装和配置过程。
568 0
在CentOS上使用yum安装与使用MySQL
|
2月前
|
Web App开发 缓存 Ubuntu
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
168 11