Home  >  Article  >  php教程  >  YUM solves RPM package installation dependencies and introduces the yum tool to explain the local source configuration method in detail

YUM solves RPM package installation dependencies and introduces the yum tool to explain the local source configuration method in detail

高洛峰
高洛峰Original
2017-01-07 13:53:561703browse

1. Background overview

In actual production environments, there are two main practical problems when installing rpm packages on Linux systems

1) Installation process of rpm packages , dependency problems are constantly emerging, resulting in the need to manually install more packages according to prompts or querying information

2) Due to the isolation of internal and external networks, the yum source of the external network cannot be connected

In view of the above, this article will introduce in detail the yum tool and the method of configuring the local yum source

2. Introduction to the yum tool

•The yum tool serves as the software management of rpm packages The server can perform daily management work such as installing, upgrading and deleting rpm packages, and can automatically analyze the dependencies between rpm packages, greatly simplifying the maintenance cost of rpm packages.

•The configuration of the yum tool is mainly controlled by two files: /etc/yum.conf and /etc/yum.repos.d/filename.repo •About the /etc/yum.conf file : Mainly responsible for global configuration [main], in addition, you can also configure the software warehouse (repository) here

• About /etc/yum.repos.d/filename.repo: Mainly responsible for the configuration of specific software warehouses ( If the software warehouse is configured in yum.conf above, you can also choose not to configure it here), and the filename can be defined by yourself.

3. Detailed explanation of the main parameters of the /etc/yum.conf file

This file is mainly responsible for global configuration. If you do not configure the repository in this file, generally no changes are required

The following is the default yum.conf configuration of system yum. The specific explanation is as follows:

[root@sunny yum.repos.d]# cat /etc/yum.conf 
[main] --main定义全局属性,只能有一个 
cachedir=/var/cache/yum --定义yum缓存目录,用于储存下载存储的rpm包等
keepcache=0 --成功安装后,缓存数据是否保存。0:不保存,1:保存 
debuglevel=2 --调试级别(0-10),默认为2
logfile=/var/log/yum.log --定义yum日志目录
distroverpkg=redhat-release --通过指定针对系统发行版的rpm包,判断当前系统的版本。默认值为redhat-release
tolerant=1 --定义是否容忍命令行发生与软件包有关的错误。0:不容忍,1:容忍
exactarch=1 --定义当更新rpm包时,yum是否仅仅升级当前架构的包。 --当设置为1,不会发生i386包升级到i686
obsoletes=1
gpgcheck=1 --定义是否对rpm包进行GPG校验。0:不校验,1:校验
plugins=1 --定义是否使用插件。0:不允许,1:允许 
# Default.
# installonly_limit = 3
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

In addition to the above parameters, the main parameters that may be used are:
exclude: This parameter is mainly used to block RPM packages that you do not want to update. You can use wildcards and use spaces to separate multiple RPM packages.

4. Detailed explanation of the main parameters of the /etc/yum.repos.d/filename.repo file

This file is mainly responsible for the configuration of the specific software warehouse. If it is in /etc It is configured in the /yum.conf file, you can choose not to configure it.

The following is the system yum default software warehouse configuration file:

[root@sunny yum.repos.d]# cat rhel-debuginfo.repo 
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

The parameters are explained as follows:

[rhel-debuginfo]: used to distinguish between different repository, in a filename.repo file, you can define one or more repositories

name: used to describe the repository

baseurl: used to specify the acquisition The source location of the rpm package supports http://, ftp://, and file:// protocols.

enabled: Used to define whether this software repository is available. 0: Unavailable, 1: Available

gpgcheck: Define whether to perform GPG verification on the rpm package.

gpgkey: The location of the gpg key file used to define verification.

5. Introduction to common commands

The following are common commands for yum management

yum repolist: View available software warehouse information

yum list rpm package: View the installation status of the rpm package, supports wildcard *, if it is installed, the available software repository is displayed

yum list installed |grep rpm package : Check whether the rpm package is installed

yum info rpm package: Check the rpm package details

yum check-update: Check the available rpm package updates

yum install rpm package: Install rpm package, supports wildcard *

yum remove rpm package: Delete rpm package

yum clean packages: Clear rpm package Cache

yum clean headers: Clear the rpm header file cache

yum clean all: Clear the rpm header file and package cache

6, Specific example of configuring local yum source

The system used in this example is redhat 5.8 64-bit. The specific process and instructions are as follows:

--安装gcc-c++包,提示因为依赖关系缺少包而无法安装--若采用手工安装,在安装提示的rpm包过程中,可能还存在其他需要的依赖关系包[root@sunny Desktop]# rpm -ivh gcc-c++-4.1.2-52.el5.x86_64.rpm 
warning: gcc-c++-4.1.2-52.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
gcc = 4.1.2-52.el5 is needed by gcc-c++-4.1.2-52.el5.x86_64
libstdc++-devel = 4.1.2-52.el5 is needed by gcc-c++-4.1.2-52.el5.x86_64
--下面开始通过配置本地源yum的方法从镜像光盘安装--查看文件系统,此时未挂载cdrom
[root@sunny ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
16G 6.1G 8.7G 42% /
/dev/sda1 99M 13M 81M 14% /boot
tmpfs 1004M 0 1004M 0% /dev/shm
--创建cdrom的挂载点目录--挂载点目录名随意,此处作者创建目录名为cdrom的目录作为挂载点
[root@sunny ~]# mkdir /cdrom
--挂载cdrom,并查看挂载情况
[root@sunny ~]# mount /dev/cdrom /cdrom
[root@sunny ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
16G 6.1G 8.7G 42% /
/dev/sda1 99M 13M 81M 14% /boot
tmpfs 1004M 0 1004M 0% /dev/shm
/dev/sr0 3.9G 3.9G 0 100% /cdrom
--进入cdrom目录,确定rpm包的位置--需要注意,rpm包所在的目录绝对路径将作为后面yum的url源路径
[root@sunny Server]# pwd
/cdrom/Server
--创建filename.repo文件,此处作者定义filename.repo名为newyum.repo--需要注意,由于是baseurl以及gpgkey均是本地位置,因此采用file://协议--需要注意,file://后面是文件所在的绝对路径,因此file://后面会以/开头,因此是file:///(三个/)
[root@sunny yum.repos.d]# vi /etc/yum.repos.d/newyum.repo 
[redhatcdrom]
name=local resource 
baseurl=fill:///cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
--查询此时可用的软件仓库,显示刚刚配置的库可用
[root@sunny yum.repos.d]# yum repolist
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
redhatcdrom | 1.5 kB 00:00 
redhatcdrom/primary | 920 kB 00:00 
redhatcdrom 3285/3285
repo id repo name status
redhatcdrom local resource 3,285
repolist: 3,285
--利用yum安装刚才的gcc-c++包--可以看到,安装过程中,yum处理了依赖关系,并将相应的包进行了安装
[root@sunny yum.repos.d]# yum install gcc-c++ -y
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
redhatcdrom | 1.5 kB 00:00 
redhatcdrom/primary | 920 kB 00:00 
redhatcdrom 3285/3285
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.1.2-52.el5 set to be updated
--> Processing Dependency: libstdc++-devel = 4.1.2-52.el5 for package: gcc-c++
--> Processing Dependency: gcc = 4.1.2-52.el5 for package: gcc-c++
--> Running transaction check
---> Package gcc.x86_64 0:4.1.2-52.el5 set to be updated
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
---> Package libstdc++-devel.x86_64 0:4.1.2-52.el5 set to be updated
redhatcdrom/filelists | 2.8 MB 00:00 
--> Running transaction check
---> Package glibc-devel.x86_64 0:2.5-81 set to be updated
--> Processing Dependency: glibc-headers = 2.5-81 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.5-81 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.18-308.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================
Package Arch Version Repository Size
======================================================================================
Installing:
gcc-c++ x86_64 4.1.2-52.el5 redhatcdrom 3.8 M
Installing for dependencies:
gcc x86_64 4.1.2-52.el5 redhatcdrom 5.3 M
glibc-devel x86_64 2.5-81 redhatcdrom 2.4 M
glibc-headers x86_64 2.5-81 redhatcdrom 596 k
kernel-headers x86_64 2.6.18-308.el5 redhatcdrom 1.4 M
libstdc++-devel x86_64 4.1.2-52.el5 redhatcdrom 2.8 M
Transaction Summary
======================================================================================
Install 6 Package(s)
Upgrade 0 Package(s)
Total download size: 16 M
Is this ok [y/N]: 
Exiting on user Command
Complete!
--查询安装结果,确定安装完成。
[root@sunny yum.repos.d]# yum list gcc-c*
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Installed Packages
gcc-c++.x86_64 4.1.2-52.el5 installed

The above is introduced by the editor. YUM solves the RPM package installation dependencies and introduces the local source configuration method of the yum tool in detail. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!

For more YUM solutions to RPM package installation dependencies and yum tool introduction to local source configuration methods, please pay attention to the PHP Chinese website for related articles!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn