当前位置:   article > 正文

配置CentOS8 yum镜像源_2023yum centos8镜像

2023yum centos8镜像

配置yum镜像主要修改三个文件:

文件位置:/etc/yum.repos.d/

CentOS-Linux-AppStream.repo
在这里插入图片描述

将上面的两段代码注释掉,之后添加清华镜
#清华云镜像地址

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/virt/$basearch/advanced-virtualization/
  • 1

#阿里云镜像地址

baseurl=https://mirrors.aliyun.com/centos-vault//$contentdir/$releasever/AppStream/$basearch/os/
  • 1

根据以上步骤将后两个文件也进行修改

CentOS-Linux-BaseOS.repo
CentOS-Linux-Extras.repo
  • 1
  • 2

修改完成后执行更新缓存


yum clean all     # 清除系统所有的yum缓存
yum repolist
yum grouplist
yum makecache     # 生成yum缓存
  • 1
  • 2
  • 3
  • 4
  • 5

centos8更换阿里云的sh脚本

#!bin/bash

#[appstream]
if cat '/etc/yum.repos.d/CentOS-Linux-AppStream.repo' | grep 'baseurl=https://mirrors.aliyun.com/centos-vault/$contentdir/$releasever/AppStream/$basearch/os/' > /dev/null
	then
		echo "warning AppStream  Mirror exists"
	else
		sed -i '15i baseurl=https://mirrors.aliyun.com/centos-vault/$contentdir/$releasever/AppStream/$basearch/os/' /etc/yum.repos.d/CentOS-Linux-AppStream.repo
		cat -n /etc/yum.repos.d/CentOS-Linux-AppStream.repo |grep -v "#"
		echo "Configuration succeeded!" 
	fi

#[baseos]
if cat '/etc/yum.repos.d/CentOS-Linux-BaseOS.repo' | grep 'baseurl=https://mirrors.aliyun.com/centos-vault/$contentdir/$releasever/BaseOS/$basearch/os/' > /dev/null
	then
		echo "warning BaseOS Mirror exists"
	else
		sed -i '15i baseurl=https://mirrors.aliyun.com/centos-vault/$contentdir/$releasever/BaseOS/$basearch/os/' /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
		cat -n /etc/yum.repos.d/CentOS-Linux-BaseOS.repo |grep -v "#"
		echo "Configuration succeeded!"
	fi

#[extras]
if cat '/etc/yum.repos.d/CentOS-Linux-Extras.repo' | grep 'baseurl=https://mirrors.aliyun.com/centos-vault/$contentdir/$releasever/extras/$basearch/os/' > /dev/null
	then
		echo 'warning Extras Mirror exists'
	else
		sed -i '15i baseurl=https://mirrors.aliyun.com/centos-vault/$contentdir/$releasever/extras/$basearch/os/' /etc/yum.repos.d/CentOS-Linux-Extras.repo
		cat -n /etc/yum.repos.d/CentOS-Linux-Extras.repo |grep -v "#"
		echo 'Configuration succeeded!'
	fi

yum clean all
yum makecache

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号