鏡像下載、功能變數名稱解析、時間同步請點擊 阿裡雲開源鏡像站 在CentOS中使用yum命令出現報錯: 今天想給linux裝個git 管理代碼 執行命令: 1 yum -y install git 然後出現了這麼一句 error:There are no enabled repositories in "/ ...
鏡像下載、功能變數名稱解析、時間同步請點擊 阿裡雲開源鏡像站
在CentOS中使用yum命令出現報錯:
今天想給linux裝個git 管理代碼
執行命令:
1 yum -y install git
然後出現了這麼一句
error:There are no enabled repositories in "/etc/yum.repos.d", "/etc/yum/repos.d
然後就各種找問題,各種查,各種試
比如(別複製這段,這段是錯的,解決不了)
vi /etc/yum.repos.dopenEuler_x86_64.repo
#generic-repos is licensed under the Mulan PSL v2.
#You can use this software according to the terms and conditions of the Mulan PSL v2.
#You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
#THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
#PURPOSE.
#See the Mulan PSL v2 for more details.
[OS]
name=OS
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler
[everything]
name=everything
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/RPM-GPG-KEY-openEuler
[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/EPOL/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler
[debuginfo]
name=debuginfo
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/RPM-GPG-KEY-openEuler
[source]
name=source
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/source/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/source/RPM-GPG-KEY-openEuler
[update]
name=update
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/update/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler
然後發現yum源根本沒有
所以,首先先安裝yum源
解決辦法
安裝yum源
1.進入目錄
cd /etc/yum.repos.d
2.查看並刪除/etc/yum.repos.d目錄下所有的配置文件
1 ll //查看當前目錄的所有文件
2 rm -rf ./* //刪除當前的所有文件
然後會出現(這圖是截圖人家的,我當時沒截圖)
3.下載centos8的鏡像源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
然後會看到這樣
接著
ls //查看文件
yum -y clean all //清除所有文件
yum -y makecache //建立緩存
然後你可能會發現,建立緩存失敗
提示是這樣
Error: Failed to download metadata for repo 'base'
解決辦法
切換源(任選一個命令,我這選的是1 看著來吧)
命令1:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
命令2:
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
然後再重新建立緩存
yum makecache
如果還不成功就運行這個
yum clear all
然後建立緩存
yum makecache
然後就可以了!反正我到這一步後就可以yum -y install git 了
最後
yum取的源可能是CentOS-Base.repo裡面的配置,也可能取的是單個配置文件裡面的,比如AppStream的源可能取CentOS-AppStream.repo裡面的配置,也可能取CentOS-Base.repo的配置,這兩者可能會衝突,也可能不會衝突,不衝突報錯可不理,若是報錯,建議先重命名備份CentOS-AppStream.repo文件。
本文轉自:https://blog.csdn.net/weixin_56483756/article/details/124185212