【Linux】搭建私有yum仓库(类阿里云)

embedded/2024/9/24 23:27:24/

在搭建本地yum仓库并配置国内镜像阿里云源中了解yum

yum : Yellow dog Updater,Modified,是一种基于rpm包的自动升级和软件包管理工具。yum能从指定的服务器自动下载rpm包并安装,自动计算出程序之间的依赖关系和软件安装的步骤,自动一次安装所有依赖的软件包。yum便于管理大量软件更新,采用客户端/服务器工作机制。

yumyum旨在解决软件依赖关系,yum源就是软件安装来源或软件仓库,用来存放软件列表信息和软件包。

详解如何在云上搭建私有yum仓库及定时同步阿里云yum源到本地文章中提到共享yum源的概念

其中yum源的基本工作机制

1)服务器端:在服务器上面存放了所有的RPM软件包,然后以相关的功能去分析每个RPM文件的依赖性关系,将这些数据记录成文件存放在服务器的某特定目录内。

2)客户端:如果需要安装某个软件时,先下载服务器上面记录的依赖性关系文件(可通过WWW或FTP方式),通过对服务器端下载的纪录数据进行分析,然后取得所有相关的软件,一次全部下载下来进行安装。

共享yum源就是在局域网内(或本地)搭建一个yum源,然后局域网内(或本地)所有的计算机在离线的环境下可以使用yum命令安装软件。

原文链接:https://blog.csdn.net/qq_28721869/article/details/115036342

搭建私有yum仓库(类阿里云)

  • (一)配置本地yum源和阿里源
  • (二)服务端
    • 1.安装nginx
    • 2.将公网镜像同步到本地私有yum仓库
    • 3.配置nginx
    • 4.启动nginx
  • (三)客户端

yum_23">(一)配置本地yum源和阿里源

[root@localhost ~]# rm -rf /etc/yum.repos.d/*.repo
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/                    repo/Centos-7.repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0    773      0  0:00:03  0:00:03 --:--:--   773
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100   664  100   664    0     0   1183      0 --:--:-- --:--:-- --:--:--  1185
//期间有报错可以不理会
[root@localhost ~]# yum clean all && yum makecache
[root@localhost ~]# yum repolist
[root@localhost ~]# yum -y install   yum-utils   createrepo plugin-priorities

(二)服务端

1.安装nginx

[root@localhost ~]# yum install -y nginx

在这里插入图片描述

yum_53">2.将公网镜像同步到本地私有yum仓库

  • reposync 是 yum-utils 软件包中的一个工具,它允许用户将远程的 YUM 仓库内容同步到本地目录,从而创建一个本地的 YUM 仓库镜像。
//建立私有yum仓库的存放目录
[root@localhost ~]# mkdir -p /data/centos/7/{base,extras,updates,epel}
//使用nohup在后台运行reposync,将远程YUM仓库的内容(只同步更新的包)同步到/data/centos/7目录,并将所有输出(包括正常输出和错误消息)写入/opt/yum.log文件。
[root@localhost ~]# nohup reposync -np  /data/centos/7   > /opt/yum.log 2>&1&
[5] 11444
  • 建本地私有库:在/data/centos/7/目录下的base、extras、updates和epel子目录中分别创建YUM仓库的元数据
[root@localhost ~]# cd /data/centos/7/
[root@localhost 7]# cd base && createrepo -p ./ && cd -
Spawning worker 0 with 192 pkgs
Spawning worker 1 with 192 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
/data/centos/7
[root@localhost 7]# cd extras && createrepo -p ./ && cd -
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
/data/centos/7
[root@localhost 7]# cd updates && createrepo -p ./ && cd -
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
/data/centos/7
[root@localhost 7]# cd epel && createrepo -p ./ && cd -
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
/data/centos/7

在这里插入图片描述

3.配置nginx

[root@localhost 7]# vim /etc/nginx/nginx.confuser root;
---server {listen       80;listen       [::]:80;server_name  mirrors.dfwlg.com;    #设置服务名root         /data/centos/7/;location / {autoindex on;        #打开目录浏览功能autoindex_exact_size off;  # off:以可读的方式显示文件大小autoindex_localtime on; # on、off:是否以服务器的文件时间作为显示的时>间charset utf-8,gbk; #展示中文文件名index index.html;}

在这里插入图片描述

4.启动nginx

[root@localhost 7]# systemctl restart nginx
[root@localhost 7]# setenforce 0

输入IP访问
在这里插入图片描述

补充:出现403,问题是要禁用(selinux

[root@localhost 7]# vim /etc/selinux/config

在这里插入图片描述

在这里插入图片描述

(三)客户端

cat > /etc/yum.repos.d/mirrors-dfwlg.repo <<EOF
[base]
name=CentOS-$releasever - Base - mirror.dfwlg.com
baseurl=http://10.0.0.88/base/
path=/
enabled=1
gpgcheck=0 [updates]
name=CentOS-$releasever - Updates - mirror.dfwlg.com
baseurl=http://10.0.0.88/updates/
path=/
enabled=1
gpgcheck=0 [extras]
name=CentOS-$releasever - Extras - mirrors.dfwlg.com
baseurl=http://10.0.0.88/extras/
path=/
enabled=1
gpgcheck=0 [epel]
name=CentOS-$releasever - epel - mirrors.dfwlg.com
baseurl=http://10.0.0.88/epel/
failovermethod=priority
enabled=1
gpgcheck=0
EOF[root@localhost ~]# yum clean all && yum makecache

在这里插入图片描述

客户端测试

[root@localhost ~]# yum install -y yum-utils
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
mirrors-dfwlg.repo

[参考文章]
https://zhuanlan.zhihu.com/p/412791423
https://blog.csdn.net/qq_28721869/article/details/115036342


http://www.ppmy.cn/embedded/33236.html

相关文章

工控领域常用的组态软件有哪些?

工控&#xff08;工业控制&#xff09;领域常用的组态软件有很多种&#xff0c;其中包括&#xff1a; LabVIEW&#xff08;National Instruments&#xff09;&#xff1a;LabVIEW是一种图形化编程环境&#xff0c;特别适用于数据采集、信号处理和控制系统设计。它的特点是可视化…

【深耕 Python】Data Science with Python 数据科学(18)Scikit-learn机器学习(三)

写在前面 关于数据科学环境的建立&#xff0c;可以参考我的博客&#xff1a; 【深耕 Python】Data Science with Python 数据科学&#xff08;1&#xff09;环境搭建 往期数据科学博文一览&#xff1a; 【深耕 Python】Data Science with Python 数据科学&#xff08;2&…

FFmpeg学习记录(二)—— ffmpeg多媒体文件处理

1.日志系统 常用的日志级别&#xff1a; AV_LOG_ERRORAV_LOG_WARNINGAV_LOG_INFOAV_LOG_DEBUG #include <stdio.h> #include <libavutil/log.h>int main(int argc, char *argv[]) {av_log_set_level(AV_LOG_DEBUG);av_log(NULL, AV_LOG_DEBUG, "hello worl…

编写你的第一个 golang 的应用程序

进行你的第一个golang的程序 当你把程序都安装好以后 环境变量配置 好 vscode 插件下载好以后 1. 创建一个test.go 的文件 //主包&#xff0c;可执行文件所在包 package main//导入包 import "fmt"//主函数&#xff0c;入口函数 func main() { }2.解释 需要导入包 …

数字资产:究竟靠什么形成?

在当今数字化的时代&#xff0c;数字资产成为了一个备受关注的话题。那么&#xff0c;数字资产究竟是靠什么形成的呢&#xff1f;这是一个值得我们深入探讨的问题。 数字资产的形成离不开以下几个关键因素&#xff1a; 1.技术创新&#xff1a;不断发展的科技为数字资产的产生…

绘唐3软件注册邀请码在哪

绘唐3软件注册邀请码在哪 点击在这里哦 安装完成 解压所需配套驱动 将您下载好的驱动解压后会获得如下文件夹 将驱动程序移动至安装目录下的SJ_SoftwareData文件夹内 打开绘唐3安装目录 打开SJ_SoftwareData文件夹将解压后的驱动程序移动至此 ❗❗…

5G图标显示分析

1、问题现象 MTK平台项目中出现一个5G图标显示问题&#xff0c;注册5G时&#xff0c;拨打电话&#xff0c;对比机图标显示回落到4G&#xff0c;测试机一直显示5G。 2、原因分析 2.1、NSA显示规则 根据GSMA协议&#xff0c;NSA架构下5G图标显示有如下4种. 2.2、Android中显示5G…

【openLooKeng集成Hive连接器完整过程】

【openLooKeng集成Hive连接器完整过程】 一、摘要二、正文2.1 环境说明2.2 Hadoop安装2.2.1. 准备工作2.2.2 在协调节点coordinator上进行安装hadoop2.2.3、将Hadoop安装目录分发到从节点worker2.2.4、在协调节点coordinator上启动hadoop集群2.3 MySQL安装2.4 Hive安装及基本操…