http://blog.csdn.net/zhngjan/article/details/20843465
在使用redhat linux的yum来安装或者更新软件的时候会提示
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 No package gcc available. Error: Nothing to do
由于 redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,需将redhat的yum卸载后,重启安装,再配置其他源,如下:
1、首先到http://mirrors.163.com/centos下载软件包
x86 地址:http://mirrors.163.com/centos/6/os/i386/Packages/
x86_64 地址:
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.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-3.2.29-40.el6.centos.noarch.rpm wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
[注] :版本不一定要最新的(http://mirrors.163.com/centos/6/os/x86_64/Packages/ 查找对应版本)
2、卸载RedHat自带的yum
rpm -qa | grep yum | xargs rpm -e --nodeps
注:a> xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题
b> --nodeps 强制卸载,不管依赖性
3、安装下载的centos的yum包:
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
[注] :最后2个需要一起安装,否则会出现依赖性错误
4、到http://mirrors.163.com的 centos帮助文档 中下载CentOS6-Base-163.repo文件,存放到/etc/yum.repo.d中
cd /etc/yum.repo.d/ wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
5、编辑CentOS6-Base-163.repo文件,将其中的$releasever更改为centos的版本号
注意:留意163源会整合版本,如将6.0---6.4都整合到6,若出现404错误,则查看目录下的readme文件
6、yum clean all 清除原有缓存
7、yum makecache 获取yum列表
出现下面提示,表示yum更改完成:
Metadata Cache Created
shell
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH # Check if user is root if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script" exit 1 fi clear echo "=========================================================================" echo "Replace Redhat Enterprise Yum to CentOS Yum and Repos, Written by Licess" echo "=========================================================================" # uninstall rhel yum echo "Uninstall Rhel Yum......" rpm -qa|grep yum|xargs rpm -e --nodeps # delete old rpm echo "Clean old cache......" rm -rf python-iniparse-0.3.1-2.1.el6.noarch.rpm rm -rf yum-metadata-parser-1.1.2-16.el6.x86_64.rpm rm -rf yum-3.2.29-40.el6.centos.noarch.rpm rm -rf yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm # download CentOS Yum echo "Download Python-iniparse......" wget http://mirrors.163.com/centos/6. ... -2.1.el6.noarch.rpm echo "Download yum-metadata-parse......" wget http://mirrors.163.com/centos/6. ... 2-16.el6.x86_64.rpm echo "Download yum......" wget http://mirrors.163.com/centos/6. ... 6.centos.noarch.rpm echo "Download yum fastmirror......" wget http://mirrors.163.com/centos/6. ... 0-14.el6.noarch.rpm # install CentOS Yum echo "Installing......" 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 # replace repos rm -rf /etc/yum.repos.d/CentOS-Base.repo echo "[base] name=CentOS-6.5 - Base - 163.com baseurl=http://mirrors.163.com/centos/6.5/os/x86_64/ #mirrorlist=http://mirrors.163.com/?release=6.5&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-6.5 - Updates - 163.com baseurl=http://mirrors.163.com/centos/6.5/updates/x86_64/ #mirrorlist=http://mirrors.163.com/?release=6.5&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-6.5 - Extras - 163.com baseurl=http://mirrors.163.com/centos/6.5/extras/x86_64/ #mirrorlist=http://mirrors.163.com/?release=6.5&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-6.5 - Plus - 163.com baseurl=http://mirrors.163.com/centos/6.5/centosplus/x86_64/ #mirrorlist=http://mirrors.163.com/?release=6.5&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-6.5 - Contrib - 163.com baseurl=http://mirrors.163.com/centos/6.5/contrib/x86_64/ #mirrorlist=http://mirrors.163.com/?release=6.5&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6" >> /etc/yum.repos.d/CentOS-Base.repo ##### yum clean all yum makecache yum update echo "==========================================================================" echo "You have successfully replace RedhatEnterprise Yum to CentOS yum and repos" echo "=========================================================================="
################# yum操作 ####################
一、更新和安装
1.列出所有可更新的软件清单
命令:yum check-update
2.安装所有更新软件
命令:yum update
3.仅安装指定的软件
命令:yum install <package_name>
4.仅更新指定的软件
命令:yum update <package_name>
5.列出所有可安裝的软件清单
命令:yum list
二、安装与删除软件
安装的命令是,yum install xxx,yum会查询数据库,有无这一软件包,如果有,则检查其依赖冲突关系,如果没有依赖冲突,那么最好,下载安装;如果有,则会给出提示,询问是否要同时安装依赖,或删除冲突的包,你可以自己作出判断。
删除的命令是,yum remove xxx,同安装一样,yum也会查询数据库,给出解决依赖关系的提示。
1.用YUM安装软件包
命令:yum install <package_name>
2.用YUM删除软件包
命令:yum remove <package_name>
三、查询软件信息
我 们常会碰到这样的情况,想要安装一个软件,只知道它和某方面有关,但又不能确切知道它的名字。这时yum的查询功能就起作用了。你可以用 yum search keyword这样的命令来进行搜索,比如我们要则安装一个Instant Messenger,但又不知到底有哪些,这时不妨用 yum search messenger这样的指令进行搜索,yum会搜索所有可用rpm的描述,列出所有描述中和messeger有关的rpm包,于 是我们可能得到gaim,kopete等等,并从中选择。
有时我们还会碰到安装了一个包,但又不知道其用途,我们可以用yum info packagename这个指令来获取信息。
1.查找软件包
命令:yum search <keyword>
2.列出所有可安装的软件包
命令:yum list
3.列出所有可更新的软件包
命令:yum list updates
4.列出所有已安装的软件包
命令:yum list installed
5.列出所有已安装但不在 Yum Repository 內的软件包
命令:yum list extras
6.列出所指定的软件包
命令:yum list <package_name>
7.使用YUM获取软件包信息
命令:yum info <package_name>
8.列出所有软件包的信息
命令:yum info
9.列出所有可更新的软件包信息
命令:yum info updates
10.列出所有已安裝的软件包信息
命令:yum info installed
11.列出所有已安裝但不在 Yum Repository 內的软件包信息
命令:yum info extras
12.列出软件包提供哪些文件
命令:yum provides <package_name>
四、清除YUM缓存
yum 会把下载的软件包和header存储在cache中,而不会自动删除。如果我们觉得它们占用了磁盘空间,可以使用yum clean指令进行清除,更精确 的用法是yum clean headers清除header,yum clean packages清除下载的rpm包,yum clean all一 股脑儿端
1.清除缓存目录(/var/cache/yum)下的软件包
命令:yum clean packages
2.清除缓存目录(/var/cache/yum)下的 headers
命令:yum clean headers
3.清除缓存目录(/var/cache/yum)下旧的 headers
命令:yum clean oldheaders
4.清除缓存目录(/var/cache/yum)下的软件包及旧的headers
命令:yum clean, yum clean all (= yum clean packages; yum clean oldheaders)
转载于:https://blog.51cto.com/jacker/1535511