创建本地yum源:
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/Centos-7.repo >/dev/null 2>&1
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo >/dev/null 2>&1
sed -i ‘s#keepcache=0#keepcache=1#g’ /etc/yum.conf
yum clean all && yum makecache
yum repolist
安装依赖
yum -y install yum-utils createrepo plugin-priorities
同步公网镜像到本地私有仓库
用repoync 命令,Reposync用于将远程yum存储库同步到本地存储库,
-n:只下载最新的包
-p:下载包的路径:默认为当前目录
mkdir -p /var/www/html/centos/{base,extras,updates,epel}
nohup reposync -np /var/www/html/centos/ > /opt/yum.log 2>&1&
cd /var/www/html/centos/
createrepo ./
cd base && createrepo -p ./ && cd -
cd extras && createrepo -p ./ && cd -
cd updates && createrepo -p ./ && cd -
cd epel && createrepo -p ./