【經典應用案例】
查看此文前,可先查看 此博文中:在安裝軟件過程中,如何解決的依賴組件問題?
[數據庫/Linux]CentOS7安裝MySQL Percona版(RPM方式) : 2-1 依賴組件問題 - 博客園/千千寰宇
rpm
和 yum
命令的全部完整解析:
rpm --help
yum --help
0 搜索 軟件包
yum -C search "關鍵詞"
[root@node116 repo]# yum -C search "curl"
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
================================================================================== N/S matched: curl ===================================================================================
libcurl-devel.x86_64 : Files needed for building applications with libcurl
python-pycurl.x86_64 : A Python interface to libcurl
curl.x86_64 : A utility for getting files from remote servers (FTP, HTTP, and others)
libcurl.x86_64 : A library for getting files from web servers
Name and summary matches only, use "search all" for everything.

1 查看包依賴
1-1 思路1: 服務器 查看RPM包依賴
-q : query / 查看對應的rpm包
-R: require / 依賴哪些軟件包
【0# YUM方式】
deplist := dependency list
yum deplist <軟件包名> := 顯示軟件包的依賴信息
[root@govern ~]# yum deplist curl
已加載插件:fastestmirror
查找依賴:
Loading mirror speeds from cached hostfile
* c6-media:
軟件包:curl.x86_64 7.19.7-52.el6
依賴: libssh2.so.1()(64bit)
provider: libssh2.x86_64 1.4.2-2.el6_7.1
依賴: libz.so.1()(64bit)
provider: zlib.x86_64 1.2.3-29.el6
依賴: libkrb5.so.3()(64bit)
provider: krb5-libs.x86_64 1.10.3-57.el6
依賴: libldap-2.4.so.2()(64bit)
provider: openldap.x86_64 2.4.40-12.el6
依賴: libpthread.so.0()(64bit)
provider: glibc.x86_64 2.12-1.192.el6
依賴: libgssapi_krb5.so.2()(64bit)
provider: krb5-libs.x86_64 1.10.3-57.el6
依賴: libpthread.so.0(GLIBC_2.2.5)(64bit)
provider: glibc.x86_64 2.12-1.192.el6
依賴: libcurl.so.4()(64bit)
provider: libcurl.x86_64 7.19.7-52.el6
依賴: libnssutil3.so()(64bit)
provider: nss-util.x86_64 3.21.0-2.el6
依賴: libk5crypto.so.3()(64bit)
provider: krb5-libs.x86_64 1.10.3-57.el6
依賴: libplc4.so()(64bit)
provider: nspr.x86_64 4.11.0-1.el6
依賴: librt.so.1(GLIBC_2.2.5)(64bit)
provider: glibc.x86_64 2.12-1.192.el6
依賴: libplds4.so()(64bit)
provider: nspr.x86_64 4.11.0-1.el6
依賴: libdl.so.2()(64bit)
provider: glibc.x86_64 2.12-1.192.el6
依賴: libnss3.so()(64bit)
provider: nss.x86_64 3.21.0-8.el6
依賴: libc.so.6(GLIBC_2.7)(64bit)
provider: glibc.x86_64 2.12-1.192.el6
依賴: libcom_err.so.2()(64bit)
provider: libcom_err.x86_64 1.41.12-22.el6
依賴: librt.so.1()(64bit)
provider: glibc.x86_64 2.12-1.192.el6
依賴: libssl3.so()(64bit)
provider: nss.x86_64 3.21.0-8.el6
依賴: libsmime3.so()(64bit)
provider: nss.x86_64 3.21.0-8.el6
依賴: libnspr4.so()(64bit)
provider: nspr.x86_64 4.11.0-1.el6
依賴: libidn.so.11()(64bit)
provider: libidn.x86_64 1.18-2.el6
依賴: rtld(GNU_HASH)
provider: glibc.i686 2.12-1.192.el6
provider: glibc.x86_64 2.12-1.192.el6
依賴: libcurl = 7.19.7-52.el6
provider: libcurl.x86_64 7.19.7-52.el6
provider: libcurl.i686 7.19.7-52.el6
【1# RPM方式 - 未被安裝時】
rpm -qpR <軟件包名>
【#2 RPM方式 - 已被安裝時】
[root@govern ~]# rpm -qR curl
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libcom_err.so.2()(64bit)
libcurl = 7.19.7-52.el6
libcurl.so.4()(64bit)
libdl.so.2()(64bit)
libgssapi_krb5.so.2()(64bit)
libidn.so.11()(64bit)
libk5crypto.so.3()(64bit)
libkrb5.so.3()(64bit)
libldap-2.4.so.2()(64bit)
libnspr4.so()(64bit)
libnss3.so()(64bit)
libnssutil3.so()(64bit)
libplc4.so()(64bit)
libplds4.so()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
librt.so.1()(64bit)
librt.so.1(GLIBC_2.2.5)(64bit)
libsmime3.so()(64bit)
libssh2.so.1()(64bit)
libssl3.so()(64bit)
libz.so.1()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1
1-2 第三方網站 查看RPM包/庫的第三方網站的包依賴分析報告
通過查詢下列安裝資源網站來【查詢/下載/安裝】包的依賴關系:




-
通過
yum install --downloadonly --downloaddir=[download_dir] [package]
來只下載包不安裝包 -
運行
yum list [package] --showduplicates
來查看包的多個版本 -
安裝.rpm 包時,檢測包依賴
如果缺少依賴,報錯信息中會打印出缺少的依賴:
rpm -ivh [package]
或
yum localinstall *.rpm
2 指定組件 是否被其它依賴?
通過rpm -e --test <軟件包名>
進行測試刪除,查看是否有依賴關系
如果有,會阻止刪除
[root@sdc70 ~]# rpm -e --test curl
error: Failed dependencies:
curl is needed by (installed) rpm-4.8.0-55.el6.x86_64
3 補充: rpm -q
/ yum info
rpm -q 軟件包名
[root@govern ~]# rpm -q libcurl
libcurl-7.19.7-52.el6.x86_64
[root@govern ~]# rpm -qa libcurl
libcurl-7.19.7-52.el6.x86_64
[↓推薦使用↓]
[root@govern ~]# rpm -qa | grep -i Percona
Percona-Server-shared-57-5.7.24-27.1.el6.x86_64
Percona-Server-server-57-5.7.24-27.1.el6.x86_64
Percona-Server-client-57-5.7.24-27.1.el6.x86_64
注: grep -i : 查找時 忽略大小寫的不同
yum info 軟件包名
[root@govern ~]# yum info libcurl
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* c6-media:
file:///media/CentOS/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/CentOS/repodata/repomd.xml
嘗試其他鏡像。
file:///media/cdrecorder/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/cdrecorder/repodata/repomd.xml
嘗試其他鏡像。
c6-media | 4.0 kB 00:00 ...
已安裝的軟件包
Name : libcurl
Arch : x86_64
Version : 7.19.7
Release : 52.el6
Size : 339 k
Repo : installed
From repo : anaconda-CentOS-201605220104.x86_64
Summary : A library for getting files from web servers
URL : http://curl.haxx.se/
License : MIT
Description : This package provides a way for applications to use FTP, HTTP, Gopher and
: other servers for getting files.
可安裝的軟件包
Name : libcurl
Arch : i686
Version : 7.19.7
Release : 52.el6
Size : 176 k
Repo : c6-media
Summary : A library for getting files from web servers
URL : http://curl.haxx.se/
License : MIT
Description : This package provides a way for applications to use FTP, HTTP, Gopher and
: other servers for getting files.
" 那有沒有辦法,按需獲取rpm包的各項信息呢? "
rpm -q --queryformat [QUERYFMT]
[root@govern ~]# rpm -q --qf '%{name}-%{version}-%{release}--%{arch}-%{DEPENDSDICT}\n' libcurl
libcurl-7.19.7-52.el6--x86_64-1375731722
其中,【QUERYFMT】 是一系列rpm的查詢標志,可以通過以下命令查詢有哪些標志可以使用:
[root@govern ~]# rpm --querytags
ARCH
ARCHIVESIZE
BASENAMES
BUGURL
BUILDARCHS
BUILDHOST
BUILDTIME
C
CAPABILITY
CHANGELOGNAME
CHANGELOGTEXT
CHANGELOGTIME
CLASSDICT
CONFLICTFLAGS
CONFLICTNAME
CONFLICTS
CONFLICTVERSION
COOKIE
DBINSTANCE
DEPENDSDICT
DESCRIPTION
DIRINDEXES
DIRNAMES
DISTRIBUTION
DISTTAG
DISTURL
DSAHEADER
...
rpm -qi <軟件包名>
-q - query
-i - information - 選項表示查詢軟件信息(版本 / 安裝時間 / ...)
[root@govern ~]# rpm -qi /root/centos6_mysql5.7.24_install/percona/Percona-Server-server-57-5.7.24-27.1.el6.x86_64.rpm
package /root/centos6_mysql5.7.24_install/percona/Percona-Server-server-57-5.7.24-27.1.el6.x86_64.rpm is not installed
[root@govern ~]# rpm -qi libcurl
Name : libcurl Relocations: (not relocatable)
Version : 7.19.7 Vendor: CentOS
Release : 52.el6 Build Date: 2016年05月11日 星期三 05時45分10秒
Install Date: 2019年12月04日 星期三 22時40分24秒 Build Host: worker1.bsys.centos.org
Group : Development/Libraries Source RPM: curl-7.19.7-52.el6.src.rpm
Size : 347536 License: MIT
Signature : RSA/SHA1, 2016年05月12日 星期四 18時48分11秒, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://curl.haxx.se/
Summary : A library for getting files from web servers
Description :
This package provides a way for applications to use FTP, HTTP, Gopher and
other servers for getting files.
注: Signature - 制作RPM的時候加入數字簽名