加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

yum centos 修改镜像源

发布时间:2020-12-15 22:37:28 所属栏目:安全 来源:网络整理
导读:参考:https://blog.csdn.net/sj349781478/article/details/78736873 ? ? ? ? ? 先说下安装网络源的步骤: 修改CentOS默认yum源为mirrors.163.com 1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo 1 [[email?protected] ~]# mv /etc/yum

参考:https://blog.csdn.net/sj349781478/article/details/78736873

?

?

?

?

?

先说下安装网络源的步骤:

修改CentOS默认yum源为mirrors.163.com

1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
1

[[email?protected] ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


2、进入yum源配置文件所在的文件夹
1

[[email?protected] ~]# cd /etc/yum.repos.d/


3、下载163的yum源配置文件到上面那个文件夹内

CentOS7
1

[[email?protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo


CentOS6
1

[[email?protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo


CentOS5
1

[[email?protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS5-Base-163.repo


4、运行yum makecache生成缓存
1

[[email?protected] yum.repos.d]# yum makecache


5、这时候再更新系统就会看到以下mirrors.163.com信息
1
2
3
4
5
6

[[email?protected] 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

[[email?protected] ~]# 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

[[email?protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


CentOS6
1

[[email?protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


CentOS5
1

[[email?protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo


3、运行yum makecache生成缓存
1

[[email?protected] ~]# yum makecache


4、这时候再更新系统就会看到以下mirrors.aliyun.com信息
1
2
3
4
5
6

[[email?protected] ~]# yum -y update
已加载插件:fastestmirror,security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
是不是很Easy!

-----------------------------------------------------------------------------------------------------------

其实我也是按照这个步骤操作的,但是报了错:

[[email?protected] 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">rn‘

这是啥情况,问题在于你下载的不对,这里建议使用浏览器下载,然后上传至服务器。

[[email?protected] 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
你会发现又报错了,百思不得其解~~
[[email?protected] 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,然后上传至服务器。

[[email?protected] yum.repos.d]# yum install fail2banLoaded plugins: fastestmirrorSetting up Install ProcessDetermining fastest mirrorsepel | 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 fileTrying other mirror.Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try again

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读