一、需求背景 在某个内网环境中,只有一台服务器可以连接外部网络,在此情况下,需要在该台服务器搭建yum源,以便其他内网服务器能够使用yum安装软件以解决依赖关系。二、具体实现1、查看系统版本信息 4、安装yum依赖环境# yum install -y wget make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel createrepo yum-utils yum-utils:reposync同步工具 createrepo:编辑yum库工具 plugin-priorities:控制yum源更新优先级工具,这个工具可以用来控制进行yum源检索的先后顺序,建议可以用在client端。 5、创建本地目录并同步mkdir /temp/repocd /temp/reporeposync -np /temp/repo/base #执行后耐心等待,时间与服务器网络有关备注:如果只想同步某一个yum源到本地,可执行以下命令。 createrepo -po /temp/repo/extras/ /temp/repo/extras/ createrepo -po /temp/repo/updates/ /temp/repo/updates/ createrepo -po /temp/repo/epel/ /temp/repo/epel/ createrepo -po /temp/repo/docker-ce-stable/ /temp/repo/docker-ce-stable/ 6、更新repo源数据 createrepo --update /temp/repo/base createrepo --update /temp/repo/extras createrepo --update /temp/repo/updates createrepo --update /temp/repo/epel createrepo --update /temp/repo/docker-ce-stable/ 三、测试验证2、下载阿里云yum源、epel源到本地
3、检查源是否处于正常状态:yum repolist
[root@cheliangweb yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,791
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 526
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 6,173
repolist: 30,562
Removing docker-scan-plugin-0.7.0-3.el7.x86_64.rpm, due to missing GPG key.
Removing docker-scan-plugin-0.8.0-3.el7.x86_64.rpm, due to missing GPG key.
Removing docker-scan-plugin-0.9.0-3.el7.x86_64.rpm, due to missing GPG key.
之后重新安装即可。
在CentOS 7下使用阿里云yum源搭建本地YUM仓库(1):同步yum源保存到本地【测试成功】
发布于 2025-04-02 18 次阅读