当前位置: 首页 > article >正文

centos7更新yum国内源

目录在:/etc/yum.repos.d

[root@gip yum.repos.d]# pwd
/etc/yum.repos.d
[root@gip yum.repos.d]# ls
bak  CentOS-Base.repo
[root@gip yum.repos.d]# cat CentOS-Base.repo

# 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 - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

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

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

将/etc/yum.repos.d目录下的: CentOS-Base.repo 修改成上边的内容。(最好将原来的文件本地先做个备份)

#更新缓存

yum clean all

yum makecache

通过yum list available检查是否可用。

如果以后安装软件时,遇到问题,再将其它的repo文件从bak文件中考出来。

附:常见的国内 CentOS 镜像源地址:


阿里云镜像:

基础仓库 (Base):

baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
mirrorlist=https://mirrors.aliyun.com/repo/Centos-$releasever/base/

更新仓库 (Updates):

baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
mirrorlist=https://mirrors.aliyun.com/repo/Centos-$releasever/updates/

额外仓库 (Extras):

baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
mirrorlist=https://mirrors.aliyun.com/repo/Centos-$releasever/extras/

清华大学镜像站:

基础仓库 (Base):
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
更新仓库 (Updates):
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
额外仓库 (Extras):
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/

腾讯云镜像:

基础仓库 (Base):
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/
更新仓库 (Updates):
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/updates/$basearch/
额外仓库 (Extras):
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/

华为云镜像:

基础仓库 (Base):
baseurl=https://repo.huaweicloud.com/centos/$releasever/os/$basearch/
更新仓库 (Updates):
baseurl=https://repo.huaweicloud.com/centos/$releasever/updates/$basearch/
额外仓库 (Extras):
baseurl=https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/


中国科学技术大学镜像:

基础仓库 (Base):
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
更新仓库 (Updates):
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
额外仓库 (Extras):
baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/


请注意,上面的 $releasever 和 $basearch 是占位符,它们代表你的 CentOS 版本和架构。例如,在 CentOS 7 中,$releasever 将是 7,而 $basearch 通常是 x86_64。

当在 /etc/yum.repos.d/CentOS-Base.repo 文件中使用这些地址时,记得更新这些变量以匹配你的系统环境。例如,对于阿里云镜像的基础仓库,将这样设置:

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
mirrorlist=https://mirrors.aliyun.com/repo/Centos-$releasever/base/
#baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7



可以选择其中一个镜像源,将其地址复制粘贴到你的 CentOS-Base.repo 文件中,然后根据实际的 CentOS 版本和架构进行调整。


http://www.kler.cn/news/343176.html

相关文章:

  • 【hot100-java】合并 K 个升序链表
  • 【含文档】基于Springboot+Vue的小区家政服务预约平台(含源码+数据库+lw)
  • CST软件优化超表面--- 偏振片- 线圆极化转换,天线阵任务,远场算轴比AR
  • 学习之偏函数
  • 数据挖掘学习笔记:朴素贝叶斯 | Python复现
  • 搬砖10、Python 图形用户界面和游戏开发
  • java:pdfbox 3.0 去除扫描版PDF中文本水印
  • 电子取证新视角:Windows系统中文用户输入痕迹信息提取方法研究与实现
  • 使用Qt Creator创建项目
  • 腾讯云SDK用量统计
  • SpringBoot开发——整合Actuator监控和管理Spring Boot 应用
  • vuex安装报错
  • v-html里面的标签设置样式没有用怎么办?
  • 尚硅谷rabbitmq 2024第30-33节 死信队列 答疑
  • Linux:进程调度算法和进程地址空间
  • No.9 笔记 | PHP学习指南:从入门到精通的要点总结
  • 关于Integer和int的拆箱和装箱
  • HiRT | 异步控制策略,告别VLA时延问题
  • 【RPC】—Thrift协议 VS Protobuf
  • StringEntity 用于将字符串内容作为 HTTP 请求实体(请求体)