那么該如何鎖定包在特定版本下呢?下面我來介紹一種方法。使用yum versionlock 命令來鎖定版本。
1. 安裝
# yum install yum-plugin-versionlock.noarch
2. 添加鎖定包
例子:將perl包鎖定到當(dāng)前版本
# 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. 清除單個(gè)包鎖定
# 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. 實(shí)例
# 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當(dāng)前版本
# 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
使用該指令就可以避免誤升級軟件包到最新版本。特別是在生產(chǎn)環(huán)境下的軟件包,版本的更新可以有些配置參數(shù)不兼容到服務(wù)停止,從而影響正常的訪問。