redhat更改自帶的yum

#redhat使用minimal的方式安裝

#查看原來的yum源
[root@redhat home]# rpm -qa|grep yum
yum-3.2.29-40.el6.noarch
yum-rhn-plugin-0.9.1-48.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64

#卸載
[root@redhat home]# rpm -qa|grep yum |xargs rpm -e
error: Failed dependencies:
	yum is needed by (installed) rhn-client-tools-1.0.0.1-16.el6.noarch
	yum >= 3.2.19-15 is needed by (installed) subscription-manager-1.9.11-1.el6.x86_64
	yum-rhn-plugin >= 0.9.1-35 is needed by (installed) rhn-check-1.0.0.1-16.el6.noarch

#強制卸載
[root@redhat home]# rpm -qa|grep yum |xargs rpm -e --nodeps

#查看已經卸載完成
[root@redhat home]# rpm -qa|grep yum

接下來上傳centos的yum包

#直接在centos鏡像提取的包

1. python-urlgrabber-3.9.1-11.el6.noarch.rpm 
2. yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
3. yum-3.2.29-81.el6.centos.noarch.rpm
4. yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
#3與4一起安裝
#如果無法上傳就安裝一個lrzsz,用完不需要可以卸載了
#下載包的目錄
http://rpm.pbone.net/index.php3/stat/4/idpl/40679993/dir/centos_6/com/lrzsz-0.12.20-27.1.el6.x86_64.rpm.html
#直接下載
wget ftp://mirror.switch.ch/pool/4/mirror/centos/6.9/os/x86_64/Packages/lrzsz-0.12.20-27.1.el6.x86_64.rpm

#wget也沒有,那就用curl下載
[root@redhat software]# curl -O  ftp://mirror.switch.ch/pool/4/mirror/centos/6.9/os/x86_64/Packages/lrzsz-0.12.20-27.1.el6.x86_64.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 72436  100 72436    0     0   3486      0  0:00:20  0:00:20 --:--:-- 69052
[root@redhat software]# ls
lrzsz-0.12.20-27.1.el6.x86_64.rpm
[root@redhat software]# rpm -ivh lrzsz-0.12.20-27.1.el6.x86_64.rpm 
warning: lrzsz-0.12.20-27.1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:lrzsz                  ########################################### [100%]

yum安裝

#安裝yum包,有依賴關係,那麼從頭開始安裝
[root@redhat yum]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm 
warning: yum-3.2.29-81.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-81.el6.centos.noarch
	yum-metadata-parser >= 1.1.0 is needed by yum-3.2.29-81.el6.centos.noarch
	yum-plugin-fastestmirror is needed by yum-3.2.29-81.el6.centos.noarch
[root@redhat yum]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm 

-------------------------------------------------------------------------------------------------------
#python-urlgrabber,已經存在,版本較低,那就升級了
[root@redhat 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-9.el6.noarch
	file /usr/lib/python2.6/site-packages/urlgrabber/grabber.pyc from install of ...python-urlgrabber-3.9.1-9.el6.noarch
	file /usr/lib/python2.6/site-packages/urlgrabber/grabber.pyo from install of ...conflictspython-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-9.el6.noarch
	file /usr/lib/python2.6/site-packages/urlgrabber/progress.pyo from install of ...python-urlgrabber-3.9.1-9.el6.noarch

[root@redhat yum]# rpm -qa |grep python-urlgrabber 
python-urlgrabber-3.9.1-9.el6.noarch
#升級
[root@redhat yum]# rpm -Uvh 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%]
[root@redhat yum]# rpm -qa |grep python-urlgrabber 
python-urlgrabber-3.9.1-11.el6.noarch
-------------------------------------------------------------------------------------------------------
#2.yum-metadata-parse
[root@redhat yum]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 
warning: 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%]

#3.yum-plugin-fastestmirror,與yum想互依賴
[root@redhat yum]# rpm -ivh yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 
warning: yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
	yum >= 3.0 is needed by yum-plugin-fastestmirror-1.1.30-40.el6.noarch

[root@redhat yum]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm 
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
	yum-plugin-fastestmirror is needed by yum-3.2.29-81.el6.centos.noarch
#唯有一起安裝了
[root@redhat yum]# rpm -ivh yum-3.2.29-81.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm 
warning: yum-3.2.29-81.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:yum-plugin-fastestmirro########################################### [ 50%]
   2:yum                    ########################################### [100%]

配置yum源

#下載阿里雲的yum源,版本是Centos6
[root@redhat ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
102  2572  102  2572    0     0  39592      0 --:--:-- --:--:-- --:--:-- 91857

#建立緩存的時候出現這個錯誤
[root@redhat 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.
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
http://mirrors.aliyun.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: 
[Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on 
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!')
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

#http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml, 
發現這鏈接不對,版本號沒有顯示,那麼就手動改吧。

#統計一下$releasever有20個
[root@redhat yum.repos.d]# grep  -o "\$releasever" /etc/yum.repos.d/CentOS-Base.repo |wc -l
20
#替換
[root@redhat yum.repos.d]# sed -i "s/\$releasever/6/" /etc/yum.repos.d/CentOS-Base.repo
-------------------------------------------------------------------------------------------------------

#清空所有的緩存
[root@redhat 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
Cleaning up list of fastest mirrors
\#雖然提示沒有註冊,但是並不影響使用,

#重新建立緩存
[root@redhat 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: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                            | 3.7 kB     00:00     
base/group_gz                                                   | 226 kB     00:00     
base/filelists_db                                               | 6.4 MB     00:01     
base/primary_db                                                 | 4.7 MB     00:01     
base/other_db                                                   | 2.8 MB     00:00     
extras                                                          | 3.4 kB     00:00     
extras/filelists_db                                             |  26 kB     00:00     
extras/prestodelta                                              | 1.7 kB     00:00     
extras/primary_db                                               |  30 kB     00:00     
extras/other_db                                                 |  32 kB     00:00     
updates                                                         | 3.4 kB     00:00     
updates/filelists_db                                            | 4.7 MB     00:00     
updates/prestodelta                                             | 270 kB     00:00     
updates/primary_db                                              | 7.5 MB     00:00     
updates/other_db                                                | 108 MB     00:14     
Metadata Cache Created

#安裝一個vim試試
[root@redhat yum.repos.d]# yum -y install vim
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
.........省略............  
Complete!

#完成可用


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章