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下载其他软件了。

相关文章
|
Linux
Centos6配置阿里云yum源报错
在CentOS 6配置阿里云Yum源时,可能出现EPEL仓库访问报错(404 Not Found)。解决方法:编辑`/etc/yum.repos.d/epel.repo`文件,将`enabled`和`gpgcheck`参数设为0 ``` 此设置可解决仓库无法访问的问题。
2504 29
|
存储 Linux 网络安全
如何从CentOS7升级到8?CentOS8最新安装教程
从CentOS 7升级到8只需三步:清理系统、更换软件包及存储库、安装新内核与发布版本。首先确保系统最新并清理冗余包,接着替换基础系统包为CentOS 8版本,最后通过DNF工具完成内核更新与系统同步。整个过程需在终端执行,建议升级前备份VPS快照以防数据丢失。此方法可避免重装系统导致的数据清除问题,实现平滑升级。
3262 6
|
安全 网络安全
gbase8a centos8(kylinv10)加载报登录 ftp失败报错530 Login incorrect 排查过程及解决办法
centos8(kylinv10)加载报登录 ftp失败报错530 Login incorrect 排查过程及解决办法
|
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“解决方法
2743 1
|
缓存 Linux 编译器
【C++】CentOS环境搭建-安装log4cplus日志组件包及报错解决方案
通过上述步骤,您应该能够在CentOS环境中成功安装并使用log4cplus日志组件。面对任何安装或使用过程中出现的问题,仔细检查错误信息,对照提供的解决方案进行调整,通常都能找到合适的解决之道。log4cplus的强大功能将为您的项目提供灵活、高效的日志管理方案,助力软件开发与维护。
868 0
|
缓存 Linux 开发工具
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
1316 0
|
Linux Shell Python
centos执行pip3 install etcd3报错
centos执行pip3 install etcd3报错
|
缓存 关系型数据库 MySQL
百度搜索:蓝易云【CentOS8服务器安装MySQL报错:no match mysql-community-server】
现在,你已经成功安装了MySQL服务器并解决了"no match mysql-community-server"的报错问题。祝你使用愉快!
590 1
|
Linux 数据库管理 Python
CentOS7编译安装Python3.10(含OpenSSL1.1.1安装),创建虚拟环境,运行Django项目(含sqlite版本报错)
CentOS7编译安装Python3.10(含OpenSSL1.1.1安装),创建虚拟环境,运行Django项目(含sqlite版本报错)
2807 4
|
Linux Shell Swift
django(二)centos安装django3.2报错SQLite 3.8.3 or later is required (found 3.7.17)
我正在参加「掘金·启航计划」 Centos安装diango3.2框架请参照《django(一)ubuntu18.04安装框架》 在运行: 复制代码 python3 manage.py runserver 0.0.0.0:81 的时候报错: swift 复制代码 django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17). 报错的大体意思是:对sqlite最低版本的需求的3.8.3,但是现在只找到了3.7.17。
656 1