1. 程式人生 > 實用技巧 >yum update 和 upgrade 出現的慘案

yum update 和 upgrade 出現的慘案

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
formore information) If the packages or globs speci- fied match to packages which are not currently installed then update will not install them. update operatesongroups, files, provides and filelists just like the"install" command. If the main obsoletes configure optionistrue(default) or the --obsoletes flagis
present yum will include package obsoletesinits calculations -thismakes it better fordistro-version changes,forexample: upgradingfromsomelinux 8.0 to somelinux 9. Note that"update"worksoninstalled packages first, and onlyifthere are no matches does it lookforavailable packages. The differenceismost noticeable when youdo "update foo-1-2"which will act exactlyas"update foo"iffoo-1-2isinstalled. You can use the"update-to"ifyou’d prefer that nothing happeninthe abovecase.

  yum upgrade

Is the sameasthe update command with the — obsoletes flagset. See updateformore details.

經查閱相關文件及眾說紛紜的部落格可以得出

  yum update 升級所有包,會保留舊版本的 package,更新系統核心根據obsoletes 配置而定


  yum upgrade 升級所有包,會刪除舊版本的 package,更新系統核心


  yum 的upgrade 是等價於開啟 obsoletes配置的 yum update

  而預設中/etc/yum.conf配置檔案obsoletes是開啟的,因此這兩個指令針對系統核心來說是等價的。


若一定要升級,如果軟體依賴舊版本的package,最好是使用 yum update,確保不會出現相容問題。但再正式環境最好不要使用yum更新,會出現意想不到的問題。