Centos8 安装软件慢的解决方法

假方法-修改DNS

谷歌第一位是这个修改DNS的方法,修改DNS只是让你能下得动,并不加速,想要加速,只能是换源解决,换成阿里源。

image-20201122000742472

换阿里源

1
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

后面的不用看了,上面设置好效果爆棚。

验证

查看一下是否安装完成,执行命令

1
ls -l /etc/yum.repos.d/

将会看到如下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
-rw-r--r--. 1 root root  731 8月  14 14:42 CentOS-AppStream.repo.bak
-rw-r--r--. 1 root root 2595 12月 25 19:44 CentOS-Base.repo
-rw-r--r--. 1 root root 712 8月 14 14:42 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 798 8月 14 14:42 CentOS-centosplus.repo.bak
-rw-r--r--. 1 root root 1320 8月 14 14:42 CentOS-CR.repo
-rw-r--r--. 1 root root 668 8月 14 14:42 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 756 8月 14 14:42 CentOS-Extras.repo.bak
-rw-r--r--. 1 root root 338 8月 14 14:42 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 928 8月 14 14:42 CentOS-Media.repo
-rw-r--r--. 1 root root 736 8月 14 14:42 CentOS-PowerTools.repo.bak
-rw-r--r--. 1 root root 1382 8月 14 14:42 CentOS-Sources.repo
-rw-r--r--. 1 root root 74 8月 14 14:42 CentOS-Vault.repo
123456789101112

再执行以下命令查看一下内容,确认是否更改成功

1
cat /etc/yum.repos.d/CentOS-Base.repo

如果看到如下内容,则代表升级成功了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061

后续

这样就完成了将本地CentOS Linux 8的yum安装源更换为国内源(阿里源)。
运行以下命令生成以下缓存

1
yum makecache

执行以下命令升级所有的软件包试试看速度如何:

1
yum -y update

主要是习惯了YUM,你也可以用这个命令“dnf -y update”。如果你是网络安装的CentOS Linux 8,系统应该不会有什么软件包需要升级,提示内容如下:

1
2
3
4
上次元数据过期检查:0:06:18 前,执行于 2019年12月25日 星期三 23时34分12秒。
依赖关系解决。
无需任何处理。
完毕!