亲宝软件园·资讯

展开

CentOS、Redhat中锁定、解锁软件包版本的方法(yum versionlock使用详解)

人气:0

那么该如何锁定包在特定版本下呢?下面我来介绍一种方法。使用yum versionlock 命令来锁定版本。

1. 安装

# yum install yum-plugin-versionlock.noarch

2. 添加锁定包

例子:将perl包锁定到当前版本


# yum versionlock perl
Loaded plugins: fastestmirror, versionlock
Adding versionlock on: 4:perl-5.10.1-127.el6
versionlock added: 1

3. 查看锁定列表

# yum versionlock list
Loaded plugins: fastestmirror, versionlock
4:perl-5.10.1-127.el6.*
versionlock list done

4. 清除单个包锁定

# yum versionlock delete '4:perl-5.10.1-127.el6.*'
Loaded plugins: fastestmirror, versionlock
Deleting versionlock for: 4:perl-5.10.1-127.el6.*
versionlock deleted: 1

5. 清除所有锁定

# yum versionlock clear
Loaded plugins: fastestmirror, versionlock
versionlock cleared

6. 实例

# yum check-update perl
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.163.com
* updates: mirrors.163.com

perl.x86_64 4:5.10.1-136.el6 base

锁定perl当前版本

# yum versionlock perl
Loaded plugins: fastestmirror, versionlock
Adding versionlock on: 4:perl-5.10.1-127.el6
versionlock added: 1

更新perl版本


# yum update perl
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* epel: mirror01.idc.hinet.net
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Update Process
No Packages marked for Update

No Packages marked for Update可见锁定成功了。

为了更新取消perl锁定


# yum versionlock delete '4:perl-5.10.1-127.el6.*'
Loaded plugins: fastestmirror, versionlock
Deleting versionlock for: 4:perl-5.10.1-127.el6.*
versionlock deleted: 1
# yum versionlock list
Loaded plugins: fastestmirror, versionlock
0:mysql-server-5.1.73-3.el6_5.*
0:mysql-5.1.73-3.el6_5.*
versionlock list done

更新perl包


# yum update -y perl
Updated:
perl.x86_64 4:5.10.1-136.el6
Complete!

更新前后perl版本


[root@AY14040211382766189cZ ~]
# rpm -qa | grep perl
perl-5.10.1-127.el6.x86_64
[root@AY14040211382766189cZ ~]
# rpm -qa | grep perl
perl-5.10.1-136.el6.x86_64

使用该指令就可以避免误升级软件包到最新版本。特别是在生产环境下的软件包,版本的更新可以有些配置参数不兼容到服务停止,从而影响正常的访问。

加载全部内容

相关教程
猜你喜欢
用户评论