Red Hat 安装配置Yum

在公司接手一台服务器,准备做点想做的事,发现竟然连vim都没有,没事,我自己装,悲剧的发现连Yum都没装…..

服务器的的环境是Red Hat Enterprise Linux AS release 4 (Nahant Update 8),这都早八百年的老系统了,服务器的配置还行。好了,我们开始干正事,我的目标是:

  1. 安装Yum,配置好CentOS的源,选了[网易163的源](http://mirrors.163.com/.help/centos.html?1304848825 "网易163的源")
  2. 顺便用Yum安装一个Vim来玩

首先从这篇文章[Red Hat 安装Yum](http://www.blags.org/red-hat-centos-install-yum/ "Red Hat 安装Yum"),按照下面的步骤来安装Yum

先下载Yum的rpm包

    cd /syr/local/
    wget -c http://yum.baseurl.org/download/2.0/yum-2.0.8-1.src.rpm

使用rpm方式安装

    rpmbuild --rebuild yum-2.0.8-1.src.rpm
    cd /usr/src/redhat/RPMS/noarch/
    rpm -ivh yum-2.0.8-1.noarch.rpm

运行yum会出现报错

    retrygrab() failed for:   http://mirror.dulug.duke.edu/pub/yum-repository/redhat/4AS/i386/headers/header.info
    Executing failover method
    failover: out of servers to try
    Error getting file http://mirror.dulug.duke.edu/pub/yum-repository/redhat/4AS/i386/headers/header.info
    [Errno 4] IOError: 

Red Hat默认的源太老了,都没办法更新了,得更换为163的源.

修改yum.conf配置文件

    vi /etc/yum.conf

详细配置如下

    [main]
    cachedir=/var/cache/yum
    debuglevel=2
    logfile=/var/log/yum.log
    pkgpolicy=newest
    installonlypkgs=kernel kernel-smp kernel-devel kernel-smp-devel kernel-largesmp kernel-largesmp-devel kernel-hugemem kernel-hugemem-devel
    distroverpkg=centos-release
    tolerant=1
    exactarch=1
    retries=20
    obsoletes=1
    gpgcheck=1
    plugins=1 

    # PUT YOUR REPOS HERE OR IN separate files named file.repo 

    # in /etc/yum.repos.d

根据163的说明,配置好/etc/yum.repos.d/CentOS-Base.repo文件,就可以开始安装Vim了。

先找到Vim的安装包

yum list | grep vim

会列出与vim相关的包

    vim-minimal.i386                         1:6.3.046-2.el4.1      installed
    vim-X11.i386                             1:6.3.046-2.el4.1      base
    vim-common.i386                          1:6.3.046-2.el4.1      base
    vim-enhanced.i386                        1:6.3.046-2.el4.1      base

安装vim-enhanced.i386这个包就可以了

    yum install vim-enhanced.i386

会提示你是否导入GPG key,输入y即可

    warning: rpmts_HdrFromFdno: V3 DSA signature: NOKEY, key ID 443e1821
    Public key for vim-enhanced-6.3.046-2.el4.1.i386.rpm is not installed
    Retrieving GPG key from http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
    Importing GPG key 0x443E1821 "CentOS-4 key "
    Is this ok [y/N]: y

最后终于安装成功了,Vim我爱死你了。

    Key imported successfully
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing: vim-common                   ######################### [1/2]
      Installing: vim-enhanced                 ######################### [2/2]

    Installed: vim-enhanced.i386 1:6.3.046-2.el4.1
    Dependency Installed: vim-common.i386 1:6.3.046-2.el4.1
    Complete!

Done!

“Red Hat 安装配置Yum”的3个回复

  1. 我按你上面所述安装yum,可是操作rpm -ivh yum-2.0.8-1.noarch.rpm这步时提示error: open of yum-2.0.8-1.noarch.rpm failed: 没有那个文件或目录,显然这步不对吧,下载的文件不是在/sry/local中吗?切换到cd /usr/src/redhat/RPMS/noarch/这里再操作rpm -ivh yum-2.0.8-1.noarch.rpm就会有问题吧?我刚学linux,对这些操作不懂。

    1. 因为我们下载的是源代码,需要rpmrebuild下,变成适合我们系统版本。利用以下代码:
      rpmbuild --rebuild yum-2.0.8-1.src.rpm
      然后找到rebuild后的安装包进行安装就可以了。
      查找rebuild之后安装包可以使用以下命令:
      find / -name yum-2.0.8-1.noarch.rpm
      找到这个文件,切换该目录,利用rpm安装命令进行安装即可。

发表评论

电子邮件地址不会被公开。 必填项已用*标注