Configure the yum source in the country

Article source: Tao Teacher operation notes – wechat official account

1. Yum

Yum (full Yellow Dog Updater, Modified) is a Shell front-end package manager in Fedora and RedHat and CentOS. Based on RPM package management, RPM packages can be automatically downloaded and installed from a specified server, dependencies can be automatically handled, and all dependent software packages can be installed at one time. The main function of YUM is to easily add, delete, and update RPM packages, which automatically solves the dependency problem of packages and facilitates the management of a large number of system updates.

Yum sources can come from a variety of file servers:

  • http://
  • https://
  • ftp://
  • file:// Local files

2. Use the yum command

1. Install software: yum install S 2. Uninstall software: yum remove S 3. Check dependencies: yum deplist S 4. Yum check-update 7. Yum check-update 7. Yum List InstalledCopy the code

Installation:

Yum install Package install the specified installation package. Yum install package -y yum install package -y Yum groupinsall group Setup group group.Copy the code

Update:

Yum update all updates. Yum Update Package Specifies the package to be updated. Yum check-update checks for updatable programs. Yum Upgrade Package Specifies the upgrade package package. Yum groupupdate group Upgrade group.Copy the code

Find and display:

Yum repolist View (open) the repository. Yum repolist all View all resource libraries. Yum Search Uses yum to find packages. Yum Search String Installs packages based on the string keyword. Yum Info Package Displays installation package information package. Yum info updates lists the updated information. Yum Info Installed Lists installation package information. Yum List displays all installed and installable packages. Yum List updates lists all updatable packages. Yum List Installed lists all installed packages. Yum List Extras lists all installed packages that are not in the REPo. Yum list package displays the installation status of the specified package package. Yum groupInfo group Displays program group information.Copy the code

Delete program:

Yum remove Package yum Remove package Yum groupremove Group Yum deplist Package Check package dependencies.Copy the code

Clear cache:

Yum Clean Packages Clears software packages in the cache directory. Yum Clean headers Clears headers from the cache directory. Yum clean oldheaders clears oldheaders from the cache directory. Yum clean/yum clean all Clears the software package and the old headers in the cache directory.Copy the code

Import RPM -gpg file:

rpm --import gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
Copy the code

3. Yum configuration file

The yum configuration file is split into two parts: Main and Repository

  • The main section defines global configuration options, and there should be only one main for the entire YUM configuration file. Often found in /etc/yum.conf.
  • The Repository section defines the specific configuration of each source/server, which can be one or more. Usually located in the /etc/yum.rebo. d directory.

3.1 yum. Conf

The yum. Conf file is usually located in the /etc directory. /etc/yum.

#yum configuration file
$cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever #yum cache directory after download
keepcache=0    0 indicates no cache and 1 indicates cache
debuglevel=2
logfile=/var/log/yum.log  #yum install log
exactarch=1
obsoletes=1
gpgcheck=1  # Whether to perform GPG check by default. 0 indicates no check and 1 checkplugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?categ ory=yum distroverpkg=centos-releaseCopy the code
configuration instructions
cachedir The directory where yum stores downloaded RPM packages and databases, typically /var/cache/yum.
debuglevel The debugging level ranges from 0 to 10. The default value is 2.
logfile yum The default is /var/log/yum.log.
exactarch There are two options: 1 and 0, which indicate whether to upgrade only packages with the same CPU system as the package you installed. If set to 1, for example, if you installed an I386 RPM, yum will not upgrade packages with 686.
gpgchkeck There are two options, 1 and 0, respectively, indicating whether to perform GPG verification. If there is no GPG verification, the default is check.

3.2 the repository configuration

Yum’s repository configuration file is typically placed in /etc/yum.repos.d/. Example 1: influxdb. Repo

cat /etc/yum.repos.d/influxdb.repo 
[influxdb]
name = InfluxDB Repository - RHEL $releasever
baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
Copy the code

Example 2: Aliyun repo

[CentOS6-base]   This parameter is mandatory
name=CentOS-$releasever-base  # Source description, you can leave it blank, but there will be a prompt
#baseurl=file:///misc/cd/ # local CD file, can have multiple addresses. mandatory
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/x86_64/
gpgcheck=1                    # whether to enable validation, as defined in yum. Conf default is 1
enabled=1                     # Whether to disable this yum source. Default
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
# install RPM public key when no RPM public key is imported
RPM --import /etc/pki/rpm-gpg/RPM -gpg-key-centos-6

[aliyun_epel]   # This is an extension pack for Redhat
name=ailiyun_yum_epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/x86_64
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
gpgcheck=1
Copy the code

When configuring the yum source, you need at least two lines, [reponame] and baseurl:

configuration instructions
reponame [reponame] written in [], for example, user-defined software name [influxdb] or [base],[contrib],[extras], etc
$releasever Represents the version of the distribution, obtained from the distroverpkg in the [main] section, or judged by the Redhat-Release package if not.
$arch CPU system, such as I686, Athlon, etc
$basearch The basic architecture group of cpus, such as the I686 and Athlon, belong to the i386

4. Change the yum source to the domestic source

4.1 Common Domestic YUM sources

When installing software, the network speed of the foreign YUM source is usually not as fast as that of the domestic source. In order to speed up the installation, you can use the domestic YUM source. Domestic yum mirror sites: netease source: mirrors.163.com/centos/6/os… Tsinghua university: mirror.tuna.tsinghua.edu.cn/centos/6/os… Source: ali mirrors.aliyun.com/centos http://mirrors.zju.edu.cn/centos/6/os/x86_64/, zhejiang university

4.2 Changing the YUM source to a Domestic YUM source

The following are the steps for modifying the CentOS yum source.

4.2.1 Backing up the original REPO File

Backup/etc/yum. Repos. D/CentOS – Base. Repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
Copy the code

4.2.2 Downloading domestic REPO files

/etc/yum. Repos. D/aliyun

Wget Centos5 address: -o/etc/yum repos. D/CentOS - 5 - aliyun. Repo Centos6 address: http://mirrors.aliyun.com/repo/Centos-5.repo Wget - O/etc/yum. Repos. D/CentOS - 6 - aliyun. Repo http://mirrors.aliyun.com/repo/Centos-6.repo or curl - O The/etc/yum. Repos. D/CentOS - 6 - aliyun. Repo Centos7 address: http://mirrors.aliyun.com/repo/Centos-6.repo  wget -O /etc/yum.repos.d/CentOS-7-aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repoCopy the code

163 source:

CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base-163.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base-163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
Copy the code

4.2.3 Generating cache

Clear the original cache and generate a new cache.

yum clean all
yum makecache
Copy the code

5. EPEL source

EPEL (Extra Packages for Enterprise Linux) is a Fedora community project that provides high quality software Packages for RHEL and its derived distributions such as CentOS. Install EPEL, yum can install a lot of previously need to compile install software, such as now popular Nginx, HTOP, NCDU, vnstat, etc., can use EPEL very convenient installation update.

Liverpoolfc.tv: fedoraproject.org/wiki/EPEL/z…

5.1 install the EPEL

Run the yum install epel-release command

$yumInstall the epel - release or http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm# Check installation
$rpm -q epel-release
$rpm -qa |grep epel -i
$ls -l /etc/yum.repos.d/
# import keyRPM --import /etc/pki/rpm-gpg/RPM -gpg-key-epel-6 restore cache yum makecacheCopy the code

5.2 Install EPEL Ali cloud source

Delete the original EPEL source:

# Check installation
$rpm -qa |grep epel -i
$rpm -q epel-release
# Remove the original official Rpel
rpm -e epel-release-6-8.noarch
Copy the code

Install Aliyun REPo:

#
epel(RHEL 5) 
wget -O /etc/yum.repos.d/epel-aliyun.repo http://mirrors.aliyun.com/repo/epel-5.repo
epel(RHEL 6)
wget -O /etc/yum.repos.d/epel-aliyun.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 7)
wget -O /etc/yum.repos.d/epel-aliyun.repo http://mirrors.aliyun.com/repo/epel-7.repo
# check
cat /etc/yum.repos.d/epel-aliyun.repo 
Copy the code

Modify the priority: modify the/etc/yum repos. D/epel. Repo file. Add a priority=11 attribute at the end of [epel], which means that yum does not go to epel’s source.

vi /etc/yum.repos.d/epel.repo
priority=11
Copy the code

Rebuild cache:

yum clean all
yum makecache
Copy the code

6. The RPM package search

If you cannot find the RPM package during RPM installation, try the following websites.

  • rpm.pbone.net/
  • rpmfind.net/

7. Download the RPM package instead of installing it

Yum -plugin-downloadonly is required.

7.1 installation yum – plugin – downloadonly:

$yum install yum-plugin-downloadonly
Copy the code

7.2 downloadonly use

–downloadonly // downloadonly, –downloaddir=/path/to/dir // download to the specified directory

Example: Download the Redis package but do not install it.

$yuminstall --downloadonly --downloaddir=/root/ redis -y ... Installed size: 1.6m Downloading Packages: No longer due --downloadonly SpecifiedCopy the code

reference

  • Teachertao Operations Notes – public account
  • Mirrors.163.com/.help/cento…
  • Mirrors.163.com/centos/6/os…
  • Mirror.tuna.tsinghua.edu.cn/centos/6/os…
  • Fedoraproject.org/wiki/EPEL/z…
  • www.cnblogs.com/mchina/arch… Configure and use the yum source