首页 > 系统相关 >搭建本地yum源

搭建本地yum源

时间:2024-07-08 23:26:24浏览次数:14  
标签:test1 centos repos repo yum 本地 root 搭建

一、环境准备

1.准备2-3台虚拟机,一台为服务端(安装yum源),其余的为客户端(测试yum源安装结果),最好是同网段的。

IP地址角色备注
192.168.116.5服务端将完整镜像上传到这台机器
192.168.116.15客户端
192.168.116.25客户端

2.准备镜像文件,这里以CentOS-7-x86_64-2009,当然最好是使用CentOS-7-x86_64-Everything-2207-02.iso(这是完整版,包含了所有软件组件,当然体积也庞大,高达9.58G。对完整版安装盘的软件进行补充,集成所有软件;不要使用mini版)

3.准备远程软件,secucrt或者FinalShell、xshell都可

4.关闭防火墙,每一台都要关闭,包括selinux。

[root@test1 yum.repos.d]# systemctl stop firewalld
[root@test1 yum.repos.d]# systemctl disabled firewalld    //设置防火墙开机不自启
root@test1 yum.repos.d]# setenforce 0        //将selinux临时状态调整为开启
[root@test1 yum.repos.d]# getenforce        //查看selinux状态
Permissive

最好是进入配置文件将状态改为disabled

[root@test1 yum.repos.d]# vim /etc/selinux/config    //进入selinux的配置文件


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled                    //此时状态由原本的enforcing改为了disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

//注,配置本地yum源要将网关改掉,使其不能联网

二、开始配置yum源

1.用xshell连上机器后,将镜像文件上传,首先点击图中所指标识

2.点击之后进入如下界面,此时找到你要上传的镜像

3.找到镜像之后,右击鼠标,然后点击传输

4.备份yum源

[root@test1 ~]# cd /etc/yum.repos.d
/etc/yum.repos.d  //yum的配置文件所在

[root@test1 yum.repos.d]# mkdir bak
[root@test1 yum.repos.d]# ls
bak                    CentOS-Media.repo
CentOS-Base.repo       CentOS-Sources.repo
CentOS-CR.repo         CentOS-Vault.repo
CentOS-Debuginfo.repo  CentOS-x86_64-kernel.repo
CentOS-fasttrack.repo
[root@test1 yum.repos.d]# mv *.repo bak/
[root@test1 yum.repos.d]# ls
bak

//注每台机器都要进行这一步操作

5.创建yum_http.repo文件

[root@test1 yum.repos.d]# mkdir yum_http.repo
[root@test1 yum.repos.d]# vim yum_http.repo

将一下内容写入

[centos]
name=centos       
baseurl=file:///opt/centos 
gpgcheck=0
enabled=1

[root@test1 yum.repos.d]# ls /opt/centos
ls: 无法访问/opt/centos: 没有那个文件或目录
[root@test1 yum.repos.d]# mkdir  /opt/centos
[root@test1 yum.repos.d]# cd /opt/centos
[root@test1 centos]# ls
[root@test1 centos]# ls
CentOS-7-x86_64-DVD-2009.iso
[root@test1 centos]# mount /opt/centos/CentOS-7-x86_64-DVD-2009.iso /opt/centos    //挂载镜像文件,简单挂载mount: /dev/loop0 写保护,将以只读方式挂载

6.安装httpd服务

[root@test1 yum.repos.d]# yum -y install httpd

7.配置httpd服务

[root@test1 ~]# cd /var/www/html/            //进入到httpd的默认目录
[root@test1 html]# ll
总用量 0
[root@test1 html]# mkdir centos                      //创建一个centos目录
[root@test1 html]# ll
总用量 0
drwxr-xr-x. 2 root root 6 4月  23 10:37 centos

8.将将/opt/centos下挂载的文件软连接到http默认访问目录下,当然也可以使用cp命令,不过镜像文件较大,使用软连接更快

[root@test1 html]# ln -s /opt/centos/ /var/www/html/centos

[root@test1 html]# ll
总用量 4
lrwxrwxrwx 1 root root   12 7月   8 16:06 centos -> /opt/centos/
-rw-r--r-- 1 root root 1592 7月   8 15:50 index.html
drwxr-xr-x 2 root root   26 7月   8 16:01 test

9.启动httpd服务

[root@test1 yum.repos.d]# systemctl start httpd

10.修改http.repo(这里以自己创建的名字为准)文件中的baseurl为服务端ip

[root@test3 yum.repos.d]# vim http.repo 
[centos]
name=centos
baseurl=http://192.168.168.5:8080/centos    //此处IP为服务端IP地址,如果修改了端口记得加上
gpgcheck=0
enabled=1
[root@test3 yum.repos.d]# yum -y install httpd

后续也可以进行其他测试

标签:test1,centos,repos,repo,yum,本地,root,搭建
From: https://blog.csdn.net/m0_52310738/article/details/140276384

相关文章

  • springboot(maven,本地jar包,打包报错)
    maven,本地jar包,打包报错情况:部署一个springboot+vue的项目(若依)项目中用到了一个"本地的第三方jar包"//为什么使用本地jar,因为我们使用的阿里云的maven没有这个jar包,只能使用本地自己的问题来了,打包时候报错:而且他用的是:本地路径导入:本地jar//(这个不影响本地运行,但是影......
  • 淘宝扭蛋机小程序搭建全攻略
    一、引言在数字化时代,线上娱乐方式层出不穷,其中扭蛋机小程序以其独特的互动性和趣味性,受到了广大用户的喜爱。淘宝扭蛋机小程序作为其中的佼佼者,不仅为用户提供了丰富的奖品选择,还通过创新的玩法和营销策略,吸引了大量用户的关注和参与。本文将详细介绍淘宝扭蛋机小程序的搭建......
  • 解决Spring Boot中的国际化与本地化问题
    解决SpringBoot中的国际化与本地化问题大家好,我是微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!国际化与本地化概述在开发面向全球用户的应用程序时,国际化(Internationalization,简称i18n)和本地化(Localization,简称l10n)是非常重要的考虑因素。国际化指设计和实现软......
  • 使用gitea搭建源码管理【0到1架构系列】
    使用开源搭建Git源码方案,gitlab和gitea是两个不错的方案,gitlab以前简单易用,现在功能复杂且对开源并不友好,gitea一直保持功能单一易用且完全开源,个人推荐gitea。通过容器安装比较简单易用,使用镜像加速器拉取或许更快些。dockerpullbitnami/giteagitea需要数据库储存,可以选择my......
  • CentOS7云服务器环境搭建
    一、下载、更新依赖1、更新系统版本至7.9yumupdate2、下载Vimyuminstallvim-y3、下载gcc(C语言环境,redis依赖它)yuminstallgcc软件统一安装在/usr/local/software目录下,源码统一解压缩在/usr/local/source二、Java参考:CSDN1、下载java1.8_202压缩包wgethtt......
  • 海外短剧系统CPS平台源码搭建 ,海量正版短剧推广分佣
    海外短剧cps推广分佣系统,短剧平台的分销推广功能,这个功能它到底有啥优点呢?做海外短剧怕不懂海外市场、怕海外做不出流量、怕入不敷出,海外运营推广困难等等。综合上述问题总结出了一点,就是流量问题,海外短剧推广都会用tiktok、facebook、Twitter、去推广,这个无可厚非,目前海外短......
  • 如何把本地数据库上传到生产环境数据库
    java项目打包至生产环境流程-CSDN博客j上面的文章写了如何将代码打包至生产环境,但是由于我新建表了,导致报错找不到数据库表这篇文章讲一下如何讲本地数据库上传至生产环境下的数据库.一.navicat配置生产环境数据库1.首先用fianlshell连接到服务器2.然后配置连接,点击......
  • debian11 podman搭建rocketmq (初步测试)
    前言由于个人学习测试需要,想要在debian11环境下,使用podman搭建一个简单的单节点rocketmq,搭建过程比较繁琐,所以记录下来留作后续参考。由于对rocketmq镜像不熟悉,有些配置可能存在错误,会在后续有能力优化时继续更新此文档。后续可能会补充podman-compose实现方式,目前是shell脚本......
  • Ubuntu 22.04.4 LTS 安装 FreeRADIUS 3.0 和 Daloradius 2.2 搭建radius 认证服务器
    1ubuntu安装LAMP环境(安装nginx代替apache):Ubuntu22.04.4LTS安装phpapacheLAMP环境nginx-CSDN博客2安装freeradiussudoaptupdatesudoapt-getinstalllibmysqld-devsudoapt-getinstallfreeradius#先安装libmysqld-dev,否则启动可能报错Couldnotlink......
  • 搭建VUE开发环境
    了解下VUE搭建环境,可以更好地学习VUE。三步:node.js环境(npm包管理器)vue-cli脚手架构建工具cnpmnpm的淘宝镜像1.安装node.js 在搭建vue的开发环境之前,一定要先下载node.js,,vue的运行是要依赖于node的npm的管理工具来实现,node可以在官网或者中文网里面下载,根据自己的电脑选择是32......