centos更新yum時遇到的問題
阿新 • • 發佈:2018-12-26
注:
此處更新yum自己決定進不進行,我更新後出現了一大堆問題,
若想更新,可先檢視centos的版本,對應更新。
#檢視centos版本
[root@localhost Desktop]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m
以下為我更新錯誤的yum,並遇到的問題
#更新yum
[root@localhost Desktop]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/epel-release.rpm
warning : /var/tmp/rpm-tmp.Xv1oxD: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
[root@localhost Desktop]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.BY2vkQ: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing... ########################################### [100%]
1:webtatic-release ########################################### [100%]
#安裝php
[root@localhost Desktop]# yum list installed | grep php
[root@localhost Desktop]# yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
epel/metalink | 7.3 kB 00:00
* base: mirrors.shuosc.org
* epel: mirrors.tongji.edu.cn
* extras: mirrors.shuosc.org
* updates: mirrors.shuosc.org
* webtatic: us-east.repo.webtatic.com
epel | 4.7 kB 00:00
epel/primary_db | 6.1 MB 00:23
webtatic | 3.6 kB 00:00
webtatic/primary_db | 205 kB 00:00
Error: xz compression not available
解決方法一:
1、解除安裝epel-release-latest-7.noarch.rpm : yum remove epel-release
2、清空epel目錄 : rm -rf /var/cache/yum/x86_64/6/epel/*
3、重新安裝:rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
親自執行的程式碼:
[[email protected] Desktop]# yum remove epel-release
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-5 will be erased
--> Processing Dependency: epel-release >= 7 for package: webtatic-release-7-3.noarch
--> Running transaction check
---> Package webtatic-release.noarch 0:7-3 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
epel-release noarch 7-5 installed 24 k
Removing for dependencies:
webtatic-release noarch 7-3 installed 22 k
Transaction Summary
================================================================================
Remove 2 Package(s)
Installed size: 47 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Erasing : webtatic-release-7-3.noarch 1/2
Erasing : epel-release-7-5.noarch 2/2
Verifying : epel-release-7-5.noarch 1/2
Verifying : webtatic-release-7-3.noarch 2/2
Removed:
epel-release.noarch 0:7-5
Dependency Removed:
webtatic-release.noarch 0:7-3
Complete!
[[email protected] Desktop]# rm -rf /var/cache/yum/x86_64/6/epel/*
[[email protected] Desktop]# rpm -Uvh http://mirror.webtatic.com/yum/e16/latest.rpm
Retrieving http://mirror.webtatic.com/yum/e16/latest.rpm
curl: (22) The requested URL returned error: 404 Not Found
error: skipping http://mirror.webtatic.com/yum/e16/latest.rpm - transfer failed
#檢查yum
[[email protected] Desktop]# yum search munin
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
* webtatic: us-east.repo.webtatic.com
Error: xz compression not available
以上並沒有解決我的問題
解決方法二:
1、rm -fr /var/cache/yum/x86_64/6/epel/
2、rm -rf /etc/yum.repos.d/epel*
3、重新安裝epel源和base源
wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum repolist
親自執行的程式碼:下面我將7改為了6,這也可能是不成功的原因
[[email protected] Desktop]# rm -fr /var/cache/yum/x86_64/6/epel/
[[email protected] Desktop]# rm -rf /etc/yum.repos.d/epel*
[[email protected] Desktop]# wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
--2017-12-13 05:57:35-- http://mirrors.aliyun.com/repo/Centos-6.repo
Resolving mirrors.aliyun.com... 123.129.215.191, 123.129.215.252, 123.129.215.223, ...
Connecting to mirrors.aliyun.com|123.129.215.191|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2572 (2.5K) [application/octet-stream]
Saving to: “/etc/yum.repos.d/CentOS-Base.repo”
100%[======================================>] 2,572 --.-K/s in 0.005s
2017-12-13 05:57:35 (535 KB/s) - “/etc/yum.repos.d/CentOS-Base.repo” saved [2572/2572]
[[email protected] Desktop]# wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try ‘wget --help’ for more options.
[[email protected] Desktop]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
--2017-12-13 05:58:13-- http://mirrors.aliyun.com/repo/epel-6.repo
Resolving mirrors.aliyun.com... 123.129.215.223, 123.129.215.221, 123.129.215.191, ...
Connecting to mirrors.aliyun.com|123.129.215.223|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1083 (1.1K) [application/octet-stream]
Saving to: “/etc/yum.repos.d/epel.repo”
100%[======================================>] 1,083 --.-K/s in 0.001s
2017-12-13 05:58:13 (1.39 MB/s) - “/etc/yum.repos.d/epel.repo” saved [1083/1083]
[[email protected] Desktop]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
* webtatic: us-east.repo.webtatic.com
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:21
Error: xz compression not available
[[email protected] Desktop]# yum search muninLoaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
* webtatic: us-east.repo.webtatic.com
Error: xz compression not available
也沒有解決我的問題,於是決定解除安裝重灌yum。
解決方法三:
1、將現有的yum源解除安裝
[root@localhost Desktop]# rpm -qa yum
yum-3.2.29-40.el6.centos.noarch
#這一步一定要執行,而且要將所有的元件解除安裝掉,如果解除安裝不乾淨,後面安裝會有問題
[root@localhost Desktop]# rpm -qa | grep yum |xargs rpm -e --nodeps
[root@localhost Desktop]# rpm -qa yum
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
3、安裝
[root@localhost Desktop]# ls //檢視
yum-3.2.29-81.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
[root@localhost Desktop]# rpm -ivh yum-* //安裝
error: Failed dependencies:
python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-81.el6.centos.noarch
#發現錯誤,python-urlgrabber版本必須大於等於3.9.1-10
#若安裝失敗可重新輸入此命令並加引數--nodeps
[root@localhost Desktop]# rpm -ivh yum-* --nodeps
Preparing... ########################################### [100%]
1:yum-metadata-parser ########################################### [ 33%]
2:yum-plugin-fastestmirro########################################### [ 67%]
3:yum ########################################### [100%]
[root@localhost Desktop]# rpm -qa yum //檢視是否已經安裝上
yum-3.2.29-81.el6.centos.noarch
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
② 編輯配置檔案
[[email protected] Desktop]# cd /etc/yum.repos.d
[[email protected] yum.repos.d]# ls
CentOS-Base.repo CentOS-Vault.repo webtatic-archive.repo
CentOS-Debuginfo.repo mysql-community.repo webtatic.repo
CentOS-Media.repo mysql-community-source.repo webtatic-testing.repo
[[email protected] yum.repos.d]# vi CentOS-Base.repo
改為
:wq儲存退出
5、檢測安裝的yum是否有問題,執行命令進行測試
[[email protected] yum.repos.d]# yum clean all //清理yum快取
Loaded plugins: fastestmirror
Cleaning repos: base extras mysql-connectors-community mysql56-community updates
: webtatic
Cleaning up Everything
Cleaning up list of fastest mirrors
#將伺服器軟體包資訊快取至本地,提高搜尋安裝效率
[[email protected] yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.shuosc.org
* webtatic: us-east.repo.webtatic.com
base | 3.7 kB 00:00
base/group_gz | 226 kB 00:00
base/filelists_db | 6.4 MB 00:24
base/primary_db | 4.7 MB 00:19
base/other_db | 2.8 MB 00:09
extras | 3.4 kB 00:00
extras/filelists_db | 25 kB 00:00
extras/prestodelta | 1.3 kB 00:00
extras/primary_db | 29 kB 00:00
extras/other_db | 30 kB 00:00
mysql-connectors-community | 2.4 kB 00:00
mysql-connectors-community/filelists_db | 3.3 kB 00:00
mysql-connectors-community/primary_db | 6.8 kB 00:00
mysql-connectors-community/other_db | 1.4 kB 00:00
mysql56-community | 2.5 kB 00:00
mysql56-community/filelists_db | 538 kB 00:01
mysql56-community/primary_db | 174 kB 00:00
mysql56-community/other_db | 53 kB 00:00
updates | 3.4 kB 00:00
updates/filelists_db | 3.3 MB 00:11
updates/prestodelta | 163 kB 00:00
updates/primary_db | 5.3 MB 00:19
updates/other_db | 75 MB 05:14
webtatic | 3.6 kB 00:00
webtatic/group_gz | 374 B 00:00
webtatic/filelists_db | 152 kB 00:01
webtatic/primary_db | 306 kB 00:02
webtatic/other_db | 77 kB 00:00
Metadata Cache Created
成功了。。。。