全称为Yellow dog Updater, Modified,
是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,且简洁而又好记。
1.命令格式:
yum [选项][文件]
2.命令功能:
HTML: HyperText Mark Language
XML: eXtended Mark Language (半结构化的数据:XML, JSON)
yum仓库中的元数据文件:
1)primary.xml.gz (主要信息)
所有RPM包的列表;
依赖关系;
每个RPM安装生成的文件列表;
2)filelists.xml.gz (文件列表)
当前仓库中所有RPM包的所有文件列表;
3)other.xml.gz (额外信息)
额外信息,RPM包的修改日志;
4)repomd.xml
记录的是上面三个文件的时间戳和校验和;
5)comps*.xml: RPM包分组信息
[root@localhost yum.repos.d]# yum list |less
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Installed Packages
Deployment_Guide-as-IN.noarch 5.2-11 installed
Deployment_Guide-bn-IN.noarch 5.2-11 installed
...
[root@localhost yum.repos.d]# vim server.repo
[Base]
name=RHEL5 Server
baseurl=fpt://110.199.134.200//pub5.4_64/Server
enabled=1
gpgcheck=0
list: 列表 支持glob
all
available:可用的,仓库中有但尚未安装的
installed: 已经安装的
updates: 可用的升级
eg1.yum list all zsh*
clean: 清理缓存
[ packages | headers | metadata | dbcache | all ]
eg1.yum clean all
repolist: 显示repo列表及其简要信息
all
enabled: 默认
disabled
install: 安装
yum install PACKAGE_NAME
update: 升级
update_to: 升级为指定版本
remove|erase:卸载 相依赖的一起卸载
info:
[root@JackTest yum.repos.d]# yum info zsh
Available Packages
Name : zsh
Arch : i386
Version: 4.3.4
Release: 4.fc8
Size : 1.9 M
Repo : Base01
Summary: A powerful interactive shell
Description:
The zsh shell is a command interpreter usable as an interactive login
shell and as a shell script command processor. Zsh resembles the ksh
shell (the Korn shell), but includes many enhancements. Zsh supports
command line editing, built-in spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and more.
provides| whatprovides: 查看指定的文件或特性是由哪个包安装生成的;
[root@JackTest yum.repos.d]# yum provides /etc/inittab
filelists.sqlite.bz2 100% |=========================| 2.6 MB 00:00
initscripts.i386 : The inittab file and the /etc/init.d scripts
initscripts.i386 : The inittab file and the /etc/init.d scripts
groupinfo
grouplist
groupinstall
groupremove
groupupdate
[root@JackTest yum.repos.d]# yum grouplist
Setting up Group Process
Fedora-8-comps.xml 100% |=========================| 1.2 MB 00:00
Installed Groups:
Office/Productivity
MySQL Database
Administration Tools
Editors
System Tools
Fonts
Text-based Internet
GNOME Desktop Environment
Authoring and Publishing
Hardware Support
Games and Entertainment
Network Servers
X Window System
Graphics
Web Server
Printing Support
Mail Server
Server Configuration Tools
Legacy Fonts
Sound and Video
Graphical Internet
Available Groups:
Engineering and Scientific
Window Managers
GNOME Software Development
News Server
...
PostgreSQL Database
Development Libraries
Development Tools
Done
[root@JackTest yum.repos.d]# yum groupinstall “Development Libraries” “Development Tools”
Package gcc - 4.1.2-33.i386 already installed and latest version
...
Resolving Dependencies
--> Running transaction check
---> Package gdbm-devel.i386 0:1.8.0-27.fc7 set to be updated
---> Package ctags.i386 0:5.6-1.1 set to be updated
Total download size: 77 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: zlib-devel ####################### [ 1/94]
Installing: pciutils-devel ####################### [ 2/94]
...
Installing: perl-ExtUtils-Embed ####################### [94/94]
php-ldap.i386 5.2.4-3 Base01
php-mbstring.i386 5.2.4-3 Base01
php-mysql.i386 5.2.4-3 Base01
php-odbc.i386 5.2.4-3 Base01
php-pdo.i386 5.2.4-3 Base01
php-pecl-apc.i386 3.0.14-2.fc8 Base01
php-pgsql.i386 5.2.4-3 Base01
php-xml.i386 5.2.4-3 Base01
phpldapadmin.noarch 1.0.1-1.fc6 Base01
[root@JackTest yum.repos.d]# yum install php-mysql.i386 自动安装
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.i386 0:5.2.4-3 set to be updated
--> Processing Dependency: php-pdo for package: php-mysql
--> Processing Dependency: php-common = 5.2.4-3 for package: php-mysql
--> Running transaction check
---> Package php-common.i386 0:5.2.4-3 set to be updated
---> Package php-pdo.i386 0:5.2.4-3 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
php-mysql i386 5.2.4-3 Base01 80 k
Installing for dependencies:
php-common i386 5.2.4-3 Base01 221 k
php-pdo i386 5.2.4-3 Base01 60 k
Transaction Summary
=============================================================================
Install 3 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 360 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: php-common ######################### [1/3]
Installing: php-pdo ######################### [2/3]
Installing: php-mysql ######################### [3/3]
Installed: php-mysql.i386 0:5.2.4-3
Dependency Installed: php-common.i386 0:5.2.4-3 php-pdo.i386 0:5.2.4-3
Complete!
[root@JackTest yum.repos.d]#
2、创建yum源
[root@JackTest yum.repos.d]# yum list createrepo
Available Packages
createrepo.noarch 0.4.10-1.fc8 Base01
[root@JackTest yum.repos.d]# yum install createrepo
[root@localhost ~]# mkdir -pv /yum/VT *1*创建个目录 *2*安装createrepo
mkdir: created directory `/yum'
mkdir: created directory `/yum/VT'
[root@localhost ~]# cp /media/VT/*.rpm /yum/VT/ **复制RPM包
[root@localhost ~]# cd /yum/VT/
[root@localhost VT]# ls |wc -l
72
[root@localhost VT]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel-debuginfo.repo.bk server.repo
[root@JackTest yum.repos.d]# yum list **无源仓库文件而报错
file:///yum/VT/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: '/yum/VT/repodata/repomd.xml'
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: VT. Please verify its path and try again
[root@JackTest yum.repos.d]# yum repolist
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
file:///yum/ServerRH5/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: '/yum/ServerRH5/repodata/repomd.xml'
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: ServerRH5. Please verify its path and try again
[root@localhost ~]# cp /media/repodata/Fedora-8-comps.xml ./
[root@JackTest ~]# createrepo -g /root/Fedora-8-comps.xml /yum/VT/ *3*生成/repodata源仓库文件
116/116 - arts-devel-1.5.8-4.fc8.i386.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
You have new mail in /var/spool/mail/root
[root@JackTest yum.repos.d]# ls /yum/VT/repodata/
Fedora-8-comps.xml filelists.xml.gz other.xml.gz primary.xml.gz repomd.xml
[root@JackTest yum.repos.d]# yum clean all
Cleaning up Everything
[root@JackTest yum.repos.d]# yum repolist
repo id repo name status
Base01 RHEL5 Server enabled
VT VT enabled