Linux-搭建内网yum源
部署要求:
服务器: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源的更多相关文章
- 搭建内网Yum源
搭建内网yum源 阅读(2,238) 一:因内网服务器 众多,当统一安装一些比较大的rpm的时候全部从外网下载就比较慢,而且还占用了一定的出口流量,因此在内网部署了一台yum服务器,将阿里云的epel ...
- RadHat搭建内网YUM源server
前言:随着内网linuxserver越来越多,在每台server上安装软件.都要先把安装盘上传上去.在配置本地yum服务,即麻烦又费时.能够在内网的一台linuxserver上安装yum服务,然后其它 ...
- linux 配置内网yum源
一.yum服务器端配置1.安装FTP软件#yum install vsftpd #service vsftpd start#chkconfig --add vsftpd#chkconfig vsftp ...
- #centos7 创建内网yum源 OpenStack源部署
#centos7 创建内网yum源#centos7 自动化安装 本地 内网 web源创建.更新 createrepo http OpenStack源部署 Elven原创 http://www.cnbl ...
- 【转】内网yum源搭建
我们内网yum要玩的话,先加hosts,然后找运维要CentOS_base.repo这个文件,然后yum clean all && yum makecache ========== ...
- Linux学习笔记5-搭建内网Yum源
一.安装Nginx 1.安装依赖: [root@nodeSource local]# yum install gc-devel gcc-c++ pcre-devel zlib-devel 2.解压N ...
- 利用nginx 来实现内网yum源(反向代理)
简介 在项目部署时,尤其是在政府企业,对于外网简直是奢望,但是对于运维来说,没有外网的话只能自建yum源.我今天来说的是一种简单的自建yum源方法,前提是必须有一台内外网都有的机器,我们一般称为前置机 ...
- 公司内网yum源
新增yum源配置文件 vi /etc/yum.repos.d/szyum.repo 内容如下: #[redhat6.3] [base] name=redhat63 baseurl=http://10. ...
- linux搭建内网邮件服务器
一.配置发件服务器 1.1 根据现场IP,配置主机名 vi /etc/hosts 192.168.40.133 mail.test.com 将主机名更改为邮件服务器域名mail.test.com 1. ...
- linux里如何配置本地yum源和外网yum源
一:本地和外网源配置方法 二:外网YUM源的地址 一: ① 本地源配置方法:以光盘里rpm举例(这里使用虚拟机演示) 1.挂载一个iso的镜像 把光盘挂载到一个目录里,然后进入/etc/yum.rep ...
随机推荐
- UI自动化测试中图片验证码的处理?
首先定位验证码image的元素,然后通过element.screenshot('a.png')截图保存到本地,通过第三方接口识别本地图片验证码
- 以Servlet来解释 抽象实现类
在 Java Servlet API 中: Servlet 接口定义了一个 Servlet 的基本行为.这个接口是抽象的,因为它包含抽象方法,比如 service(), init(), 和 destr ...
- MK5 机械键盘 说明书
FN + 右箭头 就是加快节奏 FN + ScrLk 就是切换模式
- C++学习笔记之基础语法
目录 基础语法 switch和if区别 枚举定义及作用域 结构体数据耐齐--缺省对齐原则 函数重载overload与C++Name Mangling 指向函数的指针与返回指针的函数 基础语法 swit ...
- k8s通过help、dry-run、explain提高编写yaml效率
在Kubernetes(k8s)环境中,help.dry-run和explain命令可以帮助你提高编写YAML文件的效率.这些命令提供了关于资源定义.命令用法和字段说明的信息,从而让你能够更快速.更准 ...
- python tcp socket 源码分享
服务端的源码: import socketserver class Handler_TCPServer(socketserver.BaseRequestHandler): ""&q ...
- 手把手的使用Toolkit插件在诗情画意中完成AI诗朗诵
本文分享自华为云社区<[云驻共创]手把手的使用Toolkit插件在诗情画意中完成AI诗朗诵>,作者: 红目香薰. 云原生时代,开发者们的编程方式.编程习惯都发生了天翻地覆的变化,大家逐渐地 ...
- 矢量数据库与LLM的集成:实践指南
矢量数据库与LLM的集成:实践指南 本文将了解到什么是矢量数据库,以及如何与LLMs进行集成.通过LLMs和向量数据库的结合,可以节省微调带来的开销和时间. 通常,LLM会在各种各样的数据上进行训练, ...
- linux kernel 中进程间描述符的传递方法及原理
PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明 本文作为本人csdn blog的主站的备份.(Bl ...
- 文心一言 VS 讯飞星火 VS chatgpt (216)-- 算法导论16.2 3题
三.假定在 0-1 背包问题中,商品的重量递增序与价值递减序完全一样.设计一个高效算法求此背包问题的变形的最优解,证明你的算法是正确的.如果要写代码,请用go语言. 文心一言: 在0-1背包问题中,如 ...