Write in front: the blogger is a real combat development after training into the cause of the “hill pig”, nickname from the cartoon “Lion King” in “Peng Peng”, always optimistic, positive attitude towards things around. My technical path from Java full stack engineer all the way to big data development, data mining field, now there are small achievements, I would like to share with you what I have learned in the past, I hope to help you on the way of learning. At the same time, the blogger also wants to build a perfect technical library through this attempt. Any anomalies, errors and matters needing attention related to the technical points of the article will be listed at the end, and everyone is welcome to provide materials in various ways.

  • Please criticize any mistakes in the article and revise them in time.
  • If you have any questions you would like to discuss or learn, please contact me at [email protected].
  • The style of the published article varies from column to column, and all are self-contained. Please correct the deficiencies.

CentOS software management – YUM tools

Key words: Linux, CentOS, software management, YUM tools, resolve dependency \

The article directories

I. Introduction to YUM

1. YUM

YUM, Yellowdog Updater Modified, is a Shell front-end package manager based on RPM package management. Because it is based on the RPM package manager, the application scenario is similar to that of RPM. The supported Linux operating systems are RedHat, CentOS, and Fedora. YUM also provides graphical front-end tools: Yumex and Kyum, which need to be used when YUM is working properly.

2. YUM

  • Developing with Python
  • Need a corresponding repository
  • Automatically upgrade, install, and remove RPM packages
  • It can solve the dependency problem of RPM software package
  • You can customize multiple repositories /yum source (repository)

3. YUM Workflow

  • Run yum command
  • Read the YUM configuration file to obtain warehouse information
  • Search metadata files in the repository to determine the software required and dependent software
  • Download related software packages and verification files
  • Install software packages in sequence
  • The local cache (software meta-information) can be updated with the corresponding command when the remote repository is updated

Two, common operations

After the system is installed, network sources are configured by default. If the network is smooth, you can use the yum command to install, upgrade, and uninstall the software.

1. Common commands

  • Install {package1} [package2] […].

    • To install the latest version of the software and related dependencies, you can install multiple software packages at the same time, separated by Spaces
    • The specified package can be either a name or an RPM package file
    • When specified as an RPM package file, the effect is equivalent to localinstall
  • The update/update – to [package1] [package2] […].

    • If you do not set the software package parameters, all system software will be updated to the latest version
    • The specified package can be either a name or an RPM package file
    • When specified as an RPM package file, the effect is equivalent to localupdate
    • Update-to: indicates that the software can be upgraded to a certain version
  • Check-update: Lists all software that can be updated

  • Remove/erase {package1} [package2] […]. : Deletes the specified software package

  • list

    • If no parameter is specified, it is the same as all: lists all available software packages and installed software packages
    • Available: Lists all installable packages in the YUM source
    • Updates: Lists all packages available for updates in YUM
    • Installed: Lists information about all installed software packages

  • Info: lists detailed information about a software package or all software packages. The options supported are the same as list

  • clean

    • If no parameter is specified, the effect is the same as clean All: all local cache files will be cleared
    • Packages: Clears all downloaded software packages. They are not automatically deleted by default
    • Metadata: Clear the downloaded metadata cache file and re-download it when you run yum again
    • Expire-cache: Clears the expired cache. If cached data is still available, no deletion will be performed
    • RPMDB: clears all the RPM software database information cached locally
    • Plugins: Clear all cached data corresponding to plug-ins
    • All: Clears all cached data listed above
  • Makecache: Cache metadata locally

  • Search {string1} [string2] […]. : Searches for software packages based on the provided information. The system searches for software packages based on the software package name. If no software package is found, the system uses the description to match the SOFTWARE package URL
  • Localinstall {rpmfile1} [rpmfile2] […]. : Using yum to install an RPM package will automatically search the available sources for dependencies required for installation
  • Localupdate {rpmfile1} [rpmfile2] […]. : Upgrading an RPM package with yum automatically searches the available sources for dependencies required for installation
  • Reinstall {package1} [package2] […]. : Reinstalls a software package based on the latest version
  • Deplist {package1} [package2] […]. : Lists the dependencies of a software package

RPM software dependency can turn into a nightmare if you are not careful, yum, thank you for having you.

  • repolist [all/enabled/disabled]

    • All: displays all the yum sources
    • Enabled: Displays all the yum sources that are enabled
    • Disabled: Displays all disabled yum sources

  • Check: Checks whether the local RPM database and product information is incorrect

2. Common options

  • -y: indicates the option in the yes reply process
  • -q: cancels output and installs silently
  • -v: displays detailed information
  • -r: Sets the maximum waiting time, in minutes
  • –version: Displays the current version of the YUM tool

  • — Skip-broken: Resolve dependency errors when uninstalling software
  • Downloadonly: downloads only software
  • –downloaddir: specifies the path to download the software package

3. YUM source management and maintenance

1. Yum configuration file

  • Yum configuration file directory: /etc/yum.repos.d
  • Yum configuration file: *.repo

2. Configure the domestic mirror

By default, Base corresponds to the network image, and Media corresponds to the local image. The IP address of the network image is the image list provided by centos.org. You can change the image to the domestic ali and netease images to improve the download speed.

  • Backing up the original Base configuration file (Optional)
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
Copy the code
  • Download the Aliyun YUM configuration file and write it into the corresponding file
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
Copy the code

  • To generate cache
yum makecache
Copy the code

Configure the local YUM source

1. Description of configuration items

  • [ServerID] : Unique IDENTIFIER of the REPO, used to distinguish different REPOs

  • Name: Description of the REPO. Variable values can be quoted using $

  • Mirrorlist: indicates the address of the mirrorlist. After this function is opened, a list of multiple mirror addresses is displayed. Mirror resources are automatically scanned and selected in the list

    • Release: a large version number, such as 6 or 7
    • Arch: System architecture, 32-bit generally corresponds to I386, 64-bit corresponds to X86_64
    • Repo: Warehouse type, such as OS, Fasttrack, etc
    • Infra: This option can be omitted. The corresponding value is stock, which can be viewed in /etc/yum/vars/infra



  • Baseurl: Points directly to a YUM source address that supports multiple protocols

    • HTTP: network transport protocol
    • FTP: file transfer protocol
    • File: a file protocol that can point to a local disk path
  • Gpgcheck: indicates whether to enable GPG check

    • 0: shut down
    • 1: open
  • Gpgkey: specifies the URL of the verification file

  • Enabled: Indicates whether to enable the configuration

    • 0: shut down
    • 1: open
  • Failovermethode: How to select when the warehouse fails

    • Roundrobin: The default option is selected randomly
    • Priority: Selected in sequence

2. Mount the CD-ROM image

Since system images contain most common software packages, they are generally used as the source of YUM when offline. You can mount an IMAGE file to a VM, set up an FTP server on a physical server, burn the image file to a USB flash drive and mount it, or copy all the contents to a path in the system.

After the CD-ROM image is mounted, it will be identified as cdrom under /dev. Run the following command to mount the cd-rom image:

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
Copy the code

3. Modify the configuration file

  • Disable the default Base configuration, or the server will not be found when there is no network connection
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
Copy the code
  • Using the Media file as the template, specify baseurl as the cd-rom mounting path and complete the configuration as follows (centos-media.repo) :

[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
Copy the code

If gpgCheck is set to 1, the gpgkey value must be set to the path where the check file is located, for example, / MNT /cdrom/RPM -gpg-key-centos-6

4. Verify availability

yum makecache
Copy the code

* * and