!!!再此之前, 如果已經安裝yum而且網速也不慢, 就不用操作以下步驟了,
還有一個方法見 https://mirrors.tuna.tsinghua.edu.cn/help/centos/
查看當前包
rpm -qa | grep yum
有內容, 執行卸載 (如果沒有內容顯示, 跳過這一步)
rpm -qa | grep yum | xargs rpm -e --nodeps
從網易鏡像站下載安裝包, 分別執行下列4條命令, 因爲有些包會更新, 以實際版本爲準
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/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
查看當前目錄
ls
安裝, 分別執行以下2條命令
rpm -ivh yum*
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
修改yum源倉庫
cd /etc/yum.repos.d/ #進入/etc/yum.repos.d/目錄
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
sed 's#$releasever#7#g' CentOS7-Base-163.repo
sed 's#$releasever#7#g' CentOS7-Base-163.repo -i
創建yum元數據緩存
yum makecache
更新yum
yum update -y
增加EPEL源, 對 RHEL 標準yum源是一個很好的補充
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
下載例子: 用命令下載apache
yum -y install httpd
參考網站: https://www.cnblogs.com/xilong-devops/p/9033249.html