CentOS7在2024年6月30停止维护
Loaded plugins: fastestmirrorDetermining fastest mirrorsCould not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was14: curl#7 - "Failed to connect to 2600:1f16:c1:5e01:4180:6610:5482:c1c0: Network is unreachable"One of the configured repositories failed (Unknown),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ..4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-manager repos --disable=<repoid>5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: base/7/x86_64
yum本地源配置之前需要先往/etc/yum.repos.d文件中下载CentOS7的repo包
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
如果没有wget可以使用curl下载
curl -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
也可以在自己本机浏览器中下载
http://mirrors.aliyun.com/repo/Centos-7.repo
然后打开SSH连接软件,找到/etc/yum.repos.d文件,将上面下载的repo文件直接拖到远程软件中
然后开始yum本地源配置
详细步骤:
mkdir /mnt/cdrom
mount /dev/sr0 /mnt/cdrom #挂载点
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
vi local.repo #随便起个名字,后缀必须为repo,输入以下内容
[姓名] #随便起
name=随便起
baseurl=file://(挂载点)
gpgcheck=0(不检查密钥,1是检查密钥)
enabled=1(让yum源配置文件生效)清除之前的缓存 yum clean all
创建新的缓存 yum makecache
然后下载就没有问题啦!
如果不下载CentOS7的repo包,就会出现以下问题:
No package nginx available.
Error: Nothing to do
(自己换了好几个虚拟机,然后发现是没有包的问题,一直报错!决定写下来~)