2014년 12월 5일 금요일

Re: Unable connect to MongoDB 2.6.5 deployed on Amazon EC2

I have the same problem. I launched and configured a new mongodb installation and cannot connect to it. I simply did a mongodump and mongorestore to transfer the data and created the user I had for authentication with addUser. I saw that addUser changed in between my old instance version 2.4.10 and the new instance 2.6.5.

As Stephen mentioned the new installation had the bind_ip parameter that I commented out and restarted mongod but I still get the same error. Otherwise the config file between the two versions are the same. Is there something more specific that must be done when creating a user?
This is what I did 
db.mydb.addUser({ user: "myuser", pwd: "mypassword", roles: [] })

Anything else I should look at or test?

Stephen Steneker wrote:
On Monday, 27 October 2014 22:55:37 UTC+11, Gia Mai wrote:
I get error during deploy my web application to Amazon EC2. I have 2 EC2 instances, an Ubuntu instance for Mongodb, a Windows instance for web front end. I am trying to connect the database from asp.net mvc web application. But it throwing exception "No connection could be made because the target machine actively refused it 172.31.26.17:27017". I know there is a firewall issue on Ubuntu server, but I don't know what I'm missing.

Hi Gia,

In a default Ubuntu install of MongoDB 2.6 the mongod server will only be bound to the localhost interface (127.0.0.1). You probably need to remove or adjust the bind_ip directive in /etc/mongod.conf and then restart the mongod service.

Note: with your security group allowing access from any IP, you definitely want to enable authentication (or perhaps connect using ssh port forwarding or a VPN instead).

For more information on security & best practices see: http://docs.mongodb.org/manual/security/.



Are you creating the user by using your database name?



I did the following:

use mydb
db.addUser({ user: "myuser", pwd: "mypassword", roles: [] })

* There was a typo in my first email



I have been looking at the documentation and it mentions that I must create the system user administrator and then use the system user to create my database user.
I did not create my user using the system user.
In my notes for the previous installation 2.3 or 2.4, I created the system user first but do not recall having to connect to mongo with the system user.

So can someone confirm that there's are the actual steps:
  1. Run mongo without authentication
  2. Create system user
    1. use admin
    2. db.createUser( ... roles { role: "userAdminAnyDatabase", db: "admin" } )
  3. Restart mongod with authentication -> mongod --auth
  4. Run mongo with system user credentials
    1. mongo -u ... -p ....
  5. Create user for database
    1. use mydb
    2. db.createUser( .... )
If I do a getUsers() I can see my user even If it was not created using the system user. What is the difference between the two? 
What properties can I look at to see the difference?


댓글 없음:

댓글 쓰기