安裝軟件:
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