centos7配置阿里云的镜像站点作为软件包下载源

目录

1、备份

[2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/](#2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/)

3、测试


阿里镜像提供的配置方法:centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站

1、备份

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

出现错误的原因:我在配置静态IP时,没有配置DNS服务器地址,导致本地无法将域名解析成IP地址,从而导致无法连接上阿里云服务器的镜像仓库。

重启网卡,使得修改的配置文件信息生效。重新下载,发现此时能成功下载了。

3、测试

[root@localhost ~]# yum install httpd -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
base                                                                                                                                                                                       | 3.6 kB  00:00:00     
extras                                                                                                                                                                                     | 2.9 kB  00:00:00     
updates                                                                                                                                                                                    | 2.9 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-99.el7.centos.1 for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-99.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7_9.1 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                           Arch                                         Version                                                       Repository                                     Size
==================================================================================================================================================================================================================
Installing:
 httpd                                             x86_64                                       2.4.6-99.el7.centos.1                                         updates                                       2.7 M
Installing for dependencies:
 apr                                               x86_64                                       1.4.8-7.el7                                                   base                                          104 k
 apr-util                                          x86_64                                       1.5.2-6.el7_9.1                                               updates                                        92 k
 httpd-tools                                       x86_64                                       2.4.6-99.el7.centos.1                                         updates                                        94 k
 mailcap                                           noarch                                       2.1.41-2.el7                                                  base                                           31 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 3.0 M
Installed size: 10 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/5): apr-1.4.8-7.el7.x86_64.rpm                                                                                                                                                          | 104 kB  00:00:00     
(2/5): apr-util-1.5.2-6.el7_9.1.x86_64.rpm                                                                                                                                                 |  92 kB  00:00:00     
(3/5): httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm                                                                                                                                        |  94 kB  00:00:00     
(4/5): mailcap-2.1.41-2.el7.noarch.rpm                                                                                                                                                     |  31 kB  00:00:00     
(5/5): httpd-2.4.6-99.el7.centos.1.x86_64.rpm                                                                                                                                              | 2.7 MB  00:00:05     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                             519 kB/s | 3.0 MB  00:00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-7.el7.x86_64                                                                                                                                                                         1/5 
  Installing : apr-util-1.5.2-6.el7_9.1.x86_64                                                                                                                                                                2/5 
  Installing : httpd-tools-2.4.6-99.el7.centos.1.x86_64                                                                                                                                                       3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                                                                                                                                                    4/5 
  Installing : httpd-2.4.6-99.el7.centos.1.x86_64                                                                                                                                                             5/5 
  Verifying  : httpd-2.4.6-99.el7.centos.1.x86_64                                                                                                                                                             1/5 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                                                                                                    2/5 
  Verifying  : apr-1.4.8-7.el7.x86_64                                                                                                                                                                         3/5 
  Verifying  : httpd-tools-2.4.6-99.el7.centos.1.x86_64                                                                                                                                                       4/5 
  Verifying  : apr-util-1.5.2-6.el7_9.1.x86_64                                                                                                                                                                5/5 

Installed:
  httpd.x86_64 0:2.4.6-99.el7.centos.1                                                                                                                                                                            

Dependency Installed:
  apr.x86_64 0:1.4.8-7.el7                    apr-util.x86_64 0:1.5.2-6.el7_9.1                    httpd-tools.x86_64 0:2.4.6-99.el7.centos.1                    mailcap.noarch 0:2.1.41-2.el7                   

Complete!

从上面的日志来看,确实是从阿里云的镜像站点下载了软件包。在YUM配置中,使用了默认的镜像站点作为软件包的下载源。

配置成功!

相关推荐
小安运维日记6 小时前
Linux云计算 |【第四阶段】NOSQL-DAY1
linux·运维·redis·sql·云计算·nosql
萌新求带啊QAQ13 小时前
腾讯云2024年数字生态大会开发者嘉年华(数据库动手实验)TDSQL-C初体验
云计算·腾讯云·tdsql-c
苓诣14 小时前
Submariner 部署全过程
云计算·k8s
GDAL20 小时前
全面讲解GNU:从起源到应用
服务器·云计算·gnu
【D'accumulation】1 天前
配置RHEL和centOS的阿里云镜像源
linux·阿里云·centos
九河云1 天前
确保在AWS上的资源安全:构建坚不可摧的云安全防线
安全·云计算·aws
阿里云大数据AI技术1 天前
对接开源大模型应用开发平台最佳实践
人工智能·阿里云·llm·opensearch
KubeSphere 云原生1 天前
云原生周刊:Prometheus 3.0 Beta 发布|2024.09.16
云计算·k8s·容器平台·kubesphere
Java码农杂谈1 天前
浅谈Tair缓存的三种存储引擎MDB、LDB、RDB
java·redis·分布式·后端·阿里云·缓存
Jasonakeke1 天前
本地镜像发布到阿里云
阿里云·云计算