I set dbpath
in mongodb config file:
#dbpath=/var/lib/mongodb
dbpath=~/data/db
Then try start mongodb but got error:
ERROR: dbpath (~/data/db) does not exist.
Allthough I can check existance of ~/data/db
easy:
# cd ~/data/db
user@server:~/data/db# pwd
/root/data/db
When I run it...
# mongod --dbpath ~/data/db
... got output:
Tue Oct 15 05:05:49.040 [initandlisten] MongoDB starting : pid=3786 port=27017 dbpath=/root/data/db 64-bit host=callzone2
Tue Oct 15 05:05:49.040 [initandlisten] db version v2.4.6
Tue Oct 15 05:05:49.040 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Tue Oct 15 05:05:49.041 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Tue Oct 15 05:05:49.041 [initandlisten] allocator: tcmalloc
Tue Oct 15 05:05:49.041 [initandlisten] options: { dbpath: "/root/data/db" }
Tue Oct 15 05:05:49.044 [initandlisten] exception in initAndListen std::exception: locale::facet::_S_create_c_locale name not valid, terminating
Tue Oct 15 05:05:49.044 dbexit:
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: going to close listening sockets...
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: going to flush diaglog...
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: going to close sockets...
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: waiting for fs preallocator...
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: lock for final commit...
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: final commit...
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: closing all files...
Tue Oct 15 05:05:49.044 [initandlisten] closeAllFiles() finished
Tue Oct 15 05:05:49.044 [initandlisten] shutdown: removing fs lock...
Tue Oct 15 05:05:49.044 dbexit: really exiting now
And client shows that server not started:
# mongo
MongoDB shell version: 2.4.6
connecting to: test
Tue Oct 15 05:08:22.139 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
When I run in this way...
# sudo service mongodb restart
... got output in mongo log file:
*********************************************************************
ERROR: dbpath (~/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Tue Oct 15 05:10:39.311 dbexit:
Tue Oct 15 05:10:39.311 [initandlisten] shutdown: going to close listening sockets...
Tue Oct 15 05:10:39.311 [initandlisten] shutdown: going to flush diaglog...
Tue Oct 15 05:10:39.311 [initandlisten] shutdown: going to close sockets...
Tue Oct 15 05:10:39.311 [initandlisten] shutdown: waiting for fs preallocator...
Tue Oct 15 05:10:39.311 [initandlisten] shutdown: lock for final commit...
Tue Oct 15 05:10:39.311 [initandlisten] shutdown: final commit...
Tue Oct 15 05:10:39.311 [initandlisten] shutdown: closing all files...
Tue Oct 15 05:10:39.311 [initandlisten] closeAllFiles() finished
Tue Oct 15 05:10:39.311 dbexit: really exiting now
So cannot change dbpath
.
My ubuntu version:
# uname -a
Linux hostName 3.2.0-23-virtual #36-Ubuntu SMP Tue Apr 10 22:29:03 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux