CentOS7 重裝yum
1. 卸載 yum
rpm -aq|grep yum|xargs rpm -e --nodeps
2. 下載rpm包
包倉庫 :http://mirrors.163.com/centos/7/os/x86_64/Packages/
可以使用wget 方式下載,如下:
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
也可以直接在倉庫搜索點擊下載,如下 :
下載如下包:
python-iniparse-0.4-9.el7.noarch.rpm
python-pycurl-7.19.0-19.el7.x86_64.rpm
python-2.7.5-86.el7.x86_64.rpm
python-urlgrabber-3.10-9.el7.noarch.rpm
python-libs-2.7.5-86.el7.x86_64.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
yum-3.4.3-163.el7.centos.noarch.rpm
執行 rpm -ivh python-*
,安裝python*包;
執行 `rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm ,安裝yum-metadata-parser-1.1.4-10.el7.x86_64.rpm包;
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm 與yum-3.4.3-163.el7.centos.noarch.rpm 相互依賴;
所以執行 rpm -ivh yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm yum-3.4.3-163.el7.centos.noarch.rpm
安裝;
輸入 yum -v
測試yum 安裝;
4. 修改yum源
cd /etc/yum.repos.d
進入 yum源目錄 ;
從http://mirrors.163.com/.help/CentOS7-Base-163.repo 下載yum源,上傳至 /etc/yum.repos.d 目錄 ,備份原有repo,
修改CentOS7-Base-163.repo 名稱為 CentOS-Base.repo (這一步不是必須的);
修改CentOS-Base.repo 內容 ,替換 $release 為 7 (單簽centos版本);替換原有網址為163的網址:
完整內容如下 :
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
5. yum update
運行makecache 生成緩存
yum makecache
運行yum clean all
yum clean all
更新yum文件
yum update
yum update 過程中,可能會出現以下問題:
1. 發現 XX 個已存在的 RPM 數據庫問題 :
1.首先yum clean all
,
2.安裝 package-cleanup工具,有下面命令就不需要安裝了,有的系統會自帶
yum install yum-utils
然后更新一下倉庫
package-cleanup --cleandupes
2. There are unfinished transactions remaining
1.安裝 yum-complete-transaction(這是一個能發現未完成或被中斷的yum事務的程序)
yum -y install yum-utils
2.清除yum緩存
yum clean all
3.運行 yum-complete-transaction,清理未完成事務
yum-complete-transaction --cleanup-only
3. conflicts with file from package
conflicts with file from package的問題導致軟件安裝失敗。
需要使用如下命令解決
rpm -ivh --replacefiles xxxx.rpm
4. Rpmdb checksum is invalid: pkg checksums
RUN rpm --rebuilddb命令可以一條條修復rpm, 但是發現
執行 yum clean all
, yum makecache
更加直接 .