Linux CentOS7 VMware 安装软件包的三种方法、rpm包介绍、rpm工具用法、yum工具用法、yum搭建本地仓库 您所在的位置:网站首页 rpm安装软件包挂载到父文件夹下的路径怎么写 Linux CentOS7 VMware 安装软件包的三种方法、rpm包介绍、rpm工具用法、yum工具用法、yum搭建本地仓库

Linux CentOS7 VMware 安装软件包的三种方法、rpm包介绍、rpm工具用法、yum工具用法、yum搭建本地仓库

2024-05-21 13:01| 来源: 网络整理| 查看: 265

一、安装软件包的三种方法

Linux下游三种安装方法,rpm工具、yum工具、源码包。rpm按装一个程序包时,有可能因为该程序包依赖另一个程序包而无法安装;yum工具,可以连同依赖的程序包一起安装。

二、rpm包介绍

rpm包是预先在Linux上编译并打包的文件,安装快捷。

缺点:安装环境必须预编译环境一致或相当;当宝与包之间存在着相互依赖,则卸载时必须先把依赖包卸载。

如果依赖的包是系统必须的,就不能卸载这个包,否则系统会崩溃。

如果虚拟机光驱中还有系统安装盘镜像,就可以通过执行命令把光驱挂载到/mnt目录下。先检查下VMware右下角的小光驱图标是否点亮,如果没有就单击下点亮,当挂载光驱后,会在/mnt/Packages目录下看到后缀为.rpm文件,这些就是rpm包。

*使用:设置光驱并挂载

rpm包格式,包名、版本号、发布版本号、平台

rpm -ivh rpm 包文件//安装

rpm -Uvh rpm 包文件// 升级

rpm -e 包名//卸载

rpm -qa //查询安装的包

rpm -q 包名 //查询指定包是否安装

rpm -qi 包名//查询指定包信息

rpm -ql 包名 //列出安装包的文件

rpm -qf 文件绝对路径 //查看一个文件是由拿个包安装的

 先点亮光驱

挂载到/mnt/目录下

[root@davery ~]# df -h文件系统 容量 已用 可用 已用% 挂载点/dev/sda3 36G 1.3G 35G 4% /devtmpfs 907M 0 907M 0% /devtmpfs 916M 0 916M 0% /dev/shmtmpfs 916M 8.6M 908M 1% /runtmpfs 916M 0 916M 0% /sys/fs/cgroup/dev/sda1 397M 123M 274M 31% /boottmpfs 184M 0 184M 0% /run/user/0

[root@davery ~]# ls /mnt/

[root@davery ~]# mount /dev/cdrom /mnt/    挂载

mount: /dev/sr0 写保护,将以只读方式挂载

[root@davery ~]# cd /mnt/ 进入[root@davery mnt]# lsCentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL[root@davery mnt]#

[root@davery mnt]# df -h文件系统 容量 已用 可用 已用% 挂载点/dev/sda3 36G 1.3G 35G 4% /devtmpfs 907M 0 907M 0% /devtmpfs 916M 0 916M 0% /dev/shmtmpfs 916M 8.6M 908M 1% /runtmpfs 916M 0 916M 0% /sys/fs/cgroup/dev/sda1 397M 123M 274M 31% /boottmpfs 184M 0 184M 0% /run/user/0/dev/sr0 8.1G 8.1G 0 100% /mnt

 

[root@davery mnt]# cd Packages 

yum-rhn-plugin-2.0.1-9.el7.noarch.rpmyum-updateonboot-1.1.31-42.el7.noarch.rpmyum-utils-1.1.31-42.el7.noarch.rpmzenity-3.22.0-1.el7.x86_64.rpmzip-3.0-11.el7.x86_64.rpmzlib-1.2.7-17.el7.i686.rpmzlib-1.2.7-17.el7.x86_64.rpmzlib-devel-1.2.7-17.el7.i686.rpmzlib-devel-1.2.7-17.el7.x86_64.rpmzlib-static-1.2.7-17.el7.i686.rpmzlib-static-1.2.7-17.el7.x86_64.rpmzsh-5.0.2-28.el7.x86_64.rpmzsh-html-5.0.2-28.el7.x86_64.rpmzziplib-0.13.62-5.el7.i686.rpmzziplib-0.13.62-5.el7.x86_64.rpmzziplib-devel-0.13.62-5.el7.i686.rpmzziplib-devel-0.13.62-5.el7.x86_64.rpmzziplib-utils-0.13.62-5.el7.x86_64.rpm

rpm包格式,包名、版本号、发布版本号、平台

......

.....

[root@davery mnt]#

三、rpm工具用法

安装rpm

[root@davery ~]# cd /mnt/[root@davery mnt]# cd Packages

[root@davery Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm   安装准备中... ################################# [100%]正在升级/安装... 1:zsh-5.0.2-28.el7 ################################# [100%][root@davery Packages]#

[root@davery Packages]# rpm -Uvh zsh-5.0.2-28.el7.x86_64.rpm 升级

[root@davery Packages]# rpm -e zsh       卸载,不会显示卸载步骤

[root@davery Packages]# rpm -qa   查询

evice-mapper-1.02.140-8.el7.x86_64cryptsetup-libs-1.7.4-3.el7.x86_64kmod-20-15.el7.x86_64dbus-1.6.12-17.el7.x86_64polkit-pkla-compat-0.1-4.el7.x86_64initscripts-9.49.39-1.el7.x86_64

....

[root@davery Packages]# rpm -q ppp 查询ppp是否安装未安装软件包 ppp 

[root@davery Packages]# rpm -qi vim-enhanced 查询安装信息Name : vim-enhancedEpoch : 2Version : 7.4.160Release : 2.el7Architecture: x86_64Install Date: 2018年04月02日 星期一 18时54分03秒Group : Applications/EditorsSize : 2292098License : VimSignature : RSA/SHA256, 2017年08月11日 星期五 04时15分38秒, Key ID 24c6a8a7f4a80eb5Source RPM : vim-7.4.160-2.el7.src.rpmBuild Date : 2017年08月02日 星期三 08时46分12秒Build Host : c1bm.rdu2.centos.orgRelocations : (not relocatable)Packager : CentOS BuildSystem Vendor : CentOSURL : http://www.vim.org/Summary : A version of the VIM editor which includes recent enhancementsDescription :VIM (VIsual editor iMproved) is an updated and improved version of thevi editor. Vi was the first real screen-based editor for UNIX, and isstill very popular. VIM improves on vi by adding new features:multiple windows, multi-level undo, block highlighting and more. Thevim-enhanced package contains a version of VIM with extra, recentlyintroduced features like Python and Perl interpreters.

Install the vim-enhanced package if you'd like to use a version of theVIM editor which includes recently added enhancements likeinterpreters for the Python and Perl scripting languages. You'll alsoneed to install the vim-common package.[root@davery Packages]#

[root@davery Packages]# rpm -ql vim-enhanced  列出安装包的文件/etc/profile.d/vim.csh/etc/profile.d/vim.sh/usr/bin/rvim/usr/bin/vim/usr/bin/vimdiff/usr/bin/vimtutor[root@davery Packages]#

[root@davery Packages]# rpm -qf /usr/bin/vim 查看一个文件是由拿个包安装的vim-enhanced-7.4.160-2.el7.x86_64[root@davery Packages]#

 

四、yum工具用法

比rpm方便,优势在于可以联网去下载所需要的安装包,然后自动安装

yum list  列出可用的rpm包

ls /etc/yun.repos.d/    查看yum配置文件

yum search vim 搜索包

yum  install -y 包名    安装

yum remove -y 包名 卸载

yum update -y 包名 更新

 [root@davery ~]# cd /mnt/[root@davery mnt]# cd Packages

[root@davery Packages]# yum install texlive  安装

root@davery Packages]# yum list  列出可安装列表

[root@davery Packages]# ls /etc/yum.repos.d/    查看yum配置文件CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo[root@davery Packages]#

 

[root@davery Packages]# ls /etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo

[root@davery Packages]# yum search vim  搜索vim已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn=========================================================== N/S matched: vim ============================================================protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptionsvim-X11.x86_64 : The VIM version of the vi editor for the X Window Systemvim-common.x86_64 : The common files needed by any version of the VIM editorvim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancementsvim-filesystem.x86_64 : VIM filesystem layoutvim-minimal.x86_64 : A minimal version of the VIM editor

名称和简介匹配 only,使用“search all”试试。[root@davery Packages]#

拓展

[root@davery Packages]# yum list |grep 'vim'  搜索vim-common.x86_64 2:7.4.160-2.el7 @base vim-enhanced.x86_64 2:7.4.160-2.el7 @base vim-filesystem.x86_64 2:7.4.160-2.el7 @base vim-minimal.x86_64 2:7.4.160-2.el7 @anacondaprotobuf-vim.x86_64 2.5.0-8.el7 base vim-X11.x86_64 2:7.4.160-2.el7 base [root@davery Packages]#

[root@davery Packages]# yum grouplist  搜索组已加载插件:fastestmirror没有安装组信息文件Maybe run: yum groups mark convert (see man yum)Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn可用的环境分组: 最小安装 基础设施服务器 计算节点 文件及打印服务器 基本网页服务器 虚拟化主机 带 GUI 的服务器 GNOME 桌面 KDE Plasma Workspaces 开发及生成工作站可用组: 传统 UNIX 兼容性 兼容性程序库 图形管理工具 安全性工具 开发工具 控制台互联网工具 智能卡支持 科学记数法支持 系统管理 系统管理工具完成[root@davery Packages]#

 

[root@davery Packages]# yum install -y protobuf-vim   安装

 

已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 protobuf-vim.x86_64.0.2.5.0-8.el7 将被 安装--> 解决依赖关系完成

 

依赖关系解决

 

========================================================================================================================================= Package 架构 版本 源 大小=========================================================================================================================================正在安装: protobuf-vim x86_64 2.5.0-8.el7 base 8.7 k

 

事务概要=========================================================================================================================================安装 1 软件包

 

总下载量:8.7 k安装大小:3.7 kDownloading packages:protobuf-vim-2.5.0-8.el7.x86_64.rpm | 8.7 kB 00:00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transaction 正在安装 : protobuf-vim-2.5.0-8.el7.x86_64 1/1 验证中 : protobuf-vim-2.5.0-8.el7.x86_64 1/1

 

已安装: protobuf-vim.x86_64 0:2.5.0-8.el7

[root@davery Packages]# yum remove protobuf-vim 卸载已加载插件:fastestmirror正在解决依赖关系--> 正在检查事务---> 软件包 protobuf-vim.x86_64.0.2.5.0-8.el7 将被 删除--> 解决依赖关系完成

依赖关系解决

========================================================================================================================================= Package 架构 版本 源 大小=========================================================================================================================================正在删除: protobuf-vim x86_64 2.5.0-8.el7 @base 3.7 k

事务概要=========================================================================================================================================移除 1 软件包

安装大小:3.7 k是否继续?[y/N]:yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction 正在删除 : protobuf-vim-2.5.0-8.el7.x86_64 1/1 验证中 : protobuf-vim-2.5.0-8.el7.x86_64 1/1

删除: protobuf-vim.x86_64 0:2.5.0-8.el7

完毕![root@davery Packages]#

[root@davery Packages]# yum update bash  更新已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 bash.x86_64.0.4.2.46-28.el7 将被 升级---> 软件包 bash.x86_64.0.4.2.46-29.el7_4 将被 更新--> 解决依赖关系完成

依赖关系解决

========================================================================================================================================= Package 架构 版本 源 大小=========================================================================================================================================正在更新: bash x86_64 4.2.46-29.el7_4 updates 1.0 M

事务概要=========================================================================================================================================升级 1 软件包

总下载量:1.0 MIs this ok [y/d/N]: yDownloading packages:Delta RPMs disabled because /usr/bin/applydeltarpm not installed.bash-4.2.46-29.el7_4.x86_64.rpm | 1.0 MB 00:00:04 Running transaction checkRunning transaction testTransaction test succeededRunning transaction 正在更新 : bash-4.2.46-29.el7_4.x86_64 1/2 清理 : bash-4.2.46-28.el7.x86_64 2/2 验证中 : bash-4.2.46-29.el7_4.x86_64 1/2 验证中 : bash-4.2.46-28.el7.x86_64 2/2

更新完毕: bash.x86_64 0:4.2.46-29.el7_4

完毕![root@davery Packages]#

五、yum搭建本地仓库

在linux不联网条件下使用

1、挂载光盘

2、删除/etc/yum.repos.d 目录下所有repo文件(删除前做一个备份)

3、创建新文件dvd.repo

4、刷新repos生成缓存

[root@davery Packages]# ls /mnt/CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL[root@davery Packages]# cd[root@davery ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bak[root@davery ~]# cd /etc/yum.repos.d[root@davery yum.repos.d]# lsCentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo[root@davery yum.repos.d]# rm -f ./*

[root@davery yum.repos.d]# vi dvd.repo

 

[dvd]name=install dvdbaseurl=file:///mntenabled=1gpgcheck=0

[root@davery yum.repos.d]# yum clean all 已加载插件:fastestmirror正在清理软件源: dvdCleaning up everythingMaybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed reposCleaning up list of fastest mirrors[root@davery yum.repos.d]#

[root@davery yum.repos.d]# yum install GConf2已加载插件:fastestmirrorLoading mirror speeds from cached hostfile正在解决依赖关系--> 正在检查事务---> 软件包 GConf2.x86_64.0.3.2.6-8.el7 将被 安装--> 正在处理依赖关系 /usr/bin/killall,它被软件包 GConf2-3.2.6-8.el7.x86_64 需要--> 正在检查事务---> 软件包 psmisc.x86_64.0.22.20-15.el7 将被 安装--> 解决依赖关系完成

依赖关系解决

========================================================================================================================================= Package 架构 版本 源 大小=========================================================================================================================================正在安装: GConf2 x86_64 3.2.6-8.el7 dvd 1.0 M为依赖而安装: psmisc x86_64 22.20-15.el7 dvd 141 k

事务概要=========================================================================================================================================安装 1 软件包 (+1 依赖软件包)

总下载量:1.1 M安装大小:6.8 MIs this ok [y/d/N]: yDownloading packages:-----------------------------------------------------------------------------------------------------------------------------------------总计 32 MB/s | 1.1 MB 00:00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transaction 正在安装 : psmisc-22.20-15.el7.x86_64 1/2 正在安装 : GConf2-3.2.6-8.el7.x86_64 2/2 验证中 : psmisc-22.20-15.el7.x86_64 1/2 验证中 : GConf2-3.2.6-8.el7.x86_64 2/2

已安装: GConf2.x86_64 0:3.2.6-8.el7

作为依赖被安装: psmisc.x86_64 0:22.20-15.el7

完毕![root@davery yum.repos.d]#

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有