安装了一个redhat64系统,想要通过wget在 http://mirrors.163.com/centos/6/os/x86_64/ 装yum源,但是由于是最小化安装,没有wget这个命令(系统提示-bash: wget: command not found)。所以第一步就是下载一个wget-1.12-1.4.el6.x86_64.rpm包,然后通过rpm命令安装wget程序。
一安装wget(如果已经存在则忽略此步骤),删除原有的yum
1到http://rpm.pbone.net/index.php3 搜索wget-1.12-1.4.el6.x86_64.rpm
2使用rpm -ivh wget-1.12-1.4.el6.x86_64.rpm 安装,当然需要把wget-1.12-1.4.el6.x86_64.rpm放置到RedHat64的目录下,到此目录下去执行rpm -ivh wget-1.12-1.4.el6.x86_64.rpm
3删除redhat原有的yum
rpm -aq|grep yum|xargs rpm -e --nodeps
二下载yum软件包(注意以下的软件包不一定能够成功的下载,原因就是版本的不断变化,如果下载不到的话可以直接到http://mirrors.163.com/centos/6/os/x86_64/Packages/ 然后通过ctrl f 快速寻找到匹配到最前面的几个字样的rpm包,比如ctrl f yum-3)
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
如果在这个过程中提示Couldn't resolve host 'mirrors.163.com 字样,有可能是DNS没有设置好,
通过:
#cd ~
#cd /etc
# vi resolv.conf
添加一个nameserver 8.8.8.8
三安装yum.按照以下顺序格式安装,注意最后yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm需要同时安装,他们互相依赖
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
四配置repo文件
#cd ~
#cd //etc/yum.repos.d
#ls
查看是否存在rhel-debuginfo.repo以及rhel-debuginfo.repo.bak(我的系统最小化安装没有这两个文件),如果存在,删除掉(通过rm命令)
创建/etc/yum.repos.d/CentOS-Base.repo文件,定义yum更新源,这里使用的是上海交大的CentOS更新源
[root@linux-a ~]# vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-5-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#released updates
[update]
name=CentOS-5-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#packages used/produced in the build but not released
[addons]
name=CentOS-5-Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that may be useful
[extras]
name=CentOS-5-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5-Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#contrib - packages by Centos Users
[contrib]
name=CentOS-5-Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
# vi dag.repo
[dag]
name=Dag RPM Repository for RHEL5
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=0
gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
导入key
[root@linux-a ~]# rpm --import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
运行YUM,测试
参考文章:http://blog.chinaunix.net/uid-20729583-id-2972852.html
http://blog.itpub.net/25313300/viewspace-708509/