CentOS中yum本地源配置以及解决yum不能下载问题(详细)

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

(自己换了好几个虚拟机,然后发现是没有包的问题,一直报错!决定写下来~)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值