离线部署镜像仓库搭建

news/2025/9/24 22:21:36/文章来源:https://www.cnblogs.com/JianZuo/p/19110107

离线部署镜像仓库搭建

一、系统准备

  • 一台可联网服务器:用于同步仓库(与目标系统同架构)
  • 一台离线内网服务器:最终使用离线内网仓库的机器
  • 存储空间:至少200GB
  • 系统版本:CentOS Linux release 8.5.2111

二、在可联网服务器上同步仓库

1.安装必要工具

# 创建软件包文件,下载必要工具
mkdir /opt/rpm# 只下载包不安装
yum install --downloadonly --downloaddir=/opt/rpm yum-utils createrepo nginx  wget -y# 安装必要工具
yum install yum-utils createrepo -y

2.创建存储目录并同步阿里源

# 创建存储目录
mkdir -p /data/centos/6
mkdir -p /data/openeuler/22.03
mkdir -p /data/kylin/2403# 同步基础源(centos6)
dnf reposync --repofrompath=os,https://mirrors.aliyun.com/centos-vault/6.10/os/x86_64/ --repo=os -p /data/centos/6 -n# 同步更新源(centos6)
dnf reposync --repofrompath=updates,https://mirrors.aliyun.com/centos-vault/6.10/updates/x86_64/ --repo=updates -p /data/centos/6 -n# 同步扩展源(centos6)
dnf reposync --repofrompath=extras,https://mirrors.aliyun.com/centos-vault/6.10/extras/x86_64/ --repo=extras -p /data/centos/6 -n# 同步epel源(centos6)
dnf reposync --repofrompath=epel,https://mirrors.aliyun.com/epel-archive/6/x86_64/ --repo=epel -p /data/centos/6 -n# 同步基础源(openeuler22.03)
dnf reposync --repofrompath=os,https://mirrors.aliyun.com/openeuler/openEuler-22.03-LTS-SP4/OS/x86_64/ --repo=os -p /data/openeuler/22.03 -n# 同步EPOL源(openeuler22.03)
dnf reposync --repofrompath=EPOL,https://mirrors.aliyun.com/openeuler/openEuler-22.03-LTS-SP4/EPOL/main/x86_64/ --repo=EPOL -p /data/openeuler/22.03 -n# 同步everything源(openeuler22.03)
dnf reposync --repofrompath=everything,https://mirrors.aliyun.com/openeuler/openEuler-22.03-LTS-SP4/everything/x86_64/ --repo=everything -p /data/openeuler/22.03 -n# 同步update源(openeuler22.03)
dnf reposync --repofrompath=update,https://mirrors.tuna.tsinghua.edu.cn/openeuler/openEuler-22.03-LTS-SP4/update/x86_64/ --repo=update -p /data/openeuler/22.03 -n#同步基础源(Kylin2403)
dnf reposync --repofrompath=base,https://update.cs2c.com.cn/NS/V10/V10SP3-2403/os/adv/lic/base/x86_64/ --repo=base -p /data/kylin/2403 -n#同步updates源(Kylin2403)
dnf reposync --repofrompath=updates,https://update.cs2c.com.cn/NS/V10/V10SP3-2403/os/adv/lic/updates/x86_64/ --repo=updates -p /data/kylin/2403 -n

3.下载并保存 GPG 公钥

# 下载官方GPG公钥rpm(centos6)
wget https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6 -O /data/centos/6/RPM-GPG-KEY-CentOS-6# 赋予合适权限
chmod 644 /data/centos/6/RPM-GPG-KEY-CentOS-6# 下载官方GPG公钥EPEL(centos6)
wget https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-6 -O /data/centos/6/RPM-GPG-KEY-EPEL-6# 赋予合适权限
chmod 644 /data/centos/6/RPM-GPG-KEY-EPEL-6# 下载官方GPG公钥rpm(openeuler22.03)
wget https://mirrors.aliyun.com/openeuler/openEuler-22.03-LTS-SP4/OS/x86_64/RPM-GPG-KEY-openEuler -O /data/openeuler/22.03/RPM-GPG-KEY-openEuler# 赋予合适权限
chmod 644 /data/openeuler/22.03/RPM-GPG-KEY-openEuler

4.打包并传输到离线服务器

# 打包源文件
tar -zcvf centos.tar.gz -C /data centos
tar -zcvf kylin.tar.gz -C /data kylin
tar -zcvf openeuler.tar.gz -C /data openeuler
tar -zcvf rpm.tar.gz -C /opt rpm# 通过存储介质传输或者到离线服务器
# 内部网络:如果有隔离的网络通道,使用scp/rsync,传输至指定文件夹
scp data.tar.gz root@10.160.5.145:/data
scp kylin.tar.gz root@10.160.5.145:/data
scp openeuler.tar.gz root@10.160.5.145:/data
scp rpm.tar.gz root@10.160.5.145:/data

三、在内网服务器上创建仓库

1.安装必要工具

按顺序安装rpm包
rpm -ivh /opt/rpm/drpm-0.4.1-3.el8.x86_64.rpm
rpm -ivh /opt/rpm/libmetalink-0.1.3-7.el8.x86_64.rpm
rpm -ivh /opt/rpm/createrepo*.rpm
rpm -ivh /opt/rpm/nginx*.rpm
rpm -ivh /opt/rpm/wget-1.19.5-10.el8.x86_64.rpm
rpm -ivh /opt/rpm/yum-utils-4.0.21-3.el8.noarch.rpm

2.创建元数据

# 生成centos6仓库数据
createrepo /data/centos/6/epel
createrepo /data/centos/6/os
createrepo /data/centos/6/updates
createrepo /data/centos/6/extras# 生成kylin仓库数据
createrepo /data/kylin/2403/base
createrepo /data/kylin/2403/updates# 生成kylin仓库数据
createrepo /data/openeuler/22.03/EPOL
createrepo /data/openeuler/22.03/os
createrepo /data/openeuler/22.03/update
createrepo /data/openeuler/22.03/everything

image-20250924175649777

image-20250924180020382

3.Nginx 服务配置

  • /etc/nginx/conf.d/ 目录下创建一个新的配置文件yum-repo.conf
# 创建专门用于YUM源的配置文件
cat > /etc/nginx/conf.d/yum-repo.conf << 'EOF'
server {listen       80;server_name  _;  # 匹配所有域名# 设置根目录为你的YUM源路径root /data;# 开启目录列表autoindex on;autoindex_exact_size off;autoindex_localtime on;charset utf-8;# 主位置块location / {# 不显示默认的index.html,直接显示目录列表# 可以注释掉index指令# index index.html;}# 确保正确显示中文charset_types text/html text/plain text/xml text/css application/javascript;# 错误页面配置error_page 404 /404.html;error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}
}
EOF
  • Nginx主配置文件配置
# 注释掉38-57行
[root@hwua ~]# cat /etc/nginx/nginx.conf
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/user nginx;
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 2048;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 default_server;
#        listen       [::]:80 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }}

4.检查并重启Nginx

# 检查配置文件语法
nginx -t# 重新加载配置(如果语法检查通过)
systemctl reload nginx# 或者重启Nginx
systemctl restart nginx

image-20250924184437872

5.检查网页数据

image-20250924184722835

四、客户端测试

1.centos 测试

# 检查系统环境
[root@localhost ~]# cat /etc/centos-release
CentOS release 6.2 (Final)# 移除系统自带仓库
[root@localhost ~]# mkdir /etc/yum.repos.d/centos
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv ./*.repo centos# 配置镜像仓库
cat > centos.repo << EOF
[os]
name=os
baseurl=http://10.160.11.18/centos/6/os/
gpgcheck=1
enabled=1
gpgkey=http://10.160.11.18/centos/6/RPM-GPG-KEY-CentOS-6[epel]
name=epel
baseurl=http://10.160.11.18/centos/6/epel/
gpgcheck=1
enabled=1
gpgkey=http://10.160.11.18/centos/6/RPM-GPG-KEY-EPEL-6[updates]
name=updates
baseurl=http://10.160.11.18/centos/6/updates/
gpgcheck=1
enabled=1
gpgkey=http://10.160.11.18/centos/6/RPM-GPG-KEY-CentOS-6[extras]
name=extras
baseurl=http://10.160.11.18/centos/6/extras/
gpgcheck=1
enabled=1
gpgkey=http://10.160.11.18/centos/6/RPM-GPG-KEY-CentOS-6
EOF# 清除YUM缓存
yum clean all
yum makecache# 验证配置
yum repolist
yum install -y nginx # 测试安装一个包,验证GPG校验是否正常#如果在安装过程中出现 GPG 验证错误,可检查公钥路径是否正确或重新导入公钥:
rpm --import http://10.160.11.18/centos/6/RPM-GPG-KEY-CentOS-6
rpm --import http://10.160.11.18/centos/6/RPM-GPG-KEY-EPEL-6

2.麒麟系统kylin测试

# 检查系统环境
[root@localhost ~]# cat /etc/kylin-release
Kylin Linux Advanced Server release V10 (Halberd)# 移除系统自带仓库
[root@localhost ~]# mkdir /etc/yum.repos.d/kylin
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv ./*.repo kylin# 配置镜像仓库
cat > kylin.repo << EOF
[base]
name = base
baseurl = http://10.160.11.18/kylin/2403/base/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1[updates]
name = updates
baseurl = http://10.160.11.18/kylin/2403/updates/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1
EOF# 清除YUM缓存
yum clean all
yum makecache# 验证配置
yum repolist
yum install -y nginx # 测试安装一个包,验证GPG校验是否正常

3.欧拉系统测试

# 检查系统环境
[root@localhost ~]# cat /etc/openEuler-release
openEuler release 22.03 (LTS-SP4)# 移除系统自带仓库
[root@localhost ~]# mkdir /etc/yum.repos.d/openEuler
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv ./*.repo openEuler# 配置镜像仓库
cat > openEuler.repo << EOF
[EPOL]
name=EPOL
baseurl=http://10.160.11.18/openeuler/22.03/EPOL/
enabled=1
gpgcheck=1
gpgkey=http://10.160.11.18/openeuler/22.03/RPM-GPG-KEY-openEuler[everything]
name=everything
baseurl=http://10.160.11.18/openeuler/22.03/everything/
enabled=1
gpgcheck=1
gpgkey=http://10.160.11.18/openeuler/22.03/RPM-GPG-KEY-openEuler[os]
name=os
baseurl=http://10.160.11.18/openeuler/22.03/os/
enabled=1
gpgcheck=1
gpgkey=http://10.160.11.18/openeuler/22.03/RPM-GPG-KEY-openEuler[update]
name=update
baseurl=http://10.160.11.18/openeuler/22.03/update/
enabled=1
gpgcheck=1
gpgkey=http://10.160.11.18/openeuler/22.03/RPM-GPG-KEY-openEuler
EOF# 清除YUM缓存
yum clean all
yum makecache# 验证配置
yum repolist
yum install -y nginx # 测试安装一个包,验证GPG校验是否正常

image-20250924213602001

image-20250924213733839

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/916333.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Temporal和Airflow有什么差别

Temporal和Airflow有什么差别 Temporal 和 Apache Airflow 是两种主流的工作流编排工具,但它们在设计理念、核心优势和适用场景上有着显著的不同。下面通过一个表格快速梳理它们的核心差异,然后我会进一步解释这些差…

厚街公司网站建设wordpress模板和下载不同

转载一篇问题解决博客&#xff1a;问题解决 一、烧录系统 使用SDK烧录 二、安装archiconda3 JETSON TX2 NX的架构是aarch64,与win10,linxu不同,所以不能安装Anaconda&#xff0c;这里安装对应的archiconda。 1. 安装 wget https://github.com/Archiconda/build-tools/rel…

有前景的长沙企业网站建设开发一套小程序大概多少钱

在C语言中&#xff0c;位段&#xff08;Bit Fields&#xff09;是一种用来对结构体中的成员进行位级别的控制的特性。通过位段&#xff0c;我们可以灵活地控制结构体中各个成员的位数&#xff0c;从而节省内存空间并提高程序的效率。本篇博客将详细讲解C语言中位段的相关知识&a…

建立网站教程dedecms_v5.6室内装饰设计公司企业网站模板.rar

今日继续学习树莓派4B 4G&#xff1a;&#xff08;Raspberry Pi&#xff0c;简称RPi或RasPi&#xff09; 本人所用树莓派4B 装载的系统与版本如下: 版本可用命令 (lsb_release -a) 查询: Opencv 版本是4.5.1&#xff1a; 紧接着上篇文章学习的串口通信,今日学习如何让树莓派开机…

lc1035-不相交的线

难度:中等(中期)题目描述“连连看” 上下两个数组,相同的数可以连线,问在不交叉的情况下最多可以连多少条线示例 输入:nums1 = [1,4,2], nums2 = [1,2,4] 输出:2 解释: 1 4 2 | \ 1 2 4输入:nums1 = [2,5,1,…

Spring Boot 接入 Redis Sentinel:自动主从切换与读写分离实战(修复单机多实例与 Sentinel 配置坑) - 指南

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

智能中控终端-多环境联动的智慧管控中枢

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

自我介绍与未来规划

自我介绍与未来规划一、自我介绍 大家好,我叫李昊,专业是数据科学与大数据技术; 方向:大数据开发、大数据分析; 兴趣爱好:听歌、排球、调酒(熟练使用基础调酒工具,能够调制多款经典鸡尾酒并且自研了多款特调)…

广西网站建设开发深圳网站建设哪家公司便宜

为什么要判断物理机&#xff0c;因为授权不能对虚拟机安装后的软件进行授权。虚拟机可以复制可以克隆&#xff0c;无法作为一个不可复制ID来使用。 总结了如何判断物理机&#xff1a; 1. 用systeminfo的系统型号。&#xff08;注&#xff0c;有资料是看处理器和bios。但是我这…

做网站映射tcp打开百度官网

引言 在现代软件开发中&#xff0c;我们经常需要处理大量的数据。为了有效地管理这些数据&#xff0c;我们需要使用一些强大的框架。其中&#xff0c;Spring Boot和MyBatis-Plus是两个非常流行的框架。Spring Boot是一个基于Spring的开源Java框架&#xff0c;可以用于创建独立…

图片展示类网站北京引流推广公司

时钟周期、状态周期、机器周期、指令周期与晶振频率之间的关系 1、晶振频率与脉冲的关系 假设单片机的晶振频率是12MHz&#xff0c;那么它的一个脉冲为1/12微秒&#xff1b;晶振单位时间发出的脉冲则为&#xff1a; 12 ∗ 1 0 6 12*10^6 12∗106。 假设单片机的晶振频率是4MH…

解构React Server Components:服务端序列化与流式传输的底层逻辑

组件的渲染与传输始终是平衡性能与体验的核心命题。React Server Components(RSC)并非简单的“服务端渲染升级版”,而是一套重构了组件传输链路的技术体系—它打破了传统客户端组件“全量打包下发”的模式,通过在服…

js里面的单引号、双引号及反引号的用法

js里面的单引号、双引号及反引号的用法在JavaScript中,单引号()、双引号(")和反向引号(`,也称为模板字面量或反引号)都用于定义字符串,但它们有一些不同的特性和应用场景。 下面是对它们的区别和应用方法…

牛客刷题-Day4

动态规划1:线性dp、背包问题,区间 https://ac.nowcoder.com/acm/contest/24213?from=acdiscuss牛客刷题-Day4 今日刷题:\(1016-1020\) 1016 牛牛的旅游纪念品 题目描述 牛牛在牛市的旅游纪念商店里面挑花了眼,于是…

Skinned Mesh Renderer与LOD系统蒙皮变形异常全解析

角色视觉表现力直接影响玩家沉浸感,而Skinned Mesh Renderer(蒙皮网格渲染器)与LOD(细节层次)系统的协同,是兼顾角色动态效果与场景性能的核心技术组合。Skinned Mesh Renderer通过骨骼权重精准驱动网格变形,能…

K8S (Containerd)初始化安装流程

Highlight: 一定要注意Containerd+ kubeadm+Linux内核的兼容性,初次尝试在Ubuntu24.04,内核 6.8.0 上安装,出现kube apiserver 不断重启的问题。切换到5.15内核后问题解决。 本次安装版本如下: containerd: 1.6.3…

河北省建设厅官方网站网络推广和优化是什么意思

区间预测 | MATLAB实现QRLSTM长短期记忆神经网络分位数回归多输入单输出区间预测 目录 区间预测 | MATLAB实现QRLSTM长短期记忆神经网络分位数回归多输入单输出区间预测效果一览基本介绍模型描述程序设计参考资料 效果一览 基本介绍 MATLAB实现QRLSTM长短期记忆神经网络分位数回…

?模拟赛 赛后总结

好像是教练凑了两套mx的j组模拟赛的CD题给我们做的。 题目在这里!A 鲁的石板\(n=1\) 的时候特判即可。 对于最后一块石板,只计算到它为止相邻颜色不相同的方案是很简单的,到第 \(n\) 块的方案数为 \(a_{n}=m \times…

日志|动态规划|最长回文子串|最长公共子序列|HTML CSS

力扣中心扩展法 对于奇数个:l和r初始位置都在中心字符,不断向前向后找到相同的位置 对于偶数个:l和r在中心字符差一,不断向前向后找相同位置 迭代每个字符,分开找奇数偶数。点击查看代码 class Solution {public …

Java 字段命名避坑: success和isSuccess

前几天开发时踩了个坑,前端拿不到 isSuccess 的值,调接口看返回也确实有数据,排查了半天才发现是字段命名的问题。今天就把这个踩坑过程整理出来,希望能帮大家少走弯路。 Java Bean 的 getter/setter 规范普通类型…