配置Yum

Yum(Yellowdog Updater Modified)是包管理工具,可以自动解决依赖,从yum库里面查询、下载、安装rpm包。更多yum的说明可以参考man yum或者man yum.conf页面。友情链接:Linux yum命令Linux yum源

平台:RHEL6 64bit

这里主要讲解一下Yum的配置,Yum配置文件为/etc/yum.conf,里面通常包含两个部分[main]和[repository]。[main]部分设置之后是全局的,对所有的yum库都有效,[repository]部分是局部的。相关目录/etc/yum.repos.d/

[root@rhel6164 ~]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'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 correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
下面介绍一下在 [main]部分的常用选项,更多的选项,可以查看 man yum.conf页面

  • assumeyes=value value=0是默认选项,交互式选项,在进行操作的时候进行确认
  • cachedir=directory 缓存目录
  • debuglevel=value value从1到10,值越高就会显示越多的debug信息,debuglevel=0是disabledebug信息输出,默认为2
  • exactarch=value value=0不关心准确的arch,如果value=1就会关心准确的arch,比如不会去升级一个i386的RPM包(已经安装了i686的RPM包),这个是默认选项
  • exclude=package_name [more_package_names] 在安装/升级的时候,排除RPM包
  • gpgcheck=value value=0 Disable GPG signature checking,包括本地包安装,value=1是缺省值,Enable GPG signature checking
  • groupremove_leaf_only=value 0为缺省值,在删除package group的时候,不检查每个包的依赖
  • plugin=value 0为disable yum plug-ins globally

[repository]部分,允许定义自己的yum库,每一个[repository]部分必须要包含以下的内容

  1. name=repository_name repository_name是描述repository的字符串
  2. baseurl=repository_url 可以是下面的格式http://path/to/repo(HTTP),ftp://path/to/repo(FTP),file:///path/to/local/path(local),http://user:password@www.example.com/repo(需要账号和密码的HTTP)
  3. enable=value 0为disable yum库,也可以在用yum的时候用参数--enablerepo=repo_name或者--disablerepo=repo_name

Yum内嵌变量

  • $releasever:release version,$releasever为在/etc/yum.conf中distroverpkg=value的值,如果没有定义distroverpkg,就是redhat-release的值
  • $arch:系统的平台
  • $basearch:the base architecture,例如,i686和i386都是i386的base arch,AMD64和Intel64都是x86_64的base arch
  • $YUM0~9,替换shell中名字一样的环境变量

可以自己定义变量,放在/etc/yum/vars/,可以覆盖已有的变量

#echo "Fedora" > /etc/yum/vars/osname #替换osname成Fedora
name=$osname $releasever #使用被重新赋值的osname变量

yum-config-manager命令,查看现在的配置,命令的说明,可以参考 yum-config-manager -h页面

常用参数:

  • section:section可以是可用的yum库,列出该yum库的相关信息
  • main:列出main部分信息
增加新的yum库有两种办法,第一种是,直接在/etc/yum.conf里面增加[repository]部分;第二种办法是在/etc/yum.repos.d/目录里面新建XXX.repo文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值