Connecting rails app with remote mongodb server [mongodb ubuntu]


Problems faced:

P1. My DB server is running but ping not working correctly:
To ping an EC2 instance, you need to allow ICMP traffic in the instance’s security group.

See Why can’t I ping my instance in the EC2 FAQ.

stackoverflow
Instance security group link is given on instances page under Security Groups column.

P2. How to check mongodb is running?
Run this command:

service mongodb status

Output if running:

mongodb start/running, process some_pid

P3. How to specify your host machine ip address and port number in mongoid.yml?


development:
  consistency: :strong
  sessions:
  default:
      # Defines the name of the default database that Mongoid can connect to.
      # (required).
      database: mongoid_development_db
      # Provides the hosts the default session can connect to. Must be an array
      # of host:port pairs. (required)
      hosts:
        # - 127.0.0.1:27017
        #below is host ip address and port host:port it can be you your host url
        - 34.288.151.60:27017
        # - youhost.com:27017 <- if you want to specify your host url
      #these are optional its upto you
      options:
        pool_size: 25
        max_retries: 3
        down_interval: 1     # 30 by default

OR


default: &default
  sessions:
    default:      
      uri: "mongodb://your-ip-address-OR-hostname:port-no-OR-27017/database"
      options:
        timeout: 15
        retry_interval: 1
        max_retries: 5
        pool_size: 10

development:
  <<: *default

P4. Mongodb wont start ERROR: child process failed, exited with error number 100
Log file details [command]:

tailf /var/log/mongo/mongod.log

Solution:

1. run this command:

sudo mongod --smallfiles

2. run this command:

sudo nano /etc/mongod.conf

3. Find “nojournal” and replace


------------
nojournal = true
-----------

4. run this command

sudo service mongod restart

Reference of p4

Advertisements

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

Tagged with: , , ,
Posted in amazon, 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: