更新yum安装包
CentOS 7.x
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
CentOS 6.x
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOS 5.x
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
注:
此处更新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
问题:Error: xz compression not available
centos6升级php时误安装:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
即安装了epel-release-latest-7.noarch.rpm 导致在使用yum命令时出现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
问题参考自:http://blog.csdn.net/fanren224/article/details/71480268
和https://www.cnblogs.com/phpzhou/p/5602986.html
亲自执行的代码:
[root@localhost 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!
[root@localhost Desktop]# rm -rf /var/cache/yum/x86_64/6/epel/*
[root@localhost 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
[root@localhost 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
以上并没有解决我的问题
后有参考:https://www.iyunv.com/thread-300506-1-1.html
解决方法二:
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,这也可能是不成功的原因
[root@localhost Desktop]# rm -fr /var/cache/yum/x86_64/6/epel/
[root@localhost Desktop]# rm -rf /etc/yum.repos.d/epel*
[root@localhost 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]
[root@localhost 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.
[root@localhost 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]
[root@localhost 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
[root@localhost 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。
卸载重装yum参考:http://blog.csdn.net/m0_37886429/article/details/75009382
http://blog.csdn.net/xy2204/article/details/51781287
https://jingyan.baidu.com/article/ed2a5d1f5a9fbe09f6be17ea.html
解决方法三:
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
2、下载rpm包
先访问http://mirrors.163.com/centos/6/os/x86_64/Packages/
找到要用的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
4、更改yum源
① 下载配置文件http://mirrors.163.com/.help/CentOS6-Base-163.repo
将此配置文件替换/etc/yum.repos.d同名文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
② 编辑配置文件
[root@localhost Desktop]# cd /etc/yum.repos.d
[root@localhost 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
[root@localhost yum.repos.d]# vi CentOS-Base.repo
改为
:wq保存退出
5、检测安装的yum是否有问题,执行命令进行测试
[root@localhost 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
#将服务器软件包信息缓存至本地,提高搜索安装效率
[root@localhost 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
成功了。。。。