centos-stream8 制作YUM镜像仓库

Posted 晦暗留给过往

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos-stream8 制作YUM镜像仓库相关的知识,希望对你有一定的参考价值。

`思路:
机器A: 192.168.238.17
1. 找个"最小化安装的版本" 去下载软件包和依赖包,最小化的安装版本不会让你少下载某些依赖包
2. 使用createrepo制作软件仓库
3. 搭建httpd服务器创建lan repo
机器B:192.168.238.18
4. 配置需要安装软件包的服务器,指向搭建的软件仓库进行测试
---------------------------------------------------------------------------------------------------------------------------------------
机器A:
1.下载vim软件包和所需的依赖包
# 只下载不安装,且将下载的包保存到/root/download目录下
[root@localhost ~]#  yum install  vim  --downloadonly  --downloaddir /root/test  -y
[root@localhost ~]# mkdir  /root/download
[root@localhost ~]# cp /root/test/*  /root/download/
[root@localhost ~]# cd /root/download/
[root@localhost download]# ls
gpm-libs-1.20.7-17.el8.x86_64.rpm           vim-enhanced-8.0.1763-16.el8_5.12.x86_64.rpm
vim-common-8.0.1763-16.el8_5.12.x86_64.rpm  vim-filesystem-8.0.1763-16.el8_5.12.noarch.rpm
[root@localhost download]# cd ..
[root@localhost ~]# 

2. 使用createrepo制作软件仓库
#下载安装createrepo
[root@localhost ~]# yum install createrepo -y
#将download制作软件仓库
[root@localhost ~]# createrepo  download
Directory walk started
Directory walk done - 4 packages
Temporary output repo path: download/.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished
[root@localhost ~]# 

# 进入到download中,发现产生了元数据repodata,repodata创建出来,目录名称和文件位置都是不可以改变的,如需改变需要改变后重新createrepo,重新生成repodate
[root@localhost ~]# ls download/
gpm-libs-1.20.7-17.el8.x86_64.rpm           vim-enhanced-8.0.1763-16.el8_5.12.x86_64.rpm
repodata                                    vim-filesystem-8.0.1763-16.el8_5.12.noarch.rpm
vim-common-8.0.1763-16.el8_5.12.x86_64.rpm


3. 搭建httpd服务器创建lan repo
#软件仓库做好了,需要搭建仓库环境,将仓库共享出来,别人才可以访问下载
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# ls
autoindex.conf  README  userdir.conf  welcome.conf
[root@localhost conf.d]# mv welcome.conf  welcome.conf.bak
[root@localhost conf.d]# cd 
[root@localhost ~]# cp -ra download/  /var/www/html/
[root@localhost ~]# systemctl enable httpd --now
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce  0
[root@localhost ~]# 
#这个时候用命令行curl是可以看到 download目录的,也可以图形化访问IP地址,如下图
[root@localhost ~]# curl 192.168.238.17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
 <head>
  <title>Index of /</title>
 </head>
 <body>
<h1>Index of /</h1>
  <table>
   <tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
   <tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="download/">download/</a>              </td><td align="right">2022-05-26 11:35  </td><td align="right">  - </td><td>&nbsp;</td></tr>
   <tr><th colspan="5"><hr></th></tr>
</table>
</body></html>


机器B:
4. 配置需要安装软件包的服务器,指向搭建的软件仓库进行测试

[root@bogon ~]# cd /etc/yum.repos.d/
[root@bogon yum.repos.d]# ls
CentOS-Stream-AppStream.repo  CentOS-Stream-Extras-common.repo     CentOS-Stream-Media.repo  
CentOS-Stream-BaseOS.repo     CentOS-Stream-Extras.repo            CentOS-Stream-NFV.repo    
CentOS-Stream-Debuginfo.repo  CentOS-Stream-HighAvailability.repo  CentOS-Stream-PowerTools.r
[root@bogon yum.repos.d]# rm -rf *
[root@bogon yum.repos.d]# cat vim.repo 
[vim]
name=vim
baseurl=http://192.168.238.17/download
gpgcheck=0
enabled=1
[root@bogon yum.repos.d]# yum repolist
repo id                                         repo name
vim                                             vim
[root@bogon yum.repos.d]# yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
YUM version: 4.7.0
cachedir: /var/cache/dnf
vim                                                         1.2 MB/s |  11 kB     00:00    
Repo-id            : vim
Repo-name          : vim
Repo-revision      : 1653579348
Repo-updated       : Thu 26 May 2022 11:35:48 AM EDT
Repo-pkgs          : 4
Repo-available-pkgs: 4
Repo-size          : 7.8 M
Repo-baseurl       : http://192.168.238.17/download
Repo-expire        : 172,800 second(s) (last: Fri 27 May 2022 01:32:58 AM EDT)
Repo-filename      : /etc/yum.repos.d/vim.repo
Total packages: 4
[root@bogon yum.repos.d]# 
[root@bogon yum.repos.d]# yum install vim -y

以上是关于centos-stream8 制作YUM镜像仓库的主要内容,如果未能解决你的问题,请参考以下文章

centos-stream8 制作YUM镜像仓库

Centos-Stream 配置本地yum源和配置阿里云yum源

yum管理——搭建iso镜像私有yum源仓库

自己动手制作一个本地的yum仓库

使用Nginx制作内网yum镜像代理

使用VM虚拟机安装CentOS-stream系统