软件管理以及yum工作原理

  • 软件管理以及yum工作原理已关闭评论
  • 160 次浏览
  • A+
所属分类:linux技术
摘要

1.1 系统发行版的光盘或官方的服务器:
(https://developer.aliyun.com/mirror/)
(http://mirrors.sohu.com/)
(http://mirrors.163.com/)
1.2 项目官方站点
1.3 第三方组织
1.3.1 Fedora-EPEL(推荐)
1.3.2 搜索引擎
(https://pkgs.org/)
(http://rpmfind.net/)
(http://rpm.pbone.net/)
1.4 自己制作


软件管理以及yum工作原理

1.获取程序包的途径

1.1 系统发行版的光盘或官方的服务器:
(https://developer.aliyun.com/mirror/)
(http://mirrors.sohu.com/)
(http://mirrors.163.com/)
1.2 项目官方站点
1.3 第三方组织
1.3.1 Fedora-EPEL(推荐)
1.3.2 搜索引擎
(https://pkgs.org/)
(http://rpmfind.net/)
(http://rpm.pbone.net/)
1.4 自己制作

2.软件包管理器的职责

2.1 将二进制程序,库文件,配置文件,帮助文件打包成一个文件;
2.2 安装软件时按需将二进制文件,库文件,配置文件,帮助文件放到相应的位置;
2.3 生成数据库,追踪所安装的每一个文件;
2.4 软件卸载时根据安装时生成的数据库将对应的文件删除

3. 软件包管理器的核心功能

3.1 制作软件包
3.2 安装软件
3.3 卸载软件
3.4 升级软件
3.5 查询软件
3.6 校验软件

4. 软件包管理

4.1 程序的组成清单(每个包独有)
4.1.2 文件清单
4.1.3 安装或卸载时运行的脚本
4.2 数据库(公共)
4.2.2 程序包名称及版本
4.2.3 依赖关系
4.2.4 功能说明
4.2.5 安装生成的各文件的文件路径及校验码信息

[root@lnh ~]# md5sum anaconda-ks.cfg  71756277efda3ecedb2c80cff65a68c4  anaconda-ks.cfg [root@lnh ~]# echo "#" >>anaconda-ks.cfg  [root@lnh ~]# md5sum anaconda-ks.cfg  f299732a8f45d688add57e88e1a7d8f7  anaconda-ks.cfg //查看校验码信息 

5. 软件包分类

5.1 二进制格式(编译好的,装上就可以用)
5.1.2 rpm包作者下载源程序,编译配置完成后,制作成rpm包
5.1.3 why would we do that? because:
5.1.3.1 有些特性是编译时选定的,如果编译时未选定此特性,将无法使用
5.1.3.2 rpm包的版本会落后于源码包,甚至落后很多
5.2 源码格式(需要编译,也叫定制)
5.2.1 命名方式:name-VERSION.tar.gz
5.2.1.1 VERSION:major.minor.release

6. 软件包管理工具

6.1 分类:
6.1.1 前端工具,常用的前端工具有以下这些:
yum
apt-get
zypper (suse上的rpm前端管理工具)
dnf(Fedora 22+ rpm前端管理工具)
6.1.2 后端工具,常用的后端工具有以下这些:
rpm
dpt
注意:
前端工具是依赖于后端工具的
前端工具是为了自动解决后端工具的依赖关系而存在的

7. 软件安装方式

通过前端工具安装
通过后端工具安装
编译安装

8. rpm包命名规范

软件管理以及yum工作原理
包的组成
主包:bind-9.7.1-1.el5.i586.rpm
子包:bind-libs-9.7.1-1.el5.i586.rpm bind-utils-9.7.1-1.el5.i586.rpm
包名格式
name-version-release-arch.rpm
bind-major.minor.release-release.arch.rpm
包名格式说明
major(主版本号):重大改进
minor(次版本号):某个子功能发生重大变化
release(发行号):修正了部分bug,调整了一点功能
常见的arch
x86:i386,i486,i586,i686
x86_64:x64,x86_64,amd64
跟平台无关:noarch

9. rpm包管理

9.1 什么是rpm及其作用

rpm是Redhat Package Manager的简称,用于管理软件包。
rpm有一个强大的数据库/var/lib/rpm。
rpm的管理工作包括软件的安装、卸载、升级、查询、校验、重建数据库、验证软件包来源合法性等等。

9.2 RPM包安装

// 语法: rpm -ivh /PATH/TO/PACKAGE_FILE ...
// 常用选项:
-i: 安装
-v: 显示详细信息
-h: 显示安装进度条
--test: 测试安装,但不真正执行安装过程
--nodeps: 忽略依赖关系
--replacepkgs: 重新安装,替换原有安装
--oldpackage: 降级
--force: 强行安装,可以实现重装或降级
--nodigest: 不检查包的完整性
--nosignature: 不检查包的来源合法性
--noscripts: 不执行程序包脚本片断
%pre:安装前脚本 --nopre
%post:安装后脚本 --nopost
%preun:卸载前脚本 --nopreun
%postun:卸载后脚本 --nopostun

[root@lnh ~]# ls /var/lib/rpm Basenames     Enhancename      Packages       Suggestname Conflictname  Filetriggername  Providename    Supplementname __db.001      Group            Recommendname  Transfiletriggername __db.002      Installtid       Requirename    Triggername __db.003      Name             Sha1header Dirnames      Obsoletename     Sigmd5 //这些都是rpm包 [root@lnh ~]# mount /dev/cdrom /mnt/ mount: /mnt: WARNING: device write-protected, mounted read-only. //read-only出现这个只读表示挂载成功 [root@lnh ~]# ls /mnt/ AppStream  BaseOS  EFI  images  isolinux  LICENSE  media.repo  TRANS.TBL //安装包的位置一般在AppStream BaseOS里面 [root@lnh ~]# ls /mnt/BaseOS/ Packages  repodata [root@lnh ~]# ls /mnt/AppStream/ Packages  repodata [root@lnh ~]# ls /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm //可以看见我们需要的包在这个里面 [root@lnh ~]# rpm -ivh /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.19.5-10.el8               ################################# [100%] //此处是本地包的安装,要指明包的路径 [root@lnh ~]# rpm -ivh --test /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] [root@lnh ~]# rpm -q wget  package wget is not installed //此处是测试是否可以安装成功并没有真正的安装上去 [root@lnh ~]# rpm -ivh  /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.19.5-10.el8               ################################# [100%] [root@lnh ~]# rpm -ivh --replacepkgs /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.19.5-10.el8               ################################# [100%] //重新安装替换原来的安装 [root@lnh ~]# ll total 576 -r--r--r--. 1 root root      0 Jul  4 12:20 222 -rw-------. 1 root root   1005 Jul  4 19:40 anaconda-ks.cfg -rw-------. 1 lxb  root   1003 Jul  4 13:18 lxb -rw-r--r--. 1 root root  15032 Jul  4 08:33 outfile -rw-r--r--. 1 root root    156 Jul  3 07:38 test drwxr-xr-x. 3 root root     17 Jul  4 17:20 tushanbu -rw-r--r--. 1 root root 560272 Jul  8 20:44 wget-1.14-18.el7_6.1.x86_64.rpm [root@lnh ~]# rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm  warning: wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY error: Failed dependencies: 	libcrypto.so.10()(64bit) is needed by wget-1.14-18.el7_6.1.x86_64 	libcrypto.so.10(libcrypto.so.10)(64bit) is needed by wget-1.14-18.el7_6.1.x86_64 	libidn.so.11()(64bit) is needed by wget-1.14-18.el7_6.1.x86_64 	libidn.so.11(LIBIDN_1.0)(64bit) is needed by wget-1.14-18.el7_6.1.x86_64 	libssl.so.10()(64bit) is needed by wget-1.14-18.el7_6.1.x86_64 	libssl.so.10(libssl.so.10)(64bit) is needed by wget-1.14-18.el7_6.1.x86_64 [root@lnh ~]# rpm -ivh --nodeps wget-1.14-18.el7_6.1.x86_64.rpm  warning: wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.14-18.el7_6.1             ################################# [100%] //不考虑依赖性进行安装 [root@lnh ~]# rpm -q wget  wget-1.19.5-10.el8.x86_64 [root@lnh ~]# rpm -ivh --force  /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.19.5-10.el8               ################################# [100%] //包已经存在再次强制性进行安装 

9.3 RPM包查询

rpm -q PACKAGE_NAME //查询指定的包是否已安装
rpm -qa //查询已经安装的所有包
rpm -qi PACKAGE_NAME //查询指定包的说明信息
rpm -ql PACKAGE_NAME //查询指定软件包安装后生成的文件列表
rpm -qf /path/to/somefile //查询指定的文件是由哪个rpm包安装生成的
rpm -qc PACKAGE_NAME //查询指定包安装的配置文件
rpm -qd PACKAGE_NAME //查询指定包安装的帮助文件
rpm -q --scripts PACKAGE_NAME //查询指定包中包含的脚本
rpm -q --whatprovides CAPABILITY //查询指定的CAPABILITY(能力)由哪个包所提供
如:rpm -q --whatprovides /bin/cat
rpm -q --whatrequires CAPABILITY //查询指定的CAPABILITY被哪个包所依赖
rpm -q --changelog COMMAND //查询COMMAND的制作日志
rpm -q --scripts PACKAGE_NAME //查询指定软件包包含的所有脚本文件
rpm -qR PACKAGE_NAME //查询指定的软件包所依赖的CAPABILITY
rpm -q --provides PACKAGE_NAME //列出指定软件包所提供的CAPABILITY

rpm -qpi /PATH/TO/PACKAGE_FILE //查询指定未安装包的说明信息
rpm -qpl /PATH/TO/PACKAGE_FILE //查询未安装的软件包会产生哪些文件

[root@lnh ~]# rpm -q wget  wget-1.19.5-10.el8.x86_64 //查看指定包是否安装 [root@lnh ~]# rpm -e wget  [root@lnh ~]# rpm -q wget  package wget is not installed //对已安装包进行卸载 [root@lnh ~]# rpm -qa |grep wget wget-1.19.5-10.el8.x86_64 //模糊查找系统已安装的rpm包 [root@lnh ~]# rpm -qi wget Name        : wget Version     : 1.19.5 Release     : 10.el8 Architecture: x86_64 Install Date: Fri 08 Jul 2022 07:05:56 PM CST Group       : Applications/Internet Size        : 2895440 License     : GPLv3+ Signature   : RSA/SHA256, Wed 29 Apr 2020 12:08:57 AM CST, Key ID 05b555b38483c65d Source RPM  : wget-1.19.5-10.el8.src.rpm Build Date  : Mon 27 Apr 2020 10:09:54 AM CST Build Host  : x86-02.mbox.centos.org Relocations : (not relocatable) Packager    : CentOS Buildsys <[email protected]> Vendor      : CentOS URL         : http://www.gnu.org/software/wget/ Summary     : A utility for retrieving files using the HTTP or FTP protocols Description : GNU Wget is a file retrieval utility which can use either the HTTP or FTP protocols. Wget features include the ability to work in the background while you are logged out, recursive retrieval of directories, file name wildcard matching, remote file timestamp storage and comparison, use of Rest with FTP servers and Range with HTTP servers to retrieve files over slow or unstable connections, support for Proxy servers, and configurability. //查询wget软件包的相关信息 [root@lnh ~]# rpm -ql wget /etc/wgetrc /usr/bin/wget /usr/lib/.build-id /usr/lib/.build-id/8d /usr/lib/.build-id/8d/ec58c9a41fa3f0d9966de12c634bfa25b11451 /usr/share/doc/wget /usr/share/doc/wget/AUTHORS /usr/share/doc/wget/COPYING /usr/share/doc/wget/MAILING-LIST /usr/share/doc/wget/NEWS /usr/share/doc/wget/README /usr/share/doc/wget/sample.wgetrc /usr/share/info/wget.info.gz /usr/share/locale/be/LC_MESSAGES/wget.mo /usr/share/locale/bg/LC_MESSAGES/wget.mo /usr/share/locale/ca/LC_MESSAGES/wget.mo /usr/share/locale/cs/LC_MESSAGES/wget.mo /usr/share/locale/da/LC_MESSAGES/wget.mo /usr/share/locale/de/LC_MESSAGES/wget.mo /usr/share/locale/el/LC_MESSAGES/wget.mo /usr/share/locale/en_GB/LC_MESSAGES/wget.mo /usr/share/locale/eo/LC_MESSAGES/wget.mo /usr/share/locale/es/LC_MESSAGES/wget.mo /usr/share/locale/et/LC_MESSAGES/wget.mo /usr/share/locale/eu/LC_MESSAGES/wget.mo /usr/share/locale/fi/LC_MESSAGES/wget.mo /usr/share/locale/fr/LC_MESSAGES/wget.mo /usr/share/locale/ga/LC_MESSAGES/wget.mo /usr/share/locale/gl/LC_MESSAGES/wget.mo /usr/share/locale/he/LC_MESSAGES/wget.mo /usr/share/locale/hr/LC_MESSAGES/wget.mo /usr/share/locale/hu/LC_MESSAGES/wget.mo /usr/share/locale/id/LC_MESSAGES/wget.mo /usr/share/locale/it/LC_MESSAGES/wget.mo /usr/share/locale/ja/LC_MESSAGES/wget.mo /usr/share/locale/lt/LC_MESSAGES/wget.mo /usr/share/locale/nb/LC_MESSAGES/wget.mo /usr/share/locale/nl/LC_MESSAGES/wget.mo /usr/share/locale/pl/LC_MESSAGES/wget.mo /usr/share/locale/pt/LC_MESSAGES/wget.mo /usr/share/locale/pt_BR/LC_MESSAGES/wget.mo /usr/share/locale/ro/LC_MESSAGES/wget.mo /usr/share/locale/ru/LC_MESSAGES/wget.mo /usr/share/locale/sk/LC_MESSAGES/wget.mo /usr/share/locale/sl/LC_MESSAGES/wget.mo /usr/share/locale/sr/LC_MESSAGES/wget.mo /usr/share/locale/sv/LC_MESSAGES/wget.mo /usr/share/locale/tr/LC_MESSAGES/wget.mo /usr/share/locale/uk/LC_MESSAGES/wget.mo /usr/share/locale/vi/LC_MESSAGES/wget.mo /usr/share/locale/zh_CN/LC_MESSAGES/wget.mo /usr/share/locale/zh_TW/LC_MESSAGES/wget.mo /usr/share/man/man1/wget.1.gz //查询rpm包所安装的文件 [root@lnh ~]# rpm -qc wget /etc/wgetrc //查询rpm包相关的配置文件 [root@lnh ~]# rpm -qip   /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  Name        : wget Version     : 1.19.5 Release     : 10.el8 Architecture: x86_64 Install Date: (not installed) Group       : Applications/Internet Size        : 2895440 License     : GPLv3+ Signature   : RSA/SHA256, Wed 29 Apr 2020 12:08:57 AM CST, Key ID 05b555b38483c65d Source RPM  : wget-1.19.5-10.el8.src.rpm Build Date  : Mon 27 Apr 2020 10:09:54 AM CST Build Host  : x86-02.mbox.centos.org Relocations : (not relocatable) Packager    : CentOS Buildsys <[email protected]> Vendor      : CentOS URL         : http://www.gnu.org/software/wget/ Summary     : A utility for retrieving files using the HTTP or FTP protocols Description : GNU Wget is a file retrieval utility which can use either the HTTP or FTP protocols. Wget features include the ability to work in the background while you are logged out, recursive retrieval of directories, file name wildcard matching, remote file timestamp storage and comparison, use of Rest with FTP servers and Range with HTTP servers to retrieve files over slow or unstable connections, support for Proxy servers, and configurability. //查询未安装的软件包会产生哪些文件 

9.4 RPM包升级

[root@lnh ~]# curl -O http://mirror.centos.org/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--       0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--       0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--       8  547k    8 47550    0     0  21515      0  0:00:26  0:00:02  0:00:24 2150 12  547k   12 72234    0     0  22049      0  0:00:25  0:00:03  0:00:22 2204 18  547k   18  101k    0     0  24160      0  0:00:23  0:00:04  0:00:19 2415 24  547k   24  135k    0     0  26069      0  0:00:21  0:00:05  0:00:16 2747 31  547k   31  169k    0     0  27524      0  0:00:20  0:00:06  0:00:14 3415 36  547k   36  200k    0     0  28530      0  0:00:19  0:00:07  0:00:12 3163 42  547k   42  235k    0     0  28407      0  0:00:19  0:00:08  0:00:11 3242 45  547k   45  249k    0     0  27104      0  0:00:20  0:00:09  0:00:11 2959 48  547k   48  263k    0     0  26205      0  0:00:21  0:00:10  0:00:11 2634 52  547k   52  287k    0     0  26261      0  0:00:21  0:00:11  0:00:10 2462 55  547k   55  305k    0     0  25518      0  0:00:21  0:00:12  0:00:09 2122 57  547k   57  317k    0     0  24558      0  0:00:22  0:00:13  0:00:09 1770 61  547k   61  335k    0     0  24150      0  0:00:23  0:00:14  0:00:09 1837 62  547k   62  342k    0     0  23025      0  0:00:24  0:00:15  0:00:09 1641 65  547k   65  356k    0     0  22547      0  0:00:24  0:00:16  0:00:08 1422 68  547k   68  375k    0     0  22133      0  0:00:25  0:00:17  0:00:08 1397 74  547k   74  408k    0     0  22720      0  0:00:24  0:00:18  0:00:06 1800 77  547k   77  425k    0     0  22663      0  0:00:24  0:00:19  0:00:05 1840 80  547k   80  440k    0     0  22279      0  0:00:25  0:00:20  0:00:05 2001 85  547k   85  467k    0     0  22456      0  0:00:24  0:00:21  0:00:03 2217 87  547k   87  477k    0     0  21878      0  0:00:25  0:00:22  0:00:03 2098 92  547k   92  508k    0     0  22388      0  0:00:25  0:00:23  0:00:02 2113100  547k  100  547k    0     0  23233      0  0:00:24  0:00:24 --:--:-- 25460 [root@lnh ~]# ll total 576 -r--r--r--. 1 root root      0 Jul  4 12:20 222 -rw-------. 1 root root   1005 Jul  4 19:40 anaconda-ks.cfg -rw-------. 1 lxb  root   1003 Jul  4 13:18 lxb -rw-r--r--. 1 root root  15032 Jul  4 08:33 outfile -rw-r--r--. 1 root root    156 Jul  3 07:38 test drwxr-xr-x. 3 root root     17 Jul  4 17:20 tushanbu -rw-r--r--. 1 root root 560272 Jul  8 20:44 wget-1.14-18.el7_6.1.x86_64.rpm //从网址上面进行下载老版本wget的rpm包 [root@lnh ~]# rpm -ivh --nodeps wget-1.14-18.el7_6.1.x86_64.rpm  warning: wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.14-18.el7_6.1             ################################# [100%] [root@lnh ~]# rpm -qa |grep wget wget-1.14-18.el7_6.1.x86_64 [root@lnh ~]# rpm -Fvh /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm   Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.19.5-10.el8               ################################# [ 50%] Cleaning up / removing...    2:wget-1.14-18.el7_6.1             ################################# [100%] [root@lnh ~]# rpm -e wget  [root@lnh ~]# rpm -qa |grep wget [root@lnh ~]# rpm -Fvh /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm  //如果装有老版本的,则升级;否则,退出 [root@lnh ~]# rpm -ivh --nodeps wget-1.14-18.el7_6.1.x86_64.rpm  warning: wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.14-18.el7_6.1             ################################# [100%] [root@lnh ~]# rpm -Uvh /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm   Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.19.5-10.el8               ################################# [ 50%] Cleaning up / removing...    2:wget-1.14-18.el7_6.1             ################################# [100%] [root@lnh ~]# rpm -e wget  [root@lnh ~]# rpm -qa |grep wget [root@lnh ~]# rpm -Uvh /mnt/AppStream/Packages/wget-1.19.5-10.el8.x86_64.rpm Verifying...                          ################################# [100%] Preparing...                          ################################# [100%] Updating / installing...    1:wget-1.19.5-10.el8               ################################# [100%] //如果装有老版本的,则升级;否则,则安装 

升级注意事项:
不要对内核做升级操作
Linux支持多内核版本并存,因此,可直接安装新版本内核
如果原程序包的配置文件安装后曾被修改,升级时,新版本提供的同一个配置文件并不会直接覆盖老版本的配置文件,而把新版本的文件重命名(FILENAME.rpmnew)后保留

9.5 RPM包卸载

[root@lnh ~]# rpm -q wget  wget-1.19.5-10.el8.x86_64 [root@lnh ~]# rpm -e wget  [root@lnh ~]# rpm -q wget  package wget is not installed //先查询是否有此安装包然后进行卸载 

注意:
如果其他包依赖于要卸载的包,这个被依赖的包是无法卸载的,除非强制卸载,强制卸载后依赖于这个包的其他程序将无法正常工作

yum工作原理

1. rpm的弊端

前面我们讲了下rpm,那么rpm有什么弊端呢?其弊端是显而易见的,当用rpm安装软件时,若遇到有依赖关系的软件,必须先安装依赖的软件才能继续安装我们要安装的软件,当依赖关系很复杂的情况下,这种安装方式就很让人头疼,所以我们需要另一种安装方式来解决这个问题,今天我们要来学习的就是这样一个工具--yum

2.yum的优劣势

yum有什么优势呢?yum最大的优势就是能够解决rpm的依赖问题,yum能够自动解决软件安装时的依赖关系。
当然了,有优势就有劣势,人无完人嘛,软件也是一样的,yum的缺陷就是如果在未完成安装的情况下强行中止安装过程,下次再安装时将无法解决依赖关系,Fedora22+、redhat7和centos7等可以通过手动安装dnf工具来解决此问题。
dnf是redhat7上用来代替yum的一个工具,其存在的意义就是处理yum的缺陷,但其用法与yum是完全一样的,甚至连选项都是一样的,你可以理解为dnf就是yum,只是换了个名字而已。所以说只要学会了yum就自然会dnf,大家不用担心学了yum又要去学dnf之类的问题

3. 什么是yum及其作用

那么什么是yum呢?yum是yellowdog update manager的简称,它能够实现rpm管理的所有操作,并能够自动解决各rpm包之间的依赖关系。yum是rpm的前端工具,是基于rpm来实现软件的管理的一个工具。
你不能用yum去管理windows的exe程序包,也不能用yum去管理ubuntu的deb程序包,只能用yum来管理redhat系列的rpm包

4. 挂载光盘

软件管理以及yum工作原理

[root@lnh ~]# mount /dev/cdrom /mnt/ mount: /mnt: WARNING: device write-protected, mounted read-only. //read-only出现这个只读表示挂载成功 [root@lnh ~]# ls /mnt/ AppStream  BaseOS  EFI  images  isolinux  LICENSE  media.repo  TRANS.TBL 

5. yum的原理

软件管理以及yum工作原理
yum的工作需要两部分来合作,一部分是yum服务器,另一部分就是client的yum工具。下面分别介绍两部分工作原理。
yum服务器端工作原理
所有要发行的rpm包都放在yum服务器上以提供别人来下载,rpm包根据kernel的版本号,cpu的版本号分别编译发布。yum服务器只要提供简单的下载就可以了,ftp或者http的形式都可以。yum服务器有一个最重要的环节就是整理出每个rpm包的基本信息,包括rpm包对应的版本号、conf文件、binary信息,以及很关键的依赖信息。在yum服务器上提供了createrepo工具,用于把rpm包的基本概要信息做成一张“清单”,这张“清单”就是描述每个rpm包的spec文件中信息。
client端工作原理
client每次调用yum install或者search的时候,都会去解析/etc/yum.repos.d下面所有以.repo结尾的配置文件,这些配置文件指定了yum服务器的地址。yum会定期去更新yum服务器上的rpm包清单,然后把清单下载保存到yum客户端自己的cache里面,根据/etc/yum.conf里配置(默认是/var/cache/yum下面),每次调用yum装包的时候都会去这个cache目录下去找清单,根据清单里的rpm包描述从而来确定安装包的名字、版本号、所需要的依赖包等,然后再去yum服务器下载rpm安装。(前提是不存在rpm包的cache)

6. yum的配置文件

配置文件有哪些:
/etc/yum.conf 作用:为所有仓库提供公共配置
/etc/yum.repos.d/*.repo 作用:为仓库的指向提供配置
yum的repo配置文件中可用的变量:
$releaseversion:当前OS的发行版的主版本号
$arch:平台类型
$basearch:基础平台
为yum定义repo文件:

[Repo_Name]:仓库名称 name:描述信息 baseurl:仓库的具体路径,接受以下三种类型     ftp://     http://     file:/// enabled:可选值{1|0},1为启用此仓库,0为禁用此仓库 gpgcheck:可选值{1|0},1为检查软件包来源合法性,0为不检查来源     如果gpgcheck设为1,则必须用gpgkey定义密钥文件的具体路径     gpgkey=/PATH/TO/KEY 
vim /etc/yum.conf cachedir=/var/cache/yum/$basearch/$releasever   //缓存目录 keepcache=0     //缓存软件包, 1启动 0 关闭 debuglevel=2    //调试级别 logfile=/var/log/yum.log    //日志记录位置 exactarch=1     //检查平台是否兼容 obsoletes=1     //检查包是否废弃 gpgcheck=1      //检查来源是否合法,需要有制作者的公钥信息 plugins=1       //是否启用插件 tolerant={1|0}  //容错功能,1为开启,0为关闭,当设为0时,如果用yum安装多个软件包且其中某个软件包已经安装过就会报错;当设为1时,当要安装的软件已经安装时自动忽略 installonly_limit=5 bugtracker_url metadata_expire=90m //每小时手动检查元数据 in /etc/yum.repos.d   //包含repos.d目录