centos 8 epel 私有仓库

本文介绍了如何在CentOS 8系统上建立EPEL私有仓库,包括安装EPEL-release,使用rsync同步EPEL RPM,设置本地HTTPD服务器,并创建自定义metalink文件以实现本地共享和验证。

目的

本地缓存 epel 库
利用本地 http 对 eple rpm 进行本地共享

epel rpm 安装

yum install -y epel-release

epel 下载

建议使用 rsync 进行 epel 下载
eple 常见有两个库 ( modular-8 与 8 )
参考下面获取 mirrorlist 方法

curl --insecure "https://mirrors.fedoraproject.org/metalink?repo=epel-modular-8&arch=x86_64&infra=stock&content=centos"
curl --insecure "https://mirrors.fedoraproject.org/metalink?repo=epel-8&arch=x86_64&infra=stock&content=centos"

只举例上面其中一个 modular 8 , 通过 curl 获得下面信息

<?xml version="1.0" encoding="utf-8"?>
<metalink version="3.0" xmlns="http://www.metalinker.org/" type="dynamic" pubdate="Thu, 14 Jan 2021 02:40:57 GMT" generator="mirrormanager" xmlns:mm0="http://fedorahosted.org/mirrormanager">
 <files>
  <file name="repomd.xml">
   <mm0:timestamp>1609464721</mm0:timestamp>
   <size>3102</size>
   <verification>
    <hash type="md5">f14e20b89fd948bad1c86823291d68b8</hash>
    <hash type="sha1">ed6e1fb06988e55a005f5efb33b15333e5dc37ff</hash>
    <hash type="sha256">a29f3dfe36d3413ded9c1e625432167793d8ec1a818676cc5eeb7b095b5f5d24</hash>
    <hash type="sha512">af6e48f0df298502453626708046df7def214e1f81cfcfef92359b7a044e1fcd739d9d8ae4d8d099a67bd645194a1983cb8d7b1e1c5ee4d0aa63be97dafa2ce3</hash>
   </verification>
   <resources maxconnections="1">
    <url protocol="https" type="https" location="CN" preference="100">https://mirrors.tuna.tsinghua.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="CN" preference="100">http://mirrors.tuna.tsinghua.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="CN" preference="100">rsync://mirrors.tuna.tsinghua.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="CN" preference="99">https://mirrors.ustc.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="CN" preference="99">http://mirrors.ustc.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="CN" preference="99">rsync://rsync.mirrors.ustc.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="CN" preference="98">http://mirrors.bfsu.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="CN" preference="98">rsync://mirrors.bfsu.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="CN" preference="97">http://mirrors.neusoft.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="CN" preference="97">https://mirrors.neusoft.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="CN" preference="97">rsync://mirrors.neusoft.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="CN" preference="96">https://mirror.sjtu.edu.cn/fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="CN" preference="95">http://mirror.lzu.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="CN" preference="95">https://mirror.lzu.edu.cn/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="JP" preference="94">http://ftp.iij.ad.jp/pub/linux/Fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="JP" preference="94">rsync://ftp.iij.ad.jp/pub/linux/Fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="JP" preference="93">https://nrt.edge.kernel.org/fedora-buffet/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="JP" preference="92">http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora-projects/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="JP" preference="92">https://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora-projects/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="JP" preference="92">rsync://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora-projects/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="JP" preference="91">http://ftp.riken.jp/Linux/fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="JP" preference="91">rsync://ftp.riken.jp/fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="SG" preference="90">rsync://download.nus.edu.sg/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="SG" preference="90">https://download.nus.edu.sg/mirror/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="SG" preference="90">http://download.nus.edu.sg/mirror/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="ID" preference="89">http://mirror.poliwangi.ac.id/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="ID" preference="88">rsync://epel.mirror.angkasa.id/fedora-epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="ID" preference="88">http://epel.mirror.angkasa.id/pub/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="IQ" preference="87">http://mirror.earthlink.iq/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="JP" preference="86">http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="JP" preference="86">rsync://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="HK" preference="85">http://epel.01link.hk/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="HK" preference="85">https://epel.01link.hk/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="TH" preference="84">http://mirrors.bestthaihost.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="TH" preference="84">rsync://mirrors.bestthaihost.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="TH" preference="83">http://mirror2.totbb.net/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="TH" preference="83">rsync://mirror2.totbb.net/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="AZ" preference="82">http://mirror.yer.az/fedora-epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="AZ" preference="82">https://mirror.yer.az/fedora-epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="BD" preference="81">http://mirror.xeonbd.com/fedora-epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="KZ" preference="80">rsync://mirror.ps.kz/fedora-epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="KZ" preference="80">http://mirror.ps.kz/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="KZ" preference="80">https://mirror.ps.kz/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="MY" preference="79">http://my.mirrors.thegigabit.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="KZ" preference="78">https://mirror.hoster.kz/fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="KZ" preference="78">http://mirror.hoster.kz/fedora/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="KZ" preference="78">rsync://mirror.hoster.kz/fedora-epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="MY" preference="77">http://fedora.ipserverone.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="MY" preference="77">https://fedora.ipserverone.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="TW" preference="76">http://fedora.cs.nctu.edu.tw/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="TW" preference="76">rsync://fedora.cs.nctu.edu.tw/fedora-epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="HK" preference="75">http://hk.mirrors.thegigabit.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="HK" preference="74">https://hkg.mirror.rackspace.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="HK" preference="74">rsync://hkg.mirror.rackspace.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="HK" preference="74">http://hkg.mirror.rackspace.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="TH" preference="73">https://mirrors.thzhost.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="rsync" type="rsync" location="TH" preference="73">rsync://mirrors.thzhost.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="TH" preference="73">http://mirrors.thzhost.com/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="http" type="http" location="ID" preference="72">http://mirror.telkomuniversity.ac.id/epel/8/Modular/x86_64/repodata/repomd.xml</url>
    <url protocol="https" type="https" location="ID" preference="72">https://mirror.telkomuniversity.ac.id/epel/8/Modular/x86_64/repodata/repomd.xml</url>
   </resources>
  </file>
 </files>
</metalink>

其实这里已经提供了允许你使用 rsync 获取 epel8 软件的服务器地址, 自己选择一个网速好的进行数据同步

rsync 同步

rsync  -av rsync://mirrors.tuna.tsinghua.edu.cn/epel/8/Everything/x86_64/*  .
rsync  -av rsync://mirrors.tuna.tsinghua.edu.cn/epel/8/Modular/x86_64/*  .

私有 httpd

参考下面 epel repo

[epel-modular]
name=Extra Packages for Enterprise Linux Modular $releasever - $basearch
#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Modular/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-modular-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

准备

从上面 repo 知道我们需要准备两个条件
1 dns 强制接管, 即本地需要有 DNS 服务器, bind 或 pdns , 并创建 fedoraproject.org 主域
2 http 服务器需要支持 https 访问 并支持 vhost (mirros.fedoraproject.org 的访问

DNS 及 http 服务器搭建(略)

metalink 创建

repo 中有这个 metalink 配置

https://mirrors.fedoraproject.org/metalink?repo=epel-modular-$releasever&arch=$basearch&infra=$infra&content=$contentdir

意味着可以通过 https://mirrors.fedoraproject.org url 访问到一个 metalink 的文件
这个文件访问时候带了参数

repo=epel-modular-$releasever
arch=$basearch
infra=$infra
content=$contentdir

使用个简答的 php 回应就可以, 目的就是为了返回一个完整的 metalink 文件 (参考)之前 epel 下载演示

exaple:

当我这里的服务器访问了下面 url 之后, 可以返回我自定义的一个 metalink data info

url

https://mirrors.fedoraproject.org/metalink?repo=epel-modular-$releasever&arch=$basearch&infra=$infra&content=$contentdir

metalink data

<?xml version="1.0" encoding="utf-8"?>
<metalink version="3.0" xmlns="http://www.metalinker.org/" type="dynamic" pubdate="Thu, 14 Jan 2021 02:40:57 GMT" generator="mirrormanager" xmlns:mm0="http://fedorahosted.org/mirrormanager">
 <files>
  <file name="repomd.xml">
   <mm0:timestamp>1609464721</mm0:timestamp>
   <size>3102</size>
   <verification>
    <hash type="md5">f14e20b89fd948bad1c86823291d68b8</hash>
    <hash type="sha1">ed6e1fb06988e55a005f5efb33b15333e5dc37ff</hash>
    <hash type="sha256">a29f3dfe36d3413ded9c1e625432167793d8ec1a818676cc5eeb7b095b5f5d24</hash>
    <hash type="sha512">b827c7823ed6c84849b879fc29a7a0b7726be320d8837edddb0a834497cba3f5139a1fafa998da1cd7d1fba3ba6007e20e75b37ce901c02f4572d6ab39a25002</hash>
   </verification>
   <resources maxconnections="1">
    <url protocol="http" type="http" location="CN" preference="100">http://我的epelhttp服务器dns/epel/8/Modular/x86_64/repodata/repomd.xml</url>
   </resources>
  </file>
 </files>
</metalink>

最重要就是要从 metalink data 中获取下面这段信息, 而这个就是我的 epel http 可以访问的地址

    <url protocol="http" type="http" location="CN" preference="100">http://我的epelhttp服务器dns/epel/8/Modular/x86_64/repodata/repomd.xml</url>

注意

由于这个是自己写的 metadatalink , 因此, 你不可以直接复制 官方 epel 的 sha512 码
当客户端检测到错误的 sha512 码以后, 会返回下面信息

- Downloading successful, but checksum doesn't match. Calculated: b827c7823ed6c84849b879fc29a7a0b7726be320d8837edddb0a834497cba3f5139a1fafa998da1cd7d1fba3ba6007e20e75b37ce901c02f4572d6ab39a25002(sha512)  Expected: af6e48f0df298502453626708046df7def214e1f81cfcfef92359b7a044e1fcd739d9d8ae4d8d099a67bd645194a1983cb8d7b1e1c5ee4d0aa63be97dafa2ce3(sha512)

根据上面提示知道

当前的 sha512 是 b827c7823ed6c84849b879fc29a7a0b7 。。。。。。。。
而服务器配置的 metalink 上写的是 af6e48f0df29850245362670804。。。。
你只需要复制 b827c7823ed6c84849b879fc29a7a0b7 。。。。。。。。 替换到 metalink 返回即可完美创建私有 epel repo

notice

https://mirrors.bfsu.edu.cn/epel/7/x86_64/
https://admin.fedoraproject.org/mirrormanager/mirrors/EPEL
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值