red hat 6.5 配置yum源
轉載於:https://blog.csdn.net/qq_29963431/article/details/52564726
今天準備在自己的虛擬機器配置一下yum源,在網上各種找教程,但是因為相容性的問題還有一些下載地址錯誤,一直裝不好,決定自己記錄一下。
我的虛擬機器是red hat 6.5 64位,這裡的下載地址也是64位的。配置的是CentOS-6
的yum源,python版本是2.6
剛裝的red hat6.5,當我們使用yum命令的時候會報錯:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
為了省去註冊操作,通常選擇配置CentOS yum源,配置步驟如下:
-
檢查是否安裝有yum包
[[email protected] ~]# rpm -qa |grep yum
-
刪除自帶的yum包
[[email protected] ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
因為一些包之間可能會有依賴關係,所以我們需要加上引數 --nodeps 無視依賴關係
之後我們再次使用 rpm -qa | grep yum,確定yum包全部刪除
-
下載yum包
這一點一定要注意,因為
再次重申,我的red hat是6.5版本,64位
Yum包下載地址http://mirrors.163.com/centos/
在這個網站裡,你可以自己選擇需要下載的檔案,進入形如5/或者6/的檔案下載,其他的無法下載
REHL6.5 x86_64的看這裡
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm
如果以上地址出錯,可以直接進網站下載三個檔案,
形如yum.*.centos.noarch.rpm yum-metadata-parser*.rpm
yum-plugin-fastemirror.*.rpm
-
解壓yum包
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-3.2.29-73.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm --force --nodeps
如果直接解壓可能會出現包的依賴錯誤,這裡我直接選擇忽視依賴性
因為這裡下載的檔案可能不一樣,建議解壓命令自己打,多tab幾下就好
接下來更換yum源
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
vi 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-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&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-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
5清理快取
yum clean all
重建快取
yum makecache
-
更新
yum update
中間遇到很多問題比如
[[email protected] ~ ]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.6.7 (************)
解決方法:
查詢yum檔案,並編輯此py檔案
[[email protected] ~ ]# which yum
/usr/bin/yum
[[email protected] ~ ]# vi /usr/bin/yum
將
#!/usr/bin/python
改為:
whereis python出來的結果
#!/usr/bin/python2.6
如果實在不行,重新安裝yum包吧(就是上邊說的三個檔案,重新進入網站自選),少年,這個yum包可能不適合你的系統版本
裝好之後試一下yum list命令,如果出現一大堆包,恭喜你