一.软件安装包格式类型
安装包格式类型 | 适用的系统 |
---|---|
rpm | linux(suse centos redhat) |
deb | ub deb |
tar | 绿色软件 |
源码编译 |
二.rpm包名称分析
[dhcp]-[4.2.5-68].[el7_5.1].[x86_64].[rpm]
rpm包名称 | 说明 |
---|---|
dhcp | 软件名称 |
4.2.5-68 | 软件版本 |
el7_5.1 | 软件授权 |
x86_64 | 软件多少位 |
rpm | 软件后缀表示软件包是rpm类型的 |
在管理rpm软件包时用rpm命令
三.rpm命令
1.rpm管理命令
命令 | 含义 |
---|---|
rpm -ivh | 安装 |
rpm -v | 显示过程 |
rpm -h | hash 检测查看软件中的hash值是否有改变 |
rpm -i | install 安装 |
rpm -e | 卸载 |
rpm -q | 查看 |
rpm -a | 所有 |
rpm -qa | 查看所有安装过的软件 |
rpm -l | 列出安装然后在系统中生成的文件 |
rpm -p | 操作对象为软件包 |
rpm --scripts | 查看软件在安装或卸载时在系统中执行的脚本 |
rpm --force | 强制安装 |
rpm -nodeps | 忽略软件依赖性安装 |
rpm -K | 检测软件是否是原版软件 |
2.设定实验环境
1.建立系统安装镜像挂载点
mkdir /software
2.在虚拟机光驱中添加系统匹配镜像
3.挂载镜像到/software
mount /dev/cdrom /software ##适用于虚拟机光驱中有镜像
mount /iso/rhel-server-7.3-x86_64-dvd.iso /software ##适用于虚拟机中有镜像文件
4.ls /software/
[root@rhel7 ~]# ls /software/
addons GPL media.repo RPM-GPG-KEY-redhat-release
EFI images Packages TRANS.TBL
EULA isolinux repodata
extra_files.json LiveOS RPM-GPG-KEY-redhat-beta
3.软件包如何拆解
rpm2cpio dhcp-4.2.5-68.el7_5.1.x86_64.rpm | cpio -id
四.yum软件仓库
1.软件仓库搭建的目的
rpm不能自动解决软件依赖关系
yum仓库可以解决此问题
上层软件管理工具,最重要的功能是可以解决软件的倚赖关系
yum能够投入使用的前提是必须要有yum源,以及配置源的指向文件
2.搭建软件仓库的步骤
1.得到与当前系统匹配的系统安装镜像文件
2.建立系统安装镜像挂载点:
mkdir /softwaresource
3.挂载镜像到镜像挂载点:
mount /iso/rhel-server-7.3-x86_64-dvd.iso /softwaresource
mount /dev/cdrom /softwaresource
4.配置系统访问软件路径(yum仓库指向文件)
cd /etc/yum.repos.d/
rm -fr *
在rhel7中
vim yum.repo
[rhel7] #仓库名称
name=westos rhel7 source #仓库描述
baseurl=file:///softwaresource #资源路径
gpgcheck=0|1 #软件包授权检测开关
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release #软件包授权码
enabled=1 #仓库启用开关
在rhel8中
vim yum.repo
[rhel8AppStream] #仓库名称
name=rhel8 source AppStream #仓库描述
baseurl=file:///softwaresource/AppStream #资源路径
gpgcheck=0|1 #软件包授权检测开关
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release #软件包授权码
enabled=1 #仓库启用开关
[rhel8BaseOS] #仓库名称
name=rhel7 source BaseOS #仓库描述
baseurl=file:///softwaresource/BaseOS #资源路径
gpgcheck=0|1 #软件包授权检测开关
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release#软件包授权码
enabled=1 #仓库启用开关
5.清空yum缓存识别新文件案内容
rhel7:
yum clean all
rhel8
dnf clean all
企业8中依然可以使用yum,yum其实是dnf的一个软链接
[root@rhel8_clone ~]# ls -l /bin/yum
lrwxrwxrwx. 1 root root 5 Feb 14 2019 /bin/yum -> dnf-36.查看软件仓库
rhel7:
[root@rhel7 yum.repos.d]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
rhel7 | 4.3 kB 00:00
(1/2): rhel7/group_gz | 146 kB 00:00
(2/2): rhel7/primary_db | 4.2 MB 00:00
repo id repo name status
rhel7 rhel7 source 5,152
repolist: 5,152
rhel8:
[root@rhel8_clone yum.repos.d]# dnf repolist
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel8 source AppStream 30 MB/s | 5.3 MB 00:00
rhel8 source BaseOS 24 MB/s | 2.2 MB 00:00
repo id repo name status
rhel8AppSream rhel8 source AppStream 4,672
rhel8BaseOS rhel8 source BaseOS 1,658
五.yum命令
命令 | 说明 |
---|---|
yum install | 安装 |
yum remove | 卸载 |
yum reinstall | 重新安装 |
yum list installed | available |
yum update | 更新 |
yum repolist | 列出仓库信息 |
yum history | 查看yum历史 |
yum info | 查看软件包信息 |
yum clean all | 清除yum缓存 |
yum search | 根据软件信息搜索 |
yum whatprovides | 根据软件包含文件搜索 |
yum groups install | 组安装 |
yum groups remove | 组卸载 |
yum groups info | 组信息 |
[root@rhel7 ~]# yum history ##查看yum历史
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
5 | root <root> | 2020-02-19 00:08 | Reinstall | 1
4 | root <root> | 2020-02-19 00:08 | Install | 1
3 | root <root> | 2020-02-19 00:07 | Erase | 1
2 | root <root> | 2020-02-19 00:07 | Install | 5 <
1 | System <unset> | 2020-02-12 07:41 | Install | 1390 >
history list
[root@rhel7 ~]# yum history info 5 ##查看yum历史第五条软件包信息
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Transaction ID : 5
Begin time : Wed Feb 19 00:08:38 2020
Begin rpmdb : 1396:a9b8b73d9e0589bef582f07fa390fd53cc057e08
End time : 00:08:39 2020 (1 seconds)
End rpmdb : 1396:a9b8b73d9e0589bef582f07fa390fd53cc057e08
User : root <root>
Return-Code : Success
Command Line : reinstall httpd -y
Transaction performed with:
Installed rpm-4.11.3-35.el7.x86_64 @anaconda/7.6
Installed subscription-manager-1.21.10-2.el7.x86_64 @anaconda/7.6
Installed yum-3.4.3-161.el7.noarch @anaconda/7.6
Packages Altered:
Reinstall httpd-2.4.6-88.el7.x86_64 @rhel7
history info
六.第三方软件仓库
我们以第三方画图软件kolourpaint为例:
1.把所有rpm结尾的软件包存放到一个目录/software中
[root@rhel7 software]# ls
kolourpaint-4.10.5-4.el7.x86_64.rpm kolourpaint-libs-4.10.5-4.el7.x86_64.rpm
2.createrepo -v /software ##生成软件数据库存放软件属性
3.修改yum仓库指向文件
vim /etc/yum.repos.d/yum.repo
[software]
name=software
baseurl=file:///software
gpgcheck=0
4.yum clean all
5.安装kolourpaint软件
yum install kolourpaint -y
画图软件kolourpaint安装成功