今天在Linux上面安裝PostgreSQL的時(shí)候發(fā)生了 報(bào)錯(cuò)情況?failure: repodata/repomd.xml from xxxxxx: [Errno 256] No more mirrors to try.
#安裝postgresql15-server
sudo yum install -y postgresql15-server
?看了一下報(bào)錯(cuò)分析貌似是yum源出現(xiàn)了問(wèn)題,查了一些資料后進(jìn)行嘗試
1、方法一
既然是yum源有問(wèn)題那么就嘗試把yum源文件進(jìn)行更新試
1.備份一下yum原來(lái)的“.repo”文件(CentOS-Base.repo)? 一般“.repo”文件都會(huì)放在?/etc/yum.repos.d 目錄下
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2.然后下載一個(gè)阿里云的yum源 并命名CentOS-Base.repo ? 根據(jù)自己的centos版本去選擇自己的yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
3.清理緩存
yum clean all
yum makecache
問(wèn)題一般解決了,但是上面那種方法還是沒(méi)有解決我這邊的問(wèn)題,還是一樣的報(bào)錯(cuò)。
認(rèn)真看了一下 這個(gè)報(bào)錯(cuò) ?“No more mirrors to try”大體意思就是沒(méi)有更多的鏡像文件可以嘗試 然后下面一串url,還報(bào)了個(gè)“[Errno 14] HTTPS Error 404 - Not Found” 那就是路徑錯(cuò)誤 ?http://mirrors.aliyun.com/centos/7-7.1908.0.el7.centos/os/x86_64/repodata/repomd.xml這是我報(bào)錯(cuò)的路徑 自己訪問(wèn)了一下 果然就是 404 ,去 http://mirrors.aliyun.com/centos 看了一下 并沒(méi)有 7-7.1908.0.el7.centos 目錄稍微看了一下,這個(gè)路徑里的7-7.1908.0.el7.centos 有點(diǎn)怪怪的,那么 這個(gè)7-7.1908.0.el7.centos怎么來(lái)的呢?于是打開(kāi)報(bào)錯(cuò)的“.repo”文件看一下,以我這邊的?CentOS-Base.repo?為例
cat /etc/yum.repos.d/CentOS-Base.repo
?看了一下“.repo”文件的內(nèi)部結(jié)構(gòu)
# 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/7/os/$basearch/
http://mirrors.aliyuncs.com/centos/7/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/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/7/updates/$basearch/
http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/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/7/extras/$basearch/
http://mirrors.aliyuncs.com/centos/7/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/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/7/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/7/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/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/7/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/7/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
?大概分析了一下 這些屬性都是有什么用的
[base] #方括號(hào)里面的是軟件源的名稱,將被yum取得并識(shí)別
name=CentOS-$releasever - Base - mirrors.aliyun.com #倉(cāng)庫(kù)的名稱 用于識(shí)別
failovermethod=priority #這個(gè)屬性有兩種值可選roundrobin和priority 值為roundrobin會(huì)隨機(jī)選擇baseurl 值為priority 會(huì)根據(jù)順序一個(gè)個(gè)來(lái) 如果不指定值的話 默認(rèn)就是roundrobin
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/
#baseurl為yum源地址 包括HTTP(http://)、本地(file:///)、FTP(ftp://)
gpgcheck=1 #設(shè)置此yum源是否校驗(yàn)文件,1為校驗(yàn),0為不校驗(yàn)
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #若開(kāi)啟gpg校驗(yàn),此為公鑰文件地址
#enabled:1 設(shè)置此yum源是否可用,1為可用,0為不可用
可能就是 baseurl 這個(gè)參數(shù)的路徑出現(xiàn)了問(wèn)題? 那路勁里面 沒(méi)有7-7.1908.0.el7.centos 那是怎么來(lái)的呢? 大概就是$releasever,$basearch這個(gè)參數(shù)搞的
那就從這兩個(gè)參數(shù)入手,結(jié)果發(fā)現(xiàn)?.repo文件中的$releasever 值是先參考/etc/yum.conf中的distroverpkg的值
#使用 cat 查看yum.conf
$ cat /etc/yum.conf
[main]
cachedir=/var/cache/yum #yum下載的RPM包的緩存目錄
keepcache=0 #緩存是否保存,1保存,0不保存。
debuglevel=2 #調(diào)試級(jí)別(0-10),默認(rèn)為2(具體調(diào)試級(jí)別的應(yīng)用,我也不了解)。
logfile=/var/log/yum.log #yum的日志文件所在的位置
exactarch=1 #在更新的時(shí)候,是否允許更新不同版本的RPM包,
#比如是否在i386上更新i686的RPM包。
obsoletes=1 #這是一個(gè)update的參數(shù),具體請(qǐng)參閱yum(8),
#簡(jiǎn)單的說(shuō)就是相當(dāng)于upgrade,允許更新陳舊的RPM包。
gpgcheck=1 #是否檢查GPG(GNU Private Guard),一種密鑰方式簽名。
plugins=1 #是否允許使用插件,默認(rèn)是0不允許,
#但是我們一般會(huì)用yum-fastestmirror這個(gè)插件。
installonly_limit=3 #允許保留多少個(gè)內(nèi)核包。
exclude=selinux* #屏蔽不想更新的RPM包,可用通配符,多個(gè)RPM包之間使用空格分離。
distroverpkg=centos-release #將 $releasever設(shè)置為centos-release 這個(gè)RPM包的版本號(hào)
centos-release是一個(gè)rpm包(通過(guò):rpm可以查詢到該軟件包并沒(méi)有被安裝)
rpm -q centos-release
#結(jié)果報(bào)出package centos-release is not installed 發(fā)現(xiàn)自己沒(méi)安裝centos-release
yum install centos-release
#結(jié)果有爆出我已經(jīng)安裝了 但是沒(méi)辦法使用
最后沒(méi)辦法 只能手動(dòng)把$releasever替換成7也就是我自己centos的版本,然后清空一下緩存文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-476007.html
yum clean all
yum makecache
最后再去安裝,就沒(méi)問(wèn)題了。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-476007.html
到了這里,關(guān)于failure: repodata/repomd.xml from xxxxxx: [Errno 256] No more mirrors to try.的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!