添加本地yum源-可使用http访问

一、挂载

1.挂载官方镜像 everything ios镜像

/dev/loop1                11G   11G     0 100% /mnt/cdrom/centos7

2.使用docker部署apache httpd

将目录挂载到docker中 /mnt/cdrom/:/usr/local/apache2/htdocs/

[root@poc-215 tmp]# docker ps
CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS                NAMES
a4d091c815e0        httpd               "httpd-foreground"   22 hours ago        Up 27 hours         0.0.0.0:8080->80/tcp   yumhttp

3.查看

http://192.168.254.74:81/
添加本地yum源-可使用http访问_第1张图片

二、使用

mkdir /opt/repobak
mv /etc/yum.repos.d/* /opt/repobak
vi myiso.repo


[centos7-local]
name=CentOS-$releasever - Media
#这里的IP根据现场的yum源决定
baseurl=http://192.168.254.74:81/centos7
#baseurl=file:///mnt/cdrom
gpgcheck=1
#enabled=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


cp myiso.repo  /etc/yum.repos.d/

更新yum缓存

yum clean all
yum makecache

CentOS使用ISO镜像做本地YUM源

参考

CentOS使用ISO镜像做本地YUM源 https://blog.csdn.net/Post_Yuan/article/details/79455379 (推荐)
centos7 配置本地yum源 https://blog.csdn.net/no_ob/article/details/78668255
CentOS7本地yum源设置(断网情况下轻松安装各种依赖包)亲测有效! https://blog.csdn.net/u010463613/article/details/81196260

你可能感兴趣的:(linux,yum)