YUM:Yellowdog Updater Modified
Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。(bing 词典)
yum可以检测软件间的依赖性,并提示用户解决,将发布的软件放到yum server,然后分析这些软件的依赖关系,然后将软件相关性记录成列表。当客户端有软件安装请求时,yum客户端在yum服务器上下载记录列表,然后通 过列表信息与本机rpm数据库已安装软件数据对比,明确软件的依赖关系,能够判断出那些软件需要安装。
列表信息保存在yum客户端的/var/cache/yum中,每次yum启动都会通过校验码与yum服务器同步更新列表信息。
使用yum需要有yum repositories,用来存放软件列表信息和软件包。yum repositories可以是http站点,ftp站点,本地站点。
路径格式:
ftp://hostname/PATH/TO/REPO REPO指repodata所在路径的父目录
http://hostname/PATH/TO/REPO
file:///PATH/TO/REPO
yum配置
[root@localhost ~]
[main]
cachedir= /var/cache/yum/ $basearch/$releasever
keepcache=0
debuglevel=2
logfile= /var/log/yum .log
exactarch=1
obsoletes=1
plugins=1
installonly_limit=5
bugtracker_url=
distroverpkg=centos-release
|
[root@localhost yum.repos.d]
[base]
name=CentOS-$releasever - Base name,
mirrorlist=http: //mirrorlist .centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
enabled = 1
gpgcheck=1
gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
.....
|
注意:[REPO_ID]中不能有空格,否则报错
定义仓库指向可用变量:
$releasever: 引用当前系统的主版本号;从[main]部分的distroverpkg获取;
$basearch: 当前系统的基本架构;i386, i486, i586, i686: i386
例如:http://mirror.centos.org/centos/$releasever/os/$basearch/
示例:配置aliyun的yum源
[root@localhost yum.repos.d]
1 [aliyun]
2 name=CentOS-$releasever-aliyun
3 baseurl=http: //mirrors .aliyun.com /centos/ $releasever /os/ $basearch/
4 enabled=1
5 gpgcheck=1
6 gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost yum.repos.d]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.skyshe.cn
* extras: mirrors.cqu.edu.cn
* updates: mirrors.pubyun.com
repo id repo name status
aliyun CentOS-7-aliyun 8,652
base /7/x86_64 CentOS-7 - Base 8,652
extras /7/x86_64 CentOS-7 - Extras 181
updates /7/x86_64 CentOS-7 - Updates 1,480
|
yum命令:
语法:yum [options] [command] [package ...]
选项:
安装: install package1 [package2] [...]
卸载:remove | erase package1 [package2] [...] 卸载指定包
autoremove [package1] [...] 同时卸载相关依赖包
升级:update [package1] [package2] [...]
check-update 检测已安装包的更新信息
[root@localhost ~]
......
NetworkManager.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates
NetworkManager-adsl.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates
NetworkManager-libnm.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates
NetworkManager-tui.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates
bind-libs-lite.x86_64 32:9.9.4-18.el7_1.5 updates
......
[root@localhost ~]
[root@localhost ~]
|
重新安装:reinstall package1 [package2] [...]
降级安装:downgrade package1 [package2] [...]
|
[root@localhost packages]
|
查询:info [...]
[root@localhost ~]
......
Available Packages
Name : php
Arch : x86_64
Version : 5.4.16
Release : 36.el7_1
Size : 1.4 M
Repo : updates /7/x86_64
Summary : PHP scripting language for creating dynamic web sites
......
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
|
rpm包列表:list [...]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
|
搜索rpm包:search string1 [string2] [...]
[root@localhost ~]
[root@localhost ~]
|
清理缓存:clean [ packages | headers | metadata | expire-cache | rpmdb | plugins | all ]
|
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
|
创建缓存:makecache [fast]
|
[root@localhost packages]
|
包组:groups [...]
|
[root@localhost packages]
.......
Available Groups:
Compatibility Libraries
Console Internet Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
[root@localhost packages]
[root@localhost packages]
[root@localhost packages]
|
仓库命令:
[root@localhost ~]
......
repo id repo name status
aliyun /7/x86_64 CentOS-7-aliyun 8,652
base /7/x86_64 CentOS-7 - Base 8,652
extras /7/x86_64 CentOS-7 - Extras 181
updates /7/x86_64 CentOS-7 - Updates 1,480
repolist: 18,965
[root@localhost ~]
......
Repo- id : aliyun /7/x86_64
Repo-name : CentOS-7-aliyun
Repo-revision: 1427842153
Repo-updated : Wed Apr 1 06:50:46 2015
Repo-pkgs : 8,652
Repo-size : 6.3 G
Repo-baseurl : http: //mirrors .aliyun.com /centos/7/os/x86_64/
Repo-expire : 21,600 second(s) (last: Thu Sep 17 09:22:44 2015)
Repo-filename: /etc/yum .repos.d /CentOS-aliyun .repo
......
|
使用光盘作为本地库:
1 挂载光盘至某目录
2 定义仓库,使用file:///指明访问路径
示例:
|
[root@localhost cdrom]
[root@localhost yum.repos.d]
[centos7-ISO]
name=centos- local -iso
baseurl= file : ///mnt/cdrom
enabled=1
gpgcheck=0
cost=100
root@localhost yum.repos.d]
......
repo id repo name status
centos7-ISO centos- local -iso 325
aliyun /7/x86_64 CentOS-7-aliyun 8,652
......
|
创建本地仓库:
1 安装createrepo工具
2 建立repository资源,建立header文件
[root@localhost ~]
Spawning worker 0 with 2 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost ~]
2048-cli-0.9-4.git20141214.723738c.el7.x86_64.rpm repodata
openstack-ceilometer-alarm-2014.2.2-1.fc22.noarch.rpm
|
3 可以在/etc/yum.repos.d目录下定义本地repository
[root@localhost yum.repos.d]
[localrepo]
name= local -repo
baseurl= file : ///root/packages
gpgcheck=0
enabled=1
|
DNF包管理器前端管理工具:
后续更新。
如有错误,敬请指正!
谢谢!
(责任编辑:IT) |