redhat6下安装centos的yum源 RedHat6使用CentOS yum源 换yum

因为redhat中的yum是收费的,未注册时不允许使用的,下面是挂载光盘后的情况,未挂载是没有yum命令。但是下面即便挂载了也是需要验证的

[root@localhost /]# yum install openssl
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Nothing to do

所以最好是去使用centos的yum源,免费的。

推文:https://blog.csdn.net/yingfengjia520/article/details/54866007

推文:RedHat6使用CentOS yum源 换yum

安装步骤:

一:查看原来的yum源,删除原有yum源

rpm -aq | grep yum    #查看
rpm -aq | grep yum|xargs rpm -e --nodeps    #删除

二:下载centos的yum安装包

这里使用网易的yum源即可,快些

http://mirrors.163.com/centos/6/os/x86_64/Packages/  #修改前面的6可以修改centos版本  注意(x86_64是64位系统,i386是32位)

安装yum源的相关依赖包

http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

yum源包

http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-updateonboot-1.1.30-40.el6.noarch.rpm
http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-utils-1.1.30-40.el6.noarch.rpm

注意:在上面yum源包中yum=metadata-parser是需要系统版本要求,需要64位,这里我们的系统是32位,会出现错误

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位的包,原来的删掉

http://mirrors.163.com/centos/6/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm
[root@localhost yum]# rm -rf yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 

三:上传安装包

[root@localhost yum]# ls
python-iniparse-0.3.1-2.1.el6.noarch.rpm
python-urlgrabber-3.9.1-11.el6.noarch.rpm
yum-3.2.29-81.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
yum-updateonboot-1.1.30-40.el6.noarch.rpm
yum-utils-1.1.30-40.el6.noarch.rpm

四:先安装python依赖包

[root@localhost yum]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm 
warning: python-iniparse-0.3.1-2.1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
        package python-iniparse-0.3.1-2.1.el6.noarch is already installed
[root@localhost yum]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm 
warning: python-urlgrabber-3.9.1-11.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
        file /usr/lib/python2.6/site-packages/urlgrabber/grabber.py from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-8.el6.noarch
        file /usr/lib/python2.6/site-packages/urlgrabber/grabber.pyc from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-8.el6.noarch
        file /usr/lib/python2.6/site-packages/urlgrabber/grabber.pyo from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-8.el6.noarch
        file /usr/lib/python2.6/site-packages/urlgrabber/progress.pyc from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-8.el6.noarch
        file /usr/lib/python2.6/site-packages/urlgrabber/progress.pyo from install of python-urlgrabber-3.9.1-11.el6.noarch conflicts with file from package python-urlgrabber-3.9.1-8.el6.noarch

这里发现:安装python-urlgrabber与原来的python中的插件冲突(已经安装了一个低版本的,我们要先去卸载他)

[root@localhost yum]# rpm -qa|grep python-url  查看已安装的旧版本python-urlgrabber

python-urlgrabber-3.9.1-8.el6.noarch

[root@localhost yum]# rpm -e --nodeps python-urlgrabber-3.9.1-8.el6.noarch  #强制卸载
[root@localhost yum]# rpm -qa|grep python-url
[root@localhost yum]# 

再次去安装新的python-urlgrabber

[root@localhost yum]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm 
warning: python-urlgrabber-3.9.1-11.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:python-urlgrabber      ########################################### [100%]

成功!!

五:开始安装yum源

[root@localhost yum]# ls
yum-3.2.29-81.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.i686.rpm
yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
yum-updateonboot-1.1.30-40.el6.noarch.rpm
yum-utils-1.1.30-40.el6.noarch.rpm
[root@localhost yum]# rpm -ivh yum-*

注意:有可能你之前有安装过其他的yum包,没有卸载干净,这时我们需要先去卸载掉原有的

[root@localhost yum]# rpm -qa| grep yum
yum-updateonboot-1.1.30-40.el6.noarch
yum-3.2.29-30.el6.noarch
yum-utils-1.1.30-14.el6.noarch
yum-rhn-plugin-0.9.1-40.el6.noarch
PackageKit-yum-0.5.8-20.el6.i686
yum-plugin-security-1.1.30-14.el6.noarch
yum-plugin-fastestmirror-1.1.30-40.el6.noarch
yum-metadata-parser-1.1.2-16.el6.i686
PackageKit-yum-plugin-0.5.8-20.el6.i686

将所有的卸载掉

[root@localhost yum]# rpm -e --nodeps yum-3.2.29-30.el6.noarch
[root@localhost yum]# rpm -e --nodeps yum-updateonboot-1.1.30-40.el6.noarch
[root@localhost yum]# rpm -e --nodeps yum-plugin-fastestmirror-1.1.30-40.el6.noarch
[root@localhost yum]# rpm -e --nodeps yum-metadata-parser-1.1.2-16.el6.i686
[root@localhost yum]# rpm -e --nodeps yum-utils-1.1.30-14.el6.noarch
[root@localhost yum]# rpm -e --nodeps yum-plugin-security-1.1.30-14.el6.noarch
[root@localhost yum]# rpm -e --nodeps PackageKit-yum-plugin-0.5.8-20.el6.i686
[root@localhost yum]# rpm -e --nodeps yum-rhn-plugin-0.9.1-40.el6.noarch

重新安装:

[root@localhost yum]# rpm -ivh yum-*
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:yum-metadata-parser    ########################################### [ 20%]
   2:yum-plugin-fastestmirro########################################### [ 40%]
   3:yum                    ########################################### [ 60%]
   4:yum-updateonboot       ########################################### [ 80%]
   5:yum-utils              ########################################### [100%]

安装完成!!

六:修改yum的repo配置文件

[root@localhost yum]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
epel.repo  epel-testing.repo  packagekit-media.repo  rhel-source.repo
[root@localhost yum.repos.d]# rm -rf *

下载centos的repo文件,放到上面的文件夹下

[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo  #没有网可以直接下载,再去上传
[root@localhost yum.repos.d]# ls
CentOS6-Base-163.repo

修改配置文件:将baseurl中的$releasever修改为centos版本号,这里使用6既可以

# 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
原来文件内容
# 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=$releasever&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=$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-$6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/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-$6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/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-$6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/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 clean all    #清空缓存
显示已安程序包及可安程序包     
yum list    #需要联网

测试安装OpenSSL

[root@redhat2 yum.repos.d]# yum install openssl
Loaded plugins: fastestmirror, product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package openssl.i686 0:1.0.0-20.el6_2.5 will be updated
---> Package openssl.i686 0:1.0.1e-57.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================
 Package                   Arch                   Version                          Repository              Size
================================================================================================================
Updating:
 openssl                   i686                   1.0.1e-57.el6                    base                   1.5 M

Transaction Summary
================================================================================================================
Upgrade       1 Package(s)

Total size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>"
 From  : http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
PackageKit-0.5.8-20.el6.i686 has missing requires of PackageKit-yum = ('0', '0.5.8', '20.el6')
PackageKit-0.5.8-20.el6.i686 has missing requires of PackageKit-yum-plugin = ('0', '0.5.8', '20.el6')
rhn-check-1.0.0-87.el6.noarch has missing requires of yum-rhn-plugin >= ('0', '0.9.1', '35')
  Updating   : openssl-1.0.1e-57.el6.i686                                                                   1/2 
  Cleanup    : openssl-1.0.0-20.el6_2.5.i686                                                                2/2 
Installed products updated.
  Verifying  : openssl-1.0.1e-57.el6.i686                                                                   1/2 
  Verifying  : openssl-1.0.0-20.el6_2.5.i686                                                                2/2 

Updated:
  openssl.i686 0:1.0.1e-57.el6                                                                                  

Complete!

成功!!正确

猜你喜欢

转载自www.cnblogs.com/ssyfj/p/9172147.html
今日推荐