1. 程式人生 > >Linux -- Centos6 yum安裝相關問題與處理

Linux -- Centos6 yum安裝相關問題與處理

更新 ges was ear xtra entos ast follow node

Centos6 yum安裝相關問題與處理

由於要使用yum下載文件,突然yum下載不了想要的文件,想更換yum源,結果得重新安裝yum

來自本人GitHub地址 https://github.com/mrsmallyi/LinuxNote/blob/master/yum.md

一、問題1

[root@bogon ~]# yum -v
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It‘s possible that the above module doesn‘t match the
current version of Python, which is:
2.6.6 (r266:84292, Nov 22 2013, 12:16:22) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

解決方法與步驟:

  1. 清除原有RHEL的YUM及相關軟件包。
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps
  1. 下載centos6的相關軟件包。 python-urlgrabber-3.9.1-11.el6.noarch.rpm python-iniparse-0.3.1-2.1.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget  http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget  http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

註意: 如果文件無法下載,就可能是版本問題,重新到http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/目錄下載相關文件

  1. 安裝下載的安裝包
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm 
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm               
rpm -ivh yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm  yum-3.2.29-81.el6.centos.noarch.rpm 

  1. 檢查是否安裝成功
 rpm -qa | grep yum
 rpm -qa | grep python

二、問題2 -- http://apt.sw.be/redhat/el6/en/x86_64/dag/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn‘t resolve host ‘apt.sw.be‘" 問題處理

[root@bogon yum.repos.d]# yum makecache
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                       | 3.7 kB     00:00     
http://apt.sw.be/redhat/el6/en/x86_64/dag/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn‘t resolve host ‘apt.sw.be‘"
嘗試其他鏡像。
錯誤:Cannot retrieve repository metadata (repomd.xml) for repository: dag. Please verify its path and try again

這個問題最後明白yum源地址不行了,得更換了;

解決方法:

  1. cd /etc/yum.repos.d 進入這個目錄,裏面有個文件dag.repo 文件(可能名稱會不一樣)裏面的 baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag

  2. vi 編譯一下裏面的地址baseurl, 把後面的地址更換 我索性網上找到了有一篇文章https://blog.csdn.net/zhujiangm/article/details/42614105有很多個地址,然後就替換進去,不怕地址都用不了。

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://archive.cs.uu.nl/mirror/dag.wieers/redhat/el$releasever/en/$basearch/dag
        http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
        http://dag.linux.iastate.edu/dag/redhat/el$releasever/en/$basearch/dag
        http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag/
        http://ftp2.lcpe.uni-sofia.bg/freshrpms/pub/dag/redhat/el$releasever/en/$basearch/dag
        http://ftp.heanet.ie/pub/freshrpms/pub/dag/redhat/el$releasever/en/$basearch/dag
        http://ftp-stud.fht-esslingen.de/dag/redhat/el$releasever/en/$basearch/dag
        http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el$releasever/en/$basearch/dag
        http://mirrors.ircam.fr/pub/dag/redhat/el$releasever/en/$basearch/dag
        http://rh-mirror.linux.iastate.edu/pub/dag/redhat/el$releasever/en/$basearch/dag
        http://rpmfind.net/linux/dag/redhat/el$releasever/en/$basearch/dag
        http://wftp.tu-chemnitz.de/pub/linux/dag/redhat/el$releasever/en/$basearch/dag
        http://www.mirrorservice.org/sites/apt.sw.be/redhat/el$releasever/en/$basearch/dag

gpgcheck=1
enabled=1

gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  1. 使用如下命令更新到最新系統
yum -y update 
# -y 代表自動回答yes來開始下載與安裝


Linux -- Centos6 yum安裝相關問題與處理