The difference between Yum update and upgrade
There are two package upgrade commands in Linux yum , yum upgrade and yum update
1. Difference
By default, the functions of yum update and yum upgrade are exactly the same, both are to update the package that needs to be updated (the package here includes conventional packages, software, system version, system kernel ) to the latest version in the software source. The difference is that yum upgrade will delete the old version of the package, while yum update will keep it, but this function requires additional configuration! ! !
yum
upgrade
is equivalent to openobsoletes
configurationyum update
.
By default,/etc/yum.conf
the configuration file obsoletes is turned on, so these two instructions are completely equivalent to the system kernel.The effect is:yum upgrade == yum updateIt is to update the package ( the package here includes conventional package, software, system version, system kernel ) that needs to be updated to the latest version in the software source.
If you must upgrade, if the software depends on the old version of the package,
最好
use ityum update
(configuration is required/etc/yum.conf下的obsoletes值为0
) to ensure that there will be no compatibility problems. But the formal environment is the best不要使用yum更新
, and unexpected problems will appear.–
1表示更新旧的rpm包的同时会删除旧包,0表示更新的时候不会删除旧包
2. Upgrade
When upgrading the software package, if you do not need to upgrade the kernel, you can add the exclude parameter filter, such as centos upgrade
$ yum --exclude=kernel* --exclude=centos-release* -y update
Or modify the configuration file directly /etc/yum.conf
, add configuration items in the [main] configuration
exclude=kernel*
exclude=centos-release*
execute after
$ yum -y update
Configuration /etc/yum.conf
file:
This is an example of a yum cache configuration file. Obsoletes defines the replacement relationship of processing packages when updating. In simple terms, 1 means that the old rpm package will be deleted while updating it, and 0 means that the old package will not be deleted when updating. ,
[root@k8s-master1 ~]#cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[root@k8s-master1 ~]#
Therefore, the functions of yum update and yum upgrade are the same, and both update the package that needs to be updated to the latest version in the source. The only difference is that yum upgrade will delete the old version of the package, while yum update will keep it (obsoletes=0) .
3. Test process
before testing
- Through the check-update option, you can know which installed packages in the system are currently updated, as shown below, there are available updates for these packages
yum check-update
- View current system version, kernel version, package version
- Check
/etc/yum.conf配置
yum update test
- Excuting an order
yum update -y
Reboot the machine:
- observe
Updated the kernel (minor version upgrade), operating system version, and software package version.
- After modification
/etc/yum.conf下的obsoletes值为0
, test again
[root@docker ~]#vim /etc/yum.conf #1表示更新旧的rpm包的同时会删除旧包,0表示更新的时候不会删除旧包,
- Upgrade again and reboot
[root@docker ~]#yum update -y
[root@docker ~]#reboot
- observe
Updated the kernel (minor version upgrade), operating system version, and software package version.
However, it is configured /etc/yum.conf下的obsoletes值为0
, but the old rpm package is still deleted. This is very strange? ? ? inconsistent with theory.
yum upgrade test
- Excuting an order
yum upgrade -y
reboot
- observe
Updated the kernel (minor version upgrade), operating system version, and software package version.
4. Reference articles
https://www.jianshu.com/p/761b24775131
https://blog.csdn.net/bisal/article/details/105061873