Mongo::Error::NoServerAvailable OR mongod stoped working rails OR Insufficient free space for journals, terminating


First I tried to remove mongod lock, but it did not worked:


sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart

Then I tried to change permission for “/tmp” folder


ls -lh /tmp
chown root:root /tmp
chmod 1777 /tmp
sudo service mongodb restart
tail -f /var/log/mongodb/mongod.log

It did not worked but guided me towards the problem.

Problem:


Insufficient free space for journal file
Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
Insufficient free space for journals, terminating
now exiting #It means mongo is stopping itself
shutdown: going to close listening sockets...
removing socket file: /tmp/mongodb-27017.sock

Solution:

sudo nano /etc/mongod.conf

and add


storage:
   mmapv1:
      smallFiles: true

Now specify for mongod to “Use the Configuration File” using command below

mongod -f /etc/mongodb.conf

In other terminal tab open log file

tail -f /var/log/mongodb/mongod.log

Restart mongod

sudo service mongod restart

log file will contain “connection now open” if everything is fine.

Side Notes:
1. To check mongod install version

mongod --version

2. mongod.conf other options


# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
  mmapv1:
   smallFiles: true  #OPTION ADDED FOR SMALL FILES
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

http://stackoverflow.com/a/8479630/1222852
https://docs.mongodb.org/manual/reference/configuration-options/
Mongodb Small file options setting for different versions

Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , , ,
Posted in mongodb, mongoid

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: