Linux下我们安装软件,可能会需要安装各种包来支持,你可以从安装介质中找到rpm,手动安装,但最常用的,可能还是yum,省了很多烦恼。
但要知道yum同样需要升级,yum怎么升级?碰巧看到杨大师的一篇文章《LINUX环境下如何重建yum源并更新》,介绍了整个操作。
1. 备份默认的yum
# mv /etc/yum.repos.d /etc/yum.repos.d.backup
2. 设置新的yum目录
# mkdir /etc/yum.repos.d
3. 下载阿里yum配置到该目录中,用wget,进行下载,
# yum install -y wget
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4. 重建缓存
yum clean all执行效果,
[root@ethanyang yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: base centosplus extras updates
Cleaning up everything
yum makecache执行效果,
[root@ethanyang yum.repos.d]# yum makecache
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base | 3.6 kB 00:00:00
centosplus | 2.9 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/13): base/x86_64/group_gz | 165 kB 00:00:00
(2/13): base/x86_64/filelists_db | 7.3 MB 00:00:08
(3/13): base/x86_64/primary_db | 6.0 MB 00:00:08
(4/13): base/x86_64/other_db | 2.6 MB 00:00:02
(5/13): centosplus/x86_64/filelists_db | 1.2 MB 00:00:02
(6/13): centosplus/x86_64/other_db | 69 kB 00:00:00
(7/13): centosplus/x86_64/primary_db | 2.7 MB 00:00:03
(8/13): extras/x86_64/filelists_db | 216 kB 00:00:00
(9/13): extras/x86_64/other_db | 106 kB 00:00:00
(10/13): extras/x86_64/primary_db | 164 kB 00:00:01
(11/13): updates/x86_64/filelists_db | 4.0 MB 00:00:03
(12/13): updates/x86_64/other_db | 493 kB 00:00:00
(13/13): updates/x86_64/primary_db | 6.7 MB 00:00:06
Metadata Cache Created
[root@ethanyang yum.repos.d]#
5. 升级所有包
yum update -y
注意:
(1) 第一次运行yum安装软件前,建议更新yum。
(2) yum update -y改变软件设置和系统设置,系统版本内核都升级,需几分钟耐心等待。
另外,熟悉Linux的亲,可能还熟悉升级方式有upgrade,这里简述下区别:
yum -y update:升级所有包同时,也升级软件和系统内核; yum -y upgrade:只升级所有包,不升级软件和系统内核,软件和内核保持原样。