欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

如何在CentOS 7下实现多台内网服务器共享同一本地yum源? 1. 将共享源服务器(IP: 192.168.100.111)上的yum源进行本地化配置; 2. 使用Nginx为共享源服务器提供外部访问地址; 3. 在其他内网服务器上配置共享源服务器的地址。 共享源本地yum源的配置: 1. 在服务器上创建目录并备份原有yum源文件: ``` mkdir /data/{centos-yum.bak,centos,centos-images} mv /etc/yum.repos.d/* /data/centos-yum.bak/ 上传镜像文件到服务器: mv CentOS-7-x86_64-DVD-1810.iso /data/centos-images/ 挂载镜像文件: mount -o loop -t iso9660 /data/centos-images/CentOS-7-x86_64-DVD-1810.iso /da

最编程 2024-02-14 21:37:11
...

这里以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