部署要求:

服务器:CentOS7

YUM源:阿里云

空间要求:CentOS6+CentOS7 50G,考虑后期更新预留,LVS空间100G

1、在服务器配置CentOS7的yum源和CentOS6的yum源

#Centos7
[base7]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 [updates7]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 [extras7]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 [epel7]
name=CentOS-7-epel-cmiot.local
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
gpgcheck=0
#Centos6
[base6]
name=CentOS-6 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/os/x86_64/
http://mirrors.aliyuncs.com/centos/6/os/x86_64/
http://mirrors.cloud.aliyuncs.com/centos/6/os/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 [updates6]
name=CentOS-6 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/updates/x86_64/
http://mirrors.aliyuncs.com/centos/6/updates/x86_64/
http://mirrors.cloud.aliyuncs.com/centos/6/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 [extras6]
name=CentOS-6 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/extras/x86_64/
http://mirrors.aliyuncs.com/centos/6/extras/x86_64/
http://mirrors.cloud.aliyuncs.com/centos/6/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 [epel6]
name=CentOS-6-epel-cmiot.local
baseurl=https://mirrors.aliyun.com/epel/6/x86_64/
gpgcheck=0

2、检查yum的可用性,并查看yum的repolist

3、安装repo同步工具和必要软件包

yum install -y wget make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel createrepo yum-utils

4、创建yum软件包目录并向阿里同步,时间较久。

mkdir -p /mirror/Aliyun/CentOS/6
reposync -n --repoid=extras6 --repoid=updates6 --repoid=base6 --repoid=epel6 -p /mirror/Aliyun/CentOS/6 mkdir -p /mirror/Aliyun/CentOS/7
reposync -n --repoid=extras7 --repoid=updates7 --repoid=base7 --repoid=epel7 -p /mirror/Aliyun/CentOS/7

5、创建索引

createrepo -po /mirror/Aliyun/CentOS/6/base6/ /mirror/Aliyun/CentOS/6/base6/
createrepo -po /mirror/Aliyun/CentOS/6/epel6/ /mirror/Aliyun/CentOS/6/epel6/
createrepo -po /mirror/Aliyun/CentOS/6/extras6/ /mirror/Aliyun/CentOS/6/extras6/
createrepo -po /mirror/Aliyun/CentOS/6/updates6/ /mirror/Aliyun/CentOS/6/updates6/
createrepo -po /mirror/Aliyun/CentOS/7/base7/ /mirror/Aliyun/CentOS/7/base7/
createrepo -po /mirror/Aliyun/CentOS/7/epel7/ /mirror/Aliyun/CentOS/7/epel7/
createrepo -po /mirror/Aliyun/CentOS/7/extras7 /mirror/Aliyun/CentOS/7/extras7
createrepo -po /mirror/Aliyun/CentOS/7/updates7/ /mirror/Aliyun/CentOS/7/updates7/

6、安装nginx并配置

user root;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /mirror ; #这里是yum源存放目录,访问以此目录为根目录。
location / {
autoindex on; #打开目录浏览功能
autoindex_exact_size off; # off:以可读的方式显示文件大小
autoindex_localtime on; # on、off:是否以服务器的文件时间作为显示的时间
charset utf-8,gbk; #展示中文文件名
index index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

7、创建更新软件包的定时任务

1 0 1 * * * /mirror/update.sh

#!/bin/bash
reposync -n --repoid=extras6 --repoid=updates6 --repoid=base6 --repoid=epel6 -p /mirror/Aliyun/CentOS/6
reposync -n --repoid=extras7 --repoid=updates7 --repoid=base7 --repoid=epel7 -p /mirror/Aliyun/CentOS/7
createrepo --update /mirror/Aliyun/CentOS/6/base6/
createrepo --update /mirror/Aliyun/CentOS/6/epel6/
createrepo --update /mirror/Aliyun/CentOS/6/extras6/
createrepo --update /mirror/Aliyun/CentOS/6/updates6/
createrepo --update /mirror/Aliyun/CentOS/7/base7/
createrepo --update /mirror/Aliyun/CentOS/7/epel7/
createrepo --update /mirror/Aliyun/CentOS/7/extras7/
createrepo --update /mirror/Aliyun/CentOS/7/updates7/

8、配置客户端yum文件使用

为方便客户端下载,可配置nginx支持从客户端直接下载yum配置文件,配置方法如下

  • 配置nginx
[root@HLWHOST ~]# cat /etc/nginx/nginx.conf

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
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 /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; server {
listen 80;
listen [::]:80;
server_name localhost; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /data/mirror/Aliyun/;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset utf-8,gbk;
index index.html;
}
location /repo { #配置repo文件的位置
alias /data/repo/;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset utf-8,gbk;
index index.html;
} error_page 404 /404.html;
location = /404.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
} }
  • 客户端下载repo文件

curl -o /etc/yum.repos.d/centos7.repo http://192.67.0.67/repo/centos7.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://192.67.0.67/Aliyun/CentOS/$releasever/base$releasever
gpgcheck=1
gpgkey=http://192.67.0.67/Aliyun/CentOS/RPM-GPG-KEY-CentOS-$releasever [updates]
name=CentOS-$releasever - Updates
baseurl=http://192.67.0.67/Aliyun/CentOS/$releasever/updates$releasever
gpgcheck=1
gpgkey=http://192.67.0.67/Aliyun/CentOS/RPM-GPG-KEY-CentOS-$releasever [extras]
name=CentOS-$releasever - Extras
baseurl=http://192.67.0.67/Aliyun/CentOS/$releasever/extras$releasever
gpgcheck=1
gpgkey=http://192.67.0.67/Aliyun/CentOS/RPM-GPG-KEY-CentOS-$releasever [epel]
name=CentOS-$releasever - epel
baseurl=http://192.67.0.67/Aliyun/CentOS/$releasever/epel$releasever
gpgcheck=0
yum clean all
yum makecache
yum repolist

9、可能遇到的问题

404
如果出现404错误,大概率可能是配置文件出错。
有可能是location后多加一个左斜杠/ 也有可以是指向的目录地址不存在 403
403 Forbidden 代表被禁止的,一般是三种情况导致的 1、目录权限不足
检查目录权限。权限不足就将权限加上 chmod -R 755 /home/files 2、nginx.conf用户权限问题
vim /etc/nginx/nginx.conf 把 user 用户名 改为 user root 或 其它有高权限的用户名称即可 3 、Centos中的selinux配置未关闭
查看SELinux状态: 如果SELinux status参数为enabled即为开启状态 /usr/sbin/sestatus -v 如何关闭? 1、临时关闭(不用重启机器): setenforce 0 2、永久关闭(要重启机器) vim /etc/selinux/config 将SELINUX=enforcing改为SELINUX=disabled

10、参考链接

https://www.cnblogs.com/vpandaxjl/p/12054227.html

https://www.cnblogs.com/omgasw/p/10194698.html

https://www.cnblogs.com/OneSeting/p/15525402.html

Linux-搭建内网yum源的更多相关文章

  1. 搭建内网Yum源

    搭建内网yum源 阅读(2,238) 一:因内网服务器 众多,当统一安装一些比较大的rpm的时候全部从外网下载就比较慢,而且还占用了一定的出口流量,因此在内网部署了一台yum服务器,将阿里云的epel ...

  2. RadHat搭建内网YUM源server

    前言:随着内网linuxserver越来越多,在每台server上安装软件.都要先把安装盘上传上去.在配置本地yum服务,即麻烦又费时.能够在内网的一台linuxserver上安装yum服务,然后其它 ...

  3. linux 配置内网yum源

    一.yum服务器端配置1.安装FTP软件#yum install vsftpd #service vsftpd start#chkconfig --add vsftpd#chkconfig vsftp ...

  4. #centos7 创建内网yum源 OpenStack源部署

    #centos7 创建内网yum源#centos7 自动化安装 本地 内网 web源创建.更新 createrepo http OpenStack源部署 Elven原创 http://www.cnbl ...

  5. 【转】内网yum源搭建

    我们内网yum要玩的话,先加hosts,然后找运维要CentOS_base.repo这个文件,然后yum clean all   && yum makecache ========== ...

  6. Linux学习笔记5-搭建内网Yum源

    一.安装Nginx  1.安装依赖: [root@nodeSource local]# yum install gc-devel gcc-c++ pcre-devel zlib-devel 2.解压N ...

  7. 利用nginx 来实现内网yum源(反向代理)

    简介 在项目部署时,尤其是在政府企业,对于外网简直是奢望,但是对于运维来说,没有外网的话只能自建yum源.我今天来说的是一种简单的自建yum源方法,前提是必须有一台内外网都有的机器,我们一般称为前置机 ...

  8. 公司内网yum源

    新增yum源配置文件 vi /etc/yum.repos.d/szyum.repo 内容如下: #[redhat6.3] [base] name=redhat63 baseurl=http://10. ...

  9. linux搭建内网邮件服务器

    一.配置发件服务器 1.1 根据现场IP,配置主机名 vi /etc/hosts 192.168.40.133 mail.test.com 将主机名更改为邮件服务器域名mail.test.com 1. ...

  10. linux里如何配置本地yum源和外网yum源

    一:本地和外网源配置方法 二:外网YUM源的地址 一: ① 本地源配置方法:以光盘里rpm举例(这里使用虚拟机演示) 1.挂载一个iso的镜像 把光盘挂载到一个目录里,然后进入/etc/yum.rep ...

随机推荐

  1. Jetpack的ViewModel与LiveData总结

    本文基于SDK 29 一.ViewModel与LiveData的作用: 1.viewModel: 数据共享,屏幕旋转不丢失数据,并且在Activity与Fragment之间共享数据. 2.LiveDa ...

  2. UI自动化如何保持登录状态?

    给页面设置cookie信息,刷新页面清楚缓存实现保持登录状态: 通过cookie保持登录,1手动登录,通过applacation提取登录的cookie,2通过driver.add_cookie({&q ...

  3. WPF --- 触摸屏下的两个问题

    引言 本片文章分享一下之前遇到的WPF应用在触摸屏下使用时的两个问题. 场景 具体场景就是一个配置界面, ScrollViewer 中包含一个StackPanel 然后纵向堆叠,已滚动的方式查看,然后 ...

  4. 动态挂载指定vue组件 Vue.extend $mount('#aaa111')

    模板中要有定位 <template> <div id="aaa111"></div> </template> 指定某个函数执行 im ...

  5. iview viewdesign 里面的Select 输入添加 query不能从新为空 @on-create 解决方案 v-if 从新刷一遍

    iview viewdesign 里面的Select 输入添加 query不能从新为空 @on-create 解决方案 v-if 从新刷一遍

  6. 基于 XAF Blazor 的规则引擎编辑器 - 实战篇

    示例项目:https://gitee.com/easyxaf/recharge-rules-engine-sample 前言 继上一篇文章对规则引擎编辑器进行了初步介绍之后,本文将通过实际应用案例深入 ...

  7. 性能优化:编译器优化选项 -O2/-O3 究竟有多强大?

    之前的"性能优化的一般策略及方法"一文中介绍了多种性能优化的方法.根据以往的项目经验,开启编译器优化选项可能是立竿见影.成本最低.效果最好的方式了. 这么说可能还不够直观,举个真实 ...

  8. 阿里云centos Linux系统挂载数据盘操作流程

    这里假设的是已经在阿里云管理后台购买完了新增的硬盘.我们只讲在Linux系统里操作挂载硬盘过程. 一. 环境: 操作系统: Centos 7 二.查看云服务下所有硬盘 使用root账号登录服务器,执行 ...

  9. 安装npm install报错npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request to https://registry.npmjs.org/webpack-subresource-integrity failed, reason

    执行命令:npm run dev 启动前端项目报如下错误,vue-cli-service是Vue一个启动的插件,需要安装 D:\nodejs\npm.cmd run dev > yuntan1h ...

  10. 记录--产品:请给我实现一个在web端截屏的功能!

    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 一.故事的开始 最近产品又开始整活了,本来是毫无压力的一周,可以小摸一下鱼的,但是突然有一天跟我说要做一个在网页端截屏的功能. 作为一个工 ...