HiveBrain v1.2.0
Get Started
← Back to all entries
debugMinor

Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91 when changing mongodb data directory

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
directoryerrorconnect27017mongo127mongodbshellsrcwhen

Problem

I already change the owner of the directory I want to use

root@ip-10-138-30-205:/media/newdrive# ls -l                                                                                                                                                                                     
total 20
drwxr-xr-x 3 mongodb root  4096 Aug 30 11:32 data
drwx------ 2 root    root 16384 Aug 30 09:56 lost+found
root@ip-10-138-30-205:/media/newdrive#


I already restart mongodb

root@ip-10-138-30-205:/media/newdrive# service mongodb restart
mongodb stop/waiting
mongodb start/running, process 17140
root@ip-10-138-30-205:/media/newdrive#


my mongodb.conf has already been changed

# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.                                                                                                                                                               
dbpath=/media/newdrive/data

#where to log
logpath=/var/log/mongodb/mongodb.log                                                                                                                                                                                             

logappend=true

#port = 27017                                                                                                                                                                                                                    

# Disables write-ahead journaling                                                                                                                                                                                                
# nojournal = true

# Enables periodic logging of CPU utilization and I/O wait


What else should I have done? I am using amazon ec2

Update: I already know what the problem is but here is the log anyway per

Solution

While I wait for your logs (see comments), there are two common causes for this:

Bad permissions on the log file, or other bad permissions in the data path. Make sure you chown/chmod everything under the /media/newdrive/data folder. Something similar to this:

sudo chown -R mongodb:mongodb /media/newdrive/data


Then make sure your other mongod instance is not running, which would mean it is currently holding the port open, or similar.

Code Snippets

sudo chown -R mongodb:mongodb /media/newdrive/data

Context

StackExchange Database Administrators Q#23438, answer score: 5

Revisions (0)

No revisions yet.