一、安装
1. 下载yum安装包并解压
wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
tar xvf yum-3.2.28.tar.gz
2. 进入目录并install
cd yum-3.2.28
sudo apt install yum
参考引用:linux中安装yum简单方法 - 简书
3. 配置yum repo
创建文件
touch /etc/yum/repo.d/CentOS-Base.repo
(我的/etc/yum/repo.d下没有文件)
下载Centos-7.repo(根据你的Centos version选择对应的)
wget -O /etc/yum/repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
4. 更新
yum check-update
yum update
yum clean all
参考:centos镜像-centos下载地址-centos安装教程-阿里巴巴开源镜像站
二、可能遇到的问题
1. apt install yum 时报:E: Unable to locate package yum
搜了下,解决方案是用:sudo apt-get update
但是发现我的apt 的软件源配置的有问题,故重新配了软件源
2. 修改软件源
vi /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
参考:https://zhuanlan.zhihu.com/p/15087295
3. 更新apt软件源后,再次 sudo apt-get install yum,发现:
很明显,没装python-sqlitecachec和python-sqlitecachec, 用apt install
sudo apt-get install python-sqlitecachec
sudo apt-get install python-urlgrabber
4. 使用yum repolist时报:
https://mirrors.aliyun.com/centos/%24releasever/AppStream/x86_64/os/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 "
发现url中有%24releasever,这个是变量,没有被系统识别,故用了简单粗暴的方法,将CentOS-Base.repo用$releasever变量的地方全部替换成对应的版本号,我用的是7
查看版本号命令:
lsb_release -a
vim CentOS-Base.repo
:%s/$releasever/7/g