CentOS下安装yum


0.首先檢查yum有沒有安裝


yum -v  
yum update  

如果有安裝的話,可直接用更新命令操作
在Linux里面依次输入下面的命令:

1,下载最新的yum-3.2.28.tar.gz并解压

wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
tar xvf yum-3.2.28.tar.gz  


2,进入目录,运行安装

cd yum-3.2.28  
yummain.py install yum  
如果结果提示错误: CRITICAL:yum.cli:Config Error: Error accessing file for config file:///etc/

可能是原来是缺少配置文件。在etc目录下面新建yum.conf文件,然后再次运行 yummain.py install yum,顺利完成安装。

3,最后更新系统。

yum check-update  
yum update  
yum clean all  
================================================================================================================================================================================================ 
LInux Centos7 重装yum
Linux yum默认安装python2.7,犹豫2020年之后不更新, 安装python3.6,出现了yum运行失败, 因为yum是依赖python的

1:先删除原有YUM


rpm -aq|grep yum|xargs rpm -e --nodeps


2:去网址下载rpm包  http://mirrors.163.com/centos/7/os/x86_64/Packages/


复制代码
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

yum-3.4.3-154.el7.centos.noarch.rpm 
yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
复制代码
下载好之后前面6个包依次安装,安装命名如下
rpm -ivh *.rpm
后面的2个包,是互相依赖,所以一起安装

rpm --nodeps --force -ivh yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
(--nodeps --force 强制安装)安装完后,查看yum安装情况

yum -V
 

3:修改yum源

进入yum源目录

cd  /etc/yum.repos.d
下载文件

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo


修改repo源:   将文件中的$releasever替換成7 (7是指LINUX版本號), 下面是本人改了之后的截图

运行makecache 生成缓存

yum makecache 
运行yum clean all

yum clean all
更新yum文件(等待时间有点长)

yum update


 

 

 
 

你可能感兴趣的:(centos)