Centos7更换yum镜像源

2022-09-02 10:43:47 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

Centos7更换yum镜像源

1、首先备份/etc/yum.repos.d/CentOS-Base.repo

代码语言:javascript复制
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份) 以CentOS7-Base-163.repo为例

代码语言:javascript复制
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

注意文件中$releasever有可能对应不上要手动写死 3、运行以下命令生成缓存

代码语言:javascript复制
yum clean all
yum makecache

4、yum代理 在/etc/yum.conf中加入下面几句.

代码语言:javascript复制
vim /etc/yum.conf
proxy=http://210.45.72.XX:808
proxy_username=username
proxy_password=password

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/138947.html原文链接:https://javaforall.cn

0 人点赞