安装软件:
yum -y install createrepo yum-utils
设置yum源为镜像,
wget -C /etc/yum.repo.d/ali.repo mirrors.aliyun/repo/centos-7.repo
wget -C /etc/yum.repo.d/epel.repo mirrors.aliyun/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