1、介绍
yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。
yum repository:yum repo :存储了众多的rpm包,以及包的相关的元数据文件,(放置在特定的目录下,repodata)
yum也是一个rpm命令
2、配置文件说明
如果想获取详细的说明文档
[root@localhost ~]#man yum.conf #说明文件
下面是配置文件
[root@localhost ~]#cat /etc/yum.conf #为所有仓库提供公共配置 [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 #whether or not yum keeps the cache of headers and packages after successful installation. Default is ’1’ (keep files) debuglevel=2 logfile=/var/log/yum.log exactarch=1 #平台是否要准确,centos7的包不能装到本地centos6上面 obsoletes=1 gpgcheck=1 #默认检查合法性 plugins=1 installonly_limit=5 #同时按照几个rpm bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release # in /etc/yum.repos.d #配置文件都放在这里,默认。必须是以repo结尾的文件
下面的目录存放不同类型仓库的配置文件,必须以 .repo 结尾
[root@localhost ~]#ls /etc/yum.repos.d/ #为仓库的指向提供配置 CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo
下面是一个配置文件的示例
[root@localhost /etc/yum.repos.d]#cat CentOS-Base.repo [base] name=CentOS-$releasever-$basearch - base - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ #baseurl=http://192.168.175.10/base/centos6.8 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os enabled=1 gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [epel] name=CentOS-$releasever-$basearch - epel - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/epel/6/$basearch http://mirrors.aliyuncs.com/epel/6/$basearch #baseurl=http://192.168.175.10/epel/centos6.8 #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch enabled=1 gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-EPEL-6 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
下面是执行yumlist命令后的结果
[root@localhost /etc/yum.repos.d]#yum repolist Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors * base: mirrors.aliyun.com * epel: mirrors.aliyun.com base | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:04 epel | 4.3 kB 00:00 epel/primary_db | 5.9 MB 00:06 repo id repo name status base CentOS-6-x86_64 - base - mirrors.aliyun.com 6,706 epel CentOS-6-x86_64 - epel - mirrors.aliyun.com 12,310 repolist: 19,016
下面是对里面的参数介绍
baseurl Must be a URL to the directory where the yum repository’s ‘repodata’ directory lives. Can be an http://, ftp:// or file:// URL. You can specify multiple URLs in one baseurl statement. The best way to do this is like this: [repositoryid] name=Some name for this repository baseurl=url://server1/path/to/repository/ url://server2/path/to/repository/ url://server3/path/to/repository/ enabled Either ‘1’ or ‘0’. This tells yum whether or not use this repository. 默认启用 gpgcheck Either ‘1’ or ‘0’. This tells yum whether or not it should perform a GPG signature check on the packages gotten from this repository. 默认启用 gpgkey A URL pointing to the ASCII-armored GPG key file for the repository. 秘钥文件,或者使用本地自带的,有时候需要使用网络上的 yum的repo配置文件中可用的变量: https://mirrors.aliyun.com/centos/6/os/x86_64/ http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ $releasever:当前os的发行版的主版本号:6或者7 $arch:平台: $basearch:基础平台
3、yum命令参数说明
yum [options] [command] [package ...] * repolist [all|enabled|disabled] 查看仓库列表 * list [...] #yum list 每个rpm包都列出来 yum list [all | glob_exp1] [glob_exp2] [...] yum list php* yum list updates [glob_exp1] [...] #就是update那个仓库里面可以升级的 yum list installed [glob_exp1] [...] yum list extras [glob_exp1] [...] * install package1 [package2] [...] * update [package1] [package2] [...] * check-update 检查更新,会列出可以更新的rpm包 * remove | erase package1 [package2] [...] 被依赖也会被卸载,比如:gcc依赖cpp。卸载cpp,gcc也会被卸载 * info [...] * clean [ packages | metadata | expire-cache | rpmdb | plugins | all ] 清理本地缓存,清理哪些元数据缓存 * makecache 构建缓存 * search string1 [string2] [...] 和grep差不多 * reinstall package1 [package2] [...] * downgrade package1 [package2] [...] * groupinstall group1 [group2] [...] * groupupdate group1 [group2] [...] * grouplist [hidden] [groupwildcard] [...] * groupremove group1 [group2] [...] * groupinfo group1 [...] * localinstall rpmfile1 [rpmfile2] [...] 安装本地的rpm,指定rpm的文件目录位置,会自动解决依赖关系 (maintained for legacy reasons only - use install) * localupdate rpmfile1 [rpmfile2] [...] (maintained for legacy reasons only - use update)
yum的常用命令行选项
--nogpgcheck:禁止进行gpg check -y:自动回答为yes
3、本地制作yum源
1、挂载光盘,然后在yum配置中指向repodata目录即可
mount -r -t iso9660 /dev/cdrom /media/cdrom
2、修改yum源配置
[base] name=CentOS-Local baseurl=file:///media/cdrom enabled=1 #很重要,1才启用 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
–
–
–
评论前必须登录!
注册