[实践OK]rpmbuid基础知识之AutoReqProv/requires/provides/ ,rpm包文件安装位置及列表,rpm软件依赖检查命令,查看嵌入脚本,自动产生rpm包依赖关系,rpm的配置文件查看,rpm包配置文件验证,rpm里的一个文件反查属于哪个rpm包,配置好源后查看rpm输出信息知道仓库在哪儿,yum本地缓存目录,本地缓存的位置及对应关系,指定仓库安装里面的rpm包,指定更新仓库索引。
查看YUM的RPM包依赖的包由谁来提供,以及对应的包命令yum deplist yumPKg:
yum deplist openssh|grep -i ssl
dependency: libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit)
provider: openssl.x86_64 1.0.1e-57.el6
provider: openssl.x86_64 1.0.1e-57.el6
dependency: libcrypto.so.10(OPENSSL_1.0.1)(64bit)
provider: openssl.x86_64 1.0.1e-57.el6
provider: openssl.x86_64 1.0.1e-57.el6
rpm -q openssh-5.3p1 --requires|grep ssl
CentOS7上面运行yum clean all时会有这个提示:
AutoReqProv no:
--requires list capabilities required by package(s)
--provides list capabilities that this package provides
rpm -qp php-5.6.20-160919111909.el7.centos.x86_64.rpm --requires
libiconv
libmcrypt
mcrypt
mhash
libtool-ltdl-devel
rpm -qp mkvtoolnix-13.0.0-1.x86_64.rpm --requires
hicolor-icon-theme
libFLAC.so.8()(64bit)
libQt5Concurrent.so.5()(64bit)
libQt5Core.so.5()(64bit)
libQt5Core.so.5(Qt_5)(64bit)
libQt5Core.so.5(Qt_5.6)(64bit)
libQt5Gui.so.5()(64bit)
libQt5Gui.so.5(Qt_5)(64bit)
libQt5Multimedia.so.5()(64bit)
libQt5Multimedia.so.5(Qt_5)(64bit)
libQt5Network.so.5()(64bit)
libQt5Network.so.5(Qt_5)(64bit)
libQt5Widgets.so.5()(64bit)
libQt5Widgets.so.5(Qt_5)(64bit)
libboost_filesystem.so.1.53.0()(64bit)
libboost_regex-mt.so.1.53.0()(64bit)
libboost_system.so.1.53.0()(64bit)
rpm -qp php-5.6.20-160919111909.el7.centos.x86_64.rpm --provides
php = 5.6.20-160919111909.el7.centos
php(x86-64) = 5.6.20-160919111909.el7.centos
查询一个包是否被安装
# rpm -q < rpm package name>
列出所有被安装的rpm package
# rpm -qa
-p, --package query/verify a package file
(一)rpm包文件安装位置及列表:
[root@localhost x86_64]# rpm -qpl nginx-1.7.1-el5.x86_64.rpm
/usr/local/nginxinstallbyrpm
/usr/local/nginxinstallbyrpm/conf
/usr/local/nginxinstallbyrpm/conf/fastcgi.conf
/usr/local/nginxinstallbyrpm/conf/fastcgi.conf.default
/usr/local/nginxinstallbyrpm/conf/fastcgi_params
/usr/local/nginxinstallbyrpm/conf/fastcgi_params.default
/usr/local/nginxinstallbyrpm/conf/koi-utf
/usr/local/nginxinstallbyrpm/conf/koi-win
(二)rpm软件依赖检查命令:
[root@localhost x86_64]# rpm -qp nginx-1.7.1-el5.x86_64.rpm -requires
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
/bin/sh
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libcrypt.so.1()(64bit)
libcrypt.so.1(GLIBC_2.2.5)(64bit)
libcrypto.so.10()(64bit)
libcrypto.so.10(libcrypto.so.10)(64bit)
libpcre.so.1()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libz.so.1()(64bit)
(三)查看嵌入脚本, -scripts:(preuninstall 卸载前)
[root@localhost x86_64]# rpm -qp nginx-1.7.1-el5.x86_64.rpm -scripts
preuninstall scriptlet (using /bin/sh):
if [ -z "`ps aux | grep nginx | grep -v grep`" ];then
killall nginx >/dev/null
exit 0
fi
(四)查看rpm包的安装信息:
[root@localhost x86_64]# rpm -qpi nginx-1.7.1-el5.x86_64.rpm -scripts
Name : nginx Relocations: (not relocatable)
Version : 1.7.1 Vendor: (none)
Release : el5 Build Date: Thu 10 Mar 2016 11:42:25 AM CST
Install Date: (not installed) Build Host: iZ25dcp92ckZ
Group : Applications/Server Source RPM: nginx-1.7.1-el5.src.rpm
Size : 707923 License: GPL
Signature : (none)
Packager : yunjianfei <yunjianfei1987@gmail.com>
URL : http://nginx.org/
Summary : High Performance Web Server
Description :
nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server
preuninstall scriptlet (using /bin/sh):
if [ -z "`ps aux | grep nginx | grep -v grep`" ];then
killall nginx >/dev/null
exit 0
fi
(五)自动产生rpm包依赖关系:
autoreqprov
默认不写值是1,也就是自动产生依赖关系,而主查对于一些共享库进行依赖(除开写了的外)。
加了autoreqprov=1和autoreqprov=0的rpm包查看如下方法:
rpm -qp nginx-1.7.1-el5.x86_64.rpm --requires
/bin/sh
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
(六)rpm包的配置文件查看:
rpm -qp /usr/local/nginx/html/centos6.4/x86_64/nginx-1.7.1-el5.x86_64.rpm --configfiles
(七)查看rpm包的安装情况:
[root@localhost x86_64]# rpm -qa perl-Test-Simple
perl-Test-Simple-0.92-141.el6_7.1.x86_64
[root@localhost x86_64]# file pcre-7.8-7.el6.x86_64.rpm
pcre-7.8-7.el6.x86_64.rpm: RPM v3.0 bin i386/x86_64 pcre-7.8-7.el6
(八)rpm包配置文件验证:
[root@localhost /]# rpm -qvV nginx-filesystem
......... /etc/nginx
......... /etc/nginx/conf.d
......... /etc/nginx/default.d
......... /usr/share/nginx
......... /usr/share/nginx/html
(九)rpm伯克利文件存放rpm包安装相关信息:
[root@iZ25dcp92ckZ rpmbuild]# file /var/lib/rpm/* |grep Berkeley
/var/lib/rpm/Basenames: Berkeley DB (Btree, version 9, native byte-order)
/var/lib/rpm/Conflictname: Berkeley DB (Btree, version 9, native byte-order)
/var/lib/rpm/Dirnames: Berkeley DB (Btree, version 9, native byte-order)
(十)rpm安装好的包里反查到属于哪个软件包的方法,rpm里的一个文件反查属于哪个rpm包:
[root@localhost /]# rpm -qf /usr/bin/sz
lrzsz-0.12.20-27.1.el6.x86_64 //ls -lart /var/lib/rpm/Packages 这个表里及相关表反查到的。
(十一)查看rpm包里的配置文件:
查看一下已安装软件的配置文件;
语法格式:rpm -qc 软件名
举例:
#rpm -qa|grep nginx
nginx-1.14.0-180523170757.el7.centos.x86_64
#rpm -qc nginx-1.14.0
/usr/local/nginx/conf/fastcgi.conf
/usr/local/nginx/conf/fastcgi_params
/usr/local/nginx/conf/koi-utf
/usr/local/nginx/conf/koi-win
/usr/local/nginx/conf/mime.types
-c, --configfiles
List only configuration files (implies -l).
rpm -qf /sbin/ifconfig //找不到这个,centos7没网络,没ifconfig咋整的,反查到缺少该包。
net-tools-2.0-0.17.20131004git.el7.x86_64
实践如下:
#chattr +i /var/lib/rpm/Packages ——>添加“i”隐藏属性后,就无法更动这个文件了 ,再rpm -ihv xxx.rpm,提示这个Packages index using db3-Permission denied(13)
举例比如,rpmbuild,咱发现这个命令没有,其它机器上有,又不知道这个文件是哪个rpm包里的于是反查呗:
build:[root@iZ25dcp92ckZ vhost]# whereis rpmbuild
rpmbuild: /usr/bin/rpmbuild
[root@iZ25dcp92ckZ vhost]# rpm -qf /usr/bin/rpmbuild
rpm-build-4.11.3-17.el7.x86_64
yum install rpm-build -y
[root@iZ25dcp92ckZ vhost]# rpm -qf /usr/bin/rz
lrzsz-0.12.20-36.el7.x86_64
[root@iZ25z0ugwgtZ xdebug]# rpm -qf /usr/bin/dig //名字和包一点关系没有如何反查在这儿有用了
bind-utils-9.9.4-29.el7_2.2.x86_64
#显示文件中查看是否存在系统以外的文件
rpm -Vf /bin/ls
rpm -Vf /usr/sbin/sshd
rpm -Vf /sbin/ifconfig
rpm -Vf /usr/sbin/lsof
#检查系统是否有elf文件被替换
(十一)阻塞问题:因为berkeley db对多任务并发操作支持不够好,从而导致数据库死锁而引起进程阻塞。一般处理是杀死相关进程,清空文件,运行yum命令清空:
(十二)配置好源后查看rpm输出信息知道仓库在哪儿:
yum clean all
yum info nginx-1.7.1
Loaded plugins: fastestmirror, security
Repository base is listed more than once in the configuration
Determining fastest mirrors
......
Available Packages
Name : nginx
Arch : x86_64
Version : 1.7.1
Release : el5
Size : 242 k
Repo : extra
Summary : High Performance Web Server
URL : http://nginx.org/
License : GPL
Description : nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server
(十三)yum install nginx-1.7.1,如何检查该包是否已经被安装?
rpm -qi nginx-1.7.1
package nginx-1.7.1 is not installed
(十四)首次及更新yum服务端rpm的索引文件:
yum -y install createrepo
createrepo --u http://192.168.1.245/winrpm -d -p -o . . //实现本机并指定镜像文件在192.168.1.245上。
createrepo --update -d -p .
(十五)yum本地缓存目录:
cat /etc/yum.conf |grep cachedir
cachedir=/var/cache/yum/$basearch/$releasever // /var/cache/yum/x86_64/6/
ls -lart /var/cache/yum/x86_64/6/base/
repomd.xml
packages
gen
cachecookie
11bcf3233241e37e1a0e04d2fde8a609215059b5b0319fd660f796d462bbe6a8-primary.sqlite
(十六)本地缓存的位置及对应关系:
repomd.xml这个文件是一个从服务器上同步的,通过yum clean all可以去掉的:
服务端:
md5sum /usr/local/nginx/html/centos6.4/x86_64/repodata/repomd.xml
792442251ee4d10e68dfedfea2818041 /usr/local/nginx/html/centos6.4/x86_64/repodata/repomd.xml
客户端:
md5sum /var/cache/yum/x86_64/6/extra/repomd.xml
792442251ee4d10e68dfedfea2818041 /var/cache/yum/x86_64/6/extra/repomd.xml
客户端的配置情况[extra]目录对应上面的客户端的extra目录(/var/cache/yum/x86_64/6/extra/):
cat /etc/yum.repos.d/test.repo
[extra] //个[extra]必须是唯一的单词,不能重复。
name=centos-extra
#baseurl=http://192.168.101.227/centos6.4/extra
baseurl=http://192.168.101.227/centos6.4/x86_64
gpgcheck=1
enabled=1
(十七)对不同yum仓库里有相同的rpm包时(不推荐这么搞),如果客户端都配置了,他会去下哪一个呢?
cat /etc/yum.repos.d/yum0.repo
cat /etc/yum.repos.d/yum1.repo
cat /etc/yum.repos.d/yum2.repo
是根据cost值越小来进行下载的:
cost=100
cost=105
cost=103
(十八)指定仓库安装里面的rpm包(被追求完美的系统的管理员排斥,觉得应用把yum服务的实现绑架了,尽量不要采用指定仓库的方式来安装):
(十九) 指定更新仓库索引,大幅度提升索引更新速度:
附录:
rpm包相关信息在本地sql存起来:
sqlite3 /var/cache/yum/x86_64/6/extra/ac3d9311735ae54c215864a35307072dda8b3b03503f272bb17c281e949279b2-primary.sqlite
sqlite> .tables
conflicts db_info files obsoletes packages provides requires
sqlite> .schema packages
CREATE TABLE packages ( pkgKey INTEGER PRIMARY KEY, pkgId TEXT, name TEXT, arch TEXT, version TEXT, epoch TEXT, release TEXT, summary TEXT, description TEXT, url TEXT, time_file INTEGER, time_build INTEGER, rpm_license TEXT, rpm_vendor TEXT, rpm_group TEXT, rpm_buildhost TEXT, rpm_sourcerpm TEXT, rpm_header_start INTEGER, rpm_header_end INTEGER, rpm_packager TEXT, size_package INTEGER, size_installed INTEGER, size_archive INTEGER, location_href TEXT, location_base TEXT, checksum_type TEXT);
CREATE INDEX packageId ON packages (pkgId);
CREATE INDEX packagename ON packages (name);
CREATE TRIGGER removals AFTER DELETE ON packages BEGIN DELETE FROM files WHERE pkgKey = old.pkgKey; DELETE FROM requires WHERE pkgKey = old.pkgKey; DELETE FROM provides WHERE pkgKey = old.pkgKey; DELETE FROM conflicts WHERE pkgKey = old.pkgKey; DELETE FROM obsoletes WHERE pkgKey = old.pkgKey; END;
sqlite> select * from packages;
1|6e099492eb691f0e869c02a7352530ec6a8d0056c1aadcde3613cc1f8e24e52c|pcre|x86_64|7.8|0|7.el6|Perl-compatible regular expression library|Perl-compatible regular expression library.
PCRE has its own native API, but a set of "wrapper" functions that are based on
the POSIX API are also supplied in the library libpcreposix. Note that this
just provides a POSIX calling interface to PCRE: the regular expressions
themselves still follow Perl syntax and semantics. The header file
for the POSIX-style functions is called pcreposix.h.|http://www.pcre.org/|1437770553|1437691568|BSD|CentOS|System Environment/Libraries|c6b8.bsys.dev.centos.org|pcre-7.8-7.el6.src.rpm|1384|11408|CentOS BuildSystem <http://bugs.centos.org>|200564|529027|531768|pcre-7.8-7.el6.x86_64.rpm||sha256
2|f1bced3b528579ba55ef1f3924e03f0979dd188a3ab5a877058a2ef247bc75ca|nginx|x86_64|1.7.1|0|el5|High Performance Web Server|nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server|http://nginx.org/|1457681066|1457581345|GPL||Applications/Server|iZ25dcp92ckZ|nginx-1.7.1-el5.src.rpm|280|5836|yunjianfei <yunjianfei1987@gmail.com>|248156|707923|711684|nginx-1.7.1-el5.x86_64.rpm||sha256
3|b354e7ed72daec3d497ed85fa68e5bd77556f642a2645659d40877dc6449382f|pcre-devel|x86_64|7.8|0|7.el6|Development files for pcre|Development files (Headers, libraries for dynamic linking, etc) for pcre.|http://www.pcre.org/|1437770555|1437691568|BSD|CentOS|Development/Libraries|c6b8.bsys.dev.centos.org|pcre-7.8-7.el6.src.rpm|1384|21612|CentOS BuildSystem <http://bugs.centos.org>|327960|980154|995184|pcre-devel-7.8-7.el6.x86_64.rpm||sha256
createrepo -d -p -o /tmp ../rpm/ //把repodata输出到/tmp目录下,和rpm包分开。
================================================================
如果有修改则会出现sm5....T c /etc/boy.conf //MODE、SIZE、MD5SUM、mtime都改变列出来了。
================================================================
rpm包依赖关系的解除:
在我们安装某一个rpm包的时候,系统有可能提示某一个库文件或者rpm的支持,当想在安装需要该rpm包倚赖的这个库文件或者rpm包时,该库文件或者rpm包又依赖另外的文件或rpm包,导致安装很难快速解决包之间的以来关系达到安装需要的组件的目的。redhat提供的解决方案,安装依赖关系库,就可以解决此问题,该文件可以用find -name rpmdb* 在rpm包所在文件夹中找到,然后运行 rpm -ivh --aid abc.rpm,abc.rpm为需要安装的包即可。当然复杂的时候还需要手动解决少数包依赖关系,简单的情况下,可以一次性解决所有以来关系。
应用,平台:AS3
samba的安装
进入samba的rpm包所在目录执行
# rpm -ivh --aid samba*.rpm (一定要安装rpmdb后才可以用这种方式安装排除依赖关系)
该命令会自动把依赖关系中需要安装的包都安装上,包括:
cups-libs-1.1.17-13.3.6.rpm
samba-common-3.0.0-14.3E.i386.rpm
samba-3.0.0-14.3E.i386.rpm
samba-client-3.0.0-14.3E.i386.rpm
可以很简单地解决直接安装samba-3.0.0-14.3E.i386.rpm或者samba-client-3.0.0-14.3E.i386.rpm 对samba-common-3.0.0-14.3E.i386.rpm 的依赖,而安装samba-common- 3.0.0-14.3E.i386.rpm 出现对都libcups.so.2库文件的依赖,而且该库文件所在的rpm包无法很快确定
上述方法可以很快解决依赖关系
应用2 平台 AS3
在安装linux系统时可能会觉得开发工具是不需要的,后续在安装apache或者其他tar.gz格式的软件时,会瞪圆眼睛,想再安装gcc库时不是缺少这个文件就是缺少那个文件。实在恨不得直接重新安装系统。现在可以比较简单地解决了。
[root@vpc-test RPMS]# rpm -ivh -aid gcc*.rpm
warning: gcc-3.2.3-20.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
cpp = 3.2.3-20 is needed by gcc-3.2.3-20
glibc-devel >= 2.2.90-12 is needed by gcc-3.2.3-20
libstdc++-devel = 3.2.3 is needed by gcc-c++-3.2.3-20
libstdc++-ssa = 3.5ssa is needed by gcc-c++-ssa-3.5ssa-0.20030801.41
libstdc++-ssa-devel = 3.5ssa is needed by gcc-c++-ssa-3.5ssa-0.20030801.41
libf2c = 3.2.3-20 is needed by gcc-g77-3.2.3-20
libgnat = 3.2.3-20 is needed by gcc-gnat-3.2.3-20
libgcj-devel >= 3.2.3 is needed by gcc-java-3.2.3-20
zlib-devel is needed by gcc-java-3.2.3-20
libgcj-ssa >= 3.5ssa is needed by gcc-java-ssa-3.5ssa-0.20030801.41
libgcj-ssa-devel >= 3.5ssa is needed by gcc-java-ssa-3.5ssa-0.20030801.41
glibc-devel is needed by gcc-ssa-3.5ssa-0.20030801.41
libgcc-ssa >= 3.5ssa-0.20030801.41 is needed by gcc-ssa-3.5ssa-0.20030801.41
Suggested resolutions:
cpp-3.2.3-20.i386.rpm
glibc-devel-2.3.2-95.3.i386.rpm
libf2c-3.2.3-20.i386.rpm
libgcc-ssa-3.5ssa-0.20030801.41.i386.rpm
libgcj-devel-3.2.3-20.i386.rpm
libgcj-ssa-3.5ssa-0.20030801.41.i386.rpm
libgcj-ssa-devel-3.5ssa-0.20030801.41.i386.rpm
libgnat-3.2.3-20.i386.rpm
libstdc++-devel-3.2.3-20.i386.rpm
libstdc++-ssa-3.5ssa-0.20030801.41.i386.rpm
libstdc++-ssa-devel-3.5ssa-0.20030801.41.i386.rpm
zlib-devel-1.1.4-8.1.i386.rpm
安装如下过程
Suggested resolutions:
cpp-3.2.3-20.i386.rpm ok
libgcj-ssa-3.5ssa-0.20030801.41.i386.rpm ok
libf2c-3.2.3-20.i386.rpm ok
libgcc-ssa-3.5ssa-0.20030801.41.i386.rpm OK
libgcj-devel-3.2.3-20.i386.rpm ok
libgnat-3.2.3-20.i386.rpm OK
libstdc++-devel-3.2.3-20.i386.rpm OK
libstdc++-ssa-3.5ssa-0.20030801.41.i386.rpm Ok
libstdc++-ssa-devel-3.5ssa-0.20030801.41.i386.rpm OK
zlib-devel-1.1.4-8.1.i386.rpm
libgcj-ssa-devel-3.5ssa-0.20030801.41.i386.rpm OK(依赖libgcj-ssa-3.5ssa-0.20030801.41.i386.rpm OK)
glibc-devel-2.3.2-95.3.i386.rpm OK(依赖glibc-headers-2.3.2-95.3.i386.rpm ok(依赖glibc-kernheaders-2.4-8.34.i386.rpm OK))
上述几个包是手动按照suggest逐个安装的,括号里代表前者以来后者,先安装后者在安装前者。然后在gcc所在的目录执行下面命令,很快就可以顺利安装完成
[root@vpc-test RPMS]# rpm -ivh --aid gcc*.rpm
warning: gcc-3.2.3-20.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:gcc ########################################### [ 8%]
2:gcc-ssa ########################################### [ 17%]
3:zlib-devel ########################################### [ 25%]
4:gcc-c++ ########################################### [ 33%]
5:gcc-c++-ssa ########################################### [ 42%]
6:gcc-g77 ########################################### [ 50%]
7:gcc-g77-ssa ########################################### [ 58%]
8:gcc-gnat ########################################### [ 67%]
9:gcc-java ########################################### [ 75%]
10:gcc-java-ssa ########################################### [ 83%]
11:gcc-objc ########################################### [ 92%]
12:gcc-objc-ssa ########################################### [100%]
在AS4中测试gcc的依赖关系简单得多,直接rpm -ivh --aid gcc*.rpm就可以搞定了。
开发需要不得不用centos5,不得不用rpm,果然又碰上了预料之中的包依赖关系的问题。mysql-3.23.52-3.i386需要perl-DBD-MySQL- 2.1017-3,而perl-DBD-MySQL-2.1017-3又需要libmysqlclient10.so,这个文件包含在mysql- 3.23.52-3.i386中,这就造成了死循环。
在http://www.newsmth.net/bbscon.php?bid=69&id=1621看到一个解决的技巧,就是把所有包的名字都列上去,这样就不会提示缺少某个包了
一般可以把所有要安装的包放在一个目录里,然后rpm -ivh *.rpm
yum deplist openssh|grep -i ssl
dependency: libcrypto.so.10(OPENSSL_1.0.1_EC)(64bit)
provider: openssl.x86_64 1.0.1e-57.el6
provider: openssl.x86_64 1.0.1e-57.el6
dependency: libcrypto.so.10(OPENSSL_1.0.1)(64bit)
provider: openssl.x86_64 1.0.1e-57.el6
provider: openssl.x86_64 1.0.1e-57.el6
rpm -q openssh-5.3p1 --requires|grep ssl
CentOS7上面运行yum clean all时会有这个提示:
AutoReqProv no:
--requires list capabilities required by package(s)
--provides list capabilities that this package provides
rpm -qp php-5.6.20-160919111909.el7.centos.x86_64.rpm --requires
libiconv
libmcrypt
mcrypt
mhash
libtool-ltdl-devel
rpm -qp mkvtoolnix-13.0.0-1.x86_64.rpm --requires
hicolor-icon-theme
libFLAC.so.8()(64bit)
libQt5Concurrent.so.5()(64bit)
libQt5Core.so.5()(64bit)
libQt5Core.so.5(Qt_5)(64bit)
libQt5Core.so.5(Qt_5.6)(64bit)
libQt5Gui.so.5()(64bit)
libQt5Gui.so.5(Qt_5)(64bit)
libQt5Multimedia.so.5()(64bit)
libQt5Multimedia.so.5(Qt_5)(64bit)
libQt5Network.so.5()(64bit)
libQt5Network.so.5(Qt_5)(64bit)
libQt5Widgets.so.5()(64bit)
libQt5Widgets.so.5(Qt_5)(64bit)
libboost_filesystem.so.1.53.0()(64bit)
libboost_regex-mt.so.1.53.0()(64bit)
libboost_system.so.1.53.0()(64bit)
rpm -qp php-5.6.20-160919111909.el7.centos.x86_64.rpm --provides
php = 5.6.20-160919111909.el7.centos
php(x86-64) = 5.6.20-160919111909.el7.centos
查询一个包是否被安装
# rpm -q < rpm package name>
列出所有被安装的rpm package
# rpm -qa
-p, --package query/verify a package file
(一)rpm包文件安装位置及列表:
[root@localhost x86_64]# rpm -qpl nginx-1.7.1-el5.x86_64.rpm
/usr/local/nginxinstallbyrpm
/usr/local/nginxinstallbyrpm/conf
/usr/local/nginxinstallbyrpm/conf/fastcgi.conf
/usr/local/nginxinstallbyrpm/conf/fastcgi.conf.default
/usr/local/nginxinstallbyrpm/conf/fastcgi_params
/usr/local/nginxinstallbyrpm/conf/fastcgi_params.default
/usr/local/nginxinstallbyrpm/conf/koi-utf
/usr/local/nginxinstallbyrpm/conf/koi-win
(二)rpm软件依赖检查命令:
[root@localhost x86_64]# rpm -qp nginx-1.7.1-el5.x86_64.rpm -requires
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
/bin/sh
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libcrypt.so.1()(64bit)
libcrypt.so.1(GLIBC_2.2.5)(64bit)
libcrypto.so.10()(64bit)
libcrypto.so.10(libcrypto.so.10)(64bit)
libpcre.so.1()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libz.so.1()(64bit)
(三)查看嵌入脚本, -scripts:(preuninstall 卸载前)
[root@localhost x86_64]# rpm -qp nginx-1.7.1-el5.x86_64.rpm -scripts
preuninstall scriptlet (using /bin/sh):
if [ -z "`ps aux | grep nginx | grep -v grep`" ];then
killall nginx >/dev/null
exit 0
fi
(四)查看rpm包的安装信息:
[root@localhost x86_64]# rpm -qpi nginx-1.7.1-el5.x86_64.rpm -scripts
Name : nginx Relocations: (not relocatable)
Version : 1.7.1 Vendor: (none)
Release : el5 Build Date: Thu 10 Mar 2016 11:42:25 AM CST
Install Date: (not installed) Build Host: iZ25dcp92ckZ
Group : Applications/Server Source RPM: nginx-1.7.1-el5.src.rpm
Size : 707923 License: GPL
Signature : (none)
Packager : yunjianfei <yunjianfei1987@gmail.com>
URL : http://nginx.org/
Summary : High Performance Web Server
Description :
nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server
preuninstall scriptlet (using /bin/sh):
if [ -z "`ps aux | grep nginx | grep -v grep`" ];then
killall nginx >/dev/null
exit 0
fi
(五)自动产生rpm包依赖关系:
autoreqprov
默认不写值是1,也就是自动产生依赖关系,而主查对于一些共享库进行依赖(除开写了的外)。
加了autoreqprov=1和autoreqprov=0的rpm包查看如下方法:
rpm -qp nginx-1.7.1-el5.x86_64.rpm --requires
/bin/sh
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
(六)rpm包的配置文件查看:
rpm -qp /usr/local/nginx/html/centos6.4/x86_64/nginx-1.7.1-el5.x86_64.rpm --configfiles
(七)查看rpm包的安装情况:
[root@localhost x86_64]# rpm -qa perl-Test-Simple
perl-Test-Simple-0.92-141.el6_7.1.x86_64
[root@localhost x86_64]# file pcre-7.8-7.el6.x86_64.rpm
pcre-7.8-7.el6.x86_64.rpm: RPM v3.0 bin i386/x86_64 pcre-7.8-7.el6
(八)rpm包配置文件验证:
[root@localhost /]# rpm -qvV nginx-filesystem
......... /etc/nginx
......... /etc/nginx/conf.d
......... /etc/nginx/default.d
......... /usr/share/nginx
......... /usr/share/nginx/html
(九)rpm伯克利文件存放rpm包安装相关信息:
[root@iZ25dcp92ckZ rpmbuild]# file /var/lib/rpm/* |grep Berkeley
/var/lib/rpm/Basenames: Berkeley DB (Btree, version 9, native byte-order)
/var/lib/rpm/Conflictname: Berkeley DB (Btree, version 9, native byte-order)
/var/lib/rpm/Dirnames: Berkeley DB (Btree, version 9, native byte-order)
(十)rpm安装好的包里反查到属于哪个软件包的方法,rpm里的一个文件反查属于哪个rpm包:
[root@localhost /]# rpm -qf /usr/bin/sz
lrzsz-0.12.20-27.1.el6.x86_64 //ls -lart /var/lib/rpm/Packages 这个表里及相关表反查到的。
(十一)查看rpm包里的配置文件:
查看一下已安装软件的配置文件;
语法格式:rpm -qc 软件名
举例:
#rpm -qa|grep nginx
nginx-1.14.0-180523170757.el7.centos.x86_64
#rpm -qc nginx-1.14.0
/usr/local/nginx/conf/fastcgi.conf
/usr/local/nginx/conf/fastcgi_params
/usr/local/nginx/conf/koi-utf
/usr/local/nginx/conf/koi-win
/usr/local/nginx/conf/mime.types
-c, --configfiles
List only configuration files (implies -l).
rpm -qf /sbin/ifconfig //找不到这个,centos7没网络,没ifconfig咋整的,反查到缺少该包。
net-tools-2.0-0.17.20131004git.el7.x86_64
实践如下:
#chattr +i /var/lib/rpm/Packages ——>添加“i”隐藏属性后,就无法更动这个文件了 ,再rpm -ihv xxx.rpm,提示这个Packages index using db3-Permission denied(13)
举例比如,rpmbuild,咱发现这个命令没有,其它机器上有,又不知道这个文件是哪个rpm包里的于是反查呗:
build:[root@iZ25dcp92ckZ vhost]# whereis rpmbuild
rpmbuild: /usr/bin/rpmbuild
[root@iZ25dcp92ckZ vhost]# rpm -qf /usr/bin/rpmbuild
rpm-build-4.11.3-17.el7.x86_64
yum install rpm-build -y
[root@iZ25dcp92ckZ vhost]# rpm -qf /usr/bin/rz
lrzsz-0.12.20-36.el7.x86_64
[root@iZ25z0ugwgtZ xdebug]# rpm -qf /usr/bin/dig //名字和包一点关系没有如何反查在这儿有用了
bind-utils-9.9.4-29.el7_2.2.x86_64
#显示文件中查看是否存在系统以外的文件
rpm -Vf /bin/ls
rpm -Vf /usr/sbin/sshd
rpm -Vf /sbin/ifconfig
rpm -Vf /usr/sbin/lsof
#检查系统是否有elf文件被替换
(十一)阻塞问题:因为berkeley db对多任务并发操作支持不够好,从而导致数据库死锁而引起进程阻塞。一般处理是杀死相关进程,清空文件,运行yum命令清空:
(十二)配置好源后查看rpm输出信息知道仓库在哪儿:
yum clean all
yum info nginx-1.7.1
Loaded plugins: fastestmirror, security
Repository base is listed more than once in the configuration
Determining fastest mirrors
......
Available Packages
Name : nginx
Arch : x86_64
Version : 1.7.1
Release : el5
Size : 242 k
Repo : extra
Summary : High Performance Web Server
URL : http://nginx.org/
License : GPL
Description : nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server
(十三)yum install nginx-1.7.1,如何检查该包是否已经被安装?
rpm -qi nginx-1.7.1
package nginx-1.7.1 is not installed
(十四)首次及更新yum服务端rpm的索引文件:
yum -y install createrepo
createrepo --u http://192.168.1.245/winrpm -d -p -o . . //实现本机并指定镜像文件在192.168.1.245上。
createrepo --update -d -p .
(十五)yum本地缓存目录:
cat /etc/yum.conf |grep cachedir
cachedir=/var/cache/yum/$basearch/$releasever // /var/cache/yum/x86_64/6/
ls -lart /var/cache/yum/x86_64/6/base/
repomd.xml
packages
gen
cachecookie
11bcf3233241e37e1a0e04d2fde8a609215059b5b0319fd660f796d462bbe6a8-primary.sqlite
(十六)本地缓存的位置及对应关系:
repomd.xml这个文件是一个从服务器上同步的,通过yum clean all可以去掉的:
服务端:
md5sum /usr/local/nginx/html/centos6.4/x86_64/repodata/repomd.xml
792442251ee4d10e68dfedfea2818041 /usr/local/nginx/html/centos6.4/x86_64/repodata/repomd.xml
客户端:
md5sum /var/cache/yum/x86_64/6/extra/repomd.xml
792442251ee4d10e68dfedfea2818041 /var/cache/yum/x86_64/6/extra/repomd.xml
客户端的配置情况[extra]目录对应上面的客户端的extra目录(/var/cache/yum/x86_64/6/extra/):
cat /etc/yum.repos.d/test.repo
[extra] //个[extra]必须是唯一的单词,不能重复。
name=centos-extra
#baseurl=http://192.168.101.227/centos6.4/extra
baseurl=http://192.168.101.227/centos6.4/x86_64
gpgcheck=1
enabled=1
(十七)对不同yum仓库里有相同的rpm包时(不推荐这么搞),如果客户端都配置了,他会去下哪一个呢?
cat /etc/yum.repos.d/yum0.repo
cat /etc/yum.repos.d/yum1.repo
cat /etc/yum.repos.d/yum2.repo
是根据cost值越小来进行下载的:
cost=100
cost=105
cost=103
(十八)指定仓库安装里面的rpm包(被追求完美的系统的管理员排斥,觉得应用把yum服务的实现绑架了,尽量不要采用指定仓库的方式来安装):
(十九) 指定更新仓库索引,大幅度提升索引更新速度:
附录:
rpm包相关信息在本地sql存起来:
sqlite3 /var/cache/yum/x86_64/6/extra/ac3d9311735ae54c215864a35307072dda8b3b03503f272bb17c281e949279b2-primary.sqlite
sqlite> .tables
conflicts db_info files obsoletes packages provides requires
sqlite> .schema packages
CREATE TABLE packages ( pkgKey INTEGER PRIMARY KEY, pkgId TEXT, name TEXT, arch TEXT, version TEXT, epoch TEXT, release TEXT, summary TEXT, description TEXT, url TEXT, time_file INTEGER, time_build INTEGER, rpm_license TEXT, rpm_vendor TEXT, rpm_group TEXT, rpm_buildhost TEXT, rpm_sourcerpm TEXT, rpm_header_start INTEGER, rpm_header_end INTEGER, rpm_packager TEXT, size_package INTEGER, size_installed INTEGER, size_archive INTEGER, location_href TEXT, location_base TEXT, checksum_type TEXT);
CREATE INDEX packageId ON packages (pkgId);
CREATE INDEX packagename ON packages (name);
CREATE TRIGGER removals AFTER DELETE ON packages BEGIN DELETE FROM files WHERE pkgKey = old.pkgKey; DELETE FROM requires WHERE pkgKey = old.pkgKey; DELETE FROM provides WHERE pkgKey = old.pkgKey; DELETE FROM conflicts WHERE pkgKey = old.pkgKey; DELETE FROM obsoletes WHERE pkgKey = old.pkgKey; END;
sqlite> select * from packages;
1|6e099492eb691f0e869c02a7352530ec6a8d0056c1aadcde3613cc1f8e24e52c|pcre|x86_64|7.8|0|7.el6|Perl-compatible regular expression library|Perl-compatible regular expression library.
PCRE has its own native API, but a set of "wrapper" functions that are based on
the POSIX API are also supplied in the library libpcreposix. Note that this
just provides a POSIX calling interface to PCRE: the regular expressions
themselves still follow Perl syntax and semantics. The header file
for the POSIX-style functions is called pcreposix.h.|http://www.pcre.org/|1437770553|1437691568|BSD|CentOS|System Environment/Libraries|c6b8.bsys.dev.centos.org|pcre-7.8-7.el6.src.rpm|1384|11408|CentOS BuildSystem <http://bugs.centos.org>|200564|529027|531768|pcre-7.8-7.el6.x86_64.rpm||sha256
2|f1bced3b528579ba55ef1f3924e03f0979dd188a3ab5a877058a2ef247bc75ca|nginx|x86_64|1.7.1|0|el5|High Performance Web Server|nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server|http://nginx.org/|1457681066|1457581345|GPL||Applications/Server|iZ25dcp92ckZ|nginx-1.7.1-el5.src.rpm|280|5836|yunjianfei <yunjianfei1987@gmail.com>|248156|707923|711684|nginx-1.7.1-el5.x86_64.rpm||sha256
3|b354e7ed72daec3d497ed85fa68e5bd77556f642a2645659d40877dc6449382f|pcre-devel|x86_64|7.8|0|7.el6|Development files for pcre|Development files (Headers, libraries for dynamic linking, etc) for pcre.|http://www.pcre.org/|1437770555|1437691568|BSD|CentOS|Development/Libraries|c6b8.bsys.dev.centos.org|pcre-7.8-7.el6.src.rpm|1384|21612|CentOS BuildSystem <http://bugs.centos.org>|327960|980154|995184|pcre-devel-7.8-7.el6.x86_64.rpm||sha256
createrepo -d -p -o /tmp ../rpm/ //把repodata输出到/tmp目录下,和rpm包分开。
================================================================
如果有修改则会出现sm5....T c /etc/boy.conf //MODE、SIZE、MD5SUM、mtime都改变列出来了。
================================================================
rpm包依赖关系的解除:
在我们安装某一个rpm包的时候,系统有可能提示某一个库文件或者rpm的支持,当想在安装需要该rpm包倚赖的这个库文件或者rpm包时,该库文件或者rpm包又依赖另外的文件或rpm包,导致安装很难快速解决包之间的以来关系达到安装需要的组件的目的。redhat提供的解决方案,安装依赖关系库,就可以解决此问题,该文件可以用find -name rpmdb* 在rpm包所在文件夹中找到,然后运行 rpm -ivh --aid abc.rpm,abc.rpm为需要安装的包即可。当然复杂的时候还需要手动解决少数包依赖关系,简单的情况下,可以一次性解决所有以来关系。
应用,平台:AS3
samba的安装
进入samba的rpm包所在目录执行
# rpm -ivh --aid samba*.rpm (一定要安装rpmdb后才可以用这种方式安装排除依赖关系)
该命令会自动把依赖关系中需要安装的包都安装上,包括:
cups-libs-1.1.17-13.3.6.rpm
samba-common-3.0.0-14.3E.i386.rpm
samba-3.0.0-14.3E.i386.rpm
samba-client-3.0.0-14.3E.i386.rpm
可以很简单地解决直接安装samba-3.0.0-14.3E.i386.rpm或者samba-client-3.0.0-14.3E.i386.rpm 对samba-common-3.0.0-14.3E.i386.rpm 的依赖,而安装samba-common- 3.0.0-14.3E.i386.rpm 出现对都libcups.so.2库文件的依赖,而且该库文件所在的rpm包无法很快确定
上述方法可以很快解决依赖关系
应用2 平台 AS3
在安装linux系统时可能会觉得开发工具是不需要的,后续在安装apache或者其他tar.gz格式的软件时,会瞪圆眼睛,想再安装gcc库时不是缺少这个文件就是缺少那个文件。实在恨不得直接重新安装系统。现在可以比较简单地解决了。
[root@vpc-test RPMS]# rpm -ivh -aid gcc*.rpm
warning: gcc-3.2.3-20.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
error: Failed dependencies:
cpp = 3.2.3-20 is needed by gcc-3.2.3-20
glibc-devel >= 2.2.90-12 is needed by gcc-3.2.3-20
libstdc++-devel = 3.2.3 is needed by gcc-c++-3.2.3-20
libstdc++-ssa = 3.5ssa is needed by gcc-c++-ssa-3.5ssa-0.20030801.41
libstdc++-ssa-devel = 3.5ssa is needed by gcc-c++-ssa-3.5ssa-0.20030801.41
libf2c = 3.2.3-20 is needed by gcc-g77-3.2.3-20
libgnat = 3.2.3-20 is needed by gcc-gnat-3.2.3-20
libgcj-devel >= 3.2.3 is needed by gcc-java-3.2.3-20
zlib-devel is needed by gcc-java-3.2.3-20
libgcj-ssa >= 3.5ssa is needed by gcc-java-ssa-3.5ssa-0.20030801.41
libgcj-ssa-devel >= 3.5ssa is needed by gcc-java-ssa-3.5ssa-0.20030801.41
glibc-devel is needed by gcc-ssa-3.5ssa-0.20030801.41
libgcc-ssa >= 3.5ssa-0.20030801.41 is needed by gcc-ssa-3.5ssa-0.20030801.41
Suggested resolutions:
cpp-3.2.3-20.i386.rpm
glibc-devel-2.3.2-95.3.i386.rpm
libf2c-3.2.3-20.i386.rpm
libgcc-ssa-3.5ssa-0.20030801.41.i386.rpm
libgcj-devel-3.2.3-20.i386.rpm
libgcj-ssa-3.5ssa-0.20030801.41.i386.rpm
libgcj-ssa-devel-3.5ssa-0.20030801.41.i386.rpm
libgnat-3.2.3-20.i386.rpm
libstdc++-devel-3.2.3-20.i386.rpm
libstdc++-ssa-3.5ssa-0.20030801.41.i386.rpm
libstdc++-ssa-devel-3.5ssa-0.20030801.41.i386.rpm
zlib-devel-1.1.4-8.1.i386.rpm
安装如下过程
Suggested resolutions:
cpp-3.2.3-20.i386.rpm ok
libgcj-ssa-3.5ssa-0.20030801.41.i386.rpm ok
libf2c-3.2.3-20.i386.rpm ok
libgcc-ssa-3.5ssa-0.20030801.41.i386.rpm OK
libgcj-devel-3.2.3-20.i386.rpm ok
libgnat-3.2.3-20.i386.rpm OK
libstdc++-devel-3.2.3-20.i386.rpm OK
libstdc++-ssa-3.5ssa-0.20030801.41.i386.rpm Ok
libstdc++-ssa-devel-3.5ssa-0.20030801.41.i386.rpm OK
zlib-devel-1.1.4-8.1.i386.rpm
libgcj-ssa-devel-3.5ssa-0.20030801.41.i386.rpm OK(依赖libgcj-ssa-3.5ssa-0.20030801.41.i386.rpm OK)
glibc-devel-2.3.2-95.3.i386.rpm OK(依赖glibc-headers-2.3.2-95.3.i386.rpm ok(依赖glibc-kernheaders-2.4-8.34.i386.rpm OK))
上述几个包是手动按照suggest逐个安装的,括号里代表前者以来后者,先安装后者在安装前者。然后在gcc所在的目录执行下面命令,很快就可以顺利安装完成
[root@vpc-test RPMS]# rpm -ivh --aid gcc*.rpm
warning: gcc-3.2.3-20.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing... ########################################### [100%]
1:gcc ########################################### [ 8%]
2:gcc-ssa ########################################### [ 17%]
3:zlib-devel ########################################### [ 25%]
4:gcc-c++ ########################################### [ 33%]
5:gcc-c++-ssa ########################################### [ 42%]
6:gcc-g77 ########################################### [ 50%]
7:gcc-g77-ssa ########################################### [ 58%]
8:gcc-gnat ########################################### [ 67%]
9:gcc-java ########################################### [ 75%]
10:gcc-java-ssa ########################################### [ 83%]
11:gcc-objc ########################################### [ 92%]
12:gcc-objc-ssa ########################################### [100%]
在AS4中测试gcc的依赖关系简单得多,直接rpm -ivh --aid gcc*.rpm就可以搞定了。
开发需要不得不用centos5,不得不用rpm,果然又碰上了预料之中的包依赖关系的问题。mysql-3.23.52-3.i386需要perl-DBD-MySQL- 2.1017-3,而perl-DBD-MySQL-2.1017-3又需要libmysqlclient10.so,这个文件包含在mysql- 3.23.52-3.i386中,这就造成了死循环。
在http://www.newsmth.net/bbscon.php?bid=69&id=1621看到一个解决的技巧,就是把所有包的名字都列上去,这样就不会提示缺少某个包了
一般可以把所有要安装的包放在一个目录里,然后rpm -ivh *.rpm
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/1498/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2023-8-16 17:53
评论列表