安装wget工具
[root@byte-edu-lab2 yum.repos.d]# yum install wget -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.bfsu.edu.cn
* extras: mirrors.bfsu.edu.cn
* updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================
Installing:
wget x86_64 1.14-18.el7_6.1 base 547 k
Transaction Summary
================================================================================================================================
Install 1 Package
Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7_6.1.x86_64 1/1
Verifying : wget-1.14-18.el7_6.1.x86_64 1/1
Installed:
wget.x86_64 0:1.14-18.el7_6.1
Complete!
1. 配置Xen yum源
查看当前的repo
[root@byte-edu-lab2 ~]# cd /etc
[root@byte-edu-lab2 etc]# cd yum.repos.d
[root@byte-edu-lab2 yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
先将该目录备份一下
[root@byte-edu-lab2 ~]# cp -r /etc/yum.repos.d{,.init.bak}
删除当前的所有repo
[root@byte-edu-lab2 yum.repos.d]# rm -rf *.repo
[root@byte-edu-lab2 yum.repos.d]# ls
在当前目录(/etc/yum.repos.d/)下创建xen48.repo
[root@byte-edu-lab2 yum.repos.d]# vim xen48.repo
[xen48]
name=Xen4.8 on Aliyun
baseurl=https://mirrors.aliyun.com/centos/7/virt/x86_64/xen-48/
gpgcheck=0
enabled=1
查看现在的repolist
[root@byte-edu-lab2 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
xen48 | 2.9 kB 00:00:00
xen48/primary_db | 5.9 MB 00:00:01
repo id repo name status
xen48 Xen4.8 on Aliyun 461
repolist: 461
可知只有刚刚添加的xen48。
2. 添加阿里巴巴的Centos-7源
[root@byte-edu-lab2 yum.repos.d]# wget https://mirrors.aliyun.com/repo/Centos-7.repo
--2022-02-18 00:19:37-- https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 58.49.193.194, 150.138.203.243, 180.122.78.248, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|58.49.193.194|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘Centos-7.repo’
100%[======================================================================================>] 2,523 --.-K/s in 0s
2022-02-18 00:19:37 (695 MB/s) - ‘Centos-7.repo’ saved [2523/2523]
查看现在的目录可知新增了Centos-7.repo
[root@byte-edu-lab2 yum.repos.d]# ls
Centos-7.repo xen48.repo
3. 添加阿里巴巴的epel-7源
[root@byte-edu-lab2 yum.repos.d]# wget https://mirrors.aliyun.com/repo/epel-7.repo
--2022-02-18 00:21:41-- https://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 150.138.203.242, 180.122.78.242, 58.222.29.244, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|150.138.203.242|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 664 [application/octet-stream]
Saving to: ‘epel-7.repo’
100%[======================================================================================>] 664 --.-K/s in 0s
2022-02-18 00:21:41 (190 MB/s) - ‘epel-7.repo’ saved [664/664]
再查看一下目录
[root@byte-edu-lab2 yum.repos.d]# ls
Centos-7.repo epel-7.repo xen48.repo
4. 最后查看一下当前的repolist
[root@byte-edu-lab2 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
epel | 4.7 kB 00:00:00
(1/3): epel/x86_64/group_gz | 96 kB 00:00:00
(2/3): epel/x86_64/updateinfo | 1.1 MB 00:00:01
(3/3): epel/x86_64/primary_db | 7.0 MB 00:00:02
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,732
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 500
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 3,414
xen48 Xen4.8 on Aliyun 461
repolist: 28,179
可知新增了base、epel、extras、updates。这是因为它们都属于之前安装的源的enabled=1(或没有enabled=0)的库,可通过cat命令查看:
[root@byte-edu-lab2 yum.repos.d]# cat Centos-7.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[root@byte-edu-lab2 yum.repos.d]# cat epel-7.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://mirrors.aliyun.com/epel/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0