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

Posted davery

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux CentOS7 VMware 安装软件包的三种方法rpm包介绍rpm工具用法yum工具用法yum搭建本地仓库相关的知识,希望对你有一定的参考价值。

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

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/目录下

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

[[email protected] ~]# ls /mnt/

[[email protected] ~]# mount /dev/cdrom /mnt/    挂载

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

[[email protected] ~]# cd /mnt/ 进入
[[email protected] mnt]# ls
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[[email protected] mnt]#

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

 

[[email protected] mnt]# cd Packages 

yum-rhn-plugin-2.0.1-9.el7.noarch.rpm
yum-updateonboot-1.1.31-42.el7.noarch.rpm
yum-utils-1.1.31-42.el7.noarch.rpm
zenity-3.22.0-1.el7.x86_64.rpm
zip-3.0-11.el7.x86_64.rpm
zlib-1.2.7-17.el7.i686.rpm
zlib-1.2.7-17.el7.x86_64.rpm
zlib-devel-1.2.7-17.el7.i686.rpm
zlib-devel-1.2.7-17.el7.x86_64.rpm
zlib-static-1.2.7-17.el7.i686.rpm
zlib-static-1.2.7-17.el7.x86_64.rpm
zsh-5.0.2-28.el7.x86_64.rpm
zsh-html-5.0.2-28.el7.x86_64.rpm
zziplib-0.13.62-5.el7.i686.rpm
zziplib-0.13.62-5.el7.x86_64.rpm
zziplib-devel-0.13.62-5.el7.i686.rpm
zziplib-devel-0.13.62-5.el7.x86_64.rpm
zziplib-utils-0.13.62-5.el7.x86_64.rpm

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

......

.....

[[email protected] mnt]#

三、rpm工具用法

安装rpm

[[email protected] ~]# cd /mnt/
[[email protected] mnt]# cd Packages

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

[[email protected] Packages]# rpm -Uvh zsh-5.0.2-28.el7.x86_64.rpm 升级

[[email protected] Packages]# rpm -e zsh       卸载,不会显示卸载步骤

[[email protected] Packages]# rpm -qa   查询

evice-mapper-1.02.140-8.el7.x86_64
cryptsetup-libs-1.7.4-3.el7.x86_64
kmod-20-15.el7.x86_64
dbus-1.6.12-17.el7.x86_64
polkit-pkla-compat-0.1-4.el7.x86_64
initscripts-9.49.39-1.el7.x86_64

....

[[email protected] Packages]# rpm -q ppp 查询ppp是否安装
未安装软件包 ppp 

[[email protected] Packages]# rpm -qi vim-enhanced 查询安装信息
Name : vim-enhanced
Epoch : 2
Version : 7.4.160
Release : 2.el7
Architecture: x86_64
Install Date: 2018年04月02日 星期一 18时54分03秒
Group : Applications/Editors
Size : 2292098
License : Vim
Signature : RSA/SHA256, 2017年08月11日 星期五 04时15分38秒, Key ID 24c6a8a7f4a80eb5
Source RPM : vim-7.4.160-2.el7.src.rpm
Build Date : 2017年08月02日 星期三 08时46分12秒
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.vim.org/
Summary : A version of the VIM editor which includes recent enhancements
Description :
VIM (VIsual editor iMproved) is an updated and improved version of the
vi editor. Vi was the first real screen-based editor for UNIX, and is
still very popular. VIM improves on vi by adding new features:
multiple windows, multi-level undo, block highlighting and more. The
vim-enhanced package contains a version of VIM with extra, recently
introduced features like Python and Perl interpreters.

Install the vim-enhanced package if you‘d like to use a version of the
VIM editor which includes recently added enhancements like
interpreters for the Python and Perl scripting languages. You‘ll also
need to install the vim-common package.
[[email protected] Packages]#

[[email protected] 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
[[email protected] Packages]#

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

 

四、yum工具用法

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

yum list  列出可用的rpm包

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

yum search vim 搜索包

yum  install -y 包名    安装

yum remove -y 包名 卸载

yum update -y 包名 更新

 [[email protected] ~]# cd /mnt/
[[email protected] mnt]# cd Packages

[[email protected] Packages]# yum install texlive  安装

[email protected] Packages]# yum list  列出可安装列表

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

 

[[email protected] Packages]# ls /etc/yum.repos.d/CentOS-Base.repo
/etc/yum.repos.d/CentOS-Base.repo

[[email protected] Packages]# yum search vim  搜索vim
已加载插件:fastestmirror
Loading 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 descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor

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

拓展

[[email protected] 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 @anaconda
protobuf-vim.x86_64 2.5.0-8.el7 base
vim-X11.x86_64 2:7.4.160-2.el7 base
[[email protected] Packages]#

[[email protected] 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 兼容性
兼容性程序库
图形管理工具
安全性工具
开发工具
控制台互联网工具
智能卡支持
科学记数法支持
系统管理
系统管理工具
完成
[[email protected] Packages]#

 

[[email protected] Packages]# yum install -y protobuf-vim   安装

 

已加载插件:fastestmirror
Loading 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 k
Downloading packages:
protobuf-vim-2.5.0-8.el7.x86_64.rpm | 8.7 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running 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

[[email protected] 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]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running 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

完毕!
[[email protected] Packages]#

[[email protected] Packages]# yum update bash  更新
已加载插件:fastestmirror
Loading 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 M
Is this ok [y/d/N]: y
Downloading 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 check
Running transaction test
Transaction test succeeded
Running 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

完毕!
[[email protected] Packages]#

五、yum搭建本地仓库

在linux不联网条件下使用

1、挂载光盘

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

3、创建新文件dvd.repo

4、刷新repos生成缓存

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

[[email protected] yum.repos.d]# vi dvd.repo

 

[dvd]
name=install dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0

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

[[email protected] yum.repos.d]# yum install GConf2
已加载插件:fastestmirror
Loading 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 M
Is this ok [y/d/N]: y
Downloading packages:
-----------------------------------------------------------------------------------------------------------------------------------------
总计 32 MB/s | 1.1 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running 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

完毕!
[[email protected] yum.repos.d]#

 















































































































































































































































































以上是关于Linux CentOS7 VMware 安装软件包的三种方法rpm包介绍rpm工具用法yum工具用法yum搭建本地仓库的主要内容,如果未能解决你的问题,请参考以下文章

KVM安装CentOS7操作系统

<Linux环境搭建>虚拟机(VMware Workstation+CentOS7)安装及环境配置教程

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

VMware 安装centos7的流程

Linux学习总结 windos环境vmware安装centos7

VMware虚拟机安装Centos7图文教程