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%[====================================================================================