YUM安装调试以及命令详解

背景,需要安装cacti,google了很多安装资料,需要先yum安装一些准备lib包,比如snmp以及openssl等等。

[root@mysqlvm2 ~]# yum install net-snmp-devel

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

No package net-snmp-devel available.

Nothing to do

看到yum不识别,所以需要先在linux服务器上面安装yum软件包。

 

1 下载yum安装包

下载地址:wget http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz

[root@mysqlvm2 ~]# wget http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz

--2014-05-15 20:56:34--  http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz

正在解析主机 yum.baseurl.org... 140.211.167.207

Connecting to yum.baseurl.org|140.211.167.207|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:1140370 (1.1M) [application/x-gzip]

Saving to: `yum-3.4.3.tar.gz'

…………….

 

2 解压缩安装

tar -xvf yum-3.4.3.tar.gz

cd yum-3.4.3

yum main.py install yum

[root@mysqlvm2 yum-3.4.3]# yum main.py install yum

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

usage: yum [options] COMMAND

 

List of Commands:

红帽中出现This system is not registered with RHN这个的原因是因为红帽中没有注册RHN。解决办法:(假定你已安装yum,且网络畅通)更改yum的源,即更换/etc/yum.repos.d /rhel-debuginfo.repo 这个文件。进入/etc/yum.repos.d/目录,终端中输入wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo即可在此目录下得到CentOS- Base.repo文件,这是centos的源文件,只需将其重命名为rhel-debuginfo.repo即可,以前的文件做个备份。


 wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

 

[root@localhost yum.repos.d]# cp rhel-debuginfo.repo rhel-debuginfo.repo.bak

[root@localhost yum.repos.d]# mv CentOS-Base.repo rhel-debuginfo.repo

mv:是否覆盖“rhel-debuginfo.repo”? y

[root@localhost yum.repos.d]#

[root@mysqlvm2 yum-3.4.3]# yum makecache

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

addons                                                                                                                                                                  | 1.9 kB     00:00    

addons/filelists_db                                                                                                                                                     |  570 B     00:00    

addons/other_db                                                                                                                                                         |  554 B     00:00    

addons/primary_db

 

开始用yum安装httpd服务:

[root@mysqlvm2 yum-3.4.3]#  yum install httpd

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Package httpd-2.2.3-85.el5.centos.x86_64 already installed and latest version

Nothing to do

 

3,最后更新系统,全部搞定,收工。^_^

yum check-update
yum update  # 慎重执行,也许会影响现有的应用的运行。
yum clean all #清除YUM缓存,yum 会把下载的软件包和header存储在cache中,而不会自动删除。如果我们觉得它们占用了磁盘空间,可以使用yum clean指令进行清除,更精确 的用法是yum clean headers清除header,yum clean packages清除下载的rpm包,yum clean all一 股脑儿端

 

4,另外的一些报错:

[root@squid-2 yum-3.4.3]# yum -y install ping

Loaded plugins: fastestmirror, security

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

Check,报错:

[root@squid-2 yum-3.4.3]# nslookup  mirrorlist.centos.org

;; connection timed out; trying next origin

;; connection timed out; no servers could be reached

 

[root@squid-2 yum-3.4.3]# cat /etc/resolv.conf

 [root@squid-2 yum-3.4.3]#

Resolv.conf里面为空记录,没有数据。

看来需要重新定向一下dns了,

[root@squid-2 yum-3.4.3]# vim /etc/resolv.conf

[root@squid-2 yum-3.4.3]#

[root@squid-2 yum-3.4.3]#

 

验证,OK

[root@squid-2 yum-3.4.3]# nslookup  mirrorlist.centos.org

Server:               219.141.136.10

Address:  219.141.136.10#53

Non-authoritative answer:

Name:      mirrorlist.centos.org

Address: 64.235.47.134

Name:      mirrorlist.centos.org

Address: 204.15.73.243

Name:      mirrorlist.centos.org

Address: 72.232.223.58

 

5  GPG key retrieval failed:错误

yum install expect报错如下:

……

Total                                                                                                                                  540 kB/s | 2.9 MB     00:05    

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897

 

 

GPG key retrieval failed: [Errno 4] IOError:

后面加上 –nogpgcheck就OK,如下命令所示:

yum install expect  --nogpgcheck

 

6 修改yum源,设置优先级

有时候执行yum安装,很多都search不到,有时候找到的也不是最新的,这个时候我们可以修改yum源配置文件,添加baseurl参数。

[root@localhost ~]# ll  /etc/yum.repos.d

总计 12

-rw-r--r-- 1 root root 1426 2013-09-07 rhel-debuginfo.repo

-rw-r--r-- 1 root root  561 2010-03-10 rhel-debuginfo.repo_old

[root@localhost ~]#

[root@localhost ~]# vim /etc/yum.repos.d/rhel-debuginfo.repo

……

[testing]

name=CentOS-5 - Testing

baseurl=http://centos.ustc.edu.cn/centos/5/testing/$basearch/

gpgcheck=1

enabled=1

priority=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

 

priority=N   # N的值为1-99,数字越大优先级越低。

 

7,yum一些基本操作命令

    7.1 查找和显示

      yum search package 搜索某个软件名或重要的关键字(不要加通配符)

      yum list 列出目前yum所管理的所有的软件名称与版本 (类似rpm -qa)

      yum list package 显示指定程序包安装情况

      yum list installed 列出所有已安装的软件包

      yum list extras 列出所有已安装但不在 Yum Repository 内的软件包

      yum info 列出目前yum所管理的所有的软件名称 版本和详细信息 (类似rpm -qai)

      yum info package 显示指定程序包安装情况和详细信息

      yum info installed 列出所有已安装的软件包与详细信息

      yum info extras 列出所有已安装但不在 Yum Repository 内的软件包与详细信息

      yum grouplist 列出目前所有已安装和可以使用未安装的软件组

    yum groupinfo 后面要有接软件组的名称,则可以显示该软件组内的所有软件名称
 

    7.2 安装

     yum install package 安装指定的安装包package

     yum groupinsall group 安装程序组group


     7.3 更新和升级

  yum update 全部更新

  yum update package 更新指定程序包package

 

  yum check-update 检查可更新的程序

  yum list updates 检查可更新的程序

 

  yum info updates 列出所有可更新的软件包与详细信息

  yum upgrade package 升级指定程序包package

  yum groupupdate group 升级程序组group

 
    7.4 删除程序

  yum remove package 删除程序包package

  yum groupremove group 删除程序组group

  yum deplist package 查看程序package依赖情况

 

7.5 清除缓存

  yum clean packages 清除缓存目录下的软件包

  yum clean headers 清除缓存目录下的 headers

  yum clean oldheaders 清除缓存目录下旧的 headers

  yum clean all 清除缓存目录下的软件包及旧的headers

 

7.6 安装yum图形窗口插件

yum install yumex

 

  发现个有趣的现象,那就是yum list 与yum info几乎相同,只是yum info会列出更详细的软件信息,如Arch,Size,Sepo,Summary等。

 

参考地址:http://www.cnblogs.com/chuncn/archive/2010/10/17/1853915.html

你可能感兴趣的:(linux)