服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - Linux yum安装过程图文详解

Linux yum安装过程图文详解

2020-04-03 18:30Linux教程网 Linux

当我们在liunx系统中安装某个软件时,经常会遇到一些软件的依赖问题。yum或者Yellow dog Update或者Modified是杜克大学为了提高RPM软件包安装性而开发的一种软件包管理器。

Yum可以从众多软件包仓库中搜索软件的依赖关系,因此可以减少由于依赖关系带来的问题。还有就是我们在使用图形界面时,在应用程序-添加删除软件下的浏览里是空的。如下图:

Linux yum安装过程图文详解

第一种方法:(推荐)

第一步:新建一个文件夹,并把光盘内的所有文件复制到这个文件夹里:

[root@localhost ~]# mkdir /yum

[root@localhost ~]# cp -rvf /misc/cd/* /yum

第二步:备份repodata文件。因为有四个文件夹里都有这个文件,所以都要备份。

[root@localhost ~]# mv /yum/Server/repodata /yum/Server/repodata.bak

[root@localhost ~]# mv /yum/VT/repodata /yum/VT/repodata.bak

[root@localhost ~]# mv /yum/Cluster/repodata /yum/Cluster/repodata.bak

[root@localhost ~]# mv /yum/ClusterStorage/repodata /yum/ClusterStorage/repodata.bak

第三步:安装工具包:

[root@localhost ~]# rpm -ivh /yum/Server/createrepo-0.4.11-3.el5.noarch.rpm

第四步:生成仓库数据库:

[root@localhost ~]# createrepo -g /yum/Server/repodata.bak/comps-rhel5-server-core.xml /yum/Server/

[root@localhost ~]# createrepo -g /yum/VT/repodata.bak/comps-rhel5-vt.xml /yum/VT/

[root@localhost ~]# createrepo -g /yum/Cluster/repodata.bak/ /yum/Cluster

[root@localhost ~]# createrepo -g /yum/ClusterStorage/repodata.bak/comps-rhel5-cluster-st.xml /yum/ClusterStorage/

第五步:查看仓库数据文件:

[root@localhost ~]# ls /yum/Server/repodata/

comps-rhel5-server-core.xml//这个文件软件包组的分类。

filelists.xml.gzother.xml.gzprimary.xml.gz//这三个文件为软件包列表文件。

repomd.xml //这个文件为MD5校验信息。

在/yum/VT /yum/Cluster /yum/ClusterStorage下面都有这几个文件,作用和这一样。如果想更新软件包,只需把下载完的软件包放在Server或者其他三个目录里,再使用第四步重新生成数据库文件即可。

第六步:客户端配置:主要修改下面红色的部分:

[root@localhost ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/chenbin.repo

[root@localhost ~]# vi /etc/yum.repos.d/chenbin.repo

[rhel-Server]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///yum/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-VT]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///yum/VT

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-Cluster]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///yum/Cluster

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-ClusterStorage]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///yum/ClusterStorage

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

第七步:查看:如图,已经出现软件列表了。

Linux yum安装过程图文详解

如果在上图中的编辑里选择软件存储库,就出现下图:

Linux yum安装过程图文详解

如果把这里的勾去掉,再次打开就没有软件列表了,同时在/etc/yum.repos.d/chenbin.repo配置文件下的enabled=0。

清除一下yum安装时的缓存:

[root@localhost ~]# yum clean all

安装一个软件试试:

[root@localhost ~]# rpm -ivh /yum/Server/httpd-2.2.3-22.el5.i386.rpm

warning: /yum/Server/httpd-2.2.3-22.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

error: Failed dependencies:

libapr-1.so.0 is needed by httpd-2.2.3-22.el5.i386

libaprutil-1.so.0 is needed by httpd-2.2.3-22.el5.i386

因为依赖关系,所以不能安装。用如下命令安装:

[root@localhost ~]# yum install /yum/Server/httpd-2.2.3-22.el5.i386.rpm

系统会自动安装完成。Yum缷载如下:

[root@localhost ~]# yum remove httpd。

1.2

第一步:同上,创建一个新文件夹,并把光盘的内容全部复制到该文件夹内:

[root@localhost ~]# mkdir /yum

[root@localhost ~]# cp -rvf /misc/cd/* /yum

第二步:安装工具包:

[root@localhost ~]# rpm -ivh /yum/Server/createrepo-0.4.11-3.el5.noarch.rpm

第三步:生成仓库数据库:

[root@localhost ~]# cd /yum

[root@localhost yum]# createrepo . //注意后面的.

第四步:查看文件:文件作用同上:

[root@localhost yum]# ls /yum/repodata/

filelists.xml.gzother.xml.gzprimary.xml.gzrepomd.xml

第五步:客户端配置:

[root@localhost ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/chenbin.repo

[root@localhost ~]# vi /etc/yum.repos.d/chenbin.repo

[rhel-chenbin]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///yum/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

清除yum安装时的缓存:

[root@localhost ~]# yum clean all

至此,yum安装完成,但使用这种方法安装后在应用程序-添加删除软件的列表是空的,但使用yum安装软件是可以的。

[root@localhost ~]# yum install /yum/Server/httpd-2.2.3-22.el5.i386.rpm

[root@localhost ~]# yum remove httpd

1.3

首先把光盘放入光驱内:

然后复制配置文件:

[root@localhost ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/chenbin.repo

最后编辑配置文件:

[root@localhost ~]# vi /etc/yum.repos.d/chenbin.repo

[rhel-Server]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///misc/cd/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-VT]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///misc/cd/VT

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-Cluster]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///misc/cd/Cluster

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[rhel-ClusterStorage]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///misc/cd/ClusterStorage

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

清除缓存:

[root@localhost ~]# yum clean all

这种方法安装后在应用程序-添加删除软件里也有列表。同样可以使用yum安装缷载

[root@localhost ~]# yum install /misc/cd/Server/httpd-2.2.3-22.el5.i386.rpm

[root@localhost ~]# yum remove httpd

如果把光盘拿出后,在应用程序-添加删除软件就没有列表了,只要放入光盘就有。

1.4

1.安装软件包:

yum install package

yum localinstall package 从本机目录安装软件包

yum groupinstall group 安装某个组件的全部软件包

2.更新软件包:

yum update package

yum check-update 列出所有可更新的软件包

yum list updates mysql* 查找mysql的更新

yum update 更新所有可更新的软件包

yum update mysql* 更新所有mysql的软件包

yum groupupdate group 更新某个组件的所有软件包

yum list 列出所有已安装和仓库中可用的软件包

yum list available 列出仓库中所有可用的软件包

yum list updates 列出仓库中比当前系统更新的软件包

yum list installed 列出已安装的软件包

yum list recent 列出新加入仓库的软件包

yum info 查询软件包信息

3.删除软件包:

yum remove package

yum groupremove group 删除某个组件的全部软件包

4.清除软件包

yum clean packages 清除遗留在缓存里的包文件

yum clean metadata 清除遗留在缓存里的元数据

yum clean headers 清除遗留在缓存里的头文件

yum clean all 清除包文件,元数据,头文件

5.搜索软件包:

yum search package

yum info package 查找一个软件包的信息

yum list package 列出包含指定信息的软件包

yum list installed 列出已安装的软件包

yum list extras 列出不是通过软件仓库安装的软件包

yum list *ttp* 列出标题包含ttp的软件包

yum list updates 列出可以更新的软件包

6.查找特定文件是由什么软件包提供的:

yum whatprovides filename

例子:

yum whatprovides httpd.conf

可用选项

–disalberepo=lib 禁用某个软件仓库

–enalberepo=lib 启用某个软件仓库

-C 禁用使用本机缓存的元数据

例子:

yum –disalberepo=livna|–enalberepo=livna install mplayer

yum -C info httpd

延伸 · 阅读

精彩推荐
  • Linux确保Linux系统安全的前提条件 漏洞防护

    确保Linux系统安全的前提条件 漏洞防护

    Linux 作为开放式的操作系统受到很多程序员的喜爱,很多高级程序员都喜欢编写Linux操作系统的相关软件。这使得Linux操作系统有着丰富的软件支持,还有无...

    Linux之家2642020-04-11
  • Linuxlinux中rmdir命令使用详解(删除空目录)

    linux中rmdir命令使用详解(删除空目录)

    今天学习一下linux中命令: rmdir命令。rmdir是常用的命令,该命令的功能是删除空目录,一个目录被删除之前必须是空的 ...

    linux命令大全5372019-11-19
  • LinuxLinux常用的日志文件和常用命令

    Linux常用的日志文件和常用命令

    成功地管理任何系统的关键之一,是要知道系统中正在发生什么事。 Linux 中提供了异常日志,并且日志的细节是可配置的。Linux 日志都以明文形式存储,所...

    Linux教程网2632020-04-18
  • LinuxLinux上设置用户通过SFTP访问目录的权限的方法

    Linux上设置用户通过SFTP访问目录的权限的方法

    这篇文章主要介绍了Linux上设置用户通过SFTP访问目录的权限的方法,SFTP可以理解为使用SSH协议进行FTP传输的协议,因而同时要对OpenSSH进行相关设置,需要的朋...

    OSChina10022019-06-19
  • LinuxLinux中环境变量配置的步骤详解

    Linux中环境变量配置的步骤详解

    Linux中环境变量包括系统级和用户级,系统级的环境变量是每个登录到系统的用户都要读取的系统变量,而用户级的环境变量则是该用户使用系统时加载的...

    Myths7882022-02-10
  • Linux手把手教您在 Linux 上使用 GPG 加解密文件

    手把手教您在 Linux 上使用 GPG 加解密文件

    在本教程中,我将告诉你如何用 GPG 加密和解密文件。这是一个简单的教程,你可以在你的 Linux 系统上尝试所有的练习。这将帮助你练习 GPG 命令,并在你...

    Linux中国6962021-12-15
  • LinuxLinux lnmp下无法使用mail发邮件的两种解决方法

    Linux lnmp下无法使用mail发邮件的两种解决方法

    在配置了lnmp环境后,出现了mail函数不能发送邮件的问题,其实有两种方法,一是使用sendmail组件,而是使用postfix。下面为大家一一介绍下 ...

    Linux之家4042019-09-17
  • Linux详解Linux系统下PXE服务器的部署过程

    详解Linux系统下PXE服务器的部署过程

    这篇文章主要介绍了Linux系统下PXE服务器的部署过程,包括对PXE的API架构作了一个基本的简介,需要的朋友可以参考下...

    运维之道9812019-07-04