RHEL1:配置yum源

 刚开始自学linux,参考网上很多教程安装yum,一波三折。。

正文 :

 问题:

使用yum时发现系统报错:

[root@www ~]# yum install firefox
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Nothing to do

 上网查后得到答案是RHEL下使用yum是要收费的,但可以通过安装centos下的免费yum源解决。

 做法:

1.查看RHEL原有的yum源

[root@www ~]# rpm -qa |grep yum
yum-utils-1.1.30-14.el6.noarch
PackageKit-yum-0.5.8-21.el6.x86_64
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-plugin-security-1.1.30-14.el6.noarch
yum-rhn-plugin-0.9.1-48.el6.noarch
yum-3.2.29-40.el6.noarch
PackageKit-yum-plugin-0.5.8-21.el6.x86_64

2.卸载RHEL原有的yum源
[root@www ~]# rpm -qa | grep yum | xargs rpm -e --nodeps

//xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题
// –nodeps 强制卸载,不管依赖性

3.下载centos下的yum源

网址:http://mirrors.163.com/centos/6/os/x86_64/Packages/

需要的插件:

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

[root@www ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@www ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm 
[root@www ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm  
[root@www ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 

4.安装yum包
[root@www ~]# rpm -ivh python*
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@www ~]# rpm -ivh yum*
warning: yum-3.2.29-73.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
	python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-73.el6.centos.noarch

 根据翻译是出现了依赖性错误, 应该再下载python-urlgrabber

[root@www ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/ python-urlgrabber-3.9.1-11.el6.noarch.rpm 
再次安装yum

[root@www ~]# rpm -ivh '/root/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm'  
warning: /root/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:yum-metadata-parser    ########################################### [100%]

[root@www ~]# rpm -ivh '/root/yum-3.2.29-73.el6.centos.noarch.rpm'  '/root/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm'   '/root/python-urlgrabber-3.9.1-11.el6.noarch.rpm' 
warning: /root/yum-3.2.29-73.el6.centos.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-9.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-9.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-9.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-9.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-9.el6.noarch

存在冲突,经查可用force强制安装

<span style="color:#000000;">[root@www ~]# rpm -ivh --force  '/root/yum-3.2.29-73.el6.centos.noarch.rpm'  '/root/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm'   '/root/python-urlgrabber-3.9.1-11.el6.noarch.rpm' 
warning: /root/yum-3.2.29-73.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:python-urlgrabber      ########################################### [ 33%]
   2:yum-plugin-fastestmirro########################################### [ 67%]
   3:yum                    ########################################### [100%]</span>

对于一直出现的warning,可通过下面方法解决
[root@www rpm-gpg]# wget http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
--2016-09-26 20:16:28--  http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
Resolving mirrors.163.com... 123.58.173.185, 123.58.173.186
Connecting to mirrors.163.com|123.58.173.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1706 (1.7K) [application/octet-stream]
Saving to: “RPM-GPG-KEY-CentOS-6”

100%[======================================>] 1,706       --.-K/s   in 0s      

2016-09-26 20:16:29 (104 MB/s) - “RPM-GPG-KEY-CentOS-6” saved [1706/1706]

[root@www rpm-gpg]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

3.更改yum源

[root@www rpm-gpg]# cd /etc/yum.repos.d
[root@www yum.repos.d]#  rm -fr *                 //删除原来的配置文件
[root@www yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo     //下载新的配置文件
--2016-09-26 20:27:14--  http://mirrors.163.com/.help/CentOS6-Base-163.repo
Resolving mirrors.163.com... 123.58.173.185, 123.58.173.186
Connecting to mirrors.163.com|123.58.173.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2006 (2.0K) [application/octet-stream]
Saving to: “CentOS6-Base-163.repo”

100%[======================================>] 2,006       --.-K/s   in 0.001s  

2016-09-26 20:27:14 (1.59 MB/s) - “CentOS6-Base-163.repo” saved [2006/2006]

<span></span><pre name="code" class="cpp">[root@www yum.repos.d]# <span>vi CentOS6-Base-163.repo  //编辑CentOS6-Base-163.repo文件,将其中的$releasever更改为centos的版本号6</span>
<span></span>

 

vim编辑器的使用,按键盘i进入编辑界面,按esc退出,按shift+ZZ返回命令界面,看别人写的可以用命令 :%s/$releasever/6,不过我还不会。。

编辑后的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/6.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-$releasever - Updates - 163.com  
baseurl=http://mirrors.163.com/centos/6.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-$releasever - Extras - 163.com  
baseurl=http://mirrors.163.com/centos/6.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-$releasever - Plus - 163.com  
baseurl=http://mirrors.163.com/centos/6.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-

#contrib - packages by Centos Users  
[contrib]  
name=CentOS-$releasever - Contrib - 163.com  
baseurl=http://mirrors.163.com/centos/6.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  


4.清除缓存

[root@www yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: base extras updates
Cleaning up Everything

5.获取配置yum列表

[root@www yum.repos.d]#  yum  makecache
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Determining fastest mirrors
base                                                | 3.7 kB     00:00     
base/group_gz                                            | 226 kB     00:00     
base/filelists_db                                           | 6.4 MB     00:03     
base/primary_db                                           | 4.7 MB     00:02     
base/other_db                                            | 2.8 MB     00:01     
extras                                                   | 3.4 kB     00:00     
extras/filelists_db                                           | 38 kB     00:00     
extras/prestodelta                                           | 1.3 kB     00:00     
extras/primary_db                                           | 37 kB     00:00     
extras/other_db                                           | 51 kB     00:00     
updates                                               | 3.4 kB     00:00     
updates/filelists_db                                           | 1.5 MB     00:00     
updates/prestodelta                                           | 180 kB     00:00     
updates/primary_db                                           | 2.0 MB     00:00     
updates/other_db                                           | 26 MB     00:12     
Metadata Cache Created


完成!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值