產生這個文檔,是因為在家里的虛擬機(32位)上,RHEL6環(huán)境yum安裝MySQL非常不順利。在公司的64位一體機上,打算在虛擬機上再試一次。沒想到,尋找RHEL6的yum源配置文件,反而成了麻煩。
網站建設哪家好,找創(chuàng)新互聯(lián)!專注于網頁設計、網站建設、微信開發(fā)、重慶小程序開發(fā)、集團企業(yè)網站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了南木林免費建站歡迎大家使用!
從昨天中午到下午4點,包括這篇文檔的雛形才算基本完成。找了不少網絡資料,太多不靠譜。我是根據文中的提到的2篇“參考資料”才完成的。
yum配置,從2011年秋天學RHCE的時候,就一直是我的痛點?,F在,通過光盤掛載配置yum源應該沒有問題。但是,通過Internet配置yum……雖然反復折騰多次,但好像沒有太多的進步。
把這篇文檔整理出來,希望在日后再遇到類似的問題,可以照貓畫虎,先把問題解決再說。
1.刪除redhat原有的
[root@nagios ~]# yum rpm -aq|grep yum|xargs rpm -e --nodeps Command line error: no such option: -a error: package Usage: is not installed error: package [options] is not installed error: package COMMAND is not installed error: package shell is not installed error: package Run is not installed error: package an is not installed error: package interactive is not installed error: package shell is not installed
2.下載yum安裝文件
注意:最好自己到鏡像站點(如:http://mirrors.163.com/centos/6/os/x86_64/)找相應的包,這里列出來的包名稱,過段時間可能會過時。
[root@nagios ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm --2014-09-04 22:46:55-- http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm 正在解析主機 mirrors.163.com... 123.58.173.106 正在連接 mirrors.163.com|123.58.173.106|:80... 已連接。 已發(fā)出 HTTP 請求,正在等待回應... 200 OK 長度:1019540 (996K) [application/x-redhat-package-manager] 正在保存至: “yum-3.2.29-40.el6.centos.noarch.rpm” 100%[==========================================================================================================================================================>] 1,019,540 1.43M/s in 0.7s 2014-09-04 22:46:57 (1.43 MB/s) - 已保存 “yum-3.2.29-40.el6.centos.noarch.rpm” [1019540/1019540]) [root@nagios ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm --2014-09-04 22:47:20-- http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 正在解析主機 mirrors.163.com... 123.58.173.106 正在連接 mirrors.163.com|123.58.173.106|:80... 已連接。 已發(fā)出 HTTP 請求,正在等待回應... 200 OK 長度:27224 (27K) [application/x-redhat-package-manager] 正在保存至: “yum-metadata-parser-1.1.2-16.el6.x86_64.rpm” 100%[==========================================================================================================================================================>] 27,224 --.-K/s in 0.08s 2014-09-04 22:47:20 (343 KB/s) - 已保存 “yum-metadata-parser-1.1.2-16.el6.x86_64.rpm” [27224/27224]) [root@nagios ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm --2014-09-04 22:48:15-- http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm 正在解析主機 mirrors.163.com... 123.58.173.106 正在連接 mirrors.163.com|123.58.173.106|:80... 已連接。 已發(fā)出 HTTP 請求,正在等待回應... 200 OK 長度:28220 (28K) [application/x-redhat-package-manager] 正在保存至: “yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm” 100%[==========================================================================================================================================================>] 28,220 --.-K/s in 0.05s 2014-09-04 22:48:15 (611 KB/s) - 已保存 “yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm” [28220/28220]) [root@nagios ~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm --2014-09-04 22:49:42-- http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm 正在解析主機 mirrors.163.com... 123.58.173.106 正在連接 mirrors.163.com|123.58.173.106|:80... 已連接。 已發(fā)出 HTTP 請求,正在等待回應... 200 OK 長度:37052 (36K) [application/x-redhat-package-manager] 正在保存至: “python-iniparse-0.3.1-2.1.el6.noarch.rpm” 100%[==========================================================================================================================================================>] 37,052 88.7K/s in 0.4s 2014-09-04 22:49:43 (88.7 KB/s) - 已保存 “python-iniparse-0.3.1-2.1.el6.noarch.rpm” [37052/37052])
這里使用的是網易鏡像,在這里可以找到你想要的,不一定要用CentOS的軟件包。
3.安裝yum,必須按照順序
[root@nagios ~]# 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@nagios ~]# 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%] file /usr/lib64/python2.6/site-packages/_sqlitecache.so from install of yum-metadata-parser-1.1.2-16.el6.x86_64 conflicts with file from package yum-metadata-parser-1.1.2-14.1.el6.x86_64 file /usr/lib64/python2.6/site-packages/sqlitecachec.pyc from install of yum-metadata-parser-1.1.2-16.el6.x86_64 conflicts with file from package yum-metadata-parser-1.1.2-14.1.el6.x86_64 [root@nagios ~]# rpm -ivh yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm warning: yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:yum-plugin-fastestmirro########################################### [100%]
注意:最后兩個包必需同時安裝,否則會相互依賴。
[root@nagios ~]# rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm warning: yum-3.2.29-40.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] file /etc/bash_completion.d/yum.bash from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.27-14.el6.noarch file /etc/yum.conf from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.27-14.el6.noarch file /usr/lib/python2.6/site-packages/yum/__init__.py from install of yum-3.2.29-40.el6.centos.noarch conflicts with file from package yum-3.2.27-14.el6.noarch ……其它輸出略……
4.將CentOS 6的倉庫作為yum源
[root@nagios ~]# cd /etc/yum.repos.d/ [root@nagios yum.repos.d]# ll 總用量 0
通過這次配置發(fā)現,yum源的名稱不重要,只要保證后綴是“.repo”即可。
[root@nagios yum.repos.d]# cat 163.repo [base] #yum源的名稱 name=CentOS-$releasever - Base #這個yum源的名稱,在做kicakstart時需要特別注意 baseurl=http://mirrors.163.com/centos/6/os/$basearch/ #yum源地址:如果是本地源,“file:///”中的第3個“/”表示本地根目錄 enable=1 #不啟用這個yum源為“0”,啟用安全校驗為“1” gpgcheck=1 #不啟用安全校驗為“0”,啟動安全校驗為“1” gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #安全校驗,檢測這個yum源的rpm包是否為紅帽官方包導入gpgkey #released updates [updates] name=CentOS-$releasever - Updates baseurl=http://mirrors.163.com/centos/6/updates/$basearch/ enable=1 gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #packages used/produced in the build but not released #[addons] #name=CentOS-$releasever - Addons #baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/ #gpgcheck=1 #gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl=http://mirrors.163.com/centos/6/extras/$basearch/ enable=1 gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/ gpgcheck=1 enabled=0
參考文檔:http://yongzhilinux.blog.51cto.com/2651263/909977——RHEL5和RHEL6下本地以及網絡yum源的創(chuàng)建
5.清除yum的緩存(命令“yum clean all”)
6.yum安裝mysql
[root@nagios yum.repos.d]# yum -y install mysql-server Loaded plugins: fastestmirror, refresh-packagekit, rhnplugin This system is not registered with RHN. RHN support will be disabled. Determining fastest mirrors base | 3.7 kB 00:00 base/primary_db | 4.4 MB 00:10 extras | 3.3 kB 00:00 extras/primary_db | 19 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 4.8 MB 00:44 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mysql-server.x86_64 0:5.1.73-3.el6_5 set to be updated --> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Running transaction check ---> Package mysql.x86_64 0:5.1.73-3.el6_5 set to be updated --> Processing Dependency: mysql-libs = 5.1.73-3.el6_5 for package: mysql-5.1.73-3.el6_5.x86_64 ---> Package openssl.x86_64 0:1.0.1e-16.el6_5.15 set to be updated ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 set to be updated --> Running transaction check ---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================================================================================== Installing: mysql-server x86_64 5.1.73-3.el6_5 updates 8.6 M Installing for dependencies: mysql x86_64 5.1.73-3.el6_5 updates 894 k perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k Updating for dependencies: mysql-libs x86_64 5.1.73-3.el6_5 updates 1.2 M openssl x86_64 1.0.1e-16.el6_5.15 updates 1.5 M Transaction Summary ==================================================================================================================================================================================================== Install 3 Package(s) Upgrade 2 Package(s) Total download size: 12 M Downloading Packages: (1/5): mysql-5.1.73-3.el6_5.x86_64.rpm | 894 kB 00:01 (2/5): mysql-libs-5.1.73-3.el6_5.x86_64.rpm | 1.2 MB 00:01 http://mirrors.163.com/centos/6/updates/x86_64/Packages/mysql-server-5.1.73-3.el6_5.x86_64.rpm: [Errno 12] Timeout on http://mirrors.163.com/centos/6/updates/x86_64/Packages/mysql-server-5.1.73-3.el6_5.x86_64.rpm: (28, '') Trying other mirror. (4/5): openssl-1.0.1e-16.el6_5.15.x86_64.rpm | 1.5 MB 00:02 (5/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:00 Error Downloading Packages: mysql-server-5.1.73-3.el6_5.x86_64: failure: Packages/mysql-server-5.1.73-3.el6_5.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
安裝失敗,提示好像是沒有更多的yum源地址。
更換另1個yum源配置文件,安裝也失敗。
[root@nagios yum.repos.d]# yum -y install mysql-server Loaded plugins: fastestmirror, refresh-packagekit, rhnplugin This system is not registered with RHN. RHN support will be disabled. Loading mirror speeds from cached hostfile http://mirrors.163.com/centos/6Server/addons/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 : http://mirrors.163.com/centos/6Server/addons/x86_64/repodata/repomd.xml Trying other mirror. Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again
再次使用第1個yum源配置文件“163.repo”,安裝成功。不過,安裝過程中,還是有錯誤出現。
[root@nagios yum.repos.d]# yum -y install mysql-server Loaded plugins: fastestmirror, refresh-packagekit, rhnplugin This system is not registered with RHN. RHN support will be disabled. Loading mirror speeds from cached hostfile base | 3.7 kB 00:00 extras | 3.3 kB 00:00 updates | 3.4 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mysql-server.x86_64 0:5.1.73-3.el6_5 set to be updated --> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: mysql-server-5.1.73-3.el6_5.x86_64 --> Running transaction check ---> Package mysql.x86_64 0:5.1.73-3.el6_5 set to be updated --> Processing Dependency: mysql-libs = 5.1.73-3.el6_5 for package: mysql-5.1.73-3.el6_5.x86_64 ---> Package openssl.x86_64 0:1.0.1e-16.el6_5.15 set to be updated ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 set to be updated --> Running transaction check ---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================================================================================== Installing: mysql-server x86_64 5.1.73-3.el6_5 updates 8.6 M Installing for dependencies: mysql x86_64 5.1.73-3.el6_5 updates 894 k perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k Updating for dependencies: mysql-libs x86_64 5.1.73-3.el6_5 updates 1.2 M openssl x86_64 1.0.1e-16.el6_5.15 updates 1.5 M Transaction Summary ==================================================================================================================================================================================================== Install 3 Package(s) Upgrade 2 Package(s) Total size: 12 M Total download size: 8.6 M Downloading Packages: mysql-server-5.1.73-3.el6_5.x86_64.rpm | 8.6 MB 00:06 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY base/gpgkey | 3.3 kB 00:00 ... Importing GPG key 0xC105B9DE "CentOS-6 Key (CentOS 6 Official Signing Key) " from http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Updating : openssl-1.0.1e-16.el6_5.15.x86_64 1/7 Updating : mysql-libs-5.1.73-3.el6_5.x86_64 2/7 Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 3/7 Installing : mysql-5.1.73-3.el6_5.x86_64 4/7 Installing : mysql-server-5.1.73-3.el6_5.x86_64 5/7 Cleanup : mysql-libs-5.1.47-4.el6.x86_64 6/7 Cleanup : openssl-1.0.0-4.el6.x86_64 7/7 Installed: mysql-server.x86_64 0:5.1.73-3.el6_5 Dependency Installed: mysql.x86_64 0:5.1.73-3.el6_5 perl-DBD-MySQL.x86_64 0:4.013-3.el6 Dependency Updated: mysql-libs.x86_64 0:5.1.73-3.el6_5 openssl.x86_64 0:1.0.1e-16.el6_5.15 Complete!
參考文檔:http://www.chinadmd.com/file/r3zuu3uostrvaicitoszsocx_1.html——RHEL 6.1網絡yum配置