cat /etc/redhat-release查看版本
vim /etc/yum.repos.d/CentOS-base.repo
(可以先提前备份一下)
内容清空
将下面代码6.5改成自己的版本复制进去
(此处使用的是国外源,若使用国内源,请往下看)
[base] name=CentOS-6.5 - base #mirrorlist=http://#mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=os baseurl=https://archive.kernel.org/centos-vault/6.5/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-6.5 - Updates #mirrorlist=http://#mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=updates baseurl=https://archive.kernel.org/centos-vault/6.5/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-6.5 - Extras #mirrorlist=http://#mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=extras baseurl=https://archive.kernel.org/centos-vault/6.5/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-6.5 - Plus #mirrorlist=http://#mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=centosplus baseurl=https://archive.kernel.org/centos-vault/6.5/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-6.5 - Contrib #mirrorlist=http://#mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=contrib baseurl=https://archive.kernel.org/centos-vault/6.5/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
清理缓存 # yum clean all 更新缓存 # yum makecache #测试 yum install -y unzip zip
由于比较慢
可以使用163 centos7的yum源
[base] name=CentOS-7 - base - 163.com baseurl=http://mirrors.163.com/centos/7/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-7 - Updates - 163.com baseurl=http://mirrors.163.com/centos/7/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-7 - Extras - 163.com baseurl=http://mirrors.163.com/centos/7/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-7 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-7 - Contrib - 163.com baseurl=http://mirrors.163.com/centos/7/contrib/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
参考:https://blog.csdn.net/weixin_44160584/article/details/110872926