CentOS7 | 同步本地 yum 源(http 方式)
一、服务端配置
前提:服务器能连外网,且已配置运行 Httpd 服务,假设路径为 /root/apache/www/
# 下载
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
# 清除 yum 缓存
yum clean all
# 安装必要工具
yum install yum-utils createrepo -y
# 在 Httpd 服务路径下创建文件夹
mkdir /root/apache/www/centos7-yum-repo
# 使用 reposync 同步源
yum repolist all
reposync -r base -p /root/apache/www/centos7-yum-repo
# 创建 repo
createrepo /root/apache/www/centos7-yum-repo
可以通过设置定时脚本更新源,以下是脚本内容
#!/bin/bash
reposync -r base -p /root/apache/www/centos7-yum-repo
createrepo --update /root/apache/www/centos7-yum-repo
二、客户端配置
前提:能够正常访问服务端的 httpd 服务
yum-config-manager --add-repo=http://<服务端 ip>:<httpd 端口>/centos7-yum-repo
yum clean all
yum makecache

浙公网安备 33010602011771号