在换源之前,要确保外网畅通,可以 ping 8.8.8.8 进行检查
一:配置CentOS 镜像(CentOS-Base.repo)
1.查看服务器源目录源情况
yum repolist all //查看所有存在源目录里的源
ls /etc/yum.repos.d/ //列出源目录下的源
更新 yum 缓存
yum clean all
yum makecache
2.进入源目录
cd /etc/yum.repos.d/
3.下载源:
wget http://mirrors.aliyun.com/repo/Centos-7.repo
上面是阿里源的下载
开源镜像站:
阿里云开源镜像站:https://mirrors.aliyun.com/
网易开源镜像站:https://mirrors.163.com/
中科大开源镜像站:https://mirrors.ustc.edu.cn/
清华开源镜像站:https://mirrors.tuna.tsinghua.edu.cn/
如果报wget错误,则先安装wget:
安装wget工具:yum install -y wget
4.将下载的配置文件重命名:
mv Centos-7.repo Centos-Base.repo //Centos-7.repo为上述下载的源,Centos-Base.repo为重命名后的源名
5.清空缓存和创建yum源元数据缓存
yum clean all && yum makecache //yum clean all:清除缓存;yum makecache:建立元缓存
到处,如果未报错,换源结束
二:配置Epel 镜像(epel-7.repo)
同理在源网站下载Epel 镜像
wget -O /etc/yum.repos.d/epel-7.repo https://mirrors.aliyun.com/repo/epel-7.repo
除了第一步下载的东西不同,后续步骤同一:后续步骤
三:配置docker-ce镜像
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
同理,除了下载的repo文件不同,其他同一
四:配置kubernetes镜像
创建配置文件并添加以下内容:vi /etc/yum.repos.d/kubernetes.repo
[k8s]
name=k8s
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
五:配置ceph镜像(ceph-rpm-15.2.17.repo)
创建配置文件并添加以下内容:vi /etc/yum.repos.d/ceph-rpm-15.2.17.repo
[ceph-rpm-15.2.17_x86_64]
name=ceph-rpm-15.2.17_x86_64
baseurl=https://mirrors.aliyun.com/ceph/rpm-15.2.17/el7/x86_64/
enabled=1
gpgcheck=0
[ceph-rpm-15.2.17-noarch]
name=ceph-rpm-15.2.17-noarch
baseurl=https://mirrors.aliyun.com/ceph/rpm-15.2.17/el7/noarch/
enabled=1
gpgcheck=0
六:配置SCLo-scl镜像(CentOS-SCLo-scl-7-9.repo)
创建配置文件并添加以下内容:vi /etc/yum.repos.d/CentOS-SCLo-scl-7-9.repo
[CentOS-SCLo-scl]
name=CentOS-SCLo-scl
baseurl=https://mirrors.aliyun.com/centos/7.9.2009/sclo/x86_64/sclo/
enabled=1
gpgcheck=0
[CentOS-SCLo-scl-rh]
name=CentOS-SCLo-scl-rh
baseurl=https://mirrors.aliyun.com/centos/7.9.2009/sclo/x86_64/rh
enabled=1
gpgcheck=0