rpm和yum比较说明

yum命令在多数Linux开发公司(比如RedHat)是收费的,需要购买其官方注册码才能使用。而CentOS属于社区维护,因此不需要付费。 不管是rpm命令还是yum命令,管理的都是rpm包,它们之间的区别在于rpm命令是手动管理rpm包,手动处理依赖问题;而yum命令是自动管理yum包,自动处理依赖问题。 使用yum命令管理rpm包是不一定要连接到互联网,也可以使用本地光盘rpm源。

yum源配置说明

Linux 的yum源配置信息在/etc/yum.repos.d目录下,相关说明如下:

  1. ## 配置信息说明
  2. [root@localhost yum.repos.d]# pwd
  3. /etc/yum.repos.d ## 所在路径
  4. [root@localhost yum.repos.d]# ls -lh
  5. -rw-r--r--. 1 root root 1.7K CentOS-Base.repo ## 默认使用的yum源配置文件,需要联网
  6. -rw-r--r--. 1 root root 1.3K CentOS-CR.repo
  7. -rw-r--r--. 1 root root 649 CentOS-Debuginfo.repo
  8. -rw-r--r--. 1 root root 314 CentOS-fasttrack.repo
  9. -rw-r--r--. 1 root root 630 CentOS-Media.repo ## 本地光盘yum源,离线时可使用
  10. -rw-r--r--. 1 root root 1.3K CentOS-Sources.repo
  11. -rw-r--r--. 1 root root 5.6K CentOS-Vault.repo ## 虚拟yum源

网络yum源配置文件说明

即CentOS-Base.repo yum源配置文件说明,该yum源为默认配置,使用时需要联网

  1. ## CentOS-Base.repo 配置文件内容
  2. [root@localhost yum.repos.d]# cat CentOS-Base.repo
  3. # CentOS-Base.repo
  4. #
  5. # The mirror system uses the connecting IP address of the client and the
  6. # update status of each mirror to pick mirrors that are updated to and
  7. # geographically close to the client. You should use this for CentOS updates
  8. # unless you are manually picking other mirrors.
  9. #
  10. # If the mirrorlist= does not work for you, as a fall back you can try the
  11. # remarked out baseurl= line instead.
  12. #
  13. [base]
  14. name=CentOS-$releasever - Base
  15. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
  16. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
  17. gpgcheck=1
  18. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  19. #released updates
  20. [updates]
  21. name=CentOS-$releasever - Updates
  22. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
  23. #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
  24. gpgcheck=1
  25. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  26. #additional packages that may be useful
  27. [extras]
  28. name=CentOS-$releasever - Extras
  29. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
  30. #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
  31. gpgcheck=1
  32. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  33. #additional packages that extend functionality of existing packages
  34. [centosplus]
  35. name=CentOS-$releasever - Plus
  36. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
  37. #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
  38. gpgcheck=1
  39. enabled=0
  40. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

字段说明
[ ]:容器名称(软件池),一定要放在 [ ] 中

从上述配置文件中可以看出,一个用4个“[ ]”内容,因此有4个软件池,分别为 base、updates、extras、centosplus,每个软件池均有不同的作用。

name:容器标识

做标识说明,可以自己随便写

mirrorlist:镜像站点地址

默认是官方地址,可以修改国内的免费镜像地址

baseurl:yum源服务器地址

默认是CentOS官方yum源服务器地址,可以使用,也可以修改成国内的免费yum源服务器

enabled:容器是否生效

不写或值为1表示容器生效,0表示容器不生效

gpgcheck:RPM的数字证书是否生效

1表示生效,0表示不生效

gpgkey:数字证书的公钥文件保存位置