yum error: Couldn’t fork Cannot allocate memory

yum error: Couldn’t fork Cannot allocate memory

I’ve been doing some awesome things to a new VM for work, namely installing CouchDB, Apache and running Node.JS apps along side a WordPress plugin using Angular.JS. It’s pretty cool. But computer’s are dicks so when it came down to installing Monit to ensure everything was lovely I got the following error: Couldn’t fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory. Bum.

error: Couldn’t fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory

Seem’s simple enough, for whatever reason Yum cannot allocate memory, so lets take a peak

root@bridge opt]# free
             total       used       free     shared    buffers     cached
Mem:       1020376     832736     187640          0       3988      81256
-/+ buffers/cache:     747492     272884
Swap:            0          0          0

Man there’s totally enough memory there, 187MB of RAM is free, Quake took less than that and is way more complicated than some stupid RPMs.. maybe it’s something else!

Quite often this error is caused because the RPM database has duplicates or got corrupted in some way, so lets try and clean that up.

[root@bridge ~]# package-cleanup --cleandupes
Loaded plugins: fastestmirror, protectbase
Loading mirror speeds from cached hostfile
 * base: mirror.checkdomain.de
 * epel: mirrors.n-ix.net
 * extras: mirror.checkdomain.de
 * rpmforge: mirror1.hs-esslingen.de
 * updates: mirror.checkdomain.de
1490 packages excluded due to repository protections
No duplicates to remove
[root@bridge ~]# rpm --rebuilddb

Well no duplicates and the RPM database is all cool, so lets try again ..

[root@bridge ~]# yum install monit
Loaded plugins: fastestmirror, protectbase

Running Transaction
Error in PREIN scriptlet in rpm package monit-5.5-1.el6.rf.x86_64
error: Couldn't fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory
error:   install: %pre scriptlet failed (2), skipping monit-5.5-1.el6.rf
  Verifying  : monit-5.5-1.el6.rf.x86_64                                                                                                                                                                                                                                       1/1 

Failed:
  monit.x86_64 0:5.5-1.el6.rf                                                                                                                                                                                                                                                      

Complete!

Man, haters gonna hate!

Solving error: Couldn’t fork %pre(monit-5.5-1.el6.rf.x86_64): Cannot allocate memory

Ok, lets step back a minute and assume the error is legit, lets turn some stuff off ..

[root@bridge ~]# /etc/init.d/couchdb stop
Stopping database server couchdb
[root@bridge ~]# /etc/init.d/httpd stop
Stopping httpd:                                            [  OK  ]

And try again!

[root@bridge ~]# yum install monit
Loaded plugins: fastestmirror, protectbase

Downloading Packages:
monit-5.5-1.el6.rf.x86_64.rpm                                                                                                                                                                                                                               | 267 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : monit-5.5-1.el6.rf.x86_64                                                                                                                                                                                                                                       1/1 
  Verifying  : monit-5.5-1.el6.rf.x86_64                                                                                                                                                                                                                                       1/1 

Installed:
  monit.x86_64 0:5.5-1.el6.rf                                                                                                                                                                                                                                                      

Complete!

Sweet that did it. So it was a bonafide legit error and shutting some services down freed up enough memory to allow us to install RPMs again.

root@bridge ~]# free
             total       used       free     shared    buffers     cached
Mem:       1020376     510972     509404          0      11632     146780
-/+ buffers/cache:     352560     667816
Swap:            0          0          0

mmm 509MB free, thats a lot more.. I guess Yum actually needs a ton of RAM to actually do anything. Weird. If you guys get this problem, try turning some services off and on again 😉

  1. it would simple if you add a swap space. from your ouput there is no swap.

    root@bridge opt]# free
    total used free shared buffers cached
    Mem: 1020376 832736 187640 0 3988 81256
    -/+ buffers/cache: 747492 272884
    Swap: 0 0 0

Leave a Reply

Your email address will not be published. Required fields are marked *