Red Hat Linux安裝CentOS的yum源

導讀 RedHat憑藉其卓越的穩定性和強大的服務佔領着企業linux大部分市場,系統自己免費,可是其服務倒是收費的,例如其軟件包管理服務yum。不想出錢那就本身配置yum源就行了,由於yum在線更新是收費的,未註冊則不能使用,這個是要填序列號激活的,解決辦法是更換爲CentOS的yum。

設置步驟html

Red Hat Linux安裝CentOS的yum源Red Hat Linux安裝CentOS的yum源

1. 查詢原有的yumnode

[root@orcl ~]# rpm -qa |grep yum 
yum-plugin-fastestmirror-1.1.30-37.el6.noarch 
yum-metadata-parser-1.1.2-16.el6.i686 
yum-utils-1.1.30-37.el6.noarch 
yum-plugin-security-1.1.30-37.el6.noarch 
yum-3.2.29-75.el6.centos.noarch 
yum-rhn-plugin-0.9.1-43.el6.noarch

2. 刪除原有的yumpython

[root@orcl ~]# rpm -aq|grep yum|xargs rpm -e –nodeps 
[root@orcl ~]# rpm -qa |grep yum 
[root@orcl ~]#

3. 查詢原有yum配置linux

[root@orcl ~]# whereis yum 
yum: /etc/yum 
[root@orcl ~]# rm -fr /etc/yum

4. 下載須要的安裝包
http://mirrors.163.com/centos/6.8/os/i386/Packages/
系統爲32的,因此我選擇i386。64的自行查找x86_64。
能夠使用sql

wget http://mirrors.163.com/centos/6.8/os/i386/Packages/yum-3.2.29-73.el6.centos.noarch.rpm

下載centos

yum-3.2.29-73.el6.centos.noarch.rpm 
yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm 
yum-metadata-parser-1.1.2-16.el6.i686.rpm 
Python-iniparse-0.3.1-2.1.el6.noarch.rpm

5. 安裝python緩存

[root@orcl ~]# rpm -ivh python-iniparse-….noarch.rpm 
warning: python-iniparse-0.4-9.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY 
error: Failed dependencies: 
python(abi) = 2.7 is needed by python-iniparse-0.4-9.el7.noarch

當前安裝版本與服務器不兼容,退後一個版本再試。
查看當前發行版本號服務器

cat /etc/issue

 

遇到的錯誤less

Red Hat Linux安裝CentOS的yum源Red Hat Linux安裝CentOS的yum源

系統位數與安裝程序包位數不一致 file /bin/lsthis

error: Failed dependencies: 
libc.so.6()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libc.so.6(GLIBC_2.2.5)(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libglib-2.0.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libpthread.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libpython2.6.so.1.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libsqlite3.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libxml2.so.2()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libxml2.so.2(LIBXML2_2.4.30)(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64

從新下載32位程序包

[root@orcl ~]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm 
Preparing… ########################################### [100%] 
package python-iniparse-0.3.1-2.1.el6.noarch is already installed 
[root@orcl ~]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.i686.rpm 
Preparing… ########################################### [100%] 
1:yum-metadata-parser ########################################### [100%] 
[root@orcl ~]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm 
Preparing… ########################################### [100%] 
1:yum-plugin-fastestmirro########################################### [ 50%] 
2:yum ########################################### [100%] 
[root@orcl ~]#

注意最後兩個包必需同時安裝,不然會相互依賴
更改yum源(使用網易的CentOS鏡像源)

[root@localhost yum]# cd /etc/yum.repos.d/ 
[root@localhost yum.repos.d]# rm -rf * 
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo 
[root@localhost yum.repos.d]# vi CentOS6-Base-163.repo

將全部 $releasever 修改成具體的版本號,我這裏寫的是6.8,這個本身打開(http://mirrors.163.com/centos)找一下就能夠。

# 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/6.8/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/6.8/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/6.8/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/6.8/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/6.8/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

清理yum緩存

yum clean all

顯示已安程序包及可安程序包

yum list

能夠按要求更新程序包或安裝

yum update / yum install 包名

到此結束了,親們

原文來自:http://www.linuxidc.com/Linux/2017-02/140205.htm

本文地址:http://www.linuxprobe.com/centos-linux-yum.html

相關文章
相關標籤/搜索