【小ネタ】yum updateしたら「Cannot allocate memory」が出た時の対処法

· 5 min read
【小ネタ】yum updateしたら「Cannot allocate memory」が出た時の対処法

久々に検証機でyum updateしたときの話。

# yum update
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00:00 
amzn-updates | 2.3 kB 00:00:00 
(1/2): amzn-updates/latest/updateinfo | 397 kB 00:00:00 
(2/2): amzn-updates/latest/primary_db | 436 kB 00:00:00 
Resolving Dependencies
--> Running transaction check
---> Package aws-cfn-bootstrap.noarch 0:1.4-15.9.amzn1 will be updated
---> Package aws-cfn-bootstrap.noarch 0:1.4-19.10.amzn1 will be an update
---> Package bind-libs.x86_64 32:9.8.2-0.62.rc1.55.amzn1 will be updated
---> Package bind-libs.x86_64 32:9.8.2-0.62.rc1.56.amzn1 will be an update
---> Package bind-utils.x86_64 32:9.8.2-0.62.rc1.55.amzn1 will be updated
---> Package bind-utils.x86_64 32:9.8.2-0.62.rc1.56.amzn1 will be an update
---> Package kernel.x86_64 0:4.9.38-16.33.amzn1 will be installed
---> Package kernel-headers.x86_64 0:4.9.32-15.41.amzn1 will be updated
---> Package kernel-headers.x86_64 0:4.9.38-16.33.amzn1 will be an update
---> Package kernel-tools.x86_64 0:4.9.32-15.41.amzn1 will be updated
---> Package kernel-tools.x86_64 0:4.9.38-16.33.amzn1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
 kernel x86_64 4.9.38-16.33.amzn1 amzn-updates 17 M
Updating:
 aws-cfn-bootstrap noarch 1.4-19.10.amzn1 amzn-updates 867 k
 bind-libs x86_64 32:9.8.2-0.62.rc1.56.amzn1 amzn-updates 1.0 M
 bind-utils x86_64 32:9.8.2-0.62.rc1.56.amzn1 amzn-updates 271 k
 kernel-headers x86_64 4.9.38-16.33.amzn1 amzn-updates 1.1 M
 kernel-tools x86_64 4.9.38-16.33.amzn1 amzn-updates 102 k

Transaction Summary
=============================================================================================================================================================
Install 1 Package
Upgrade 5 Packages

Total download size: 21 M
Is this ok [y/d/N]: y
Downloading packages:



Error downloading packages:
  32:bind-libs-9.8.2-0.62.rc1.56.amzn1.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
  32:bind-utils-9.8.2-0.62.rc1.56.amzn1.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
  kernel-tools-4.9.38-16.33.amzn1.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
  kernel-headers-4.9.38-16.33.amzn1.x86_64: [Errno 5] [Errno 12] Cannot allocate memory
  aws-cfn-bootstrap-1.4-19.10.amzn1.noarch: [Errno 5] [Errno 12] Cannot allocate memory
  kernel-4.9.38-16.33.amzn1.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

ヒエッ…
エラーがでてupdate出来ないンゴ…

「Cannot allocate memory」と出るくらいだからメモリが足りないのか…。

# free -m                                                                                                                                   
             total       used       free     shared    buffers     cached
Mem:           489        475         14          0          0         21
-/+ buffers/cache:        452         36
Swap:            0          0          0

まだ残ってるやんけ!

解決策

yumのキャッシュクリアしたらyumできました。。

# yum clean all
Loaded plugins: priorities, update-motd, upgrade-helper
Cleaning repos: amzn-main amzn-updates
Cleaning up everything
]# yum update
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                                                                                                                             | 2.1 kB  00:00:00     
amzn-updates                                                                                                                          | 2.3 kB  00:00:00     
(1/5): amzn-updates/latest/group                                                                                                      |  35 kB  00:00:00     
(2/5): amzn-updates/latest/updateinfo                                                                                                 | 397 kB  00:00:00     
(3/5): amzn-updates/latest/primary_db                                                                                                 | 436 kB  00:00:00     
(4/5): amzn-main/latest/group                                                                                                         |  35 kB  00:00:00     
(5/5): amzn-main/latest/primary_db                                                                                                    | 3.6 MB  00:00:01     
Resolving Dependencies
--> Running transaction check
---> Package aws-cfn-bootstrap.noarch 0:1.4-15.9.amzn1 will be updated
---> Package aws-cfn-bootstrap.noarch 0:1.4-19.10.amzn1 will be an update
---> Package bind-libs.x86_64 32:9.8.2-0.62.rc1.55.amzn1 will be updated
---> Package bind-libs.x86_64 32:9.8.2-0.62.rc1.56.amzn1 will be an update
---> Package bind-utils.x86_64 32:9.8.2-0.62.rc1.55.amzn1 will be updated
---> Package bind-utils.x86_64 32:9.8.2-0.62.rc1.56.amzn1 will be an update
---> Package kernel.x86_64 0:4.9.38-16.33.amzn1 will be installed
---> Package kernel-headers.x86_64 0:4.9.32-15.41.amzn1 will be updated
---> Package kernel-headers.x86_64 0:4.9.38-16.33.amzn1 will be an update
---> Package kernel-tools.x86_64 0:4.9.32-15.41.amzn1 will be updated
---> Package kernel-tools.x86_64 0:4.9.38-16.33.amzn1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                                Arch                        Version                                          Repository                         Size
=============================================================================================================================================================
Installing:
 kernel                                 x86_64                      4.9.38-16.33.amzn1                               amzn-updates                       17 M
Updating:
 aws-cfn-bootstrap                      noarch                      1.4-19.10.amzn1                                  amzn-updates                      867 k
 bind-libs                              x86_64                      32:9.8.2-0.62.rc1.56.amzn1                       amzn-updates                      1.0 M
 bind-utils                             x86_64                      32:9.8.2-0.62.rc1.56.amzn1                       amzn-updates                      271 k
 kernel-headers                         x86_64                      4.9.38-16.33.amzn1                               amzn-updates                      1.1 M
 kernel-tools                           x86_64                      4.9.38-16.33.amzn1                               amzn-updates                      102 k

Transaction Summary
=============================================================================================================================================================
Install  1 Package
Upgrade  5 Packages

Total download size: 21 M
Is this ok [y/d/N]: y
Downloading packages:
(1/6): bind-libs-9.8.2-0.62.rc1.56.amzn1.x86_64.rpm                                                                                   | 1.0 MB  00:00:00     
(2/6): aws-cfn-bootstrap-1.4-19.10.amzn1.noarch.rpm                                                                                   | 867 kB  00:00:00     
(3/6): bind-utils-9.8.2-0.62.rc1.56.amzn1.x86_64.rpm                                                                                  | 271 kB  00:00:00     
(4/6): kernel-headers-4.9.38-16.33.amzn1.x86_64.rpm                                                                                   | 1.1 MB  00:00:00     
(5/6): kernel-tools-4.9.38-16.33.amzn1.x86_64.rpm                                                                                     | 102 kB  00:00:00     
(6/6): kernel-4.9.38-16.33.amzn1.x86_64.rpm                                                                                           |  17 MB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                         22 MB/s |  21 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 32:bind-libs-9.8.2-0.62.rc1.56.amzn1.x86_64                                                                                              1/11 
  Updating   : 32:bind-utils-9.8.2-0.62.rc1.56.amzn1.x86_64                                                                                             2/11 
  Updating   : aws-cfn-bootstrap-1.4-19.10.amzn1.noarch                                                                                                 3/11 
  Updating   : kernel-tools-4.9.38-16.33.amzn1.x86_64                                                                                                   4/11 
  Updating   : kernel-headers-4.9.38-16.33.amzn1.x86_64                                                                                                 5/11 
  Installing : kernel-4.9.38-16.33.amzn1.x86_64                                                                                                         6/11 
  Cleanup    : aws-cfn-bootstrap-1.4-15.9.amzn1.noarch                                                                                                  7/11 
  Cleanup    : kernel-headers-4.9.32-15.41.amzn1.x86_64                                                                                                 8/11 
  Cleanup    : 32:bind-utils-9.8.2-0.62.rc1.55.amzn1.x86_64                                                                                             9/11 
  Cleanup    : 32:bind-libs-9.8.2-0.62.rc1.55.amzn1.x86_64                                                                                             10/11 
  Cleanup    : kernel-tools-4.9.32-15.41.amzn1.x86_64                                                                                                  11/11 
  Verifying  : kernel-4.9.38-16.33.amzn1.x86_64                                                                                                         1/11 
  Verifying  : kernel-headers-4.9.38-16.33.amzn1.x86_64                                                                                                 2/11 
  Verifying  : kernel-tools-4.9.38-16.33.amzn1.x86_64                                                                                                   3/11 
  Verifying  : aws-cfn-bootstrap-1.4-19.10.amzn1.noarch                                                                                                 4/11 
  Verifying  : 32:bind-utils-9.8.2-0.62.rc1.56.amzn1.x86_64                                                                                             5/11 
  Verifying  : 32:bind-libs-9.8.2-0.62.rc1.56.amzn1.x86_64                                                                                              6/11 
  Verifying  : 32:bind-libs-9.8.2-0.62.rc1.55.amzn1.x86_64                                                                                              7/11 
  Verifying  : 32:bind-utils-9.8.2-0.62.rc1.55.amzn1.x86_64                                                                                             8/11 
  Verifying  : aws-cfn-bootstrap-1.4-15.9.amzn1.noarch                                                                                                  9/11 
  Verifying  : kernel-headers-4.9.32-15.41.amzn1.x86_64                                                                                                10/11 
  Verifying  : kernel-tools-4.9.32-15.41.amzn1.x86_64                                                                                                  11/11 

Installed:
  kernel.x86_64 0:4.9.38-16.33.amzn1                                                                                                                         

Updated:
  aws-cfn-bootstrap.noarch 0:1.4-19.10.amzn1         bind-libs.x86_64 32:9.8.2-0.62.rc1.56.amzn1         bind-utils.x86_64 32:9.8.2-0.62.rc1.56.amzn1        
  kernel-headers.x86_64 0:4.9.38-16.33.amzn1         kernel-tools.x86_64 0:4.9.38-16.33.amzn1           

Complete!

やったぜ。