自建yum(银河麒麟)更新源服务器
借鉴:https://www.cnblogs.com/it-log/p/17188658.html
一、下载一个centos7.9.2009的docker镜像
docker pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/centos:centos7.9.2009
二、创建一个专门用于建立yum源的镜像
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/centos:centos7.9.2009
RUN rm -rf /etc/yum.repos.d/*
# 阿里源 - 直接覆盖
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
RUN sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
RUN yum clean all && yum makecache
RUN yum update -y && yum install -y yum-utils createrepo httpd
RUN yum clean all
# 复制httpd配置文件到/etc/http/conf/httpd.conf
COPY httpd.conf /etc/httpd/conf/httpd.conf
WORKDIR /var/www/html
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
三、修改本地yum配置为麒麟yum源
[ks10-adv-os]
name = Kylin Linux Advanced Server 10 - Os
baseurl = https://update.cs2c.com.cn/NS/V10/V10SP3-2403/os/adv/lic/base/x86_64/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1
[ks10-adv-updates]
name = Kylin Linux Advanced Server 10 - Updates
baseurl = https://update.cs2c.com.cn/NS/V10/V10SP3-2403/os/adv/lic/updates/x86_64/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1
[ks10-adv-addons]
name = Kylin Linux Advanced Server 10 - Addons
baseurl = https://update.cs2c.com.cn/NS/V10/V10SP3-2403/os/adv/lic/addons/x86_64/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 0
四、清除本地原有源缓存并建立为麒麟源建立缓存元数据
yum clean all
yum makecache
五、同步软件到本地
reposync --repoid=ks10-adv-os --repoid=ks10-adv-updates --download-metadata --newest-only --delete --download_path=/var/www/html
--newest-only:只同步最新软件包
--delete:删除旧软件包
六、分别到仓库子目录创建元数据
createrepo .
七、定期更新本地仓库,然后更新元数据
createrepo --update