


YUM solves RPM package installation dependencies and introduces the yum tool to explain the local source configuration method in detail
Jan 07, 2017 pm 01:53 PM1. 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定義全局屬性,只能有一個(gè) cachedir=/var/cache/yum --定義yum緩存目錄,用于儲(chǔ)存下載存儲(chǔ)的rpm包等 keepcache=0 --成功安裝后,緩存數(shù)據(jù)是否保存。0:不保存,1:保存 debuglevel=2 --調(diào)試級(jí)別(0-10),默認(rèn)為2 logfile=/var/log/yum.log --定義yum日志目錄 distroverpkg=redhat-release --通過指定針對(duì)系統(tǒng)發(fā)行版的rpm包,判斷當(dāng)前系統(tǒng)的版本。默認(rèn)值為redhat-release tolerant=1 --定義是否容忍命令行發(fā)生與軟件包有關(guān)的錯(cuò)誤。0:不容忍,1:容忍 exactarch=1 --定義當(dāng)更新rpm包時(shí),yum是否僅僅升級(jí)當(dāng)前架構(gòu)的包。 --當(dāng)設(shè)置為1,不會(huì)發(fā)生i386包升級(jí)到i686 obsoletes=1 gpgcheck=1 --定義是否對(duì)rpm包進(jìn)行GPG校驗(yàn)。0:不校驗(yàn),1:校驗(yàn) 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++包,提示因?yàn)橐蕾囮P(guān)系缺少包而無法安裝--若采用手工安裝,在安裝提示的rpm包過程中,可能還存在其他需要的依賴關(guān)系包[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的方法從鏡像光盤安裝--查看文件系統(tǒng),此時(shí)未掛載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 --創(chuàng)建cdrom的掛載點(diǎn)目錄--掛載點(diǎn)目錄名隨意,此處作者創(chuàng)建目錄名為cdrom的目錄作為掛載點(diǎn) [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 --進(jìn)入cdrom目錄,確定rpm包的位置--需要注意,rpm包所在的目錄絕對(duì)路徑將作為后面yum的url源路徑 [root@sunny Server]# pwd /cdrom/Server --創(chuàng)建filename.repo文件,此處作者定義filename.repo名為newyum.repo--需要注意,由于是baseurl以及gpgkey均是本地位置,因此采用file://協(xié)議--需要注意,file://后面是文件所在的絕對(duì)路徑,因此file://后面會(huì)以/開頭,因此是file:///(三個(gè)/) [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 --查詢此時(shí)可用的軟件倉庫,顯示剛剛配置的庫可用 [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處理了依賴關(guān)系,并將相應(yīng)的包進(jìn)行了安裝 [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! --查詢安裝結(jié)果,確定安裝完成。 [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!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
