---
title: "yum命令不能使用的相关错误"
author: "wkm"
date: "2015-01-28T15:10:38Z"
tags: []
categories: ["操作系统"]
slug: "yum"
draft: false
lastmod: "2024-07-18T17:36:50Z"
id: 2180824
url: "https://wkm.iteye.com/blog/2180824"
---

yum (Yellowdog Updater Modified)是一个集与查找，安装，更新和删除程序的Linux软件。它运行在RPM包兼容的Linux发行版本上，如：RedHat, Fedora, SUSE, CentOS, Mandriva。

最近安装了CentOS5.5操作系统，在使用yum命令安装的时候出现如下错误：

 

一、yum 安装软件时，报错：No package XXX available.

\[root@localhost ~]# yum -y install redis  
Loaded plugins: fastestmirror  
Loading mirror speeds from cached hostfile  
 * addons: mirrors.163.com  
 * base: mirrors.163.com  
 * extras: mirrors.163.com  
 * updates: mirrors.163.com  
Setting up Install Process  
No package redis available.  
Nothing to do

解决方法：

1）.先去更新一下yum仓库：  
#yum -y update

 

2）.如果还是不行，可能是你安装的时候包名不够详细，可以通过yum的查找参数来列出对应软件的相关包名，拿vim的安装为例：

\# yum search vim  
Loaded plugins: fastestmirror  
Loading mirror speeds from cached hostfile  
\* base: mirror.hosting90.cz  
\* extras: mirror.hosting90.cz  
\* updates: mirror.hosting90.cz  
\===================== Matched: vim ===================  
vim-X11.x86\_64 : The VIM version of the vi editor for the X Window System.  
vim-common.x86\_64 : The common files needed by any version of the VIM editor.  
vim-enhanced.x86\_64 : A version of the VIM editor which includes recent  
: enhancements.

vim-minimal.x86\_64 : A minimal version of the VIM editor.

找到包名后，执行以下命令即可：

#yum -y install vim-enhanced.x86\_64  
以上命令就能执行成功了。

其他程序也同样可以先进行yum查找，再通过匹配详细包名来进行安装，就不会出现上述错误了。

 

3）如果还是不行，应该是 EPEL未被启动，且指示的 rpm包不可用  
具体原因：使用yum搜索某些rpm包，找不到包是因为CentOS是RedHat企业版编译过来的，去掉了所有关于版权问题的东西。安装EPEL后可以很好的解决这个问题。EPEL(Extra Packages for Enterprise Linux )即企业版Linux的扩展包，提供了很多可共Centos使用的组件，安装完这个以后基本常用的rpm都可以找到。  
下载与安装EPEL的rpm文件包  
1.下载：  
#wget http://mirrors.ustc.edu.cn/fedora/epel/5/i386/epel-release-5-4.noarch.rpm  
2.安装：  
#rpm -ivh epel-release-5-4.noarch.rpm  
安装完毕后，可以使用yum安装软件。

注意：

1\. epel的版本要与centos的版本相对应，否则安装失败，即centos5版本要对应epel5版本。

2. rpm安装完后，rpm -ql  epel\*，确提示未安装，此时要导入rpm的签名信息

#rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 （root身份执行）

 

二、YUM 提示 Segmentation fault （段错误）  
本来用得好好的yum命令，突然不能用了，报出：Segmentation fault （段错误）。  
通过一番查找，原因终于找到：是有人在服务器上安装了新版本的zlib包，正巧我执行过”#yum clean all”命令。  
解决办法：  
#vi /etc/ld.so.conf，注释掉对应的行：/usr/local/zlib/lib  
#ldconfig  
#yum update  
yum完全恢复正常。

说明：yum使用的是老版本的 zlib 库。如果有用户再一次清除了 yum 缓存，那么再使用yum安装软件时依然会报段错误。

 

三、执行yum update，报如下错误：  
Loaded plugins: fastestmirror  
Loading mirror speeds from cached hostfile  
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86\_64&repo=os error was  
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"

Error: Cannot find a valid baseurl for repo: base

原因是：DNS未配置好；  
解决方案：重新配置DNS；  
#vi /etc/resolv.conf  
编辑文件内容为：  
search localdomain  
nameserver 202.101.172.35  
nameserver 202.101.172.47    
保存并退出；  
#service network restart   

重启网卡。

 

原文：http://blog.csdn.net/rachel\_luo/article/details/8692744

（已迁移）