参考:https://blog.csdn.net/sj349781478/article/details/78736873
3、清除yum缓存
yum clean all
yum makecache
先说下安装网络源的步骤:
修改CentOS默认yum源为mirrors.163.com
1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
1
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、进入yum源配置文件所在的文件夹
1
[root@localhost ~]# cd /etc/yum.repos.d/
3、下载163的yum源配置文件到上面那个文件夹内
CentOS7
1
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
CentOS6
1
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS5
1
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
4、运行yum makecache生成缓存
1
[root@localhost yum.repos.d]# yum makecache
5、这时候再更新系统就会看到以下mirrors.163.com信息
1
2
3
4
5
6
[root@localhost yum.repos.d]# yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
修改CentOS默认yum源为mirrors.aliyun.com
1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
1
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载ailiyun的yum源配置文件到/etc/yum.repos.d/
CentOS7
1
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
CentOS6
1
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS5
1
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
3、运行yum makecache生成缓存
1
[root@localhost ~]# yum makecache
4、这时候再更新系统就会看到以下mirrors.aliyun.com信息
1
2
3
4
5
6
[root@localhost ~]# yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
是不是很Easy!
-----------------------------------------------------------------------------------------------------------
其实我也是按照这个步骤操作的,但是报了错:
[root@manager yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, security
Error: File contains no section headers.
file: file:///etc/yum.repos.d/6CentOS-Base.repo, line: 1
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n'
这是啥情况,问题在于你下载的不对,这里建议使用浏览器下载,然后上传至服务器。
[root@manager yum.repos.d]# file CentOS6-Base-163.repo
CentOS6-Base-163.repo: ASCII English text
当你使用wget下载的时候,请确认下file出来是否为ASCII English text,必须是这个格式。
当然了,你可用另外一种方式装
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
你会发现又报错了,百思不得其解~~
[root@manager yum.repos.d]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
error: /var/tmp/rpm-tmp.COfzVl: not an rpm package (or package manifest):
还是相同的解决办法,在浏览器输入http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm,然后上传至服务器。
[root@manager yum.repos.d]# yum install fail2ban
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
epel | 4.2 kB 00:00
http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for epel: Damaged repomd.xml file
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again
---------------------
作者:JetBrains_孙健
来源:CSDN
原文:https://blog.csdn.net/sj349781478/article/details/78736873
版权声明:本文为博主原创文章,转载请附上博文链接!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?