Centos

為什麼 yum 試圖安裝錯誤版本的 node.js?

  • September 29, 2016

在 CentOS 7 伺服器上,我正在嘗試安裝 的版本5.xNode.js但由於某種原因,當它在下載站點找不到版本時,yum一直嘗試安裝版本並返回錯誤。該錯誤表明正在將版本文件名與版本url 連接。我認為這表明 CentOS 7 機器上的配置有問題。 安裝 5.x 版需要對以下內容進行哪些具體更改?0.x``0.x``5.x``yum``0.x``5.x``yum

根錯誤消息是:

Error downloading packages:
 nodejs-0.10.42-1nodesource.el7.centos.x86_64: [Errno 256] No more mirrors to try.

可以在以下連結中查看我下面的程式碼所源自的發布者頁面。此外,一些複雜情況可能是由於較早嘗試按照此其他連結的說明進行的。為了探索早期嘗試的可能殘餘,我目前正在執行以下命令並等待結果:grep -rnw '/path/to/somewhere/' -e "pattern"

這是設置節點源位置的終端輸出:

[root@localhost tmp]# curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
## Installing the NodeSource Node.js 5.x repo...
## Inspecting system...
+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m
## Confirming "el7-x86_64" is supported...
+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.sH82u4Gpap' 'https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.sH82u4Gpap'
## Cleaning up...
+ rm -f '/tmp/tmp.sH82u4Gpap'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
## Run `yum install -y nodejs` (as root) to install Node.js 5.x and npm.
## You may also need development tools to build native addons:
##   `yum install -y gcc-c++ make`

/tmp以下是上述命令之後 的文件夾內容列表:

[root@localhost tmp]# ls -al
total 8
drwxrwxrwt. 13 root   root    320 Feb 14 06:13 .
dr-xr-xr-x. 19 root   root   4096 Jan 29 20:54 ..
drwx------.  2 user   user     60 Feb 13 20:05 .esd-1000
drwxrwxrwt.  2 root   root     40 Feb 13 20:04 .font-unix
prw-------.  1 root   root      0 Feb 13 20:05 hogsuspend
drwxrwxrwt.  2 root   root     80 Feb 13 20:05 .ICE-unix
srwxrwxrwx.  1 mongod mongod    0 Feb 13 20:04 mongodb-27017.sock
drwx------.  2 user   user     40 Dec 31  1969 orbit-user
drwx------.  2 user   user     60 Feb 13 20:05 ssh-AmQyH8IIEC2m
drwx------.  3 root   root     60 Feb 13 20:05 systemd-private-74534ca9946043cc88dbe52a38b4344d-colord.service-hDR3Cd
drwx------.  3 root   root     60 Feb 13 20:04 systemd-private-74534ca9946043cc88dbe52a38b4344d-rtkit-daemon.service-ZAQmPk
drwxrwxrwt.  2 root   root     40 Feb 13 20:04 .Test-unix
drwx------.  2 user   user     40 Feb 13 20:08 tracker-extract-files.1000
-r--r--r--.  1 root   root     11 Feb 13 20:05 .X0-lock
drwxrwxrwt.  2 root   root     60 Feb 13 20:05 .X11-unix
drwxrwxrwt.  2 root   root     40 Feb 13 20:04 .XIM-unix

以下是嘗試使用安裝的nodejs結果yum

[root@localhost tmp]# yum install -y nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.lax.hugeserver.com
* epel: mirror.sfo12.us.leaseweb.net
* extras: mirror.keystealth.org
* updates: mirror.supremebytes.com
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-1nodesource.el7.centos will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================================
Package                            Arch                               Version                                                     Repository                              Size
================================================================================================================================================================================
Installing:
nodejs                             x86_64                             0.10.42-1nodesource.el7.centos                              nodesource                             4.5 M

Transaction Summary
================================================================================================================================================================================
Install  1 Package

Total download size: 4.5 M
Installed size: 16 M
Downloading packages:
No Presto metadata available for nodesource
nodejs-0.10.42-1nodesource.el7 FAILED                                          
https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found       ]  0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

Error downloading packages:
 nodejs-0.10.42-1nodesource.el7.centos.x86_64: [Errno 256] No more mirrors to try.
[root@localhost tmp]# 

為了記錄,gedit /etc/yum.repos.d/nodesource-el.repo顯示以下內容:

[nodesource]
name=Node.js Packages for Enterprise Linux 7 - $basearch
baseurl=https://rpm.nodesource.com/pub_5.x/el/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL

[nodesource-source]
name=Node.js for Enterprise Linux 7 - $basearch - Source
baseurl=https://rpm.nodesource.com/pub_5.x/el/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
gpgcheck=1  

我懷疑這個問題可能是由於之前執行過這個其他命令造成的:

curl --silent --location rpm.nodesource.com/setup | bash -

我猜潛在的問題是百勝如何堅持那些結果curl --silent --location ... | bash - commands


控制案例:


在不同的虛擬機上安裝不同的、全新的 CentOS 7,以下三個簡單的命令成功地安裝了 nodejs 的正確目前版本 5.x:

# cd /tmp
# curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
# yum install -y nodejs  
# node --version
v5.6.0  

控制案例的這些結果表明問題出在有問題的機器中如何配置 yum。 那麼需要對有問題的機器進行哪些具體的更改,以便配置 yum 以生成正確的下載 url? 將所有內容移植到不同的 VM 是不合理的。當然,這只是 yum 配置中的一兩行,可以更改以解決此問題。

這似乎是一個記憶體問題,但目前還不清楚出了什麼問題。在聊天中與發帖人進行了一番交談後,跑步yum clean all解決了這個問題。

海報指出以下幾點:

[root@localhost yum]# ls /var/cache/yum/x86_64/7/nodesource/packages 
nodejs-0.10.42-1nodesource.el7.centos.x86_64.rpm 
[root@localhost yum]# yum clean all
[root@localhost yum]# ls /var/cache/yum/x86_64/7/nodesource/packages 
[root@localhost yum]# yum install -y nodejs
.... much terminal output during successful install
[root@localhost yum]# node --version
v5.6.0

因此yum clean all刪除了已儲存在記憶體中的過時包。

我對基於 Red Hat 的發行版沒有足夠的知識或經驗來說明這裡出了什麼問題,因此將避免進一步評論。

引用自:https://unix.stackexchange.com/questions/263287