yum update 和 upgrade 出現的慘案
首先記錄一下慘案的事故過程
- 事故原因:首先想安裝一個插件,因為此版本yum上無此package,於是想更新一下yum源,執行yum update,因為平時也是如此操作過,無任何問題,但今天出問題了,因為某種問題,導致docker服務全體掉線,重啟服務之后發現,docker網絡又出現問題,導致服務全體下線。
- 解決辦法:重啟docker 容器,使網絡恢復,服務恢復正常,也不知道為啥。
事故產生因為對liunx操作的不謹慎及相關操作原理未深入理解導致
以下做出相應總結,以儆效尤
yum升級
Linux yum中package升級命令有兩個分別是 yum upgrade 和 yum update
首先給出相應的yum對這兩個的文檔說明
yum update
If run without any packages, update will update every currently installed package. If one or more packages or package globs are specified, Yum will only update the listed packages. While updating packages, yum will ensure that all dependencies are satisfied. (See Specifying package names for more information) If the packages or globs speci- fied match to packages which are not currently installed then update will not install them. update operates on groups, files, provides and filelists just like the "install" command. If the main obsoletes configure option is true (default) or the --obsoletes flag is present yum will include package obsoletes in its calculations - this makes it better for distro-version changes, for example: upgrading from somelinux 8.0 to somelinux 9. Note that "update" works on installed packages first, and only if there are no matches does it look for available packages. The difference is most noticeable when you do "update foo-1-2" which will act exactly as "update foo" if foo-1-2 is installed. You can use the "update-to" if you’d prefer that nothing happen in the above case.
yum upgrade
Is the same as the update command with the — obsoletes flag set. See update for more details.
經查閱相關文檔及眾說紛紜的博客可以得出
yum update 升級所有包,會保留舊版本的 package,更新系統內核根據 obsoletes 配置而定
yum upgrade 升級所有包,會刪除舊版本的 package,更新系統內核
yum 的 upgrade 是等價於打開 obsoletes 配置的 yum update。
而默認中/etc/yum.conf配置文件obsoletes是打開的,因此這兩個指令針對系統內核來說是等價的。
若一定要升級,如果軟件依賴舊版本的package,最好是使用 yum update,確保不會出現兼容問題。但再正式環境最好不要使用yum更新,會出現意想不到的問題。一不小心會搞得跟 rm -rf 一樣的快感