Red Hat 安装配置Yum

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

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

  1. 1. 安装Yum,配置好CentOS的源,选了网易163的源
  2. 2. 顺便用Yum安装一个Vim来玩

首先从这篇文章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!