1. 程式人生 > >Redhat6.4配置使用Centos的yum源實現telnet的安裝

Redhat6.4配置使用Centos的yum源實現telnet的安裝

之前在Redhat6.4中配置了本地yum源(Redhat6.4配置使用本地yum源實現telnet的安裝),從iso映象中獲取rpm包,安裝一些軟體/命令。但是有時候iso映象中並不存在某些軟體/命令,或者版本過低,需要安裝更高的版本,就需要自行下載rpm包直接安裝。但是下載rpm並自行安裝比較麻煩,所以需要yum這種方便的安裝方式。我們可以將redhat的yum源改為centos的yum源,具體修改配置的方法如下所示:

1、檢查是否安裝了yum包(可跳過):

rpm -qa |grep yum
這裡寫圖片描述

2、解除安裝RedHat自帶的yum:

rpm -qa | grep yum | xargs rpm -e –nodeps


(注:xargs的作用是將引數列表轉換成小塊分段傳遞給 其他命令,以避免參數列表過長的問題;–nodeps 強制解除安裝,不管依賴性 )
這裡寫圖片描述

四個包的下載如下所示:
這裡寫圖片描述

4、安裝下載的centos的yum包:

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.i686.rpm
rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm

注意:可以直接rpm -ivh yum*來安裝三個yum包,由於後兩個包存在依賴關係,因此後兩個一同安裝以示提醒

在安裝中如果還遇到包的依賴問題則下載相關包並安裝,解決依賴問題。我在安裝最後兩個包的過程中遇到了python-urlgrabber版本過低的問題,問題與解決方式如下圖:
這裡寫圖片描述

5、下載CentOS6-Base-163.repo檔案,存放到 /etc/yum.repo.d中,並修改CentOS6-Base-163.repo配置檔案。

關於CentOS6-Base-163.repo的內容如下所示:

# 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-$releasever - Base - 163.com baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates - 163.com baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - 163.com baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - 163.com baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

修改的要點如下所示:

#!/bin/sh
# 我們需要將repo檔案中的"$releasever"改為Redhat的版本號。
# Redhat6.4中將"$releasever"改為6
# 為什麼是6而不是6.4,可以參考http://mirrors.163.com/centos/6.4/readme
# 並且其他版本也是如此,如Redhat7.2/Centos7.2的repo檔案中寫7而不是7.2。
# 替換的命令為:

sed -i 's/\$releasever/6/g' CentOS6-Base-163.repo

6、修改完配置檔案以後,yum clean all清除yum快取,便可以執行yum install telnet進行telnet的安裝。
這裡寫圖片描述

我們可以檢視安裝的新的yum包,已經是我們重新安裝的centos的yum包:
這裡寫圖片描述