一、配置阿里云镜像源

wget http://mirrors.aliyun.com/repo/epel-7.repo -O /etc/yum.repos.d/epel-7.repo

二、安装yum-utils和createrepo

yum install yum-utils createrepo -y

三、建立本地仓库

reposync -r epel -p /root/ 
#同步epel库到本地/root目录下

createrepo -v /root/epel
#建立本地仓库

四、脚本

#!/bin/bash
mkdir /opt/repo/repobak -p
yum install wget yum-utils createrepo -y

mv /etc/yum.repos.d/*.repo /opt/repo/repobak

wget http://mirrors.aliyun.com/repo/epel-7.repo -O /etc/yum.repos.d/epel-7.repo
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo

reposync -r base -p /opt/repo/
createrepo -v /opt/repo/base

reposync -r extras -p /opt/repo/
createrepo -v /opt/repo/extras

reposync -r updates -p /opt/repo/
createrepo -v /opt/repo/updates

reposync -r epel -p /opt/repo/
createrepo -v /opt/repo/epel

标签: System Management

添加新评论