YUM软件包管理工具与yum命令的详细介绍

2019-10-13 10:32:50王冬梅

五、配置yum源

yum源配置文件通常位于/etc/yum.repo.d目录下,笔录所使用的CentOS 6.3发生版中包含以下几个配置文件:

$ # ll
总用量 16
-rw-r--r--. 1 root root 1926 6月 26 2012 CentOS-Base.repo
-rw-r--r--. 1 root root 637 6月 26 2012 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 626 6月 26 2012 CentOS-Media.repo
-rw-r--r--. 1 root root 2593 6月 26 2012 CentOS-Vault.repo

其中:

    CentOS-Base.repo - 用于配置yum网络源 CentOS-Media.repo - 用于配置yum本地源

5.1 启用yum本地源

编辑CentOS-Media.repo文件:

vi CentOS-Media.repo
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
# CentOS-6. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c6-media [command]
# 
# or for ONLY the media repo, do this:
#
# yum --disablerepo=* --enablerepo=c6-media [command]
 
[c6-media]
name=CentOS-$releasever - Media
# 本地源路径
baseurl=file:///media/CentOS/
  file:///media/cdrom/
  file:///media/cdrecorder/
gpgcheck=1
# enabled=0
# 启用本地源
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

配置后,修改CentOS-Base.repo中的enabled配置项为enabled=0,或将CentOS-Base.repo文件删除或重命名,就会从本地源安装软件

5.2 添加yum网络源

网络源通地CentOS-Base.repo文件配置,配置一个源包括以下几个部分:

    [serverid] - 源标识,必须唯一 name - 源名称,支付$releasever等变量名 mirrorlist或baseurl - 其中,

        mirrorlist是一个保存了镜像列表列表的网站

        baseurl是一个包库

如,以下是CentOS 6.3中的一个配置镜像:

[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。