安装软件:
yum -y install createrepo yum-utils
设置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
同步镜像到本地
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
更改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