Bootstrap

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

目录

1、备份

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配置中,使用了默认的镜像站点作为软件包的下载源。

配置成功!

;