Replacing CentOS Repositories to Local Mirrors

This section provides a tutorial example on how to replace CentOS repository configuration files to use local repository mirrors.

Sometimes you may want to use local CentOS repository mirrors instead of CentOS official repository servers to get reliable and faster connections.

For example, if you are in China, you way want to use CentOS repository mirrors provided by Alibaba as shown below:

1. Archive current repository configuration files:

herong$ cd /etc/yum.repos.d

herong$ sudo mkdir backup

herong$ sudo mv CentOS-*.repo backup

2. Find out the CentOS release number:

herong$ sudo grep release /etc/centos-release

CentOS Linux release 8.5.2111

3. Download repository configuration files for CentOS 8.5.2111 from Alibaba mirror site:

herong$ cd /etc/yum.repos.d

herong$ sudo wget -O /etc/yum.repos.d/CentOS-Base.repo \
  https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

Resolving mirrors.aliyun.com 202.100.222.211,
Connecting to mirrors.aliyun.com |202.100.222.211|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2495 (2.4K) [application/octet-stream]
Saving to: '/etc/yum.repos.d/CentOS-Base.repo'

herong$ ls -l CentOS-*.repo
-rw-r--r--. 1 root root 2495 Feb 14 21:16 CentOS-Base.repo

4. Try to run "dnf/yum" commands again. I see no problem accessing CentOS Linux 8.5.2111 repositories:

herong$ sudo dnf info wget
CentOS-8.5.2111 - Base - mirrors.aliyun.com              5.3 MB/s
CentOS-8.5.2111 - Extras - mirrors.aliyun.com             45 kB/s
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com         6.0 MB/s

Installed Packages
Name         : wget
Version      : 1.19.5
Release      : 10.el8
Architecture : x86_64
Size         : 2.8 M
Source       : wget-1.19.5-10.el8.src.rpm
Repository   : @System
From repo    : AppStream
...

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

Software Package Manager on CentOS - DNF and YUM

 What Is DNF

 Manage DNF Package Repositories

 What Is YUM

 What Is RPM

 What Is pkgs.org

 Install and Manage Java Packages on CentOS

 Install and Manage Perl Packages on CentOS

 Install "git-core" for GitHub Packages on CentOS

 Failed to Download Metadata for Repo ...

Replacing CentOS Repositories to Local Mirrors

 vsftpd - Very Secure FTP Daemon

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB