CentOS 8 yum source configuration method

The CentOS8 release is released through the BaseOS and AppStream (AppStream) warehouses. AppStream is a new extension to the traditional rpm format, providing multiple major versions for a component at the same time.

After the installation of CentOS8, some software packages, such as ftp, telnet, cmake, etc., are often required to be installed during server configuration or use. Generally, we will enter, take the installation of telnet as an example:

dnf -y install telnet

或 yum -y install telnet

Or rpm -ivh telnet-1:0.17-73.el8_1.1.x86_64.rpm

After the carriage return is executed, it will generally appear:

Failed to install the package: Cannot download Packages/telnet-0.17-73.el8_1.1.x86_64.rpm: All mirrors were tried; Last error: Status code: 404 for https://mirrors.aliyun.com/centos/8/ BaseOS/x86_64/os/Packages/telnet-0.17-73.el8_1.1.x86_64.rpm (IP: 106.119.194.242)

This is because we did not set up the installation source of yum. Most of the packages we need are actually in the CentOS packages that we have downloaded locally. If you are using a virtual machine, then it will be on your virtual CD-ROM drive. .

The configuration method is as follows:

      1. Create a directory #mkdir /mnt/cdrom

      2. Mount the optical drive #sudo mount /dev/cdrom /mnt/cdrom

      3. Mount the image file #mount -o loop /mnt/CentOS-8-3-2011-x86_64-dvd.iso

      4. Edit yum source

          #vi /etc/yum.repos.d/CentOS-Linux-Media.repo

# CentOS-Linux-Media.repo
#
# You can use this repo to install items directly off the installation media.
# Verify your mount point matches one of the below file:// paths.

[media-baseos]
name=CentOS Linux $releasever - Media - BaseOS
baseurl=file:///mnt/cdrom/BaseOS/
#baseurl=file:///media/CentOS/BaseOS;file:///media/cdrecorder/BaseOS
#baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[media-appstream]
name=CentOS Linux $releasever - Media - AppStream
baseurl=file:///mnt/cdrom/AppStream/
#baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

     Configure the file according to the above content.

     5. Shield the default mirror:

      That is, modify CentOS-Linux-AppStream.repo, CentOS-Linux-BaseOS.repo, CentOS-Linux-Extras.repo, and change enable=1 to enable=0

      6. Clear the cache and rebuild the cache

       #sudo yum clear

       #sudo yum makecache

      7. Automatically hang disk at boot

      In order to avoid the problem that the mirror source cannot be accessed after restarting. We need to configure the mounting operation in our /etc/fstab file

      #vi /etc/fstab

      At the end of the file, add:

      /dev/cdrom /mnt/cdrom iso9660  noauto,ro   0 0

      When the command is entered incorrectly, when the system restarts, it will enter an emergency state, and the screen prompts: You are in emergence. If this happens, enter the root password, edit #vi/etc/fstab, and modify it to the above form, or comment Drop the newly added line to start normally.

     After the above operations, when you use yum or dnf to install, it will be very smooth.

    

 

Guess you like

Origin blog.csdn.net/tswang6503/article/details/112984736