内网挂载ISO镜像搭建yum源提供局域网安装

由于各种原因,可能存在一批内网机器无法访问公网又需要批量来安装一些rpm包,在自动化部署的普及之前,打通ssh+配置yum源是一个不错的解决方法

本地使用ISO镜像作为yum源:

mount -o loop centos.iso /mnt/centos/

vim /etc/yum.repo.d/centos-media.repo

加入

[c5-media]

name=CentOS-$releasever – Media

baseurl=file:///mnt/centos/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

保存退出

cp /mnt/centos/RPM-GPG-KEY-CentOS-5 /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

这样就可以使用本地仓库c5-media 来更新了:

yum update –enablerepo=c5-media

现在来配置http服务提供yum源

本地挂载镜像做内网镜像源:

接上面本地目录/mnt/centos  挂载的ISO 目录作为内网共享给其他的内网机使用. 具体步骤:

1. 先将/mnt/centos作为http目录发布(nginx):

配置nginx.conf 添加:

server {

listen 80;

server_name centos.repo;

root /mnt/centos;

location / {

root /mnt/centos/;

index index.html index.htm;

autoindex on;

autoindex_exact_size off;

autoindex_localtime on;

}

}

开启自动列表功能,

平滑重启nginx

nginx -s reload

直接访问:



2.添加repo文件:

vim /etc/yum.repos.d/base.repo

添加:

[swhs]

name=swhs RPM Repository for wasu net

baseurl=http://centos.repo/

gpgcheck=1

enabled=1

gpgkey=http://centos.repo/RPM-GPG-KEY-CentOS-5

保存退出,如果在nginx发布时有多个虚拟主机需要在配置时加host解析,如果只有一个ip:port 就只需要将对应的地址改成http请求地址即可

添加host

vim /etc/hosts

加入  ip   servername

保存退出

测试yum update 成功:



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值