文章目录
制作本地yum源
步骤一:先将你需要的镜像找到上传到服务器里面
步骤二:创建一个目录挂载镜像
[root@k8s-node1 ~]# ls
anaconda-ks.cfg CentOS-7-x86_64-DVD-2009.iso init.sh k8s
[root@k8s-node1 ~]# mkdir /repository
[root@k8s-node1 ~]# mkdir -p /repository/{centos,temp}
[root@k8s-node1 ~]# cd /repository/
[root@k8s-node1 repository]# cp /root/CentOS-7-x86_64-DVD-2009.iso ./
[root@k8s-node1 repository]# ll
total 4601856
-rw-r--r-- 1 root root 4712300544 Mar 11 04:37 CentOS-7-x86_64-DVD-2009.iso
drwxr-xr-x 2 root root 6 Mar 11 04:35 {
centos.temp}
[root@k8s-node1 repository]# chmod 777 -R /repository/*
挂载镜像到这个目录下面,就会产生很多目录,里面的Packages 目录全是rpm包
[root@k8s-node1 repository]# ls
centos CentOS-7-x86_64-DVD-2009.iso temp
[root@k8s-node1 repository]# mount CentOS-7-x86_64-DVD-2009.iso /repository/temp/
mount: /dev/loop0 is write-protected, mounting read-only
[root@k8s-node1 repository]# cd temp/
[root@k8s-node1 temp]# ls
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
把rpm包都拷贝到centos这个目录下面
[root@k8s-node1 repository]# ls
centos CentOS-7-x86_64-DVD-2009.iso temp
[root@k8s-node1 repository]# cp -r temp/* centos/
取消挂载
[root@k8s-node1 repository]# ls
centos CentOS-7-x86_64-DVD-2009.iso temp
[root@k8s-node1 repository]# umount /repository/temp
步骤三:修改yum源的配置文件
重点,先备份原来的yum源配置文件
[root@k8s-master ~]# cd /etc/yum.repos.d/
[root@k8s-node1 yum.repos.d]# ls
CentOS-Base.repo.bak CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo kubernetes.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo docker-ce.repo
[root@k8s-node1 yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
编写新的配置文件vim Centos7.repo
[centos.repo]
name=Centos7.repo
baseurl=file:///repository/centos
enabled=1
gpgcheck=0
mv yum.repos.d yum.repos.d.bak
[root@k8s-node1 etc]# mkdir yum.repos.d
[root@k8s-node1 etc]# cp yum.repos.d.bak/Centos7.repo yum.repos.d
[root@k8s-node1 etc]# cd yum.repos.d
[root@k8s-node1 yum.repos.d]# ls
Centos7.repo
[root@k8s-node1 yum.repos.d]# yum clean all
[root@k8s-node1 yum.repos.d]# yum makecache
[root@k8s-node1 yum.repos.d]# yum repolist