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

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章