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

  • 2020-05-12 06:42:02
  • OfStack

1. Background overview

In a real production environment, there are two main practical problems with installing the rpm package on an linux system

1) in the process of installing the rpm package, there are constantly emerging dependency problems, which lead to the need to manually install more packages according to the prompts or information queries

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

In view of the above, this article will detail the yum tool and how to configure the local yum source

2. Introduction to yum tools

The & # 8226; As the software manager of the rpm package, yum tool can perform the daily management of the installation, upgrade and deletion of the rpm package, and can automatically analyze the dependencies among the rpm packages, greatly simplifying the maintenance cost of the rpm package.

The & # 8226; yum tool configuration, the main is controlled by two files: / etc/yum conf and/etc/yum repos. d/filename repo & # 8226; About /etc/ yum.conf files: mainly responsible for global configuration [main], in addition, software warehouse can be configured here (repository)

The & # 8226; About/etc yum. repos. d/filename repo: main undertake specific software configuration of the warehouse (if the above yum. conf configuration software in the warehouse, here also can choose not to configure), filename can define itself.

3. Details of main parameters of /etc/ yum.conf

This file is mainly responsible for global configuration. If the configuration of repository is not done in this file, no change is generally required

The following is the default copy of yum.conf configuration of system yum, which is explained as follows:


[root@sunny yum.repos.d]# cat /etc/yum.conf 
[main] --main Define global properties, only available 1 a  
cachedir=/var/cache/yum -- define yum Cache directory used to store downloads stored rpm Package etc. 
keepcache=0 -- After successful installation, cache data is saved. 0 : do not save, 1 : save  
debuglevel=2 -- Debug level ( 0-10 ), by default 2
logfile=/var/log/yum.log -- define yum Log directory 
distroverpkg=redhat-release -- By specifying which is specific to the system distribution rpm Package to determine the current version of the system. The default value is redhat-release
tolerant=1 -- Defines whether the command line is tolerant of package-related errors. 0 : intolerance, 1 : tolerance 
exactarch=1 -- Define when update rpm Packages, yum Whether to upgrade only the packages of the current architecture.  -- When set to 1 Will not happen i386 Package to upgrade to the i686
obsoletes=1
gpgcheck=1 -- Is the definition correct rpm Packages are GPG Check. 0 : no check, 1 : check 
plugins=1 -- Defines whether to use a plug-in. 0 : no, 1 That would allow  
# 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 mask RPM packages that do not want to be updated. You can use wildcards and separate multiple RPM packages with Spaces.

4, / etc yum. repos. d/filename. Main parameters explanation repo file

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

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


[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 different repository, one or more repository can be defined in one filename.repo file

name: used to describe repository

baseurl: used to specify the source location to obtain the rpm package. http://, ftp://, file://3 protocols are supported.

enabled: used to define whether this software repository is available. 0: not available, 1: available

gpgcheck: defines whether an GPG check is performed on an rpm package.

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

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 of the rpm package, support the wildcard *, and, if installed, display the available repositories

yum list installed |grep rpm package: check to see if the rpm package is installed

yum info rpm package: view the rpm package details

yum check-update: check for available rpm package updates

yum install rpm package: install the rpm package with support for wildcards *

yum remove rpm package: delete the rpm package

yum clean packages: clear the rpm package cache

yum clean headers: clear the rpm header cache

yum clean all: clear the rpm header and package cache

Configure a concrete example of the local yum source

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


-- The installation gcc-c++ Package that cannot be installed due to a lack of dependencies -- If manual installation is used, install it at the installation prompt rpm There may be other dependent packages required during the package process [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
-- Let's start by configuring the local source yum The method is installed from the mirror disc -- View the file system, not mounted at this time 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
-- create cdrom Mount point directory -- The mount point directory name is optional, where the author created the directory name cdrom As a mount point 
[root@sunny ~]# mkdir /cdrom
-- mount cdrom , and view the mount 
[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
-- Enter the cdrom Directory, ok rpm The location of the package -- Notice, rpm The absolute path to the directory where the package is located will be the following yum the url The source path 
[root@sunny Server]# pwd
/cdrom/Server
-- create filename.repo File, defined by the author here filename.repo called newyum.repo-- It's important to note that since yes baseurl As well as gpgkey Are local locations, so use file:// agreement -- Notice, file:// The following is the absolute path where the file is located, so file:// Later on / The beginning, therefore file:/// ( 3 a / ) 
[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
-- A query for the software repository available at this time shows that the library you just configured is available 
[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
-- using yum Install the gcc-c++ package -- As you can see, during installation, yum The dependencies are handled and the corresponding packages are installed 
[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!
-- Query the installation results to make sure the installation is 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

Related articles: