1. 程式人生 > >centos7--(2)解除安裝和安裝yum包

centos7--(2)解除安裝和安裝yum包

1、centos版本

CentOS Linux release 7.5.1804 (Core)

3、解除安裝原來的yum

[[email protected] 下載]# rpm -qa|grep yum yum-3.4.3-158.el7.centos.noarch yum-utils-1.1.31-45.el7.noarch PackageKit-yum-1.1.5-1.el7.centos.x86_64 yum-langpacks-0.4.2-7.el7.noarch yum-metadata-parser-1.1.4-10.el7.x86_64 yum-plugin-fastestmirror-1.1.31-45.el7.noarch [

[email protected] 下載]# rpm -e --nodeps yum-3.4.3-158.el7.centos.noarch [[email protected] 下載]# rpm -e --nodeps yum-utils-1.1.31-45.el7.noarch [[email protected] 下載]# rpm -e --nodeps PackageKit-yum-1.1.5-1.el7.centos.x86_64 [[email protected] 下載]# rpm -e --nodeps yum-langpacks-0.4.2-7.el7.noarch 警告:/etc/yum/pluginconf.d/langpacks.conf 已另存為 /etc/yum/pluginconf.d/langpacks.conf.rpmsave [
[email protected]
下載]# rpm -e --nodeps yum-langpacks-0.4.2-7.el7.noarch 錯誤:未安裝軟體包 yum-langpacks-0.4.2-7.el7.noarch [[email protected] 下載]# rpm -e --nodeps yum-metadata-parser-1.1.4-10.el7.x86_64 [[email protected] 下載]# rpm -e --nodeps yum-plugin-fastestmirror-1.1.31-45.el7.noarch [[email protected]
下載]# rpm -qa|grep yum [[email protected] 下載]# mkdir /tmp/yum-packages [[email protected] 下載]# cd /tmp/yum-packages/

4、從華為雲下載yum的包

5、下載到當前包後

rpm -ivh --force --nodeps *.rpm

--force 強制安裝 --nodeps 覆蓋安裝

6、安裝完畢後

備份配置檔案:cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

修改CentOS-Base.repo檔案,取消baseurl開頭的行的註釋,並增加mirrorlist開頭的行的註釋。將檔案中的http://mirror.centos.org替換成https://mirrors.huaweicloud.com,可以參考如下命令:

sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo sed -i "s/mirrorlist=http/#mirrorlist=http/g" /etc/yum.repos.d/CentOS-Base.repo sed -i "[email protected]://[email protected]://[email protected]" /etc/yum.repos.d/CentOS-Base.repo

執行yum clean all;yum makecache生成快取

遇到的問題:

File contains no section headers. file: file:///etc/yum.repos.d/google-chrome.repo, line: 2 'ogle-chrome]\n'

開啟google-chrome.repo缺少一個“[”符號