什么是rpm包
由红帽开发的软件 升级、安装、卸载、查询 工具
## vim-common-7.4.160-5.el7.x86_64.rpm vim-common:软件名称 7.4.160:版本号 5:该版本的发布次数 el7:适用系统版本(RedHat7,CentOS7)向下兼容 x86_64:系统平台 64 x86:32位 i386 rpm:包后缀名
安装方式 | 缺点 |
---|---|
rpm安装:已经编译好的源码包,下载下来后,直接使用rpm命令安装即可 | 版本会低于官方版本 |
源码安装:先编译,将源代码翻译成系统认识的软件,再安装 | 步骤复杂繁琐 |
二进制安装:绿色软件(免安装) | 不是所有程序都有二进制包 |
http://mirror.centos.org/centos/7/
1.检查光盘是否放入光驱
2.挂载
# 挂载命令 mount # 挂载语法 mount 源设备文件 目标路径 示例: [root@localhost ~]# mount /dev/cdrom /mnt mount: /dev/sr0 is write-protected, mounting read-only # 查看磁盘信息 df -h 查看磁盘分区情况,磁盘使用情况,也能查看到挂载设备及目录 # 查看挂载结果 [root@localhost ~]# ll /mnt/ total 686 -rw-rw-r-- 1 root root 14 Nov 26 2018 CentOS_BuildTag drwxr-xr-x 3 root root 2048 Nov 26 2018 EFI -rw-rw-r-- 1 root root 227 Aug 30 2017 EULA -rw-rw-r-- 1 root root 18009 Dec 10 2015 GPL drwxr-xr-x 3 root root 2048 Nov 26 2018 images drwxr-xr-x 2 root root 2048 Nov 26 2018 isolinux drwxr-xr-x 2 root root 2048 Nov 26 2018 LiveOS drwxrwxr-x 2 root root 663552 Nov 26 2018 Packages drwxrwxr-x 2 root root 4096 Nov 26 2018 repodata -rw-rw-r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7 -rw-rw-r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7 -r--r--r-- 1 root root 2883 Nov 26 2018 TRANS.TBL [root@localhost Packages]# ll /mnt/Packages -rw-rw-r-- 1 root root 1296152 Nov 12 2018 yum-3.4.3-161.el7.centos.noarch.rpm -rw-rw-r-- 1 root root 31312 Nov 21 2016 yum-langpacks-0.4.2-7.el7.noarch.rpm -rw-rw-r-- 1 root root 28348 Jul 4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm -rw-rw-r-- 1 root root 31500 Nov 12 2018 yum-plugin-aliases-1.1.31-50.el7.noarch.rpm -rw-rw-r-- 1 root root 34984 Nov 12 2018 yum-plugin-changelog-1.1.31-50.el7.noarch.rpm -rw-rw-r-- 1 root root 34500 Nov 12 2018 yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm -rw-rw-r-- 1 root root 31556 Nov 12 2018 yum-plugin-tmprepo-1.1.31-50.el7.noarch.rpm -rw-rw-r-- 1 root root 36476 Nov 12 2018 yum-plugin-verify-1.1.31-50.el7.noarch.rpm -rw-rw-r-- 1 root root 36584 Nov 12 2018 yum-plugin-versionlock-1.1.31-50.el7.noarch. [root@localhost~]# ll /mnt/Packages/zip-3.0-11.el7.x86_64.rpm -rw-rw-r-- 1 root root 266160 Nov 21 2016 /mnt/Packages/zip-3.0-11.el7.x86_64.rpm
3.卸载
# 卸载命令 umount # 卸载语法 umount 目标路径(挂载的路径) # 示例: umount /mnt
4.报错现象及解决办法
## 挂载报错 [root@ yjc ~ ] # mount /dev/cdrom /mnt mount: no medium found on /dev/sr0 原因:设备文件是空的,里面没有任何内容,光驱没有连接 ## 卸载报错 [root@localhost mnt]# umount /mnt umount: /mnt: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1)) [root@localhost mnt]# cd [root@localhost ~]# umount /mnt 原因:设备繁忙
# 语法: rpm [选项] rpm包名 ## rpm包名: - 本地包名:在系统中某个目录下的rpm包 - 远程包名:不用下载,直接使用网站上的rpm包 # 选项: -i:安装 -v:显示安装的过程 -h:显示安装的进度条 --test:仅测试,不安装 -----------------------------↓下面两个选项要配合使用 --force:强制安装 --nodeps:忽略依赖关系 ## 注意:rpm命令管理rpm包的缺点,无法解决依赖关系 示例: [root@localhost~]# rpm -ivh /mnt/Packages/mariadb-server-5.5.60-1.el7_5.x86_64.rpm error: Failed dependencies: libaio.so.1()(64bit) is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 mariadb(x86-64) = 1:5.5.60-1.el7_5 is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 perl(DBI) is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 perl(Data::Dumper) is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 perl-DBD-MySQL is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 perl-DBI is needed by mariadb-server-1:5.5.60-1.el7_5.x86_64 # -i 示例: [root@localhost~]# rpm -i /mnt/Packages/mariadb-server-5.5.60-1.el7_5.x86_64.rpm # -v 示例: [root@localhost~]# rpm -iv /mnt/Packages/zip-3.0-11.el7.x86_64.rpm Preparing packages... zip-3.0-11.el7.x86_64 # -h 示例: [root@localhost~]# rpm -ivh /mnt/Packages/zip-3.0-11.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:zip-3.0-11.el7 ################################# [100%] # --test 示例: [root@localhost~]# rpm -ivh --test /mnt/Packages/zip-3.0-11.el7.x86_64.rpm Preparing... ################################# [100%] #--force --nodeps示例: [root@localhost~]# rpm -ivh --force --nodeps /mnt/Packages/samba-4.8.3-4.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:samba-0:4.8.3-4.el7 ################################# [100%] # - 远程包名:不用下载,直接使用网站上的rpm包 示例: root@localhost~]# rpm -ivh https://mirrors.aliyun.com/centos/7.9.2009/os/x86_64/Packages/zip-3.0-11.el7.x86_64.rpm
# 语法 rpm [选项] rpm包名 # 选项 -q:查看指定的安装包是否安装 ------↓以下选项皆要配合-q使用 ----- -a:全部安装过的包 -i:详细信息 -l:列出rpm包相关的配置文件和目录 -c:只查看该软件包相关的配置文件 -d:只查看该软件的帮助文档文件 -f:反向查找,根据配置文件,目录,帮助文档,查找该文件属于哪个包 --scripts:查看安装包,安装之前之后,和卸载之前之后要执行的脚本 ## -q 示例: 1)已经安装 [root@localhost~]# rpm -q mariadb-server mariadb-server-5.5.68-1.el7.x86_64 2)没有安装 [root@localhost~]# rpm -q zip package zip is not installed ## -a -q 示例: 1) [root@localhost~]# rpm -qa firewalld-0.5.3-5.el7.noarch grub2-common-2.02-0.76.el7.centos.noarch kernel-3.10.0-957.el7.x86_64 kbd-legacy-1.15.5-15.el7.noarch . . 2) 配合过滤查询安装过的有关命令 [root@localhost~]# rpm -aq |grep 'unzip' unzip-6.0-24.el7_9.x86_64 ## -q -i 示例: 选项-q要放在最前 [root@localhost~]# rpm -iaq mariadb-server mariadb-server-5.5.68-1.el7.x86_64 [root@localhost~]# rpm -qai mariadb-server Name : mariadb-server Epoch : 1 Version : 5.5.68 Release : 1.el7 Architecture: x86_64 Install Date: Sun 01 May 2022 11:43:43 PM CST Group : Applications/Databases Size : 61148588 License : GPLv2 with exceptions and LGPLv2 and BSD Signature : RSA/SHA256, Thu 15 Oct 2020 02:55:53 AM CST, Key ID 24c6a8a7f4a80eb5 Source RPM : mariadb-5.5.68-1.el7.src.rpm Build Date : Fri 02 Oct 2020 03:25:10 AM CST Build Host : x86-02.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://mariadb.org Summary : The MariaDB server and related files Description : MariaDB is a multi-user, multi-threaded SQL database server. It is a client/server implementation consisting of a server daemon (mysqld) and many different client programs and libraries. This package contains the MariaDB server and some accompanying files and directories. MariaDB is a community developed branch of MySQL. 2) 命令组合使用: [root@localhost~]# rpm -qa | grep 'unzip'| xargs rpm -qi [root@localhost~]# rpm -qi `rpm -qa | grep 'unzip'` [root@localhost~]# rpm -qi $(rpm -qa | grep 'unzip') ## -q -l 示例: [root@localhost~]# rpm -ql mariadb-server /usr/lib64/mysql/plugin/adt_null.so /usr/lib64/mysql/plugin/auth_0x0100.so /usr/lib64/mysql/plugin/auth_pam.so /usr/lib64/mysql/plugin/auth_socket.so /usr/lib64/mysql/plugin/auth_test_plugin.so /usr/lib64/mysql/plugin/daemon_example.ini /usr/lib64/mysql/plugin/dialog_examples.so /usr/lib64/mysql/plugin/ha_innodb.so /usr/lib64/mysql/plugin/ha_sphinx.so /usr/lib64/mysql/plugin/handlersocket.so /usr/lib64/mysql/plugin/libdaemon_example.so /usr/lib64/mysql/plugin/mypluglib.so /usr/lib64/mysql/plugin/qa_auth_client.so ## -q -c 示例: [root@localhost~]# rpm -qc mariadb-server /etc/logrotate.d/mariadb /etc/my.cnf.d/server.cnf /var/log/mariadb/mariadb.log ## -q -f 示例: 1)查看隶属于那个包 [root@localhost~]# rpm -qf /etc/hostname systemd-219-62.el7.x86_64 2)查看包里都有那些命令: oot@localhost~]# rpm -ql systemd | grep bin /etc/binfmt.d /etc/udev/hwdb.bin /usr/bin/bootctl /usr/bin/busctl /usr/bin/coredumpctl /usr/bin/hostnamectl ## -q -d 示例: [root@localhost~]# rpm -qd mariadb-server /usr/share/man/man1/innochecksum.1.gz /usr/share/man/man1/msql2mysql.1.gz /usr/share/man/man1/myisam_ftdump.1.gz /usr/share/man/man1/myisamchk.1.gz /usr/share/man/man1/myisamlog.1.gz /usr/share/man/man1/myisampack.1.gz ## -q --scripts 示例: [root@localhost~]# rpm -q --scripts mariadb-server preinstall scriptlet (using /bin/sh): /usr/sbin/groupadd -g 27 -o -r mysql >/dev/null 2>&1 || : /usr/sbin/useradd -M -N -g mysql -o -r -d /var/lib/mysql -s /sbin/nologin \ -c "MariaDB Server" -u 27 mysql >/dev/null 2>&1 || : postinstall scriptlet (using /bin/sh): if [ $1 -eq 1 ] ; then # Initial installation systemctl preset mariadb.service >/dev/null 2>&1 || : fi /bin/chmod 0755 /var/lib/mysql /bin/touch /var/log/mariadb/mariadb.log /usr/sbin/update-alternatives --install /usr/bin/mysqlbug \ mysqlbug /usr/lib64/mysql/mysqlbug 64 preuninstall scriptlet (using /bin/sh): if [ $1 -eq 0 ] ; then # Package removal, not upgrade systemctl --no-reload disable mariadb.service > /dev/null 2>&1 || : systemctl stop mariadb.service > /dev/null 2>&1 || : fi postuninstall scriptlet (using /bin/sh): systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall systemctl try-restart mariadb.service >/dev/null 2>&1 || : fi if [ $1 -eq 0 ] ; then /usr/sbin/update-alternatives --remove mysqlbug /usr/lib64/mysql/mysqlbug fi