CentOS 8 安装更新国内清华大学源手记【亲测成功】

一直和各种OS打交道,仍觉得自己是小白,故深知小白们的困惑和蛋碎,特此将安装更新源的细节和步骤做了详细整理,供大家参考。红字是命令和提示,深灰色代码框中是源配置,本文采用了清华大学CentOS 8的源,按提示操作可成功,祝你好运!Good Luck!

转载请注明出处:

 

首先备份 cd /etc/yum.repos.d/

[tony@localhost home]$ su

Password: 【输入root用户的密码获取root用户权限】

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

【PS:在有的版本CentOS 8 安装完成后在源目录“/etc/yum.repos.d/” 中并没有 CentOS-Base.repo 这个文件,可能报错,那么直接用vi命令创建这个文件,并粘贴本文所附的源代码,继续往下执行即可】

[root@localhost yum.repos.d]# ll
total 56
-rw-r--r--. 1 root root  731 Mar 12 15:15 CentOS-AppStream.repo
-rw-r--r--. 1 root root 2100 Apr 10 07:19 CentOS-Base.repo
-rw-r--r--. 1 root root  798 Mar 12 15:15 CentOS-centosplus.repo
-rw-r--r--. 1 root root 1043 Mar 12 15:15 CentOS-CR.repo
-rw-r--r--. 1 root root  668 Mar 12 15:15 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  743 Mar 12 15:15 CentOS-Devel.repo
-rw-r--r--. 1 root root  756 Mar 12 15:15 CentOS-Extras.repo
-rw-r--r--. 1 root root  338 Mar 12 15:15 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  738 Mar 12 15:15 CentOS-HA.repo
-rw-r--r--. 1 root root  928 Mar 12 15:15 CentOS-Media.repo
-rw-r--r--. 1 root root  736 Mar 12 15:15 CentOS-PowerTools.repo
-rw-r--r--. 1 root root 1382 Mar 12 15:15 CentOS-Sources.repo
-rw-r--r--. 1 root root   74 Mar 12 15:15 CentOS-Vault.repo
-rw-r--r--. 1 root root  173 Apr 10 06:47 google-chrome.repo
[root@localhost yum.repos.d]# 

创建CentOS-Base.repo 文件并写入源配置

[root@localhost yum.repos.d]# vi 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.
#
#

[BaseOS]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[AppStream]
name=CentOS-$releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[PowerTools]
name=CentOS-$releasever - PowerTools
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

"ESC"键,输入:"wq" 保存并退出vi编辑器,然后执行下面的命令重新编译源缓存并执行更新操作:

[root@localhost yum.repos.d]# yum makecache 

[root@localhost yum.repos.d]# yum -y update

 

 

 

  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值