yum命令是一个工做在前端的工具,使用yum命令安装程序包时,能够自动的解决程序之间的依赖关系,解决程序安装的繁琐。yum工做在C/S架构模型,Server端能够是来自互联网,也能够来自局域网。若是你要使用yum命令,那么你就是工做在客户端。php
yum的配置文件centos
yum的配置文件分为主配置文件,即全局的配置,和次配置文件即指向每个yum仓库的相关属性的配置。主配置文件在/etc/yum.conf,次配置文件在/etc/yum.repos.d/*.repo文件中,次配置文件必须.repo后缀结尾。缓存
主配置文件:架构
[root@Bisc-lab01 ~]# cat/etc/yum.confide
[main] #<------主配置标识工具
cachedir=/var/cache/yum/$basearch/$releasever #<------缓存目录,即元数据和rpm包缓存的目录this
keepcache=0 #<------下载的rpm是否保存在缓存目录中,“0”表示不保存,“1”表示保存url
debuglevel=2 #<------调试级别,安装过程当中显示的安装内容级别spa
logfile=/var/log/yum.log #<------日志文件,存放的为yum安装的rpm包的时间、包文件
exactarch=1 #<------安装程序是否与当前平台一致
obsoletes=1 #<------检查包是否废弃
gpgcheck=1 #<------安装以前检查包的完整性和来源合法性
plugins=1 #<------yum是否支持插件
installonly_limit=5 #<------一次安装程序包的限制
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum #<------bug追踪路径
distroverpkg=centos-release #<------发行版本的程序包与哪一个版本的为例
# This is the default, if you make this biggeryum won't see if the metadata
# is newer on the remote and soyou'll "gain" the bandwidth of not having to
# download the new metadata and"pay" for it by yum not having correct
# information.
# It is esp. important, to have correctmetadata, for distributions like
# Fedora which don't keep oldpackages around. If you don't like this checking
# interupting your command lineusage, it's much better to have something
# manually check the metadataonce an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR INseparate files named file.repo #<------你须要指定的yum在必须以.repo文件结尾
# in /etc/yum.repos.d #<------文件路径在/etc/yum.repos.d目录中
次配置文件:
[root@Bisc-lab01 yum.repos.d]#cat CentOS6-Base-163.repo #<------这一个163.com的yum镜像
[base] #<------标识,在当前系统上的yum来源,此标识必须是全局惟一
name=CentOS-$releasever - Base- 163.com #<------描述信息
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch#<------指明yum仓库的访问路径
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1 #<------对程序包进行来源完整性和合法性验证
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #<------指明验证KEY的路径
enabled=1 #<------此仓库是否被使用,“0”表示禁用,“1”表示使用
注意:baserurl能够使用使用http、ftp和本地目录,若是你有多个与能够一次性的写在一次,每个分别写在一行如:
baseurl=ftp://SERVER/PATH/TO/REPOSIRY #<------使用的是ftp服务
http://SERVER/PATH/TO/REPOSIRY #<------使用是http服务
file:///SERVER/PATH/TO/REPOSIRY #<------使用是本地目录
提示:更多的信息请man yum.conf
获取网上yum站点镜像
若是你能链接到互联网,你能够使用mirrors.163.com或mirrorsaliyun.com的yum仓库的镜像,其实的镜像站点也是能够的,哪如何的获取呢?咱们以163.com的为例。
打开mirrors.163.com站点镜像,在网页的右边有每一个发行版的使用的“使用帮助”,如打开Centos镜像使用,里面介绍了当前收录的平台架构,使用说明等等相关说明,请按照相关说明进行操做。咱们系统是Centos 6.6的,首先备份原有的CentOS-Base.repo:
mv /etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup
切换至/etc/yum.repos.d/目录下
cd /etc/yum.repos.d
下载对应版本的repo文件:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
运行如下命令生成缓存:
yum clean all
yum makecache