MongoDB not starting on Ubuntu 17.10 - node.js

So I'm trying to install MongoDB for use with Node.js, but every time I try to run mongod --dbpath ~/Documents/nodejs-basics/nodetest1/data I get this error:
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] MongoDB starting : pid=4873 port=27017 dbpath=/home/brandon1407/Documents/nodejs-basics/nodetest1/data/ 64-bit host=xubuntu01
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] db version v3.6.0
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] git version: a57d8e71e6998a2d0afde7edc11bd23e5661c915
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] modules: none
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] build environment:
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] distmod: ubuntu1604
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] distarch: x86_64
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] target_arch: x86_64
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/home/brandon1407/Documents/nodejs-basics/nodetest1/data/" } }
2017-12-09T19:26:55.943-0800 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] now exiting
2017-12-09T19:26:55.943-0800 I CONTROL [initandlisten] shutting down with code:48
I had previously received a similar error about the /data/db directory missing so I created that directory but got the above error instead. Read through multiple questions asked here, but haven' found anything. It all works just fine on Windows 8.1 though which is strange.

Related

MongoDB Doesn't Run

I just installed mongoDB with AUR in arch and tried to run it just like;
mongod
but it always says;
2019-05-11T17:07:09.608+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] MongoDB starting : pid=27076 port=27017 dbpath=/data/db 64-bit host=manjaro
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] db version v4.0.9
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] git version: fc525e2d9b0e4bceff5c2201457e564362909765
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1b 26 Feb 2019
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] modules: none
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] build environment:
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] distmod: ubuntu1804
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] distarch: x86_64
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-05-11T17:07:09.611+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db", mmapv1: { smallFiles: true } } }
2019-05-11T17:07:09.611+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2019-05-11T17:07:09.612+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-05-11T17:07:09.612+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-05-11T17:07:09.612+0000 I CONTROL [initandlisten] now exiting
2019-05-11T17:07:09.612+0000 I CONTROL [initandlisten] shutting down with code:100
What should I do?
2019-05-11T17:07:09.611+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
You're missing a path to it's db directory. Create one in your root folder using:
sudo mkdir /data/db
sudo recommended here, sometimes mongoDB can run in to permission issues otherwise.

Cannot start mongo db

I have did the mongodb installation process mentioned in the following link https://docs.mongodb.com/manual/installation/ but i can't start the mongodb this is my log kindly tell me the possible way to start mongo db
C:\>"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"
2017-03-12T12:42:55.378+0530 I CONTROL [initandlisten] MongoDB starting : pid=5
400 port=27017 dbpath=C:\data\db\ 64-bit host=vimals
2017-03-12T12:42:55.379+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/W
indows Server 2008 R2
2017-03-12T12:42:55.380+0530 I CONTROL [initandlisten] db version v3.4.2
2017-03-12T12:42:55.381+0530 I CONTROL [initandlisten] git version: 3f76e40c105
fc223b3e5aac3e20dcd026b83b38b
2017-03-12T12:42:55.382+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL
1.0.1u-fips 22 Sep 2016
2017-03-12T12:42:55.382+0530 I CONTROL [initandlisten] allocator: tcmalloc
2017-03-12T12:42:55.383+0530 I CONTROL [initandlisten] modules: enterprise
2017-03-12T12:42:55.384+0530 I CONTROL [initandlisten] build environment:
2017-03-12T12:42:55.385+0530 I CONTROL [initandlisten] distmod: windows-64
2017-03-12T12:42:55.385+0530 I CONTROL [initandlisten] distarch: x86_64
2017-03-12T12:42:55.386+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-03-12T12:42:55.387+0530 I CONTROL [initandlisten] options: {}
2017-03-12T12:42:55.389+0530 I STORAGE [initandlisten] exception in initAndList
en: 98 Unable to create/open lock file: C:\data\db\mongod.lock The process canno
t access the file because it is being used by another process.. Is a mongod inst
ance already running?, terminating
2017-03-12T12:42:55.390+0530 I NETWORK [initandlisten] shutdown: going to close
listening sockets...
2017-03-12T12:42:55.390+0530 I NETWORK [initandlisten] shutdown: going to flush
diaglog...
2017-03-12T12:42:55.391+0530 I CONTROL [initandlisten] now exiting
2017-03-12T12:42:55.392+0530 I CONTROL [initandlisten] shutting down with code:
100
Looks as if your database file is locked by another process, did you try restarting the machine?
Just for notes.
In my case, after I create db with:
sudo mkdir -p /data/db
I also have to do this:
sudo chmod 777 /data/db
Then the environment is up for running by entering:
mongod
to enter the mongoldb shell.

Using Solus Linux to install MongoDB. I set path variable but Mongod shuts down at launch

I am installing MongoDB on Solus linux using the instructions here:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-linux/
I have Mongo DB in a folder named mongo on the desktop.
I used the following to "set the path variable" per the instructions ( I'm not sure if I did this correctly )
export PATH=Desktop/mongo/bin:$PATH
In the terminal I went to:
admin#solus ~ $
I then typed mongod
The result is the following error:
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] MongoDB starting : pid=5052 port=27017 dbpath=/data/db 64-bit host=solus
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] db version v3.4.1
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] allocator: tcmalloc
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] modules: none
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] build environment:
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] distarch: x86_64
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] target_arch: x86_64
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] options: {}
2016-12-21T02:53:55.328-0800 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-12-21T02:53:55.328-0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2016-12-21T02:53:55.328-0800 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] now exiting
2016-12-21T02:53:55.328-0800 I CONTROL [initandlisten] shutting down with code:100
It says it can't find the data/db folder, but I've tried placing it in the mongo directory as well as the home directory.
Try using the dbpath from the users home directory. I created /data/db in my home directory, so below is the command I use.
mongod --dbpath /home/user/data/db

Cannot start MongoDB

This my 5th time installing MongoDB where it either only connects the first time or intermittently. The fifth time I tried with Homebrew.
Here are the two different errors I've gotten:
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] MongoDB starting : pid=40879 port=27017 dbpath=/data/db 64-bit host=CA17PCG8WP
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] db version v3.2.10
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zg 14 July 2015
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] allocator: system
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] modules: none
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] build environment:
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] distarch: x86_64
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-10-18T01:19:21.746-0700 I CONTROL [initandlisten] options: {}
2016-10-18T01:19:21.747-0700 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-10-18T01:19:21.747-0700 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=9G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-10-18T01:19:22.124-0700 I CONTROL [initandlisten]
2016-10-18T01:19:22.124-0700 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2016-10-18T01:19:22.125-0700 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-10-18T01:19:22.125-0700 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-10-18T01:19:22.125-0700 I NETWORK [initandlisten] waiting for connections on port 27017
2016-10-18T01:19:22.126-0700 W NETWORK [HostnameCanonicalizationWorker] Failed to obtain address information for hostname CA17PCG8WP: nodename nor servname provided, or not known
And:
2016-10-21T18:31:30.436-0700 I CONTROL [initandlisten] MongoDB starting : pid=2982 port=27017 dbpath=/data/db 64-bit host=CA17PCG8WP
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] db version v3.2.10
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zg 14 July 2015
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] allocator: system
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] modules: none
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] build environment:
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] distarch: x86_64
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-10-21T18:31:30.437-0700 I CONTROL [initandlisten] options: {}
2016-10-21T18:31:30.437-0700 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-10-21T18:31:30.437-0700 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=9G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-10-21T18:31:30.439-0700 E STORAGE [initandlisten] WiredTiger (13) [1477099890:439019][2982:0x7fff73c85300], file:WiredTiger.wt, connection: /data/db/WiredTiger.turtle: handle-open: open: Permission denied
2016-10-21T18:31:30.446-0700 I - [initandlisten] Assertion: 28595:13: Permission denied
2016-10-21T18:31:30.447-0700 I STORAGE [initandlisten] exception in initAndListen: 28595 13: Permission denied, terminating
2016-10-21T18:31:30.447-0700 I CONTROL [initandlisten] dbexit: rc: 100
Can someone please either a) tell me what I'm doing wrong or b) tell me how to uninstall MongoDB and then install it properly?
EDIT:
I believe I already had read & write access to /data/db/, but I used chmod anyway. Here's proof I have access (right?):
whoami
this_user
ls -ld /data/
drwxr-xr-x 3 this_user wheel 102 Oct 21 18:18 /data/
ls -ld /data/db/
drwxr-xr-x 16 this_user wheel 544 Oct 21 18:31 /data/db/
And here's the error I'm still getting:
mongod
2016-10-22T12:10:26.301-0700 I CONTROL [initandlisten] MongoDB starting : pid=5912 port=27017 dbpath=/data/db 64-bit host=CA17PCG8WP
2016-10-22T12:10:26.301-0700 I CONTROL [initandlisten] db version v3.2.10
2016-10-22T12:10:26.301-0700 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-22T12:10:26.302-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zg 14 July 2015
2016-10-22T12:10:26.302-0700 I CONTROL [initandlisten] allocator: system
2016-10-22T12:10:26.302-0700 I CONTROL [initandlisten] modules: none
2016-10-22T12:10:26.302-0700 I CONTROL [initandlisten] build environment:
2016-10-22T12:10:26.302-0700 I CONTROL [initandlisten] distarch: x86_64
2016-10-22T12:10:26.302-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-10-22T12:10:26.302-0700 I CONTROL [initandlisten] options: {}
2016-10-22T12:10:26.302-0700 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-10-22T12:10:26.302-0700 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=9G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-10-22T12:10:26.304-0700 E STORAGE [initandlisten] WiredTiger (13) [1477163426:304329][5912:0x7fff73c85300], file:WiredTiger.wt, connection: /data/db/WiredTiger.turtle: handle-open: open: Permission denied
2016-10-22T12:10:26.311-0700 I - [initandlisten] Assertion: 28595:13: Permission denied
2016-10-22T12:10:26.311-0700 I STORAGE [initandlisten] exception in initAndListen: 28595 13: Permission denied, terminating
2016-10-22T12:10:26.311-0700 I CONTROL [initandlisten] dbexit: rc: 100
It's giving you a 'permission denied' error on the data directory. Make sure you've got the right permissions there. Either chown the directory (and parent) to your current user / group or adjust permissions with chmod to make sure you have both read and write access to /data/db.
EDIT
I forgot that on some systems, mongodb runs as the user mongodb. Check /etc/passwd to see if there is a mongodb user, and if so make sure that user or group has write permissions.
OK, I finally figured it out. Some combination of these two fixes did it:
mongod HostnameCanonicalizationWorker error on OS X
Mongodb wont start

Error run mongod

when run command "mongod" in terminal. Cant access localhost:28017
my log
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] MongoDB starting : pid=12891 port=27017 dbpath=/data/db 64-bit host=lucaspc
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] db version v3.2.7
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] allocator: tcmalloc
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] modules: none
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] build environment:
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] distmod: ubuntu1404
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] distarch: x86_64
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] target_arch: x86_64
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] options: {}
2016-07-08T11:31:15.531-0300 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2016-07-08T11:31:15.531-0300 E NETWORK [initandlisten] addr already in use
2016-07-08T11:31:15.531-0300 E STORAGE [initandlisten] Failed to set up sockets during startup.
2016-07-08T11:31:15.531-0300 I CONTROL [initandlisten] dbexit: rc: 48
There is already a process using the interface and port you want to use. You can find out what process that is using
sudo netstat -lpn | grep 27017
Then use
sudo kill <pid>
to stop it
Address already in use for socket: 0.0.0.0:27017
You already have an instance running on port 27017, change the port or kill the existing process.

Resources