娃哈哈好喝-真的!
技术够用就行,吃好喝好睡好!

搭建内网yum服务器

内网服务器通过一台可以连外网的服务器做代理实现yum源本地化,这里列举常用的centos和epel源,以阿里云镜像源为例

centos阿里云镜像:

http://mirrors.aliyun.com/centos

epel阿里云镜像:

http://mirrors.aliyun.com/epel

演示环境:

centos7 server nginx 10.0.0.1

centos7 test 10.0.0.2

1、nginx代理配置 在server服务器的nginx上配置

server{
  listen 80;
  server_name www.yum.cc;
  root /data/www/yum;
  location / {
      autoindex on;
      autoindex_exact_size off;
      autoindex_localtime on;
  }
  location /centos {
      proxy_pass http://mirrors.aliyun.com/centos;
  }
  location /epel {
      proxy_pass http://mirrors.aliyun.com/epel;
  }
}

这里使用的域名是yum.cc,内网机器需要能解析到这个域名,可以写hosts方式,也可以使用内部dns。

2、内网服务器配置yum源 所有内网服务器上配置

在/etc/hosts中添加一条记录

10.0.0.1  www.yum.cc

centos源配置

cat /etc/yum.repos.d/centos.repo

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://www.yum.cc/centos/$releasever/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://www.yum.cc/centos/$releasever/updates/$basearch/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://www.yum.cc/centos/$releasever/extras/$basearch/
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://www.yum.cc/centos/$releasever/centosplus/$basearch/
gpgcheck=0
enabled=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

epel源配置

cat /etc/yum.repos.d/epel.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://www.yum.cc/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://www.yum.cc/epel/7/$basearch/debug
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://www.yum.cc/epel/7/SRPMS
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0

删除其他的yum源文件,只需要保留这两个文件即可

yum clean all
yum makecache
赞(0)
未经允许不得转载:娃哈哈好喝 » 搭建内网yum服务器
分享到: 更多 (0)