删除redhat原有的yum
rpm -aq|grep yum|xargs rpm -e –nodeps
下载yum安装文件(地址可能无法访问,时好时坏)
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-69.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-30.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
RHEL7:
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-34.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-34.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
进行安装yum
rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch..
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
RHEL7:
rpm -ivh python-chardet-2.2.1-1.el7_1.noarch.rpm
rpm -ivh python-kitchen-1.1.1-5.el7.noarch.rpm
rpm -ivh yum-*
更改yum源 #我们使用网易的CentOS镜像源
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
vim CentOS6-Base-163.repo #编辑文件
把文件里面的$releasever全部替换为版本号,即6最后保存! 命令:%s/ssss/aaaa/g
RHEL7:
http://mirrors.163.com/.help/CentOS7-Base-163.repo,改为7即可
yum clean all #清理yum缓存
yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
yum install gcc
本地源
1. 挂载IS
mkdir -p /mnt
#需要一份ISO镜像
mount /dev/cdrom /mnt
2. 创建自己的repo文件
vi /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
3. 修改yumRepo.py文件
vi /usr/lib/python2.6/site-packages/yum/yumRepo.py
查找
remote = url + '/' +relative
改成
remote = url + '/local_yum_source' + relative
4. 现在即可使用本地的YUM进行安装软件
yum -y install xxx
转载于:https://blog.51cto.com/481814/1334552