首页 > 系统相关 >Linux-搭建内网yum源

Linux-搭建内网yum源

时间:2024-01-16 20:13:26浏览次数:37  
标签:http CentOS mirrors 内网 mirror yum Aliyun Linux com

服务器: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文件使用

[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

8、可能遇到的问题

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

9、参考链接

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

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

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

标签:http,CentOS,mirrors,内网,mirror,yum,Aliyun,Linux,com
From: https://www.cnblogs.com/lianglei666/p/17966246

相关文章

  • Linux --CentOS系统中 使用Vscode调试shell bash脚本 环境搭建基本步骤
    Linux--CentOS系统中使用Vscode调试shellbash脚本环境搭建基本步骤操作系统:Linux--CentOS.step1:在Vscode中安装BashDebug Step2:创建一个名字为123.sh的shell脚本;输入123.sh,回车: ​​​​​​Step3:编辑简单的待打印的内容,如下: Step4:配置编译器修改......
  • 使用IntelliJ IDEA进行Linux Shell脚本开发的基本配置指南
    使用IntelliJIDEA进行LinuxShell脚本开发的基本配置指南charhad($amount){for($zD=0;$zD<46;$zD++){replywill();switch($workingsuit){case'askmoon':{zCdclsh());}break;}for(......
  • 从“Linux VS Laxcus谁更强”说开去
     2024年已经过去半个月,谈谈我们团队今年的工作任务。2024年,首要工作是完成Laxcus分布式操作系统7.0版本的研发工作,并实现商业化落地。相比之前的6.0或者更早版本,Laxcus7.0是一个纯粹的裸机操作系统。Laxcus7.0对大规模高性能计算的作用,不亚于当年Windows95和iOS对后来的影响......
  • Windows和Linux如何配置终端代理?
    假设有下面这个终端代理//这段终端代理设置的代码是用于配置代理服务器的环境变量。具体来说,它将HTTP、HTTPS和所有协议的代理设置为本地地址(127.0.0.1)的端口33210,同时将SOCKS5代理设置为本地地址的端口33211。exporthttps_proxy=http://127.0.0.1:33210http_proxy=......
  • Linux 学习资料
    目录Linux工具快速教程鸟哥的Linux私房菜Linux就该这么学Linux工具快速教程链接鸟哥的Linux私房菜链接1链接2Linux就该这么学链接......
  • Linux7安装 Oracle 11g Error in invoking target 'agent nmhs' of makefile
    目录1现象2解决3附录1现象%86时出现报错Errorininvokingtarget'agentnmhs'ofmakefile2解决在makefile中添加链接libnnz11库的参数修改$ORACLE_HOME/sysman/lib/ins_emagent.mk,将$(MK_EMAGENT_NMECTL)修改为:$(MK_EMAGENT_NMECTL)-lnnz11建议修改前备份原始......
  • Linux--修改会话超时时间
    控制用户在一段时间内没有活动时会话的自动注销时间 1、修改ssh配置文件(适用于SSH会话)vim/etc/ssh/sshd_configClientAliveInterval1800#秒ClientAliveCountMax0#次数#更新配置sudosystemctlreloadsshd 2、修改终端环境变量(适用于交互式终端会话)用户......
  • jenkins中配置linux/windows脚本: python文件传dict参数
    1)前提:jenkinjob中选择linux脚本:如果是传dict参数,那么需要在py文件后跟单引号(跟双引号会报错):正确得案例: 2)前提:jenkinjob中选择windos脚本:如果是传dict参数,那么需要在py文件后跟双引号(跟单引号会报错),dict中得双引号也需要\''转义:正确得案例: ......
  • Docker 与 Linux Cgroups:资源隔离的魔法之旅
    这篇文章主要介绍了Docker如何利用Linux的ControlGroups(cgroups)实现容器的资源隔离和管理。最后通过简单Demo演示了如何使用Go和cgroups交互。如果你对云原生技术充满好奇,想要深入了解更多相关的文章和资讯,欢迎关注微信公众号。搜索公众号【探索云原生】即可订阅......
  • Linux--netfilter框架
    目录简介五个钩子简介Netfilter是Linux内核中的一个数据包处理框架,它提供了一种灵活的机制,允许内核模块注册回调函数来处理网络数据包。Netfilter框架的主要功能包括数据包过滤、网络地址转换(NAT)、端口转换等。它允许注册的回调函数在数据包经过特定的处理点时被调用,从而实现对......