23-Linux-软件包管理-YUM
2014-02-09 23:58
295 查看
由来
RPM软件包形式管理软件虽然方便, 但是需要手工解决软件包的依赖关系.有时安装一个软件需要首先安装几十上百个其他软件, 手工解决则过于复杂.
YUM的出现就是为了解决这个问题的.
说明
YUM, Yellowdog Updater Modified.是一个RPM的前端程序, 主要作用就是 自动解决RPM的依赖关系.
特点
自动解决依赖关系可以对RPM进行分组, 以组为单位进行批量安装操作
引入仓库的概念, 且支持多个仓库
配置简单
仓库
说明
repository, repo仓库 存放着大量的RPM软件包,
当使用YUM安装一个RPM包时, 会自动在仓库中查找依赖软件并安装.
仓库类型
本地的通过 FILE协议 方式访问
网络的
通过 HTTP、FTP、NFS协议 方式访问
配置文件
位置: /etc/yum.repos.d格式
[仓库名称]
name = 仓库的描述信息
baseurl = http://www.foo.org/yum/rpms
enabled = 0或1, 该仓库是否启用, 默认为1
gpgcheck = 0或1, 是否校验
注意
YUM配置文件必须以".repo"结尾
一个配置文件可以配置多个仓库
/etc/yum.repos.d 目录下可以存在多个配置文件
示例 : /etc/yum.repos.d/CentOS-Base.repo
[root@wuqinfei yum.repos.d]# pwd /etc/yum.repos.d [root@wuqinfei yum.repos.d]# ls -l total 16 -rw-r--r--. 1 root root 1926 Jun 26 2012 CentOS-Base.repo -rw-r--r--. 1 root root 637 Jun 26 2012 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 626 Jun 26 2012 CentOS-Media.repo -rw-r--r--. 1 root root 2593 Jun 26 2012 CentOS-Vault.repo [root@wuqinfei yum.repos.d]# vim CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
基本命令
yum install software-name 安装指定软件[root@wuqinfei yum.repos.d]# yum install tigervnc Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package tigervnc.i686 0:1.1.0-8.el6_5 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: tigervnc i686 1.1.0-8.el6_5 updates 266 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 266 k Installed size: 683 k Is this ok [y/N]: y Downloading Packages: tigervnc-1.1.0-8.el6_5.i686.rpm | 266 kB 00:06 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Importing GPG key 0xC105B9DE: Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org> Package: centos-release-6-3.el6.centos.9.i686 (@anaconda-CentOS-201207051201.i386/6.3) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : tigervnc-1.1.0-8.el6_5.i686 1/1 Verifying : tigervnc-1.1.0-8.el6_5.i686 1/1 Installed: tigervnc.i686 0:1.1.0-8.el6_5 Complete! [root@wuqinfei yum.repos.d]# rpm -qi tigervnc Name : tigervnc Relocations: (not relocatable) Version : 1.1.0 Vendor: CentOS Release : 8.el6_5 Build Date: Tue 04 Feb 2014 01:21:41 PM CST Install Date: Sun 09 Feb 2014 10:16:27 PM CST Build Host: c6b9.bsys.dev.centos.org Group : User Interface/Desktops Source RPM: tigervnc-1.1.0-8.el6_5.src.rpm Size : 699901 License: GPLv2+ Signature : RSA/SHA1, Tue 04 Feb 2014 01:35:59 PM CST, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://www.tigervnc.com Summary : A TigerVNC remote display system Description : Virtual Network Computing (VNC) is a remote display system which allows you to view a computing 'desktop' environment not only on the machine where it is running, but from anywhere on the Internet and from a wide variety of machine architectures. This package contains a client which will allow you to connect to other desktops running a VNC server.
yum remove software-name 卸载~
[root@wuqinfei yum.repos.d]# yum remove tigervnc Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package tigervnc.i686 0:1.1.0-8.el6_5 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: tigervnc i686 1.1.0-8.el6_5 @updates 683 k Transaction Summary ================================================================================ Remove 1 Package(s) Installed size: 683 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : tigervnc-1.1.0-8.el6_5.i686 1/1 Verifying : tigervnc-1.1.0-8.el6_5.i686 1/1 Removed: tigervnc.i686 0:1.1.0-8.el6_5 Complete!
yum update software-name 升级~
示例: 安装 gcc
[root@wuqinfei yum.repos.d]# yum install gcc.i686 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package gcc.i686 0:4.4.7-4.el6 will be installed --> Processing Dependency: libgomp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.i686 --> Processing Dependency: cpp = 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.i686 --> Processing Dependency: libgcc >= 4.4.7-4.el6 for package: gcc-4.4.7-4.el6.i686 --> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-4.el6.i686 --> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-4.el6.i686 --> Running transaction check ---> Package cloog-ppl.i686 0:0.15.7-1.2.el6 will be installed --> Processing Dependency: libppl_c.so.2 for package: cloog-ppl-0.15.7-1.2.el6.i686 --> Processing Dependency: libppl.so.7 for package: cloog-ppl-0.15.7-1.2.el6.i686 ---> Package cpp.i686 0:4.4.7-4.el6 will be installed --> Processing Dependency: libmpfr.so.1 for package: cpp-4.4.7-4.el6.i686 ---> Package glibc-devel.i686 0:2.12-1.132.el6 will be installed --> Processing Dependency: glibc-headers = 2.12-1.132.el6 for package: glibc-devel-2.12-1.132.el6.i686 --> Processing Dependency: glibc = 2.12-1.132.el6 for package: glibc-devel-2.12-1.132.el6.i686 --> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.132.el6.i686 ---> Package libgcc.i686 0:4.4.6-4.el6 will be updated ---> Package libgcc.i686 0:4.4.7-4.el6 will be an update ---> Package libgomp.i686 0:4.4.6-4.el6 will be updated ---> Package libgomp.i686 0:4.4.7-4.el6 will be an update --> Running transaction check ---> Package glibc.i686 0:2.12-1.80.el6 will be updated --> Processing Dependency: glibc = 2.12-1.80.el6 for package: glibc-common-2.12-1.80.el6.i686 ---> Package glibc.i686 0:2.12-1.132.el6 will be an update ---> Package glibc-headers.i686 0:2.12-1.132.el6 will be installed --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.132.el6.i686 --> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.132.el6.i686 ---> Package mpfr.i686 0:2.4.1-6.el6 will be installed ---> Package ppl.i686 0:0.10.2-11.el6 will be installed --> Running transaction check ---> Package glibc-common.i686 0:2.12-1.80.el6 will be updated ---> Package glibc-common.i686 0:2.12-1.132.el6 will be an update ---> Package kernel-headers.i686 0:2.6.32-431.3.1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: gcc i686 4.4.7-4.el6 base 8.2 M Installing for dependencies: cloog-ppl i686 0.15.7-1.2.el6 base 93 k cpp i686 4.4.7-4.el6 base 3.4 M glibc-devel i686 2.12-1.132.el6 base 978 k glibc-headers i686 2.12-1.132.el6 base 616 k kernel-headers i686 2.6.32-431.3.1.el6 updates 2.8 M mpfr i686 2.4.1-6.el6 base 153 k ppl i686 0.10.2-11.el6 base 1.3 M Updating for dependencies: glibc i686 2.12-1.132.el6 base 4.3 M glibc-common i686 2.12-1.132.el6 base 14 M libgcc i686 4.4.7-4.el6 base 112 k libgomp i686 4.4.7-4.el6 base 121 k Transaction Summary ================================================================================ Install 8 Package(s) Upgrade 4 Package(s) Total download size: 36 M Is this ok [y/N]: y Downloading Packages: (1/12): cloog-ppl-0.15.7-1.2.el6.i686.rpm | 93 kB 00:00 (2/12): cpp-4.4.7-4.el6.i686.rpm | 3.4 MB 00:58 (3/12): gcc-4.4.7-4.el6.i686.rpm | 8.2 MB 02:20 (4/12): glibc-2.12-1.132.el6.i686.rpm | 4.3 MB 00:57 (5/12): glibc-common-2.12-1.132.el6.i686.rpm | 14 MB 03:39 (6/12): glibc-devel-2.12-1.132.el6.i686.rpm | 978 kB 00:14 (7/12): glibc-headers-2.12-1.132.el6.i686.rpm | 616 kB 00:07 (8/12): kernel-headers-2.6.32-431.3.1.el6.i686.rpm | 2.8 MB 00:38 (9/12): libgcc-4.4.7-4.el6.i686.rpm | 112 kB 00:01 (10/12): libgomp-4.4.7-4.el6.i686.rpm | 121 kB 00:01 (11/12): mpfr-2.4.1-6.el6.i686.rpm | 153 kB 00:01 (12/12): ppl-0.10.2-11.el6.i686.rpm | 1.3 MB 00:16 -------------------------------------------------------------------------------- Total 66 kB/s | 36 MB 09:20 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : kernel-headers-2.6.32-431.3.1.el6.i686 1/16 Updating : libgcc-4.4.7-4.el6.i686 2/16 Updating : glibc-common-2.12-1.132.el6.i686 3/16 Updating : glibc-2.12-1.132.el6.i686 4/16 Installing : glibc-headers-2.12-1.132.el6.i686 5/16 Installing : glibc-devel-2.12-1.132.el6.i686 6/16 Installing : ppl-0.10.2-11.el6.i686 7/16 Installing : cloog-ppl-0.15.7-1.2.el6.i686 8/16 Installing : mpfr-2.4.1-6.el6.i686 9/16 Installing : cpp-4.4.7-4.el6.i686 10/16 Updating : libgomp-4.4.7-4.el6.i686 11/16 Installing : gcc-4.4.7-4.el6.i686 12/16 Cleanup : libgomp-4.4.6-4.el6.i686 13/16 Cleanup : glibc-common-2.12-1.80.el6.i686 14/16 Cleanup : glibc-2.12-1.80.el6.i686 15/16 Cleanup : libgcc-4.4.6-4.el6.i686 16/16 Verifying : glibc-devel-2.12-1.132.el6.i686 1/16 Verifying : ppl-0.10.2-11.el6.i686 2/16 Verifying : kernel-headers-2.6.32-431.3.1.el6.i686 3/16 Verifying : gcc-4.4.7-4.el6.i686 4/16 Verifying : glibc-headers-2.12-1.132.el6.i686 5/16 Verifying : libgcc-4.4.7-4.el6.i686 6/16 Verifying : glibc-2.12-1.132.el6.i686 7/16 Verifying : mpfr-2.4.1-6.el6.i686 8/16 Verifying : libgomp-4.4.7-4.el6.i686 9/16 Verifying : glibc-common-2.12-1.132.el6.i686 10/16 Verifying : cpp-4.4.7-4.el6.i686 11/16 Verifying : cloog-ppl-0.15.7-1.2.el6.i686 12/16 Verifying : libgcc-4.4.6-4.el6.i686 13/16 Verifying : libgomp-4.4.6-4.el6.i686 14/16 Verifying : glibc-common-2.12-1.80.el6.i686 15/16 Verifying : glibc-2.12-1.80.el6.i686 16/16 Installed: gcc.i686 0:4.4.7-4.el6 Dependency Installed: cloog-ppl.i686 0:0.15.7-1.2.el6 cpp.i686 0:4.4.7-4.el6 glibc-devel.i686 0:2.12-1.132.el6 glibc-headers.i686 0:2.12-1.132.el6 kernel-headers.i686 0:2.6.32-431.3.1.el6 mpfr.i686 0:2.4.1-6.el6 ppl.i686 0:0.10.2-11.el6 Dependency Updated: glibc.i686 0:2.12-1.132.el6 glibc-common.i686 0:2.12-1.132.el6 libgcc.i686 0:4.4.7-4.el6 libgomp.i686 0:4.4.7-4.el6 Complete!
YUM查询
yum search keyword : 搜索包含该关键字的rpm包[root@wuqinfei yum.repos.d]# yum search gcc Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn =============================== N/S Matched: gcc =============================== compat-libgcc-296.i686 : Compatibility 2.96-RH libgcc library gcc-c++.i686 : C++ support for GCC gcc-gnat.i686 : Ada 95 support for GCC gcc-java.i686 : Java support for GCC gcc-objc.i686 : Objective-C support for GCC gcc-objc++.i686 : Objective-C++ support for GCC libgcc.i686 : GCC version 4.4 shared support library compat-gcc-34.i686 : Compatibility GNU Compiler Collection compat-gcc-34-c++.i686 : C++ support for compatibility compiler compat-gcc-34-g77.i686 : Fortran 77 support for compatibility compiler gcc.i686 : Various compilers (C, C++, Objective-C, Java, ...) gcc-gfortran.i686 : Fortran support libgcj.i686 : Java runtime library for gcc libgcj-devel.i686 : Libraries for Java development using GCC libgcj-src.i686 : Java library sources from GCC4 preview libgomp.i686 : GCC OpenMP v3.0 shared support library libmudflap.i686 : GCC mudflap shared support library libmudflap-devel.i686 : GCC mudflap support Name and summary matches only, use "search all" for everything.
yum list (all | installed | recent | updates)
列出 所有的/已安装的/最近的/更新的
yum info packagename : 显示指定软件的信息
[root@wuqinfei yum.repos.d]# yum info gcc.i686 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn Available Packages Name : gcc Arch : i686 Version : 4.4.7 Release : 4.el6 Size : 8.2 M Repo : base Summary : Various compilers (C, C++, Objective-C, Java, ...) URL : http://gcc.gnu.org License : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions Description : The gcc package contains the GNU Compiler Collection version 4.4. : You'll need this package in order to compile C code.
yum whatprovides filename : 查询包含指定文件的rpm软件
创建yum仓库
1) 将所有rpm文件拷贝到 仓库(某个目录)2) 安装 createrepo 软件(通过rpm命令)
3) 运行 createrepo命令
作用: 创建repodata目录, 存放索引文件
createrepo -v /rpm-directory
4) 注: 如果有分组信息, 则在运行命令时使用 "-g" 来指定分组文件
createrepo -g /tmp/*comps.xml/rpm-directory
CentOS/RHEL的分组信息保存于光盘 repodata/目录下
文件名以 "comps.xml"结尾的xml文件
5) 使用
本地 : FILE协议
网路 : HTTP FTP NFS
示例
1) 查看 CentOS_6.3 光盘中的 仓库Packages(所有rpm包)
2) 创建本地仓库目录"/wuqinfei-yum-repo", 并将 Packages中的rpm包考进来
3) 安装 createrepo软件
[root@wuqinfei ~]# yum search createrepo Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn =========================== N/S Matched: createrepo ============================ createrepo.noarch : Creates a common metadata repository Name and summary matches only, use "search all" for everything. [root@wuqinfei ~]# yum install createrepo.noarch Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package createrepo.noarch 0:0.9.9-18.el6 will be installed --> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-18.el6.noarch --> Running transaction check ---> Package python-deltarpm.i686 0:3.5-0.5.20090913git.el6 will be installed --> Processing Dependency: deltarpm = 3.5-0.5.20090913git.el6 for package: python-deltarpm-3.5-0.5.20090913git.el6.i686 --> Running transaction check ---> Package deltarpm.i686 0:3.5-0.5.20090913git.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: createrepo noarch 0.9.9-18.el6 base 94 k Installing for dependencies: deltarpm i686 3.5-0.5.20090913git.el6 base 73 k python-deltarpm i686 3.5-0.5.20090913git.el6 base 27 k Transaction Summary ================================================================================ Install 3 Package(s) Total download size: 195 k Installed size: 522 k Is this ok [y/N]: y Downloading Packages: (1/3): createrepo-0.9.9-18.el6.noarch.rpm | 94 kB 00:00 (2/3): deltarpm-3.5-0.5.20090913git.el6.i686.rpm | 73 kB 00:00 (3/3): python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm | 27 kB 00:00 -------------------------------------------------------------------------------- Total 97 kB/s | 195 kB 00:02 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : deltarpm-3.5-0.5.20090913git.el6.i686 1/3 Installing : python-deltarpm-3.5-0.5.20090913git.el6.i686 2/3 Installing : createrepo-0.9.9-18.el6.noarch 3/3 Verifying : createrepo-0.9.9-18.el6.noarch 1/3 Verifying : python-deltarpm-3.5-0.5.20090913git.el6.i686 2/3 Verifying : deltarpm-3.5-0.5.20090913git.el6.i686 3/3 Installed: createrepo.noarch 0:0.9.9-18.el6 Dependency Installed: deltarpm.i686 0:3.5-0.5.20090913git.el6 python-deltarpm.i686 0:3.5-0.5.20090913git.el6 Complete!
4) 创建索引文件 : createrepo /wuqinfei-yum-repo
5) 在 "/etc/yum.repos.d"目录下 创建 "wuqinfei.repo"配置文件
[wuqinfei]
name = my repository
baseurl = file:///wuqinfei-yum-repo/
6) 清除缓存: yum clean all
相关文章推荐
- Linux系列-RPM软件包管理、YUM包管理
- Linux-软件包管理-yum在线管理-yum命令
- Linux常用yum命令—安装、升级、卸载、软件包查询、软件组管理命令、以及升级、卸载需要注意的问题
- Linux-软件包管理-yum在线管理-光盘yum源
- Linux(CentOS6.x)下使用yum软件管理工具安装LNMP(Nginx+PHP+Mysql)环境并配置虚拟主机vhost
- Linux 软件管理工具之rpm、yum
- Linux-软件包管理-yum在线安装rz、sz工具
- linux中软件包管理工具rpm和yum
- 运维笔记10 (Linux软件的安装与管理(rpm,yum))
- [Linux] 软件安装与管理 - rpm、yum
- Linux基础管理——软件包管理:rpm,yum高级使用方法(史上最全,没有之一)
- Linux系列教程(十二)——Linux软件包管理之yum在线管理
- Linux 八 软件管理:RPM、YUM
- linux下的软件管理(yum仓库)
- Linux 软件包管理常用命令 -- yum
- Linux学习--RPM软件包管理、YUM软件管理
- linux软件管理之rpm、yum netstat命令
- Linux软件包的管理--YUM
- Linux软件管理——yum命令详解
- Linux的软件包管理工具rpm和yum