CentOS7 configuration local mirror source (super detailed process)

Preface

This method is effective in pro-test and is suitable for all environments of CentOS7 version. Comes
with all the mirror files under CentOS 7.
Link: https://pan.baidu.com/s/1zQ-MzjjOacmWnvOKhliGxw Extraction code: ljw8 CentOS7
Aliyun source configuration, please refer to my other blog post: https:/ /blog.csdn.net/KingveyLee/article/details/114984534
For the configuration of RedHat7 local source, please refer to my other blog post: https://blog.csdn.net/KingveyLee/article/details/114981036

1. Environmental preparation

Mount the iso image file on the CD/DVD drive, or upload the iso image file to the server (additional operations
are required ) Example: as follows, you need to make sure that the connection is open and the media on the CD/DVD conforms to the current operation The version of the system.
Virtual machine configuration on EXSI machine

Two, manually configure the local source

  1. Create a local source folder:
mkdir -p /media/centos/
  1. Mount the image file to the specified directory.
mount /dev/cdrom /media/centos
  1. Back up the original local source.
cp -rf /etc/yum.repos.d  /etc/yum.repos.d_$(date '+%Y%m%d_%H%M%S')
  1. Delete the default original local source.
rm -rf /etc/yum.repos.d/*
  1. Configure the local source and create the Media.repo file.
vi /etc/yum.repos.d/Media.repo
  1. Configure the following:
[iso]
name=Media
baseurl=file:///media/centos/
gpgcheck=0
enabled=1
  1. Press ESC. Enter: wq save to complete the writing, and complete the configuration of the local source.
  2. Load local yum source & test
# 清除yum缓存
yum clean all
# 缓存本地yum源
yum makecache
# 测试yum本地源 
yum list

Three, script configuration local source

  1. Find a directory and create a script file:

I take the /root/ directory as an example

vi /root/auto_source.sh
  1. Write the following:
#!/bin/bash

# 创建本地源文件夹
mkdir -p /media/centos/
# 挂载镜像文件至指定的目录
mount /dev/cdrom /media/centos
# 备份原本地源
cp -rf /etc/yum.repos.d  /etc/yum.repos.d_$(date '+%Y%m%d_%H%M%S')
# 删除默认原本地源
rm -rf /etc/yum.repos.d/*
# 配置本地源,创建Media.repo文件,并配置如下内容
cd /etc/yum.repos.d/
>Media.repo
echo '[iso]'                            >> Media.repo
echo 'name=Media'                       >> Media.repo
echo 'baseurl=file:///media/centos/'    >> Media.repo
echo 'gpgcheck=0'                       >> Media.repo
echo 'enabled=1'                        >> Media.repo
# 清除yum缓存
yum clean all
# 缓存本地yum源
yum makecache
  1. Press ESC. Input: wq save, finish writing the script file of the mirror local source
  2. Give the script executable permissions
chmod +x /root/auto_source.sh
  1. Execute the script file, you can
/root/auto_source.sh

Guess you like

Origin blog.csdn.net/KingveyLee/article/details/114979418