Sometimes, when updating the system, you do not need to upgrade some software packages. you need to lock the package to a specific version. For example, for mysql-server, to avoid unexpected update errors, the RedhatCentOS label cannot be upgraded.
So how do I lock the package in a specific version? The following describes a method. Use the yum versionlock command to lock the version.
1. install
Copy codeCode: # yum install yum-plugin-versionlock.noarch
2. add a lock package
Example: Lock the perl package to the current version
Copy codeThe code is as follows:
# Yum versionlock perl
Loaded plugins: fastestmirror, versionlock
Adding versionlock on: 4: perl-5.10.1-127.el6
Versionlock added: 1
3. view the lock list
Copy codeThe code is as follows: # yum versionlock list
Loaded plugins: fastestmirror, versionlock
4: perl-5.10.1-127.el6 .*
Versionlock list done
4. clear a single package lock
Copy codeThe code is as follows: # 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. clear all locks
Copy codeThe code is as follows: # yum versionlock clear
Loaded plugins: fastestmirror, versionlock
Versionlock cleared
6. instance
Copy codeThe code is as follows: # yum check-update perl
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
* Base: mirrors.163.com
* Epel: pai01.idc.hinet.net
* Extras: mirrors.163.com
* Updates: mirrors.163.com
Perl. x86_64. 10.1-136. el6 base
Lock current perl version
Copy codeThe code is as follows: # yum versionlock perl
Loaded plugins: fastestmirror, versionlock
Adding versionlock on: 4: perl-5.10.1-127.el6
Versionlock added: 1
Update perl
Copy codeThe code is as follows:
# Yum update perl
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
* Base: mirrors.163.com
* Epel: pai01.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 indicates that the lock is successful.
Remove perl lock for updates
Copy codeThe code is as follows:
# 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
Update the perl package
Copy codeThe code is as follows:
# Yum update-y perl
Updated:
Perl. x86_64. 10.1-136. el6
Complete!
Perl versions before and after the upgrade
Copy codeThe code is as follows:
[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
Use this command to avoid mistakenly upgrading the software package to the latest version. Especially for software packages in the production environment, version updates may cause some configuration parameters to be incompatible with the service to stop, thus affecting normal access.