CentOS7 将阿里云的镜像源设置为yum源

   日期:2020-06-01     浏览:180    评论:0    
核心提示:1、实验环境[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) 2、测试网络环境服务器必须能够访问互联网,这里用ping www.baidu.com来测试,使用域名不但可以测试网络的连通性,也可以测试域名解析的功能。[root@localhost ~]# ping www.baidu.comPING www.a.shifen.com (14.215.177.39) 56(84) byt运维

1、实验环境

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

2、测试网络环境
服务器必须能够访问互联网,这里用ping www.baidu.com来测试,使用域名不但可以测试网络的连通性,也可以测试域名解析的功能。

[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=55 time=21.0 ms

3、安装wget
若Linux系统中未安装wget,需要安装wget。wget是一个非交互的下载工具,参数 y 的作用是当安装过程中需要用户输入yes或no的时候,默认为yes。

yum -y install wget

4、下载阿里云repo文件。
进入repo目录,删除系统自带的repo文件。下载阿里云的repo文件,作为服务器的yum仓库配置文件。

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2020-05-31 00:00:52--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 218.67.61.95, 218.67.61.32, 61.131.39.13, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|218.67.61.95|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to:/etc/yum.repos.d/aliyun.repo’

100%[====================================================================================>] 2,523       --.-K/s   in 0s      

2020-05-31 00:00:52 (297 MB/s) -/etc/yum.repos.d/aliyun.repo’ saved [2523/2523]

[root@localhost yum.repos.d]# ls
aliyun.repo

5、清除yum缓存。

[root@localhost yum.repos.d]# yum clean all

6、创建yum缓存。

[root@localhost yum.repos.d]# yum makecache

7、效果测试。
随便安装一个软件测试,这里使用安装httpd测试。

[root@localhost yum.repos.d]# yum -y install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-93.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-93.el7.centos for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-93.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-5.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-93.el7.centos 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-93.el7.centos                      base                   2.7 M
Installing for dependencies:
 apr                           x86_64                   1.4.8-5.el7                              base                   103 k
 apr-util                      x86_64                   1.5.2-6.el7                              base                    92 k
 httpd-tools                   x86_64                   2.4.6-93.el7.centos                      base                    92 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:
warning: /var/cache/yum/x86_64/7/base/packages/apr-1.4.8-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for apr-1.4.8-5.el7.x86_64.rpm is not installed
(1/5): apr-1.4.8-5.el7.x86_64.rpm                                                                      | 103 kB  00:00:00     
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm                                                                 |  92 kB  00:00:00     
(3/5): httpd-tools-2.4.6-93.el7.centos.x86_64.rpm                                                      |  92 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-93.el7.centos.x86_64.rpm                                                            | 2.7 MB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------
Total                                                                                         4.6 MB/s | 3.0 MB  00:00:00     
Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 From       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-5.el7.x86_64                                                                                     1/5 
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                                2/5 
  Installing : httpd-tools-2.4.6-93.el7.centos.x86_64                                                                     3/5 
  Installing : mailcap-2.1.41-2.el7.noarch                                                                                4/5 
  Installing : httpd-2.4.6-93.el7.centos.x86_64                                                                           5/5 
  Verifying  : apr-1.4.8-5.el7.x86_64                                                                                     1/5 
  Verifying  : httpd-tools-2.4.6-93.el7.centos.x86_64                                                                     2/5 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                                                                3/5 
  Verifying  : httpd-2.4.6-93.el7.centos.x86_64                                                                           4/5 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                                5/5 

Installed:
  httpd.x86_64 0:2.4.6-93.el7.centos                                                                                          

Dependency Installed:
  apr.x86_64 0:1.4.8-5.el7              apr-util.x86_64 0:1.5.2-6.el7         httpd-tools.x86_64 0:2.4.6-93.el7.centos        
  mailcap.noarch 0:2.1.41-2.el7        

Complete!

 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
更多>相关资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服