Application of YUM Source Configuration and Related Problems under Centos

Keywords: Linux yum CentOS RPM network

yum source configuration is often used in work, especially when installing databases, it is time-consuming to install dependency packages one by one, so it is enough to configure yum installation directly.

1. yum configuration instructions (reprinted in this section)

The configuration file for yum is divided into two parts: main and repository

  • The main section defines the global configuration options, and the entire Yum configuration file should have only one main. Often located in / etc/yum.conf.
  • The repository section defines the specific configuration of each source/server, which can be one or more. Often located in the / etc/yum.repo.d directory of each file.

The yum.conf file is generally located in the / etc directory, which generally only contains the configuration options of the main part.

# cat /etc/yum.conf

[main]
cachedir=/var/cache/yum
  //yum Cached directories, yum Store downloaded rpm Packets and databases, set by default to/var/cache/yum
keepcache=0
  //Whether to retain the package after installation, 0 is not retained (default is 0), 1 is retained
debuglevel=2
  //Debug Information Output Level, Range 0-10,The default is 2.
logfile=/var/log/yum.log
  //yum Log file location. Users can go to/var/log/yum.log File to check for past updates.
pkgpolicy=newest
  //Package strategy. There are two options. newest and last,This function is if you have multiple settings repository,The same software is different repository It exists at the same time. yum Which one should be installed? If so newest,be yum The latest version will be installed. If it is last,be yum Servers will be served id Sort by alphabet and select the software installation on the last server. Usually it's a choice. newest. 
distroverpkg=redhat-release
  //Specify a package. yum Your distribution will be judged based on this package. The default is redhat-release,It can also be installed for any distribution of its own. rpm Bag.
tolerant=1
  //There are two options, 1 and 0. yum Do you tolerate software package-related errors on the command line, such as installing 1,2,3 Three packages, three of which have been installed before, if you set it to 1,be yum No error message will appear. The default is 0.
exactarch=1
  //There are 1 and 0 options, set to 1, then yum Only packages that match the system architecture will be installed, for example, yum Will not i686 Package installation is suitable i386 In the system. The default is 1.
retries=6
  //If the number of retries is set to 0, the network connection will be retried indefinitely. The default value is 6.
obsoletes=1
  //This is a update Refer to the parameters. yum(8),Simply put, it is equivalent to upgrade,Allow for updating obsolete RPM Bag.
plugins=1
  //Whether or not to enable plug-ins, default 1 is allowed, 0 means not allowed. We usually use it. yum-fastestmirror This plug-in.
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum

# Note: yum-RHN-plugin doesn't honor this.
metadata_expire=1h

installonly_limit = 5

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

 

Local yum source configuration

# cd /etc/yum.repos.d/

ls. You see four repo files

 

 

CentOS-Base.repo is the configuration file for yum network source

CentOS-Media.repo is the configuration file for yum local source

To modify the name of CentOS-Base.repo, the system first loads the network source, and when using the local source, it needs to modify its name. The remaining two can be backed up or deleted.

Modify CentOS-Media.repo, change the second path in baseurl to / mnt/cdrom (that is, CD mount point) as shown below, and change enabled=0 to 1

 

 

After the configuration is completed, the yum celan all is executed to clear the cache, and then the yum makecache is executed. As shown below, two errors are caused by two other useless baseurl s, which can be deleted in practice.

 

3. Network YUM Source Configuration

Compared with the local yum source configuration, the network yum source configuration is simpler without mounting the iso image file.

CentOS-Base.repo is the configuration file of yum network source. vi This file is configured, annotate mirrolist, modify baseurl as follows

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

After configuring according to the above script, execute yum clean all to clear the cache, and then install the vim test. No problem.

4. The following are the real problems encountered and the proven solutions found on the network

1. The error log is as follows

file:///mnt/cdrom/LinuxSrc/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: '/mnt/cdrom/LinuxSrc/repodata/repomd.xml'
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: media. Please verify its path and try again

The root cause of this error is that RHEL version 5.x and RHEL version 6.x have different storage paths for rpm packages:

RHEL 5.x:.. / Server, for example: My case environment is located under / mnt/cdrom/LinuxSrc/Server.

RHEL 6.x : ../Packages

Complete solution: https://www.cnblogs.com/kerrycode/p/4835571.html

 

The reference links are as follows, and the explanations are more detailed.

https://www.cnblogs.com/mchina/archive/2013/01/04/2842275.html

https://www.cnblogs.com/kerrycode/p/4723637.html

Posted by zimmo on Mon, 14 Oct 2019 17:46:04 -0700