参考下面这篇文章:
其中那个 epel-release-5-4.noarch.rpm链接路径发生了变化 https://archives.fedoraproject.org/pub/archive/epel/5/i386/epel-release-5-4.noarch.rpm
如果提示如下错误:
[root@localhost ~]# yum install git
YumRepo Warning: not using ftp, http[s], or file for repos, skipping - Invalid release/repo/arch combination
removing mirrorlist with no valid mirrors: //var/cache/yum/base/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
需要 vim /etc/yum.repos.d/CentOS-Base.repo 将其中的项都加上enabled=0
==============================================================
在Centos系统中yum install git的时候出现下面的错误
Setting up Install Process No package git available. Nothing to do
解决办法
需要先添加EPEL(Extra Packages for Enterprise Linux) repository,添加方法如下,请根据Centos的版本和CPU自行选择,如果不清楚如何查看,请参考《Linux查看系统信息常用指令》。
(这里就用 cat /etc/redhat-release 以及 uname -m 来查询系统类型和处理器架构)
CentOS5.x 32-bit(x86/i386): rpm -Uvh https://archives.fedoraproject.org/pub/archive/epel/5/i386/epel-release-5-4.noarch.rpm CentOS5.x 64-bit(x64): rpm -Uvh https://archives.fedoraproject.org/pub/archive/epel/5/x86_64/epel-release-5-4.noarch.rpm CentOS6.x32-bit (x86/i386): rpm -Uvh https://archives.fedoraproject.org/pub/archive/epel/6/i386/epel-release-6-5.noarch.rpm CentOS6.x 64-bit(x64): rpm -Uvh https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm
之后再yum install git就能安装git了。
参考文档
http://chinacheng.iteye.com/blog/1825538
转载请注明:知识蚂蚁 » Centos安装yum install git出现No package git available的解决办法
===============================================================
常见错误0:
找不到yum命令,
解决方法:
vim /usr/bin/yum 将其中的python尝试改为你系统中的python版本,例如python2.4 或 python2.6,可能需要尝试看看哪一个合适。
常见错误一:
GPG key retrieval failed: [Errno 14] HTTP Error 404: Not Found
解决方法:
将/etc/yum.repos.d/CentOS-Base.repo 中的gpgcheck=1 改为0
=======================================================
常见错误二:
[root@dttvm0122102209330 ~]# yum install gdb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: vault.centos.org
* epel: d2lzkl7pfhq30w.cloudfront.net
base 2791/2791
file:///mnt/cdrom/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] 没有那个文件或目录: '/mnt/cdrom/repodata/repomd.xml'
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: source7.2. Please verify its path and try again
[root@dttvm0122102209330 ~]# yum install gdb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: vault.centos.org
* epel: d2lzkl7pfhq30w.cloudfront.net
file:///mnt/cdrom/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] 没有那个文件或目录: '/mnt/cdrom/repodata/repomd.xml'
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: source7.2. Please verify its path and try again
[root@dttvm0122102209330 ~]# cat /root/backup_yum.repo
[source7.2]
name=source7.2
baseurl=file:///mnt/cdrom
#enabled = 0
gpgcheck=0
本地yum.repo只有上面内容时,可以会提示
======== Red Hat Enterprise Linux Server release 5.4 (Tikanga) cat /etc/redhat-release
解决方法:替换以下内容到repo中, 然后yum clean all , yum make cache ,
注意:即使你将你本地文件重命名为backup_yum.repo, 好像也有可能被系统找到,还是有提示cdrom路径问题。最后直接将此原来的文件移到别的目录 。
===========以下为5.4 上的示例内容。
# 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-5.11 - Base - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/5.11/os/$basearch/
http://mirrors.aliyuncs.com/centos/5.11/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-5.11 - Updates - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/5.11/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-5.11 - Extras - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/5.11/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://vault.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released
[addons]
name=CentOS-5.11 - Addons - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/5.11/addons/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=addons
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5.11 - Plus - vault.centos.org
failovermethod=priority
name=CentOS-5.11 - Plus - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/5.11/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/5.11/os/x86_64/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5.11 - Contrib - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/5.11/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/5.11/os/x86_64/RPM-GPG-KEY-CentOS-5
===============如果有以下错误提示
[root@el5 ~]# yum search git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: addons
[root@el5 ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@el5 ~]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: addons
解决方法:用上面5.4 的内容替换掉 /etc/yum.repos.d/CentOS-Base.repo
==========================在此之后安装gcc-c++时若提示
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
解决方法:
rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
====================================================
没有yum命令时的解决方法:
https://vault.centos.org/5.6/os/x86_64/CentOS/
在上面链接中搜索yum-3.xxx.rpm包,安装。包括相应的依赖包。
建议使用wget下载,可以将先将wget换个别名: alias dl='wget --no-check-certificate '
然后 dl 相应的链接。
m2crypto-0.16-6.el5.8.x86_64.rpm python-urlgrabber-3.1.0-6.el5.noarch.rpm
python-elementtree-1.2.6-5.x86_64.rpm yum-3.2.22-33.el5.centos.noarch.rpm
python-iniparse-0.2.3-4.el5.noarch.rpm yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
python-sqlite-1.1.7-1.2.1.x86_64.rpm yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
下载完成后, rpm -ivh * (某些情况下,找不到依赖库时,可以--nodeps强制安装)
然后可以将以下内容作为新的源,再yum update, yum makecache
[root@localhost soft]# cat /etc/yum.repos.d/asianux.repo
[base]
name=CentOS-$releasever - Base
failovermethod=priority
baseurl=http://vault.centos.org/5.5/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5
http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
failovermethod=priority
baseurl=http://vault.centos.org/5.5/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5
http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
failovermethod=priority
baseurl=http://vault.centos.org/5.5/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5
http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
failovermethod=priority
baseurl=http://vault.centos.org/5.5/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5
http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
failovermethod=priority
baseurl=http://vault.centos.org/5.5/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5
http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5