yum

备份源文件

1
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

源配置列表

1
2
3
4
5
6
7
8
# CentOS6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos6_base.repo

# CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo

# CentOS8
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos8_base.repo

更新缓存

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

解决 Repository xxx is listed more than once in the configuration 重复

1
2
3
4
5
6
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Repository cr is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
Cleaning repos: extras os updates
Cleaning up list of fastest mirrors
1
2
3
4
5
6
7
8
9
10
11
[root@localhost ~]# ls -l /etc/yum.repos.d
total 44
-rw-r--r--. 1 root root 1923 Jul 4 2019 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 Oct 23 2020 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1309 Oct 23 2020 CentOS-CR.repo.backup
-rw-r--r--. 1 root root 649 Oct 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Oct 23 2020 CentOS-fasttrack.repo.backup
-rw-r--r--. 1 root root 630 Oct 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Oct 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Oct 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 Oct 23 2020 CentOS-x86_64-kernel.repo

yum update 和 yum upgrade 区别

  • yum update 升级所有包、系统版本和内核,改变软件设置和系统设置。
  • yum upgrade 升级所有包、系统版本,不改变内核、软件和系统设置。

过程记录

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
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
--2021-04-29 01:09:52-- http://mirrors.cloud.tencent.com/repo/centos7_base.repo
Resolving mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)... 115.231.229.139, 122.246.10.93, 117.34.50.120, ...
Connecting to mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)|115.231.229.139|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1923 (1.9K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

[======================================>] 1,923 --.-K/s in 0s

2021-04-29 01:09:54 (256 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [1923/1923]

[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Repository cr is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
Cleaning repos: extras os updates
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
Repository cr is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
Determining fastest mirrors
extras | 2.9 kB 00:00
os | 3.6 kB 00:00
updates | 2.9 kB 00:00
(1/10): extras/7/x86_64/primary_db | 232 kB 00:02
(2/10): extras/7/x86_64/filelists_db | 230 kB 00:03
(3/10): extras/7/x86_64/other_db | 138 kB 00:00
(4/10): os/7/x86_64/group_gz | 153 kB 00:00:02
(5/10): os/7/x86_64/primary_db | 6.1 MB 00:00:09
(6/10): os/7/x86_64/filelists_db | 7.2 MB 00:00:13
(7/10): os/7/x86_64/other_db | 2.6 MB 00:00:11
(8/10): updates/7/x86_64/filelists_db | 4.3 MB 00:00:12
(9/10): updates/7/x86_64/other_db | 569 kB 00:00:00
(10/10): updates/7/x86_64/primary_db | 7.1 MB 00:00:14
Metadata Cache Created
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-CR.repo /etc/yum.repos.d/CentOS-CR.repo.backup
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-fasttrack.repo /etc/yum.repos.d/CentOS-fasttrack.repo.backup