centos8本地yum设置

1、添加挂载光盘

2、创建挂载目录

mkdir /mnt/cdrom

3、挂载光盘

mount /dev/sr0 /mnt/cdrom

4、设置开机挂载

echo "/dev/sr0 /mnt/cdrom  iso9660 defaults 0 0" >> /etc/fstab

5、将原有的yum源注释掉

cd /etc/yum.repos.d

rename .repo .repo.bak *

6、添加自己的

echo "[BaseOS]

name=CentOS-BaseOS

baseurl=file:///mnt/cdrom/BaseOS

gpgcheck=0

enabled=1

[APP]

name=CentOS-APP

baseurl=file:///mnt/cdrom/AppStream

gpgcheck=0

enabled=1" > /etc/yum.repos.d/CentOS-Linux-Base.repo

7、清除yum缓存
yum clean all
8、缓存本地yum源中软件包信息
yum makecache

9、组合起来写成脚本:localYum.sh

#!/bin/bash
#2、创建挂载目录
mkdir /mnt/cdrom

#3、挂载光盘
mount /dev/cdrom /mnt/cdrom

#4、设置开机挂载
echo "/dev/sr0 /mnt/cdrom  iso9660 defaults 0 0" >> /etc/fstab

#5、将原有的yum源注释掉
cd /etc/yum.repos.d
rename .repo .repo.bak *

#6、添加自己的
echo "[BaseOS]
name=CentOS-BaseOS
baseurl=file:///mnt/cdrom/BaseOS
gpgcheck=0
enabled=1

[APP]
name=CentOS-APP
baseurl=file:///mnt/cdrom/AppStream
gpgcheck=0
enabled=1" > /etc/yum.repos.d/CentOS-Linux-Base.repo
#7、清除yum缓存
yum clean all
#8、缓存本地yum源中软件包信息
yum makecache

 配置本地yum仓库

制作流程: 先挑选一台机器如,挂载一个系统光盘到本地目录/mnt/cdrom,

然后启动一个httpd服务器,将/mnt/cdrom 软连接到httpd服务器的/var/www/html目录中 (cd /var/www/html; ln -s /mnt/cdrom ./centos )
然后通过网页访问测试一下: http://yum仓库的hostname或ip地址/centos 会看到光盘的目录内容
至此:网络版yum私有仓库已经建立完毕

剩下就是去各台yum的客户端配置这个http地址到repo配置文件中

yum install httpd -y

systemctl start httpd

systemctl enable httpd

systemctl status httpd

cd /var/www/html

ln -s /mnt/cdrom ./centos 

httpd安装参考:https://blog.csdn.net/ldy/article/details/104165171/

posted on 2021-01-14 13:54  wtsgtc  阅读(840)  评论(0编辑  收藏  举报

导航