当前位置:网站首页>yum源仓库本地搭建的两种方法
yum源仓库本地搭建的两种方法
2022-04-23 06:32:00 【King_nul】
文章目录
前言
yum源的搭建有两种方法
1、本地yum源仓库搭建
2、网络yum源
本文将详解如何搭建本地yum源仓库(经常会遇到在服务器离线的情况需要用的源的情况,这就需要搭建一个属于自己的yum源仓库来供其他服务器连接访问下载)
提示:以下是本篇文章正文内容,下面案例可供参考
一、yum是什么?
下面是来自于百度百科的介绍
Yum(全称为 Yellow dog Updater, Modified)是一个在 Fedora 和 RedHat 以及 CentOS 中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。
简单的说yum就是一个大型的安装包的聚集地,大家需要用到的软件都从这地方去下载,yum会自动的将你安装的软件所需要的其他软件或者工具(依赖包)都帮你安装上,非常的方便好用。
二、配置yum源的步骤(http版)
1.上传镜像文件
首先使用ssh连接虚拟机或者服务器(推荐使用CRT工具不需要另外安装插件)
连接好服务器点击右上角带锁的小电脑进行文件传输

将文件拖入右边的窗口就可以进行传输选择二进制传输

2.备份yum源创建http.repo文件
#在root下查看上传的镜像文件
[root@master ~] ll
total 13402504
-rw-------. 1 root root 1551 Dec 26 11:58 anaconda-ks.cfg
-rw-r--r--. 1 root root 4470079488 Oct 30 03:57 CentOS-7-x86_64-DVD-1804.iso
-rw-r--r--. 1 root root 9254078464 Oct 31 09:37 chinaskills_cloud_paas.iso
#备份源
[root@master ~] mv /etc/yum.repos.d/ /home/
#这是我们备份好的yum源
[root@master ~] ls /home/
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
#创建http.repo源文件(配置http.repo文件的本地默认路径)
[root@master ~] vi /etc/yum.repos.d/http.repo
#http.repo内容
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
#wq保存退出
#创建新文件夹centos
[root@master ~] mkdir /opt/centos
#至此yum的本机配置完成
3.镜像文件挂载(mount为临时挂载重启需要重新挂载)
过程如下(示例):
#挂载镜像到/mnt/
[root@master ~] mount -o loop CentOS-7-x86_64-DVD-1804.iso /opt/centos ##这是根目录下(因为我的镜像文件在根目录下)
[root@master ~] mount -o loop 镜像文件所在路径 /opt/centos
[root@master ~] ll /opt/centos/
total 320
-rw-r--r--. 1 root root 14 Dec 26 14:00 CentOS_BuildTag
drwxr-xr-x. 3 root root 35 Dec 26 14:00 EFI
-rw-r--r--. 1 root root 227 Dec 26 14:00 EULA
-rw-r--r--. 1 root root 18009 Dec 26 14:00 GPL
drwxr-xr-x. 3 root root 57 Dec 26 14:00 images
drwxr-xr-x. 2 root root 198 Dec 26 14:00 isolinux
drwxr-xr-x. 2 root root 43 Dec 26 14:00 LiveOS
drwxr-xr-x. 2 root root 221184 Dec 26 14:02 Packages
drwxr-xr-x. 2 root root 4096 Dec 26 14:02 repodata
-rw-r--r--. 1 root root 1690 Dec 26 14:02 RPM-GPG-KEY-CentOS-7
-rw-r--r--. 1 root root 1690 Dec 26 14:02 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Dec 26 14:02 TRANS.TBL
#清除缓存&&列出所有的源repo包
repo id repo name status
centos centos 3,971
repolist: 3971
#这里出现repolist : 数量 后说明我们的本地源是可以用的了
4.配置httpd服务
过程如下(示例):
#安装httpd服务
[root@master ~] yum install -y httpd
#安装完成后在http默认访问目录中创建centos文件夹
[root@master ~] cd /var/www/html/
[root@master html] ll
total 0
[root@master html] mkdir centos
[root@master html] ll
total 0
drwxr-xr-x. 2 root root 6 Dec 27 13:52 centos
#将/opt/centos下挂载的文件cp到http默认访问目录下
[root@master html] cp -rfv /opt/centos/* /var/www/html/centos/
#启动httpd服务、开机自启
[root@master html] systemctl start httpd && systemctl enable httpd
#更改http.repo文件访问地址的配置
[root@master html] vi /etc/yum.repos.d/http.repo
#text
[centos]
name=centos
baseurl=http://master/centos #这里master是我的主机名,需要做主机预设,建议使用ip地址
gpgcheck=0
enabled=1
#清除缓存列出rpm包
[root@master ~]# yum clean all && yum repolist
repolist: 4,139
#这里出来数量了 就说明http.repo源仓库已经可以用了
#可以用其他服务器直接配置源文件地址修改成baseurl=http://源仓库ip/centos即可访问我们的yum源仓库进行安装软件
三、配置yum源的步骤(ftp版)
1.前期准备
重复http版的前三步骤
2.配置vsftpd服务
示例:
#安装vsftpd服务
[root@master ~] yum install -y vsftpd
#配置vsftpd.conf文件(ftp的配置文件)
[root@master ~] vi /etc/vsftpd/vsftpd.conf
#在配置文件中加上
anon_root=/opt
wq保存退出
#开启ftp
[root@master html] systemctl start vsftpd && systemctl enable vsftpd
#在http.repo文件中将地址改为ftp的访问
[root@master ~] vi /etc/yum.repos.d/http.repo
[centos]
name=centos
baseurl=ftp://master/centos
gpgcheck=0
enabled=1
#再查看一下是否可以列出软件
[root@master ~] yum clean all && yum repolist
#可以列出,ftp的源仓库就做好了,如果出错,请自行查看http.repo中的地址有没有出错,或者是否开启ftp服务
总结
这里的所以内容就是 两种本地yum源仓库的搭建方法和步骤,本地yum源仓库的搭建是经常需要用到的,可以在离线的情况下帮助我们安装所需要的软件搭建需要的环境。
(谢谢观看,如有错误麻烦指出)
版权声明
本文为[King_nul]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_45925514/article/details/111782965
边栏推荐
- Unity gets a resource that is referenced by those resources
- Intranet penetration series: icmptunnel of Intranet tunnel (by master dhavalkapil)
- Interview learning route
- Intranet penetration series: ICMP of Intranet tunnel_ Tran
- CTF攻防世界刷题51-
- A programmer who works four hours a day
- SAP sto with billing process and configuration
- Chapter VII asset impairment
- Automatically fit single line text into the target rectangle
- feign如何集成hystrix
猜你喜欢

Towords Open World Object Detection

SAP自建表log功能开启

When using flash, the code ends automatically without an error, the connection cannot be maintained, and the URL cannot be accessed.

SAP tr manual import system operation manual

Internal network security attack and defense: a practical guide to penetration testing (5): analysis and defense of horizontal movement in the domain

Redis -- why is the string length of string emstr the upper limit of 44 bytes?

MySQL -- the secret of lock -- how to lock data

云计算技能大赛 -- openstack私有云环境 第二部分

Common markdown grammar learning

Three minutes to teach you to use Houdini fluid > > to solve particle fluid droplets
随机推荐
SAP自建表log功能开启
内网渗透系列:内网隧道之icmptunnel(jamesbarlow师傅的)
VBA calls SAP RFC to read & write data
VBA調用SAP RFC實現數據讀取&寫入
读书笔记
Buctf MISC brossage
Internal network security attack and defense: a practical guide to penetration testing (VII): cross domain attack analysis and defense
Complete color conversion formulas and conversion tables (31 kinds)
[NLP notes] preliminary study on CRF principle
从零开始完整学习机器学习和深度学习,包括理论和代码实现,主要用到scikit和MXNet,还有一些实践(kaggle上的)
Intranet penetration series: icmptunnel of Intranet tunnel (by master dhavalkapil)
庄懂的TA笔记(六)<FakeEnvReflect && 生锈,锈迹效果>
Intranet security attack and defense: a practical guide to penetration testing (6): domain controller security
SAP GUI security
BUUCTF MISC刷題
ABAP ALV显示金额与导出金额不一致
Understanding the role of individual units in a deep neural networks
Plane definition - plane equation
STO With Billing 跨公司库存转储退货
Common markdown grammar learning