部署要求:

服务器: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. TLS数据包重组

    TLS解密 参考以下链接:Wireshark 解密 TLS报文_在线tls解密-CSDN博客 总结: 配置环境变量 wireshark首选项配置 TLS解密例子 Frame 2700 Frame 27 ...

  2. Autofac入门与替代ASP.NET Core、ABP依赖注入容器

    目录 Autofac 的使用 1,简单的实践 2,注册组件 3,Lambda 注册组件 4,注册泛型 5,属性注入 6,解析服务 7,生命周期 8,实例作用域 9,Autofac 其它需要学习的知识 ...

  3. 原生、复杂流程操作、融合专家系统,澜码科技发布企业级Agent平台AskXBOT

    AI原生企业级Agent构建平台具备哪些特性?澜码AskXBOT平台揭晓答案 澜码科技正式发布了AI原生企业级Agent平台AskXBOT,怎么看待这个产品? 原生.复杂流程操作.融合专家系统,澜码科 ...

  4. Redis系列:RDB内存快照提供持久化能力

    ★ Redis24篇集合 1 介绍 从上一篇的 <深刻理解高性能Redis的本质> 中可以知道, 我们经常在数据库层上加一层缓存(如Redis),来保证数据的访问效率. 这样性能确实也有了 ...

  5. Word中的公式复制到Visio中乱码问题

    将word中编辑好的公式复制到Visio中出现乱码问题 如图所示问题: 解决方案(Visio 选项 --> 高级 --> 显示 ->勾选禁用增强元文件优化) 具体的公式导入和解决操作 ...

  6. 摆脱鼠标系列 - 百度搜索 - 火柴 - 快捷键 Ctrl两次

    摆脱鼠标系列 - 百度搜索 - 火柴 - 快捷键 Ctrl两次 有两款软件 utools 和 火柴,试用后觉得火柴符合试用功能 这里只用网络搜索 其他功能均不用 搜索用双核浏览器 因为用的老的chro ...

  7. docker 资料整理

    docker 资料整理 基础概念 docker deamon 守护系统:简单理解就是docker的软件系统,管控这容器的开关. docker容器:从镜像启动到内存中形成动态运行,从编程角度,如果镜像是 ...

  8. stm32 串口DMA源码解析

    一  DMA协议: DMA是STM32内的一个硬件模块,它独立于CPU在外围设备和内存之间进行数据传输,解放了CPU.每个型号的STM32 MCU有1-2个DMA,每个DMA有一定数量的Channel ...

  9. Linux常用指令2

    1.系统常用命令 1)在文件中查找内容 grep >grep  hello passwd //在passwd文件中搜索hello内容,会把hello所在行的内容打印到终端显示 2)查看系统中活跃 ...

  10. 在 Windows 上利用Qwen大模型搭建一个 ChatGPT 式的问答小助手

    本文首发于公众号:Hunter后端 原文链接:在 Windows 上利用Qwen大模型搭建一个 ChatGPT 式的问答小助手 最近 ChatGPT 式的聊天机器人比较火,可以提供各种问答功能,阿里最 ...