redhat 7 使用国内yum源

redhat 7 使用国内yum源

redhat 7 使用国内yum源

redhat 未注册的系统是无法使用yum源安装的 ,需要删除系统自带的yum命令 ,再安装对应版本的centos的yum命令

#查看所有已安装的包含"yum"关键字的rpm包
rpm -qa | grep yum

#删除已安装的包含"yum"关键字的rpm包
rpm -qa | grep yum | xargs rpm -e --nodeps

#删除已安装的包含"python-urlgrabber"关键字的rpm包
rpm -qa | grep python-urlgrabber | xargs rpm -e --nodeps

#打开阿里yum源地址,按 Ctrl +F 搜索rmp包名 
https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/

#下载这8个rpm包 ,或者在windows主机上下载好这些rpm包, 再用"WinSCP"这个软件的sftp协议传输到redhat系统中
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm   
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-langpacks-0.4.2-7.el7.noarch.rpm  
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm  
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-52.el7.noarch.rpm  
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm 
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-52.el7.noarch.rpm 
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm   

#安装该目录下所有的rpm包
rpm -ivh --force *
报错如下:意思是安装yum-3.4.3-163.el7.centos.noarch需要rpm-4.11.x的版本
warning: yum-3.4.3-163.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
        rpm >= 0:4.11.3-22 is needed by yum-3.4.3-163.el7.centos.noarch

#下载rmp-4.11.x版本的rmp包
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.11.3-40.el7.x86_64.rpm  

#再次执行
rpm -ivh --force *

#这里如果还是报错,则是需要升级安装
rpm -Uvh rpm-4.11.3-40.el7.x86_64.rpm 

#下载对应版本的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#替换CentOS-Base.repo里面的内容,"$releasever"替换为"7"
sed -i  's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo

#编辑yum.conf这个文件,
nano /etc/yum.conf
将"plugins=1"改为"plugins=0" ,表示禁用所有插件

#清理yum缓存
yum clean all

#生成缓存
yum makecache

#验证yum源是否可用
yum repolist

#搜索yum源仓库里的软件,关键字为"vim"
yum search vim

#查看yum源仓库中所有的软件, 对结果进行过滤关键字为"vim"
yum list | grep vim

#使用yum源安装"vim"这个软件
yum -y install vim

END

你可能感兴趣的:(redhat 7 使用国内yum源)