制作本地yum源

零 修订记录

序号 修订内容 修订时间
1 新增 2021/2/21

一 摘要

本文主要介绍搭建内网yum 源,以centos8.1 内网系统源为例。使用nginx 作为web 服务器。

二 环境信息

(一)软件信息

[root@10-3-170-32 ~]# createrepo --version
createrepo 0.9.9
[root@10-3-170-32 ~]#
    [root@10-3-170-32 ~]# /usr/local/nginx/sbin/nginx -v
    nginx version: nginx/1.18.0
    [root@10-3-170-32 ~]#

(二) 操作系统

[dev@10-3-170-32 ~]$ cat /etc/centos-release
CentOS Linux release 7.3.1611 (Core)
[dev@10-3-170-32 ~]$

三 实施

(一) 具体实施

3.1.1 将centos 8.1 系统盘上传到服务器上

使用xshell 等软件上传到服务器。

3.1.2 新增挂载目录,并将系统盘挂载到该目录

    [root@10-3-170-32 mnt]# rm -rf centos81/
    [root@10-3-170-32 mnt]# mkdir /mnt/centos81
    [root@10-3-170-32 mnt]# cd centos81/
    [root@10-3-170-32 centos81]# pwd
    /mnt/centos81


    [root@10-3-170-32 centos81]# mount /home/yunwei/software/centos/CentOS-8.1.1911-x86_64-dvd1.iso /mnt/centos81/
    mount: /dev/loop0 写保护,将以只读方式挂载

检查挂载是否成功

root@10-3-170-32 mnt]# cd centos81/
[root@10-3-170-32 centos81]# ll
总用量 12
dr-xr-xr-x 4 root root 2048 1月 4 2020 AppStream
dr-xr-xr-x 4 root root 2048 1月 4 2020 BaseOS
dr-xr-xr-x 3 root root 2048 1月 4 2020 EFI
dr-xr-xr-x 3 root root 2048 1月 4 2020 images
dr-xr-xr-x 2 root root 2048 1月 4 2020 isolinux
-r--r--r-- 1 root root 87 1月 4 2020 media.repo
-r--r--r-- 1 root root 664 1月 4 2020 TRANS.TBL
[root@10-3-170-32 centos81]# df -h | grep centos81
/dev/loop0 7.1G 7.1G 0 100% /mnt/centos81
[root@10-3-170-32 centos81]#

3.1.3 centos8.1 文件复制到本机

    [root@10-3-170-32 localyum]# cp -r /mnt/centos81/ /data/localyum/

3.1.4 createrepo /data/localyum/centos81/

    createrepo /data/localyum/centos81/

3.1.5 nginx 配置文件

centos81.mirror.digital.com 这个用你对应的域名

    [root@10-3-170-32 conf.d]# cat centos81mirror.conf

        server {
            listen       80;
            server_name  centos81.mirror.digital.com;
            #charset koi8-r;

            #access_log  logs/host.access.log  main;

            location / {
                root   /data/localyum/centos81;
                autoindex  on;
            }

            #error_page  404              /404.html;

            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }

        }

重启nginx

    [root@10-3-170-32 conf.d]# /usr/local/nginx/sbin/nginx -s reload

3.1.6 repo 文件参考配置

[base]
name=CentOSBase
baseurl=http://centos81.mirror.digital.com
gpgcheck=0
enabled=1

posted on 2021-02-21 14:18  weiwei2021  阅读(150)  评论(0编辑  收藏  举报