rpm和yum比较说明
yum命令在多数Linux开发公司(比如RedHat)是收费的,需要购买其官方注册码才能使用。而CentOS属于社区维护,因此不需要付费。 不管是rpm命令还是yum命令,管理的都是rpm包,它们之间的区别在于rpm命令是手动管理rpm包,手动处理依赖问题;而yum命令是自动管理yum包,自动处理依赖问题。 使用yum命令管理rpm包是不一定要连接到互联网,也可以使用本地光盘rpm源。
yum源配置说明
Linux 的yum源配置信息在/etc/yum.repos.d
目录下,相关说明如下:
## 配置信息说明
[root@localhost yum.repos.d]# pwd
/etc/yum.repos.d ## 所在路径
[root@localhost yum.repos.d]# ls -lh
-rw-r--r--. 1 root root 1.7K CentOS-Base.repo ## 默认使用的yum源配置文件,需要联网
-rw-r--r--. 1 root root 1.3K CentOS-CR.repo
-rw-r--r--. 1 root root 649 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 CentOS-Media.repo ## 本地光盘yum源,离线时可使用
-rw-r--r--. 1 root root 1.3K CentOS-Sources.repo
-rw-r--r--. 1 root root 5.6K CentOS-Vault.repo ## 虚拟yum源
网络yum源配置文件说明
即CentOS-Base.repo yum源配置文件说明,该yum源为默认配置,使用时需要联网
## CentOS-Base.repo 配置文件内容
[root@localhost yum.repos.d]# cat CentOS-Base.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
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
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:数字证书的公钥文件保存位置