Yum source deployment and usage

Time:2020-7-31

1. Preface

Why do you need an internal Yum source? It may be that the server inside the business is not available to the outside world, which is due to some security considerations. What’s the advantage of internal Yum source? First, it’s fast; second, it’s controllable. If there’s a problem in the external network, it doesn’t affect the download and installation of the intranet package.

2. Deployment

2.1 create Yum warehouse directory

mkdir -p /data/yum_data/centos/6/os/x86_64/
mkdir -p /data/yum_data/centos/6/extras/x86_64/
mkdir -p /data/yum_data/centos/6/updates/x86_64/
mkdir -p /data/yum_data/epel/6/x86_64/

2.2 mirror synchronous public network Yum source

The upstream Yum source must support Rsync protocol, otherwise Rsync cannot be used for synchronization
Official CentOS standard source: rsync://mirrors.ustc.edu.cn/centos/
EPEL source: rsync://mirrors.ustc.edu.cn/epel/
Synchronization command:

rsync -auvzP --bwlimit=1000 rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/ /data/yum_data/centos/6/os/x86_64/
rsync -auvzP --bwlimit=1000 rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /data/yum_data/centos/6/extras/x86_64/
rsync -auvzP --bwlimit=1000 rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /data/yum_data/centos/6/updates/x86_64/
#EPEL source
 rsync -auvzP --bwlimit=1000 --exclude=debug rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/ /data/yum_data/epel/6/x86_64/

2.3 provide Yum service

Deploy Tengine. The server configuration is as follows:

#/usr/local/nginx/conf.d/iso.conf
server {
listen 80;
server_name localhost;
access_log logs/iso.log main;
location / {
autoindex on;
root /data/yum_data/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
   }
}

2.4 client configuration

Configure the yum source file of the client in / etc/ yum.repos . D / below:
/etc/ yum.repos .d/CentOS- Base.repo to configure:

[base107]
name=CentOS-$releasever - Base
baseurl=http://192.168.31.107/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates
[updates107]
name=CentOS-$releasever - Updates
baseurl=http://192.168.31.107/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras107]
name=CentOS-$releasever - Extras
baseurl=http://192.168.31.107/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

/etc/ yum.repos .d/ epel.repo to configure:

[epel107]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://192.168.31.107/epel/6/$basearch
failovermethod=priority
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

2.5 client command usage

yum clean all
yum install telnet -y

3. Reference documents

  • http://www.zyops.com/autodeploy-yum

Author’s blog Qingye’s blog