概述
程序包管理器之RPM
一、rpm是什么
RPM 是RPM Package Manager(RPM软件包管理器)的缩写,这一文件格式名称虽然打上了RedHat的标志,但是其原始设计理念是开放式的。RPM包管理器(RPM)是一个强大的命令行驱动的包管理系统能够安装、卸载、验证、查询和更新计算机软件包。每个软件包包括存档的文件连同包和它的版本信息,描述等。还有一个库API,允许高级开发人员来管理
二、程序的组成部分
程序的组成部分:
编译之前:源代码
编译文件:
二进制程序
库文件
配置文件
帮助文件(手册、文档)
二进制程序:/bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin, /opt/bin, /opt/sbin
库文件:/lib, /lib64, /usr/lib, /usr/lib64, /usr/local/lib, /usr/local/lib64
配置文件:/etc, /etc/DIR, /usr/local/{etc,conf}
帮助文件:/usr/share/man, /usr/share/doc, /usr/local/share/man
注意:有些特殊的应用程序可能会将可执行文件放置在libexec目录;
三、rpm包命名格式:
rpm包命名格式:
appname-VERSION-RELEASE.ARCH.rpm
VERSION:
major:主版本号
minor:此版本号
release:发行号
RELEASE:包自身的修订号:有时候还会包含适用于os信息:比如bash-4.3.2-2.centos.x86_64.rpm
ARCH:适用的平台
x86:i386,i486,i586,i686
x86_64,adm64:x86 64bits
powerpc:ppc
noarch:跟平台无关
四、分包机制
想象一种场景:testapp有30种功能,其中有10种常用,有6次常用,余下的14种极少用;所以rpm包制作者会把一个程序的每个功能制作成一个rpm包,他们都依赖主包。
例如:
核心包,主包:命名与原项目名称一致;
bash-4.3.2-2.centos6.x86_64.rpm
子包(支包):命令为源项目名称后附加分支包中的文件提供的功能组成;
bash-devel-4.3.2-2.centos6.x86_64.rpm
程序包的获取路径:
1、系统的发行光盘镜像或官方站点(或站点镜像服务器)
挂载光盘:
mount -r /dev/cdrom /media/cdrom
官方站点,镜像:
mirrors.sohu.com
mirrors.163.com
mirrors.aliyun.com
2、程序包的官方站点
3、第三方组织:epel
4、搜索引擎
http://rpmfind.net
http://rpm.pbone.net
http://pkgs.org
建议:安装之前要验正的其合法性
来源合法
包的完整性
五、centos系统上的程序rpm包管理
安装、升级、卸载、查询、校验
5.1 安装
rpm {-i|--install} [install-options] PACKAGE_FILE1..
# rpm -i zsh-4.3.10-7.el6.x86_64.rpm # rpm -q zsh #rpm -q为查询次包是否安装,在后面的查询中会讲到。 zsh-4.3.10-7.el6.x86_64
-h:hash, 以#来表示安装进度
# rpm -ih zsh-4.3.10-7.el6.x86_64.rpm ########################################### [100%] ########################################### [100%]
-v,--verbose:显示安装过程中的详细信息
# rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm Preparing... ########################################### [100%] 1:zsh ########################################### [100%]
-vv:显示更多的详细信息
# rpm -ivvh zsh-4.3.10-7.el6.x86_64.rpm
安装时常用的组合:-ivh,-ivvh
--test:不执行真正的安装过程,而仅报告依赖关系及冲突
# rpm -ivh --test zsh-4.3.10-7.el6.x86_64.rpm Preparing... ########################################### [100%]
程序包之间存在依赖关系
由众多目的单一的小程序组成:结果程序包之间存在相关性;
--nodeps:忽略依赖关系:副作用:安装成功,但未必能够成功运行
# rpm -ivh php-5.3.3-38.el6.x86_64.rpm error: Failed dependencies: php-cli(x86-64) = 5.3.3-38.el6 is needed by php-5.3.3-38.el6.x86_64 php-common(x86-64) = 5.3.3-38.el6 is needed by php-5.3.3-38.el6.x86_64 # rpm -ivh --nodeps php-5.3.3-38.el6.x86_64.rpm Preparing... ########################################### [100%] 1:php ########################################### [100%]
--replacepkgs:覆盖安装:重新安装并覆盖原有的文件
# rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm Preparing... ########################################### [100%] package zsh-4.3.10-7.el6.x86_64 is already installed # rpm -ivh --replacepkgs zsh-4.3.10-7.el6.x86_64.rpm Preparing... ########################################### [100%] 1:zsh ########################################### [100%]
--force:强制安装
# rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm Preparing... ########################################### [100%] package zsh-4.3.10-7.el6.x86_64 is already installed # rpm -ivh --force zsh-4.3.10-7.el6.x86_64.rpm Preparing... ########################################### [100%] 1:zsh ########################################### [100%]
5.2 升级
-U:升级或安装
# rpm -q zsh zsh-4.3.10-7.el6.x86_64 # rpm -Uvh --nodeps zsh-5.1.1-3.fc24.x86_64.rpm warning: zsh-5.1.1-3.fc24.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 81b46521: NOKEY Preparing... ########################################### [100%] 1:zsh ########################################### [100%] # 此处使用--nodeps的原因是这个版本需要很多依赖关系,所以忽略依赖关系,在生产环境中升级需要安装依赖关系后在升级。
-F:升级
组合:-Uvh,-Fvh
--test
--nodeps
--force
--oldpackage:降级到旧版本;
# rpm -q zsh zsh-5.1.1-3.fc24.x86_64 # rpm -Uvh --oldpackage /misc/cd/Packages/zsh-4.3.10-7.el6.x86_64.rpm Preparing... ########################################### [100%] 1:zsh ########################################### [100%] # rpm -q zsh zsh-4.3.10-7.el6.x86_64
注意:一定不要对内核升级:Linux允许多内核共存,所以可以直接安装多个不同版本内核;
注意:如果程序包的配置文件安装后曾被修改,升级时,新版本的文件不会覆盖老版本的配置文件,而把新版本的配置文件重命名(加后缀.rpmnew)后保存
5.3 卸载
rpm {-e|--erase} [--allmatches] [--nodeps] [--test]
简单用法:rpm -e PACKAGE_NAME...
# rpm -q zsh zsh-4.3.10-7.el6.x86_64 # rpm -e zsh # rpm -q zsh package zsh is not installed
--nodeps:忽略依赖关系;
--test: 测试卸载;dry-run模式;
--allmatches: 如果一个程序包同时安装多个版本,则此选项一次全部卸载之;
注意:如果程序包的配置文件安装后曾被修改,卸载时,此文件通常不会被删除,而是被重命名(加后缀.rpmsave)后留存;
5.4 查询
rpm {-q|--query} [select-options] [query-options]
[select-options]
1、查询某包或某些包是否安装:
rpm -q PACKAGE_NAME
# rpm -q zsh zsh-5.1.1-3.fc24.x86_64
2、查询已经安装的所有包
rpm -qa PACKAGE_NAME
# rpm -qa zsh zsh-5.1.1-3.fc24.x86_64 # 或者,grep后面支持正则表达式过滤 # rpm -qa |grep "zhs"
3、查询某文件是由哪个包安装生成:
rpm -qf /PATH/TO/SOMEFILE
# rpm -qf /etc/fstab setup-2.8.14-20.el6_4.1.noarch # rpm -qf /etc/httpd/conf/httpd.conf httpd-2.2.15-39.el6.centos.x86_64
4、查询尚未安装的包文件的相关信息
-p
# rpm -qpi PACKAGE_NAME
# rpm -qpi gcc-4.4.7-11.el6.x86_64.rpm Name : gcc Relocations: (not relocatable) Version : 4.4.7 Vendor: CentOS Release : 11.el6 Build Date: 2014年10月15日 星期三 08时24分47秒 Install Date: (not installed) Build Host: c6b9.bsys.dev.centos.org Group : Development/Languages Source RPM: gcc-4.4.7-11.el6.src.rpm Size : 19495803 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions Signature : RSA/SHA1, 2014年10月18日 星期六 04时02分58秒, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://gcc.gnu.org Summary : Various compilers (C, C++, Objective-C, Java, ...) Description : The gcc package contains the GNU Compiler Collection version 4.4. You'll need this package in order to compile C code.
[query-options]:
1、查询某包的简要说明信息:
rpm -qi PACKAGE_NAME
# rpm -qi zsh Name : zsh Relocations: (not relocatable) Version : 5.1.1 Vendor: Fedora Project Release : 3.fc24 Build Date: 2015年11月05日 星期四 21时41分02秒 Install Date: 2015年11月19日 星期四 15时20分55秒 Build Host: buildvm-26.phx2.fedoraproject.org Group : System Environment/Shells Source RPM: zsh-5.1.1-3.fc24.src.rpm Size : 6474662 License: MIT Signature : RSA/8, 2015年11月05日 星期四 21时56分22秒, Key ID 73bde98381b46521 Packager : Fedora Project URL : http://zsh.sourceforge.net/ Summary : 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.
2、查询某包安装后生成了哪些文件列表;
rpm -ql PACKAGE_NAME
# rpm -ql zsh|less /etc/skel/.zshrc /etc/zlogin /etc/zlogout /etc/zprofile /etc/zshenv /etc/zshrc /usr/bin/zsh /usr/lib64/zsh /usr/lib64/zsh/5.1.1 /usr/lib64/zsh/5.1.1/zsh /usr/lib64/zsh/5.1.1/zsh/attr.so /usr/lib64/zsh/5.1.1/zsh/cap.so ......
3、查询某包安装后生成的配置文件路径
rpm -qc PACKAGE_NAME
# rpm -qc zsh /etc/skel/.zshrc /etc/zlogin /etc/zlogout /etc/zprofile /etc/zshenv /etc/zshrc
4、查询某包安装后生成的所有帮助文件
rpm -qd PACKAGE_NAME
# rpm -qd zsh /usr/share/doc/zsh/BUGS /usr/share/doc/zsh/CONTRIBUTORS /usr/share/doc/zsh/FAQ /usr/share/doc/zsh/FEATURES /usr/share/doc/zsh/LICENCE /usr/share/doc/zsh/MACHINES /usr/share/doc/zsh/NEWS /usr/share/doc/zsh/README /usr/share/doc/zsh/completion-style-guide /usr/share/doc/zsh/zsh-development-guide /usr/share/doc/zsh/zshprompt.pl /usr/share/info/zsh.info-1.gz /usr/share/info/zsh.info-2.gz /usr/share/info/zsh.info-3.gz /usr/share/info/zsh.info-4.gz /usr/share/info/zsh.info-5.gz ....
5、查看某包制作时随版本变化的changelog信息;
rpm-q --changelog PACKAGE_NAME
# rpm -q --changelog zsh * 四 11月 05 2015 Kamil Dudka <kdudka@redhat.com> - 5.1.1-3 - make loading of module's dependencies work again (#1277996) * 四 10月 08 2015 Kamil Dudka <kdudka@redhat.com> - 5.1.1-2 - fix crash in ksh mode with -n and $HOME (#1269883) * 一 9月 14 2015 Kamil Dudka <kdudka@redhat.com> - 5.1.1-1 - Update to latest upstream release: Zsh 5.1.1 * 一 8月 31 2015 Kamil Dudka <kdudka@redhat.com> - 5.1-1 - Update to latest upstream release: Zsh 5.1 - remove outdated workarounds in %check * 四 7月 30 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.8-6 - fix handling of command substitution in math context * 三 7月 22 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.8-5 - prevent infinite recursion in ihungetc() (#1245712) * 二 7月 07 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.8-4 - backport completion for dnf (#1239337) * 四 7月 02 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.8-3 - backport completion-related upstream fixes (#1238544) * 五 6月 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.0.8-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild * 三 6月 03 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.8-1 - Update to latest upstream release: Zsh 5.0.8 * 五 5月 22 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.7-8 - fix SIGSEGV of the syntax check in ksh emulation mode (#1222867) * 一 4月 20 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.7-7 - fix SIGSEGV when handling heredocs and keyboard interrupt (#972624) - queue signals when manipulating global state to avoid deadlock * 日 1月 25 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.7-6 - use correct allocation function in the new 'cd' code (#1183238) * 五 1月 23 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.7-5 - suppress a warning about closing an already closed file descriptor (#1184002) - improve handling of NULL in the 'cd' built-in (#1183238) * 三 11月 19 2014 Kamil Dudka <kdudka@redhat.com> - 5.0.7-4 - update documentation of POSIX_JOBS in the zshoptions.1 man page (#1162198) * 二 11月 18 2014 Kamil Dudka <kdudka@redhat.com> - 5.0.7-3 - replace an incorrect comment in /etc/zshenv (#1164313) * 一 11月 10 2014 Kamil Dudka <kdudka@redhat.com> - 5.0.7-2 - make the wait built-in work for already exited processes (#1162198) * 三 10月 08 2014 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.7-1 - Update to latest upstream release: Zsh 5.0.7 * 四 8月 28 2014 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.6-1 - Update to latest upstream release: Zsh 5.0.6 * 一 8月 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.0.5-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild * 四 7月 17 2014 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.5-7 - apply upstream patch which fixes CPU load issue (RHBZ#1120424) * 三 7月 09 2014 Adam Jackson <ajax@redhat.com> 5.0.5-6 - Fix missing 'fi' in %post * 四 7月 03 2014 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.5-5 - improve handling of /etc/shells * 三 7月 02 2014 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.5-4 - fix FTBFS issue (RHBZ#1106713) - remove individual _bindir setting; install to /usr/bin/ (RHBZ#1034060) - require info package instead of /sbin/install-info binary * 六 6月 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.0.5-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild * 二 4月 08 2014 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.5-1 - Update to latest upstream release: Zsh 5.0.5 * 四 1月 16 2014 James Antill <james@fedoraproject.org> - 5.0.2-8 - Remove unneeded build require on tetex. * 六 10月 26 2013 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.2-7 - Require hostname package instead of /bin/hostname * 二 10月 22 2013 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.2-6 - remove systemd completion, it delivers it's own now (RHBZ#1022039) * 四 8月 01 2013 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.2-5 - update systemd completion (adds machinectl command) * 二 6月 25 2013 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.2-4 - up-to-date systemd completion (#949003) - apply patch for building for aarch64 (#926864) * 一 4月 15 2013 James Antill <james@fedoraproject.org> - 5.0.2-3 - Fix the changelog dates. - Fix the texi itemx bug. - Resolves: bug#927863 * 五 2月 15 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.0.2-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild * 二 1月 08 2013 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.2-1 - Update to new upstream version: Zsh 5.0.2 * 三 11月 21 2012 Dominic Hopf <dmaphy@fedoraproject.org> - 5.0.0-1 - Update to new upstream version: Zsh 5.0.0 * 日 7月 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.3.17-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild * 日 3月 04 2012 Dominic Hopf <dmaphy@fedoraproject.org> - 4.3.17-1 - Update to new upstream version: Zsh 4.3.17 * 六 1月 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.3.15-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild * 六 12月 24 2011 Dominic Hopf <dmaphy@fedoraproject.org> - 4.3.15-1 - Update to new upstream version: Zsh 4.3.15 * 六 12月 17 2011 Dominic Hopf <dmaphy@fedoraproject.org> - 4.3.14-2 - change the License field to MIT (RHBZ#768548) * 六 12月 10 2011 Dominic Hopf <dmaphy@fedoraproject.org> - 4.3.14-1 - Update to new upstream version: Zsh 4.3.14 * 六 12月 03 2011 Dominic Hopf <dmaphy@fedoraproject.org> - 4.3.13-1 - Update to new upstream version: Zsh 4.3.13 * 六 8月 13 2011 Dominic Hopf <dmaphy@fedoraproject.org> - 4.3.12-1 - Update to new upstream version: Zsh 4.3.12 * 二 2月 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.3.11-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild * 四 1月 20 2011 Christopher Ailon <caillon@redhat.com> - 4.3.11-1 - Rebase to upstream version 4.3.11 * 二 12月 07 2010 Toshio Kuratomi <toshio@fedoraproject.org> - 4.3.10-6 - Rebuild for FTBFS https://bugzilla.redhat.com/show_bug.cgi?id=631197 - Remove deprecated PreReq, the packages aren't needed at runtime and they're already in Requires(post,preun,etc): lines. * 一 3月 22 2010 James Antill <james@fedoraproject.org> - 4.3.10-5 - Add pathmunge to our /etc/zshrc, for profile.d compat. - Resolves: bug#548960 * 五 8月 07 2009 James Antill <james@fedoraproject.org> - 4.3.10-4 - Allow --excludedocs command to work! - Resolves: bug#515986 * 一 7月 27 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.3.10-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild * 一 7月 20 2009 James Antill <james@fedoraproject.org> - 4.3.10-1 - Import new upstream 4.3.10 * 三 6月 10 2009 Karsten Hopp <karsten@redhat.com> 4.3.9-4.1 - skip D02glob test on s390, too * 一 3月 02 2009 James Antill <james@fedoraproject.org> - 4.3.9-4 - Remove D02glob testcase on ppc/ppc64, and hope noone cares * 三 2月 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.3.9-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
6、查询某包提供的capabilities;
rpm -q --provides PACKAGE_NAME;
# rpm -q --provides zsh /bin/zsh config(zsh) = 5.1.1-3.fc24 zsh = 5.1.1-3.fc24 zsh(x86-64) = 5.1.1-3.fc24
7、查询某包所依赖的capabilities;
rpm -q --requires PACKAGE_NAME
# rpm -q --requires zsh /bin/sh /bin/sh /bin/sh /bin/sh /bin/zsh config(zsh) = 5.1.1-3.fc24 coreutils grep grep info info libc.so.6()(64bit) libc.so.6(GLIBC_2.11)(64bit) libc.so.6(GLIBC_2.14)(64bit) libc.so.6(GLIBC_2.15)(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.3)(64bit) libc.so.6(GLIBC_2.3.4)(64bit) libc.so.6(GLIBC_2.4)(64bit) libc.so.6(GLIBC_2.7)(64bit) libdl.so.2()(64bit) libdl.so.2(GLIBC_2.2.5)(64bit) libm.so.6()(64bit) libm.so.6(GLIBC_2.2.5)(64bit) libncursesw.so.6()(64bit) librt.so.1()(64bit) librt.so.1(GLIBC_2.2.5)(64bit) libtinfo.so.6()(64bit) rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(PayloadIsXz) <= 5.2-1 rtld(GNU_HASH)
8、查询某包安装或卸载时执行脚本;
rpm -q --scripts PACKAGE_NAME
# rpm -q --scripts zsh postinstall scriptlet (using /bin/sh): if [ "$1" = 1 ]; then if [ ! -f /etc/shells ] ; then echo "/usr/bin/zsh" > /etc/shells echo "/bin/zsh" >> /etc/shells else grep -q "^/usr/bin/zsh$" /etc/shells || echo "/usr/bin/zsh" >> /etc/shells grep -q "^/bin/zsh$" /etc/shells || echo "/bin/zsh" >> /etc/shells fi fi if [ -f /usr/share/info/zsh.info.gz ]; then # This is needed so that --excludedocs works. /sbin/install-info /usr/share/info/zsh.info.gz /usr/share/info/dir --entry="* zsh: (zsh). An enhanced bourne shell." fi preuninstall scriptlet (using /bin/sh): if [ "$1" = 0 ] ; then if [ -f /usr/share/info/zsh.info.gz ]; then # This is needed so that --excludedocs works. /sbin/install-info --delete /usr/share/info/zsh.info.gz /usr/share/info/dir --entry="* zsh: (zsh). An enhanced bourne shell." fi fi postuninstall scriptlet (using /bin/sh): if [ "$1" = 0 ] && [ -f /etc/shells ] ; then sed -i '!^/usr/bin/zsh$!d' /etc/shells sed -i '!^/bin/zsh$!d' /etc/shells fi
脚本有四类:
preinstall:安装过程开始之前执行的脚本;
postinstall:安装过程后执行的脚本;
preuninstall:卸载前执行的脚本;
postuninstall:卸载过程完成之后执行的脚本;
5.5 校验
查询包安装之后生成的文件是否发生了改变
rpm {-V|--verify} [select-options] [verify-options]
# rpm -V zsh S.5....T. c /etc/zshrc
常见用法:rpm -V PACKAGE_NAME
S file Size differs
M Mode differs (includes permissions and file type)
5 digest (formerly MD5 sum) differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs
P caPabilities differ
程序包的合法性验正:
来源合法:
由我们信任的制作者提供
依赖于:制作者的数字签名;签名是作者使用自己的私钥加密程序包的特性码进行的;
内容合法:
包未被二次修改;完整性校验成功
依赖于:制作者提供的程序特征码;
验正方式:安装者用同样的特征码提取算法提取程序包的特征码,并与原作者提供的相比较;
验正其光盘中程序包的来源及完整性:
rpm --import /path/to/RPM-GPG-KEY-FILE
例如:# rpm --import RPM-GPG-KEY-CentOS-6
验正:rpm {-K|--checksig} PACKAGE_FILE
# rpm --import /misc/cd/RPM-GPG-KEY-CentOS-6 # rpm -K zsh-4.3.10-7.el6.x86_64.rpm zsh-4.3.10-7.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK # rpm -K php-5.3.3-38.el6.x86_64.rpm php-5.3.3-38.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
--nosignature: 不检查来源合法性
--nodigest: 不检查完整性
rpm管理器数据库:/var/lib/rpm
重建数据库:
rpm {--initdb|--rebuilddb} [-v] [--dbpath DIRECTORY]
--initdb: 初始化数据库,即数据库完全不存时,可新建之;
例如:
我删除__db.001、__db.002、__db.003、__db.004
# rm -rf /var/lib/rpm/__db.00{1..4} # ll /var/lib/rpm/ 总用量 57208 -rw-r--r--. 1 root root 5083136 11月 19 15:32 Basenames -rw-r--r--. 1 root root 12288 11月 10 15:20 Conflictname -rw-r--r--. 1 root root 1044480 11月 19 15:32 Dirnames -rw-r--r--. 1 root root 5263360 11月 19 15:32 Filedigests -rw-r--r--. 1 root root 20480 11月 19 15:32 Group -rw-r--r--. 1 root root 20480 11月 19 15:32 Installtid -rw-r--r--. 1 root root 49152 11月 19 15:32 Name -rw-r--r--. 1 root root 24576 11月 19 15:07 Obsoletename -rw-r--r--. 1 root root 46825472 11月 19 15:32 Packages -rw-r--r--. 1 root root 1343488 11月 19 15:32 Providename -rw-r--r--. 1 root root 696320 11月 19 15:32 Provideversion -rw-r--r--. 1 root root 12288 11月 16 15:07 Pubkeys -rw-r--r--. 1 root root 446464 11月 19 15:32 Requirename -rw-r--r--. 1 root root 253952 11月 19 15:32 Requireversion -rw-r--r--. 1 root root 90112 11月 19 15:32 Sha1header -rw-r--r--. 1 root root 86016 11月 19 15:32 Sigmd5 -rw-r--r--. 1 root root 12288 11月 10 15:20 Triggername # rpm --initdb /var/lib/rpm/ # ll /var/lib/rpm/ 总用量 58048 -rw-r--r--. 1 root root 5083136 11月 19 15:32 Basenames -rw-r--r--. 1 root root 12288 11月 10 15:20 Conflictname -rw-r--r-- 1 root root 24576 11月 19 15:38 __db.001 -rw-r--r-- 1 root root 229376 11月 19 15:38 __db.002 -rw-r--r-- 1 root root 1318912 11月 19 15:38 __db.003 -rw-r--r-- 1 root root 753664 11月 19 15:38 __db.004 -rw-r--r--. 1 root root 1044480 11月 19 15:32 Dirnames -rw-r--r--. 1 root root 5263360 11月 19 15:32 Filedigests -rw-r--r--. 1 root root 20480 11月 19 15:32 Group -rw-r--r--. 1 root root 20480 11月 19 15:32 Installtid -rw-r--r--. 1 root root 49152 11月 19 15:32 Name -rw-r--r--. 1 root root 24576 11月 19 15:07 Obsoletename -rw-r--r--. 1 root root 46825472 11月 19 15:32 Packages -rw-r--r--. 1 root root 1343488 11月 19 15:32 Providename -rw-r--r--. 1 root root 696320 11月 19 15:32 Provideversion -rw-r--r--. 1 root root 12288 11月 16 15:07 Pubkeys -rw-r--r--. 1 root root 446464 11月 19 15:32 Requirename -rw-r--r--. 1 root root 253952 11月 19 15:32 Requireversion -rw-r--r--. 1 root root 90112 11月 19 15:32 Sha1header -rw-r--r--. 1 root root 86016 11月 19 15:32 Sigmd5 -rw-r--r--. 1 root root 12288 11月 10 15:20 Triggername
--rebuilddb: 无论当前数据存在与否,都会直接重建此库;
程序包管理器之yum
一、yum是什么?
Yum(全称为 Yellow dog Updater, Modified)是在Fedora和RedHat以及SUSE中基于rpm的软件包管理器,为了解决依赖关系而生,其基于rpm所管理程序包,即管理rpm程序包,可以一次安装所需包的所有依赖包,无需繁琐地一次次下载、安装。
二、yum的组成
yum在安装时通过一个配置文件来管理,我们把每个配置文件中可以指向不同yum源的每个[main]叫做一个yum仓库,而yum源是一个路径,路径可以指向http://,ftp://,nfs://,file:///等等。
1、配置文件
/etc/yum.conf 提供yum仓库的公共配置
/etc/yum.repos.d/*.repo 为仓库的指向提供配置
2、yum仓库
[repositoryID] # yum仓库的名字,可以自定义
name=Some name for this repository # 对yum仓库的描述
baseurl=url://path/to/repository/ # yum源的路径
enabled={1|0} # 是否启用次yum仓库,默认为启用
gpgcheck={1|0} # 是否检查其来源合法性
gpgkey=URL # 指定key路径,用来检查来源合法性使用
enablegroups={1|0}
failovermethod={roundrobin|priority} # 使用yum仓库时,采用那种方式优先选择,默认为:roundrobin,意为随机挑选;
例子:
[base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
3、常见yum源及epel源
选择yum源时应使用多个yum源,以保证冗余性,并且已下载速度快的为首选,下面介绍几个国内比较快的yum源。
http://fedoraproject.org/wiki/EPEL
http://mirrors.aliyun.com/
http://mirrors.sohu.com/
http://mirrors.163.com/
http://mirrors.ustc.edu.cn/fedora/epel/
三、yum命令
yum [options] [command] [package ...]
OPTIONS:
a、安装
install package1 [package2] [...]
# yum install httpd -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-40.el7.centos will be installed --> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos for package: httpd-2.4.6-40.el7.centos.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos will be installed ................ Installed: httpd.x86_64 0:2.4.6-40.el7.centos Dependency Installed: apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-40.el7.centos Complete! # rpm -q httpd httpd-2.4.6-40.el7.centos.x86_64
reinstall package1 [package2] [...] (重新安装)
# 次处与安装没有不同,不做演示,一般用于程序出问题时使用,次处重新安装时不会重新覆盖配置文件。
b、查看
repolist:显示当前系统上仓库列表
# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com repo id repo name status base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 9,007 extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 226 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 940 repolist: 10,173
list:显示仓库中所有程序包
# yum list Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Installed Packages GConf2.x86_64 3.2.6-8.el7 @anaconda ModemManager.x86_64 1.1.0-6.git20130913.el7 @anaconda ModemManager-glib.x86_64 1.1.0-6.git20130913.el7 @anaconda NetworkManager.x86_64 1:1.0.0-14.git20150121.b4ea599c.el7 @anaconda NetworkManager-adsl.x86_64 1:1.0.0-14.git20150121.b4ea599c.el7 @anaconda NetworkManager-bluetooth.x86_64 1:1.0.0-14.git20150121.b4ea599c.el7 @anaconda NetworkManager-glib.x86_64 1:1.0.0-14.git20150121.b4ea599c.el7 @anaconda NetworkManager-libnm.x86_64 1:1.0.0-14.git20150121.b4ea599c.el7 @anaconda NetworkManager-team.x86_64 1:1.0.0-14.git20150121.b4ea599c.el7 @anaconda OpenIPMI-libs.i686 2.0.19-11.el7 base OpenIPMI-libs.x86_64 2.0.19-11.el7 base OpenIPMI-modalias.x86_64 2.0.19-11.el7 base OpenIPMI-perl.x86_64 2.0.19-11.el7 base OpenIPMI-python.x86_64 2.0.19-11.el7 base PackageKit.i686 1.0.7-5.el7.centos base PackageKit.x86_64 1.0.7-5.el7.centos base PackageKit-browser-plugin.x86_64 1.0.7-5.el7.centos base PackageKit-command-not-found.x86_64 1.0.7-5.el7.centos base PackageKit-cron.x86_64 1.0.7-5.el7.centos base PackageKit-glib.i686 1.0.7-5.el7.centos base PackageKit-glib.x86_64 1.0.7-5.el7.centos base PackageKit-glib-devel.i686 1.0.7-5.el7.centos base PackageKit-glib-devel.x86_64 1.0.7-5.el7.centos base PackageKit-gstreamer-plugin.x86_64 1.0.7-5.el7.centos base PackageKit-gtk3-module.i686 1.0.7-5.el7.centos base PackageKit-gtk3-module.x86_64 1.0.7-5.el7.centos base PackageKit-hif.x86_64 1.0.7-5.el7.centos base PackageKit-yum.x86_64 1.0.7-5.el7.centos base
@anaconda:表示安装系统时安装的程序包
base:表示来自base仓库的包
info:查看程序包详细信息
# yum info httpd Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Installed Packages Name : httpd Arch : x86_64 Version : 2.4.6 Release : 40.el7.centos Size : 9.4 M Repo : installed From repo : base Summary : Apache HTTP Server URL : http://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.
provides:查看指定的特性(可以是某文件)是由哪个程序包所提供。
# yum provides /etc/passwd Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com setup-2.8.71-6.el7.noarch : A set of system configuration and setup files Repo : base Matched from: Filename : /etc/passwd setup-2.8.71-5.el7.noarch : A set of system configuration and setup files Repo : @anaconda Matched from: Filename : /etc/passwd
c、升级
check-update:检查可用升级
# yum check-update Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com ModemManager.x86_64 1.1.0-8.git20130913.el7 base ModemManager-glib.x86_64 1.1.0-8.git20130913.el7 base NetworkManager.x86_64 1:1.0.6-27.el7 base NetworkManager-adsl.x86_64 1:1.0.6-27.el7 base NetworkManager-bluetooth.x86_64 1:1.0.6-27.el7 base NetworkManager-glib.x86_64 1:1.0.6-27.el7 base NetworkManager-libnm.x86_64 1:1.0.6-27.el7 base NetworkManager-team.x86_64 1:1.0.6-27.el7 base NetworkManager-tui.x86_64 1:1.0.6-27.el7 base NetworkManager-wifi.x86_64 1:1.0.6-27.el7 base NetworkManager-wwan.x86_64 1:1.0.6-27.el7 base PackageKit-glib.x86_64 1.0.7-5.el7.centos base PackageKit-gstreamer-plugin.x86_64 1.0.7-5.el7.centos base SDL.x86_64 1.2.15-14.el7 base abattis-cantarell-fonts.noarch 0.0.16-3.el7 base abrt.x86_64 2.1.11-36.el7.centos base abrt-addon-ccpp.x86_64 2.1.11-36.el7.centos base abrt-addon-kerneloops.x86_64 2.1.11-36.el7.centos base abrt-addon-pstoreoops.x86_64 2.1.11-36.el7.centos base abrt-addon-python.x86_64 2.1.11-36.el7.centos base abrt-addon-vmcore.x86_64 2.1.11-36.el7.centos base abrt-addon-xorg.x86_64 2.1.11-36.el7.centos base abrt-cli.x86_64 2.1.11-36.el7.centos base samba-client.x86_64 4.2.3-12.el7_2 updates samba-common.noarch 4.2.3-12.el7_2 updates samba-libs.x86_64 4.2.3-12.el7_2 updates ...................................
update:升级
# yum update samba -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Package(s) samba available, but not installed. No packages marked for update [root@bogon conf]# yum update samba-client -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package samba-client.x86_64 0:4.1.12-21.el7_1 will be updated ---> Package samba-client.x86_64 0:4.2.3-12.el7_2 will be an update --> Processing Dependency: samba-common-libs = 4.2.3-12.el7_2 for package: samba-client-4.2.3-12.el7_2.x86_64 --> Processing Dependency: samba-common = 4.2.3-12.el7_2 for package: samba-client-4.2.3-12.el7_2.x86_64 --> Processing Dependency: samba-common = 4.2.3-12.el7_2 for package: samba-client-4.2.3-12.el7_2.x86_64 --> Processing Dependency: samba-client-libs = 4.2.3-12.el7_2 for package: samba-client-4.2.3-12.el7_2.x86_64 --> Processing Dependency: libsmbclient = 4.2.3-12.el7_2 for package: samba-client-4.2.3-12. ........................... Running transaction Updating : samba-libs-4.2.3-12.el7_2.x86_64 1/13 Installing : samba-common-tools-4.2.3-12.el7_2.x86_64 2/13 Updating : samba-common-4.2.3-12.el7_2.noarch 3/13 Updating : libwbclient-4.2.3-12.el7_2.x86_64 4/13 Installing : samba-client-libs-4.2.3-12.el7_2.x86_64 5/13 Installing : samba-common-libs-4.2.3-12.el7_2.x86_64 6/13 Updating : libsmbclient-4.2.3-12.el7_2.x86_64 7/13 Updating : samba-client-4.2.3-12.el7_2.x86_64 8/13 Cleanup : samba-client-4.1.12-21.el7_1.x86_64 9/13 Cleanup : libsmbclient-4.1.12-21.el7_1.x86_64 10/13 Cleanup : samba-common-4.1.12-21.el7_1.x86_64 11/13 Cleanup : libwbclient-4.1.12-21.el7_1.x86_64 12/13 Cleanup : samba-libs-4.1.12-21.el7_1.x86_64 13/13 Verifying : samba-libs-4.2.3-12.el7_2.x86_64 1/13 Verifying : samba-common-4.2.3-12.el7_2.noarch 2/13 Verifying : samba-client-libs-4.2.3-12.el7_2.x86_64 3/13 Verifying : libwbclient-4.2.3-12.el7_2.x86_64 4/13 Verifying : samba-common-libs-4.2.3-12.el7_2.x86_64 5/13 Verifying : samba-common-tools-4.2.3-12.el7_2.x86_64 6/13 Verifying : samba-client-4.2.3-12.el7_2.x86_64 7/13 Verifying : libsmbclient-4.2.3-12.el7_2.x86_64 8/13 Verifying : samba-libs-4.1.12-21.el7_1.x86_64 9/13 Verifying : samba-common-4.1.12-21.el7_1.x86_64 10/13 Verifying : samba-client-4.1.12-21.el7_1.x86_64 11/13 Verifying : libsmbclient-4.1.12-21.el7_1.x86_64 12/13 Verifying : libwbclient-4.1.12-21.el7_1.x86_64 13/13 Dependency Installed: samba-client-libs.x86_64 0:4.2.3-12.el7_2 samba-common-libs.x86_64 0:4.2.3-12.el7_2 samba-common-tools.x86_64 0:4.2.3-12.el7_2 Updated: samba-client.x86_64 0:4.2.3-12.el7_2 Dependency Updated: libsmbclient.x86_64 0:4.2.3-12.el7_2 libwbclient.x86_64 0:4.2.3-12.el7_2 samba-common.noarch 0:4.2.3-12.el7_2 samba-libs.x86_64 0:4.2.3-12.el7_2 Complete!
downgrade:降级
# 降级与升级类似,不建议使用。
d、卸载
remove:卸载程序包
# yum remove httpd -y
e、其他
clean:清楚本地缓存
# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: base extras updates Cleaning up everything Cleaning up list of fastest mirrors
makecache:构建缓存
# yum makecache Loaded plugins: fastestmirror, langpacks Cleaning repos: base extras updates Cleaning up everything Cleaning up list of fastest mirrors [root@bogon conf]# yum makecache Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/12): base/7/x86_64/group_gz | 155 kB 00:00:07 (2/12): base/7/x86_64/primary_db | 5.3 MB 00:00:13 (3/12): extras/7/x86_64/prestodelta | 25 kB 00:00:00 (4/12): extras/7/x86_64/primary_db | 101 kB 00:00:00 (5/12): extras/7/x86_64/other_db | 317 kB 00:00:02 (6/12): updates/7/x86_64/prestodelta | 272 kB 00:00:02 (7/12): extras/7/x86_64/filelists_db | 258 kB 00:00:06 (8/12): base/7/x86_64/filelists_db | 6.2 MB 00:00:31 (9/12): base/7/x86_64/other_db | 2.3 MB 00:00:14 (10/12): updates/7/x86_64/filelists_db | 1.9 MB 00:00:15 (11/12): updates/7/x86_64/primary_db | 3.2 MB 00:00:16 (12/12): updates/7/x86_64/other_db | 27 MB 00:01:10 Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Metadata Cache Created
search:搜索 关键字搜索
# yum search httpd Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com ==================================== N/S matched: httpd ==================================== libmicrohttpd-devel.i686 : Development files for libmicrohttpd libmicrohttpd-devel.x86_64 : Development files for libmicrohttpd libmicrohttpd-doc.noarch : Documentation for libmicrohttpd httpd.x86_64 : Apache HTTP Server httpd-devel.x86_64 : Development interfaces for the Apache HTTP server httpd-manual.noarch : Documentation for the Apache HTTP server httpd-tools.x86_64 : Tools for use with the Apache HTTP Server libmicrohttpd.i686 : Lightweight library for embedding a webserver in applications libmicrohttpd.x86_64 : Lightweight library for embedding a webserver in applications mod_auth_mellon.x86_64 : A SAML 2.0 authentication module for the Apache Httpd Server mod_dav_svn.x86_64 : Apache httpd module for Subversion server Name and summary matches only, use "search all" for everything.
deplist:查看指定包所依赖的capabilities
# yum deplist vsftpd Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com package: vsftpd.x86_64 3.0.2-10.el7 dependency: /bin/bash provider: bash.x86_64 4.2.46-19.el7 dependency: /bin/sh provider: bash.x86_64 4.2.46-19.el7 dependency: libc.so.6(GLIBC_2.15)(64bit) provider: glibc.x86_64 2.17-106.el7_2.4 dependency: libcap.so.2()(64bit) provider: libcap.x86_64 2.22-8.el7 dependency: libcrypto.so.10()(64bit) provider: openssl-libs.x86_64 1:1.0.1e-51.el7_2.4 dependency: libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit) provider: openssl-libs.x86_64 1:1.0.1e-51.el7_2.4 dependency: libcrypto.so.10(libcrypto.so.10)(64bit) provider: openssl-libs.x86_64 1:1.0.1e-51.el7_2.4 dependency: libdl.so.2()(64bit) provider: glibc.x86_64 2.17-106.el7_2.4 dependency: libnsl.so.1()(64bit) provider: glibc.x86_64 2.17-106.el7_2.4 dependency: libpam.so.0()(64bit) provider: pam.x86_64 1.1.8-12.el7_1.1 dependency: libpam.so.0(LIBPAM_1.0)(64bit) provider: pam.x86_64 1.1.8-12.el7_1.1 dependency: libssl.so.10()(64bit) provider: openssl-libs.x86_64 1:1.0.1e-51.el7_2.4 dependency: libssl.so.10(libssl.so.10)(64bit) provider: openssl-libs.x86_64 1:1.0.1e-51.el7_2.4 dependency: libwrap.so.0()(64bit) provider: tcp_wrappers-libs.x86_64 7.6-77.el7 dependency: logrotate provider: logrotate.x86_64 3.8.6-7.el7_2 dependency: rtld(GNU_HASH) provider: glibc.x86_64 2.17-106.el7_2.4 provider: glibc.i686 2.17-106.el7_2.4
history:yum事物历史
# yum history Loaded plugins: fastestmirror, langpacks ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 6 | root <root> | 2016-03-19 20:27 | Erase | 1 EE 5 | root <root> | 2016-03-19 20:26 | I, U | 72 ss 4 | root <root> | 2016-03-19 20:15 | I, U | 8 3 | root <root> | 2016-03-19 20:06 | Reinstall | 1 2 | root <root> | 2016-03-19 20:04 | Install | 4 1 | System <unset> | 2016-03-01 06:56 | Install | 1244
f、安装及升级本地程序包
localinstall:本地安装(可以解决依赖关系)
# ll total 3592 -rw-r--r-- 1 root root 2823272 Mar 19 20:43 httpd-2.4.6-40.el7.centos.x86_64.rpm # yum localinstall httpd-2.4.6-40.el7.centos.x86_64.rpm -y Loaded plugins: fastestmirror, langpacks Examining httpd-2.2.15-47.el6.centos.3.x86_64.rpm: httpd-2.2.15-47.el6.centos.3.x86_64 Marking httpd-2.2.15-47.el6.centos.3.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-47.el6.centos.3 will be installed --> Processing Dependency: httpd-tools = 2.2.15-47.el6.centos.3 for package: httpd-2.2.15-47.el6.centos.3.x86_64 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com --> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-47.el6.centos.3.x86_64 --> Processing Dependency: libdb-4.7.so()(64bit) for package: httpd-2.2.15-47.el6.centos.3.x86_64 ................................... Running transaction Installing : httpd-2.4.6-40.el7.centos.x86_64 1/1 Verifying : httpd-2.4.6-40.el7.centos.x86_64 1/1 Installed: httpd.x86_64 0:2.4.6-40.el7.centos Complete!
localupdate:本地升级
# 升级与次相同,找到新的包升级就ok
g、包组管理的相关命令
grouplist:查看包组列表
# yum grouplist Loaded plugins: fastestmirror, langpacks There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Available environment groups: Minimal Install Compute Node Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done
groupinstall:安装包组
# yum groupinstall "Development Tools" -y Loaded plugins: fastestmirror, langpacks There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package autoconf.noarch 0:2.69-11.el7 will be installed --> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch ---> Package automake.noarch 0:1.13.4-3.el7 will be installed --> Processing Dependency: perl(Thread::Queue) for package: automake-1.13.4-3.el7.noarch --> Processing Dependency: perl(TAP::Parser) for package: automake-1.13.4-3.el7.noarch .............................. Installed: autoconf.noarch 0:2.69-11.el7 automake.noarch 0:1.13.4-3.el7 bison.x86_64 0:2.7-4.el7 byacc.x86_64 0:1.9.20130304-3.el7 cscope.x86_64 0:15.8-7.el7 ctags.x86_64 0:5.8-13.el7 diffstat.x86_64 0:1.57-4.el7 doxygen.x86_64 1:1.8.5-3.el7 flex.x86_64 0:2.5.37-3.el7 gcc.x86_64 0:4.8.5-4.el7 gcc-c++.x86_64 0:4.8.5-4.el7 gcc-gfortran.x86_64 0:4.8.5-4.el7 git.x86_64 0:1.8.3.1-6.el7 indent.x86_64 0:2.2.11-13.el7 intltool.noarch 0:0.50.2-6.el7 libtool.x86_64 0:2.4.2-21.el7_2 patch.x86_64 0:2.7.1-8.el7 patchutils.x86_64 0:0.3.3-4.el7 rcs.x86_64 0:5.9.0-5.el7 redhat-rpm-config.noarch 0:9.1.0-68.el7.centos rpm-build.x86_64 0:4.11.3-17.el7 rpm-sign.x86_64 0:4.11.3-17.el7 subversion.x86_64 0:1.7.14-10.el7 swig.x86_64 0:2.0.10-4.el7 systemtap.x86_64 0:2.8-10.el7 Dependency Installed: cpp.x86_64 0:4.8.5-4.el7 dwz.x86_64 0:0.11-3.el7 gettext-common-devel.noarch 0:0.18.2.1-4.el7 gettext-devel.x86_64 0:0.18.2.1-4.el7 glibc-devel.x86_64 0:2.17-106.el7_2.4 glibc-headers.x86_64 0:2.17-106.el7_2.4 kernel-devel.x86_64 0:3.10.0-327.10.1.el7 kernel-headers.x86_64 0:3.10.0-327.10.1.el7 libgfortran.x86_64 0:4.8.5-4.el7 libmpc.x86_64 0:1.0.1-3.el7 libquadmath.x86_64 0:4.8.5-4.el7 libquadmath-devel.x86_64 0:4.8.5-4.el7 libstdc++-devel.x86_64 0:4.8.5-4.el7 m4.x86_64 0:1.4.16-10.el7 mokutil.x86_64 0:0.9-2.el7 neon.x86_64 0:0.30.0-3.el7 pakchois.x86_64 0:0.4-10.el7 perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-6.el7 perl-TermReadKey.x86_64 0:2.30-20.el7 perl-Test-Harness.noarch 0:3.28-3.el7 perl-Thread-Queue.noarch 0:3.02-2.el7 perl-XML-Parser.x86_64 0:2.41-10.el7 perl-srpm-macros.noarch 0:1-8.el7 subversion-libs.x86_64 0:1.7.14-10.el7 systemtap-client.x86_64 0:2.8-10.el7 systemtap-devel.x86_64 0:2.8-10.el7 Dependency Updated: libgomp.x86_64 0:4.8.5-4.el7 rpm.x86_64 0:4.11.3-17.el7 rpm-build-libs.x86_64 0:4.11.3-17.el7 rpm-libs.x86_64 0:4.11.3-17.el7 rpm-python.x86_64 0:4.11.3-17.el7 systemtap-runtime.x86_64 0:2.8-10.el7 Complete!
groupupdate:升级包组
# yum groupupdate "Development Tools" -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Maybe run: yum groups mark install (see man yum) No packages in any requested group available to install or update
# 次处因为我这里是最新的,所以不能升级
groupremove:移除包组
# yum groupremove "Development Tools" -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com No environment named Development Tools exists Resolving Dependencies --> Running transaction check ---> Package autoconf.noarch 0:2.69-11.el7 will be erased ---> Package automake.noarch 0:1.13.4-3.el7 will be erased ............... Removed: autoconf.noarch 0:2.69-11.el7 automake.noarch 0:1.13.4-3.el7 bison.x86_64 0:2.7-4.el7 byacc.x86_64 0:1.9.20130304-3.el7 cscope.x86_64 0:15.8-7.el7 ctags.x86_64 0:5.8-13.el7 diffstat.x86_64 0:1.57-4.el7 doxygen.x86_64 1:1.8.5-3.el7 flex.x86_64 0:2.5.37-3.el7 gcc.x86_64 0:4.8.5-4.el7 gcc-c++.x86_64 0:4.8.5-4.el7 gcc-gfortran.x86_64 0:4.8.5-4.el7 git.x86_64 0:1.8.3.1-6.el7 indent.x86_64 0:2.2.11-13.el7 intltool.noarch 0:0.50.2-6.el7 libtool.x86_64 0:2.4.2-21.el7_2 patch.x86_64 0:2.7.1-8.el7 patchutils.x86_64 0:0.3.3-4.el7 rcs.x86_64 0:5.9.0-5.el7 redhat-rpm-config.noarch 0:9.1.0-68.el7.centos rpm-build.x86_64 0:4.11.3-17.el7 rpm-sign.x86_64 0:4.11.3-17.el7 subversion.x86_64 0:1.7.14-10.el7 swig.x86_64 0:2.0.10-4.el7 systemtap.x86_64 0:2.8-10.el7 Dependency Removed: gettext-devel.x86_64 0:0.18.2.1-4.el7 libquadmath-devel.x86_64 0:4.8.5-4.el7 perl-Git.noarch 0:1.8.3.1-6.el7 systemtap-devel.x86_64 0:2.8-10.el7 Complete!
groupinfo:查看包组的详细信息
# yum groupinfo "Development Tools" -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Group: Development Tools Group-Id: development Description: A basic development environment. Mandatory Packages: +autoconf +automake binutils +bison +flex +gcc +gcc-c++ gettext +libtool make +patch pkgconfig +redhat-rpm-config +rpm-build +rpm-sign Default Packages: +byacc +cscope +ctags +diffstat +doxygen elfutils +gcc-gfortran +git +indent +intltool +patchutils +rcs +subversion +swig +systemtap Optional Packages: ElectricFence ant babel bzr chrpath cmake compat-gcc-44 compat-gcc-44-c++ compat-gcc-44-g77 cvs dejagnu expect gcc-gnat gcc-objc gcc-objc++ imake javapackages-tools ksc libstdc++-docs mercurial mod_dav_svn nasm perltidy python-docs rpmdevtools rpmlint systemtap-sdt-devel systemtap-server
h、yum命令行选项
--nogpgcheck:禁止进行gpg check
# 如果在yum仓库中对gppcheck的值设定为1时如果不想检查可以使用此选项
-y: 自动回答为“yes”
-q:静默模式
# yum -q install httpd -y # rpm -q httpd httpd-2.4.6-40.el7.centos.x86_64
--disablerepo=repoidglob:临时禁用此处指定的repo
注意:此时虽然安装成功,但是没有使用[base]
# yum --disablerepo=base install samba -y Loaded plugins: fastestmirror, langpacks extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package samba.x86_64 0:4.2.3-12.el7_2 will be installed --> Finished Dependency Resolution ........ Running transaction Installing : samba-4.2.3-12.el7_2.x86_64 1/1 Verifying : samba-4.2.3-12.el7_2.x86_64 1/1 Installed: samba.x86_64 0:4.2.3-12.el7_2 Complete!
--enablerepo=repoidglob:临时启用此处指定的repo
# 一般用于仓库中 enabled=0 时
--noplugins:禁用所有插件
# 在/etc/yum/pluginconf.d/下定义
四、自建yum仓库
使用createrepo命令建立repodata文件从而处理程序包的依赖关系
createrepo [options] <directory>
1、创建仓库
# yum install createrepo -y # ll total 0 drwxr-xr-x 4 root root 33 Mar 19 21:49 xen4 # ls xen4/ drpms Packages # createrepo xen4/ Spawning worker 0 with 159 pkgs Spawning worker 1 with 159 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete # ls xen4/ drpms Packages repodata
2、指向仓库
# cat /etc/yum.repos.d/xen.repo [xen4] name=this is a xen baseurl=file:///opt/xzen4 gpgcheck=0 # yum install xen -y Loaded plugins: fastestmirror, langpacks xzen4 | 2.9 kB 00:00:00 xzen4/primary_db | 172 kB 00:00:00 Determining fastest mirrors Resolving Dependencies --> Running transaction check ---> Package xen.x86_64 0:4.2.4-30.el6.centos.alt will be installed --> Processing Dependency: xen-runtime = 4.2.4-30.el6.centos.alt for package: xen-4.2.4-30.el6.centos.alt.x86_64 .............
程序包管理器之编译安装
一、编译安装是什么?
在Linux上,有时候有的程序需要定制,可能程序内置功能很多,但是我们需要的只是一部分,用yum安装不能提供我们所需的服务的时候我们就会编译安装。编译安装就是将源代码编译成我们可以使用的可执行文件。
二、编译安装步骤
C代码编译安装三步骤:
./configure(预编译):
选项:指定安装位置、指定启用的特性
--help:获取其支持的选项
选项分类:
安装路径设定:
--prefix=/PATH/TO/SOMEWHERE
--sysconfdir=/PATH/TO/SOMEWHERE
System types:
Optional Features:可选特性
--disable-FEATURE
--enable-FEATURE[=ARG]
Optional Packages:可选包
--with-PACKAGE[=ARG]
--without-PACKAGE
make(编译)
make install(将编译好的文件复制到指定位置)
建议:安装前看INSTALL,README文件
安装后配置:
1、将可执行目录加入到PATH环境变量中
2、导出库文件路径
3、导出头文件
基于连接的方式实现
4、导出帮助手册
编辑/etc/man.config文件
添加一个MANPATH
注意:如果怕配置错误,可以放在环境变量可以识别的路径 例如/usr/local
三、实例
此处我以httpd为例
# tar xf httpd-2.4.12.tar.bz2 # ll total 4944 drwxr-xr-x 11 501 games 4096 Jan 23 2015 httpd-2.4.12 -rw-r--r-- 1 root root 5054838 Mar 19 22:11 httpd-2.4.12.tar.bz2 # ls httpd-2.4.12 ABOUT_APACHE BuildAll.dsp configure.in InstallBin.dsp NOTICE server acinclude.m4 BuildBin.dsp docs LAYOUT NWGNUmakefile srclib Apache-apr2.dsw buildconf emacs-style libhttpd.dsp os support Apache.dsw CHANGES httpd.dsp LICENSE README test apache_probes.d CMakeLists.txt httpd.spec Makefile.in README.cmake VERSIONING ap.d config.layout include Makefile.win README.platforms build configure INSTALL modules ROADMAP # ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/aprutil/ --enable-so --enable-rewritd --enable-ssl --enable-cgi --enable-cgid --enable-deflate --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" setting CFLAGS to " -g -O2 -pthread" setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE" setting LDFLAGS to " " configure: configure: Configuring Apache Portable Runtime Utility lib .................... config.status: creating docs/conf/extra/proxy-html.conf config.status: creating include/ap_config_layout.h config.status: creating support/apxs config.status: creating support/apachectl config.status: creating support/dbmmanage config.status: creating support/envvars-std config.status: creating support/log_server_status config.status: creating support/logresolve.pl config.status: creating support/phf_abuse_log.cgi config.status: creating support/split-logfile config.status: creating build/rules.mk config.status: creating build/pkg/pkginfo config.status: creating build/config_vars.sh config.status: creating include/ap_config_auto.h config.status: executing default commands # 编译 # make make[4]: Leaving directory `/opt/httpd-2.4.12/modules/mappers' make[3]: Leaving directory `/opt/httpd-2.4.12/modules/mappers' make[2]: Leaving directory `/opt/httpd-2.4.12/modules' make[2]: Entering directory `/opt/httpd-2.4.12/support' make[2]: Leaving directory `/opt/httpd-2.4.12/support' make[1]: Leaving directory `/opt/httpd-2.4.12' # 复制文件 # make install mkdir /usr/local/apache2/icons mkdir /usr/local/apache2/logs Installing CGIs mkdir /usr/local/apache2/cgi-bin Installing header files mkdir /usr/local/apache2/include Installing build system files mkdir /usr/local/apache2/build Installing man pages and online manual mkdir /usr/local/apache2/man mkdir /usr/local/apache2/man/man1 mkdir /usr/local/apache2/man/man8 mkdir /usr/local/apache2/manual make[1]: Leaving directory `/opt/httpd-2.4.12' # 配置服务并测试 # pwd /usr/local/apache2/bin [root@centos6 bin]# ls ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm rotatelogs # ./apachectl start AH00557: httpd: apr_sockaddr_info_get() failed for centos6.7 AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message # ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 :::44030 :::* LISTEN 0 128 *:48136 *:* LISTEN 0 128 :::111 :::* LISTEN 0 128 *:111 *:* LISTEN 0 128 :::80 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 128 ::1:631 :::*
程序包管理介绍到这了,编译安装根据不同环境定制.
最后
以上就是飞快钥匙为你收集整理的rpm、yum、编译安装轻松管理centos7程序包的全部内容,希望文章能够帮你解决rpm、yum、编译安装轻松管理centos7程序包所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复