美文网首页
Centos7多台内网服务器共享同一本地yum源

Centos7多台内网服务器共享同一本地yum源

作者: Habit_1027 | 来源:发表于2023-05-09 11:37 被阅读0次

一、步骤

1.1 共享源服务器(192.168.100.111),配置本地yum源

1.2 为共享源配置对外访问的地址(我这里用nginx)

1.3 其他内网服务器配置共享源的地址

二、共享源配置本地yum源

2.1 创建目录,备份原yum源文件

mkdir /data/{centos-yum.bak,centos,centos-images}

mv /etc/yum.repos.d/* /data/centos-yum.bak/

2.2 上传镜像到服务器上

mv CentOS-7-x86_64-DVD-1810.iso /data/centos-images/

2.3 挂载镜像

mount -o loop -t iso9660 /data/centos-images/CentOS-7-x86_64-DVD-1810.iso  /data/centos

#取消挂载
umount /data/centos

2.4 创建repo文件

vim /etc/yum.repos.d/my.repo
[my]
name=my
baseurl=file:///data/centos
enabled=1
gpgcheck=0

2.5制作cache

yum clean all
yum makecache

2.6 详情

[root@omnis-server data]# pwd
/data
[root@omnis-server data]# ls
 centos  centos-images  centos-yum.bak 
[root@omnis-server data]# cd centos
[root@omnis-server centos]# pwd
/data/centos
[root@omnis-server centos]# ls
CentOS_BuildTag  EFI  EULA  GPL  images  isolinux  LiveOS  Packages  repodata  RPM-GPG-KEY-CentOS-7  RPM-GPG-KEY-CentOS-Testing-7  TRANS.TBL
[root@omnis-server centos]#

三、为共享源提供对外访问地址

这里以nginx方式提供访问该地址

[root@omnis-server conf.d]# more yum_share.conf 
server {
    listen 8888;
    server_name 192.168.100.111;
  
    location / {
        root /data/centos;
    }
}


[root@omnis-server nginx]# more nginx.conf
#user  nobody;worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    include  yum_share.conf;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
   ......
   ......
   ......

配置完了之后,我们就得到了访问192.168.100.111服务器yum源的地址:http://192.168.100.111:8888/,启动nginx(此处需关闭防火墙或开启8888端口)
开放防火墙端口的命令:
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --reload

四、其它服务器配置

4.1 备份原yum源配置

mv /etc/yum.repos.d /etc/yum.repos.d.bak
mkdir /etc/yum.repos.d

4.2 创建本地yum源配置文件

[root@localhost~]# vi /etc/yum.repos.d/CentOS-local.repo
[base-local]
name=CentOS-local
baseurl=http://192.168.100.111:8888/
enabled=1
gpgcheck=0

4.3 更新yum源配置

yum clean all
yum makecache

4.4 测试yum安装软件

yum install -y  lrzsz  tree unzip zip

相关文章

  • Yum 本地源同步和配置

    情景: 为内网主机搭建 yum 源,且 yum 源同步 外网的源服务器。 同步 yum 源 同步本地 yum 源有...

  • 使用Yumsync搭建内网Yum源同步阿里Yum源

    背景: 因内网环境无法从外网获取安装包,所以需要搭建内网YUM源同步阿里YUM源环境: 内网YUM源服务器:192...

  • 常用yum源介绍及配置

    参考: CentOS 7下配置本地yum源及yum客户端 Centos7 配置本地源+阿里yum源/epel-yu...

  • centos7修改为阿里的yum源

    以centos7为例 ,以 修改为阿里的yum源 1. 备份本地yum源 mv /etc/yum.repos.d/...

  • yum服务器

    yum服务器 10.18.44.105 客户机 本地yum源

  • 配置本地yum源

    由于服务器不允许内网访问,在Linux上安装软件很不方便,需要寻找各种依赖。所以,就在服务器上配置本地yum源。 ...

  • yum源的挂载

    下面是关于本地yum源,联网的yum源,添加其他yum源,三部分 制作本地YUM源 1.准备一台Linux服务器,...

  • 共享式YUM源(CentOS6.7)

    共享式YUM源(CentOS6.7): 第一步:配置server端的本地源 方法一:挂载本地yum源 mkdir ...

  • 第四周作业

    1、自建yum仓库,分别为网络源和本地源网络源repo配置(centos7): 本地源repo配置(centos7...

  • CM+CDH构建企业大数据平台(4)--构建本地yum源

    (一)什么叫构建本地yum源? 构建本地yum源又叫部署本地库,实际上就是安装一个镜像服务器:镜像服务器(Mir...

网友评论

      本文标题:Centos7多台内网服务器共享同一本地yum源

      本文链接:https://www.haomeiwen.com/subject/yaersdtx.html