yum仓库详细解读

  • 2021-08-11 09:31:41

Yum:Yellowdog Updater,Modified的简称,起初由yellow dog发行版的开发者Terra Soft研发,用Python编写,后经杜克大学的Linux@Duke开发团队进行改进,遂有此名。Yum是一个shell前端软件包管理器,基于RPM包管理,能够从指定的服务器自动下载RPM包并安装,可以自动处理依赖关系,并且一次安装所有依赖的软件包。


一、yum的分类


1.客户端:客户端的配置非常简单,只要配置要一些基本的参数,就可以通过客户端来安装软件,并且解决软件包的依赖性。


2.服务端:将所有需要的软件包同统一放在一个目录下,该目录可以通过ftp、http、https、file将需要使用软件的客户端传输需要的软件。


二、yum的配置文件


全局配置:/etc/yum.conf yum

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=5

bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum

distroverpkg=centos-release


#  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


参数说明:

cachedir:软件包缓存目录

keepcache:缓存是否保存,1保存0不保存

debuglevel:调试级别(默认为2)

logfile:日志文件路径

gpgcheck:是否检查密钥,一种检验软件完整性的方式


仓库配置:/etc/yum.repo.d/name.repo yum

[name]:仓库id

name :仓库名字

baseurl: 为仓库的地址

gpgkey:公钥地址,若是需要检查完整性的话可以添加密钥地址

enable:是否开启当前仓库

gpgcheck:是否使用密钥验证


三、yum仓库中的变量信息


releasever:当前OS的主版本号

arch:处理器平台,i386,x86_64,i486,i586

basearch:基础平台:i386,x8664在搭建yum客户端仓库时,可以使变量让自己能够让repo配置文件在多个版本的系统中使用。但是yum服务器必须遵循命名规则。

下面以阿里举例:

https://mirrors.aliyun.com/centos/releaserver/os/$basearch/

https://mirrors.aliyun.com/centos/6.9/os/x86_64/


四、yum命令


1.启用与禁用仓库

禁用仓库:yum-config-manager --disable “仓库名"

启用仓库:yum-config-manager --enable “仓库名”


2.显示软件仓库列表

yum repolist


3.显示软件包列表

yum list


4.安装卸载与更新

安装:yum install package1 package2...

重新安装:yum reinstall package

卸载:yum remove package

更新:yum update package

降级:yum downgrage package

检查可用的更新:yum check-update


5.缓存命令

清除缓存:yum clean all

构建缓存:yum makecache


6.查看依赖性

yum deplist package1


7.包组相关命令

安装 yum groupinstall group1 [group2] [...]

更新 yum groupupdate group1 [group2] [...]

列表 yum grouplist [hidden] [groupwildcard] [...]

删除 yum groupremove group1 [group2] [...]

信息 yum groupinfo group1 [...]