1. 安装软件:
    yum  -y  install  createrepo  yum-utils
  2. 设置yum源为阿里的镜像:
    wget  -C  /etc/yum.repo.d/ali.repo  http://mirrors.aliyun.com/repo/Centos-7.repo
    wget  -C  /etc/yum.repo.d/epel.repo  http://mirrors.aliyun.com/repo/epel-7.repo
  3. 同步阿里的镜像到本地:
    a. 创建文件夹:
    mkdir  -p  /home/lee/local

    b. 同步阿里的rpm包:

    nohup  reposync  -p  /home/lee/

    c. 将所有的rpm包移动到/home/lee/local中:

    mv  /home/lee/base/Pachage/*  /home/lee/local/
    mv  /home/lee/update/Pachage/*  /home/lee/local/
    mv  /home/lee/epel/Pachage/*  /home/lee/local/
    mv  /home/lee/extra/Pachage/*  /home/lee/local/

    d. 用createrepo创建本地yum源:

    createrepo  /home/lee/  #注意,不是local
  4. 更改yum源为自己的镜像:vim /etc/yum.repo.d/local.repo,添加:
    [local]
    name=local repo
    baseurl=file:///home/lee/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    enabled=1