MongoDB - shutting down with code:100 - node.js

I've been trying to set up MongoDB on my Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-22-generic x86_64) VPS and I've been running into a few problems. I am running as a user on my server that has root access but not using the root account itself.
I started to notice the problem when I was executing db.createUser() on the admin database so I could add other users and I was getting this error:
not authorized to execute command
So I then proceeded to uninstall and install again using the tutorial as provided on the website: https://docs.mongodb.com/v3.2/tutorial/install-mongodb-on-ubuntu/
Now when I'm on stage 2 Verify that MongoDB has started successfully on the Run MongoDB Community Edition section, that is I look at my output from the file /var/log/mongodb/mongod.log, I get the following:
2017-04-14T14:23:09.309+0200 I CONTROL [main] ***** SERVER RESTARTED *****
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] MongoDB starting : pid=9691 port=27017 dbpath=/var/lib/mongodb 64-bit host=vps338741
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] db version v3.4.3
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] git version: f07437fb5a6cca07c10bafa78365456eb1d6d5e1
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] allocator: tcmalloc
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] modules: none
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] build environment:
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] distmod: ubuntu1604
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] distarch: x86_64
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] target_arch: x86_64
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten]
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=464M,session_max=20000,eviction=(threads_min=4,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),
2017-04-14T14:23:09.366+0200 E STORAGE [initandlisten] WiredTiger error (2) [1492172589:366629][9691:0x7f1755946cc0], file:WiredTiger.wt, connection: /var/lib/mongodb/WiredTiger.wt: handle-open: open: No such file or directory
2017-04-14T14:23:09.367+0200 I - [initandlisten] Assertion: 28595:2: No such file or directory src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
2017-04-14T14:23:09.367+0200 I STORAGE [initandlisten] exception in initAndListen: 28595 2: No such file or directory, terminating
2017-04-14T14:23:09.367+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-04-14T14:23:09.367+0200 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2017-04-14T14:23:09.367+0200 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-04-14T14:23:09.367+0200 I CONTROL [initandlisten] now exiting
2017-04-14T14:23:09.367+0200 I CONTROL [initandlisten] shutting down with code:100
I've looked around and it is not the same error as found here, because that is to do with the fact there isn't an /data/db folder which I have. From that log I can see it is something to do with this line:
2017-04-14T14:23:09.366+0200 E STORAGE [initandlisten] WiredTiger error (2) [1492172589:366629][9691:0x7f1755946cc0], file:WiredTiger.wt, connection: /var/lib/mongodb/WiredTiger.wt: handle-open: open: No such file or directory
Which is true, when I go to /var/lib/mongodb and do ls -l it results with:
drwxr-xr-x 2 mongodb mongodb 4096 Apr 14 14:10 journal
-rw-r--r-- 1 mongodb mongodb 0 Apr 14 14:02 mongod.lock
-rw-r--r-- 1 mongodb mongodb 0 Apr 14 14:10 WiredTiger
-rw-r--r-- 1 mongodb mongodb 21 Apr 14 14:10 WiredTiger.lock
-rw-r--r-- 1 mongodb mongodb 1004 Apr 14 14:10 WiredTiger.turtle
But I don't know if I should manually create that file as not seen this problem elsewhere. I made sure that mongodb user has permissions on these files too as stated in the answer to this question, but still no luck.
I'm really at a loss as to what to do, any help would be very appreciated as this is my like fifth attempt at getting it working!
Thanks!

If you created the mkdir -p /data/db maybe there is a chance that you must start your server with the following command : sudo mongod
macOS/OSX : https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

try :
sudo service mongod start ;
then run the mongodb with:
mongo

This is a known bug in MongoDB, check the report
Your problem is not that files are missing in general, it's that they go missing when you restart after a clean shutdown. Your problem is not related to the /data/db directory but more to WiredTiger.wt file that is missing after a restart.
Oct 1 20:00:44 alpha mongod.27017[1074]: [initandlisten] WiredTiger
(2) [1443729644:306783][1074:0x7fdba8fd4bc0], file:WiredTiger.wt,
connection: /data/db/WiredTiger.wt: No such file or directory
The bug report talks about the same thing.
Try:
I would suggest try and disable WiredTiger in the config file.
MongoDB Config Options
WiredTiger
UPDATE: To disable WiredTiger you have to change the storage.engine option in your mongo config file, by default mongod uses WiredTiger but you can also use InMemory LINK

Make a directory
sudo mkdir /data/db
Provide access to the directory
sudo chown -R $USER /data/db
Then run
mongod
If you get port already in use the stop mongod, it might be running in the background
sudo service mongod stop
If the last line is
waiting for connections on port 27017
then the mongod is working

This command helped me:
mongod --dbpath /data/db --repair

for me the 'answer' was to execute the following command (since service mongod start and just mongod failed)
sudo mongod --fork --port 27017 --replSet admin --logpath /data/log/mongo.log
I did not need to turn off wired tiger

Docker container:
In my case, I was using a docker container running
mongodb:
image: 'bitnami/mongodb:latest'
user: root
command: "chown -R $USER /bitnami/mongodb"
volumes:
- '/var/www/mongodb_data:/bitnami'
environment:
- MONGODB_USERNAME=bn_parse
- MONGODB_PASSWORD=3yfQexfqcc
- MONGODB_DATABASE=bitnami_parse
I migrated the docker host to other VPS/VM (aws is too expensive).
I added temporarily the command "chown -R $USER /bitnami/mongodb" to change the owner of that folder /bitnami/mongodb. It worked.

sudo mdkir data/db
sudo service mongod stop
sudo mongod
mongosh
this fixed it for me on ubuntu 22.04 after hours and hours of hunting down solutions

Related

When running Mongodb got NonExistentPath: Data directory /data/db not found., terminating

The error generated when executed sudo mongod executed
2018-09-13T20:56:08.259+0530 I CONTROL [initandlisten] MongoDB starting : pid=3419 port=27017 dbpath=/data/db 64-bit host=admin
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] db version v3.6.7
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] git version: 2628472127e9f1826e02c665c1d93880a204075e
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] allocator:
tcmalloc
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] modules: none
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] build environment:
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] distarch: x86_64
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] options: {}
2018-09-13T20:56:08.312+0530 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] now exiting
2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] shutting down with code:100
I'm a beginner in MEAN stack application development and stuck with this error. Please help me. Thanks in advance
This solution solves my problem
Make a directory as
sudo mkdir -p /data/db
That will make a directory named as db and than try to start with commands
sudo mongod
If you get another error or problem with starting mongod, You may find problem as
Failed to set up listener: SocketException: Address already in use
If you find that another error than you have to kill the running process of mongod by typing to terminal as
ps ax | grep mongod
Find the mongod running port and kill the process.
sudo kill ps_number
Another way is to make a specefic port when starting mongod as
sudo mongod --port 27018
cd ~
mongod
All you need to do above step to prevent the error.
Don't run the mongod at different local disk location.
eg. My computer has two local disk:
1.) Local disk E: - drive : (When I run mongod on E: drive or on targeting any location on E local disk then I will get error message as)
Admin#DESKTOP-CJBHIMO MINGW64 /e/Full-Stack-Developer
$ mongod
...
{"t":{"$date":"2021-03-22T11:33:26.675+05:30"},"s":"E", "c":"STORAGE", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"NonExistentPath: Data directory E:\\data\\db\\ not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file."}}
...
{"t":{"$date":"2021-03-22T11:33:26.677+05:30"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
{"error":"NonExistentPath: Data directory E:\data\db\ not found.
2.) Local disk C: - drive : (When I run mongod on C: drive, which I recommend to use, cause, we mostly do the installation of mongodb on C: drive as per the instruction. If in your case, you installed on another drive, then run mongod on that drive's folder on hyper. Eg. as I run mongod on C:
Admin#DESKTOP-CJBHIMO MINGW64 ~/Desktop
$ mongod
{"t":{"$date":"2021-03-22T00:52:23.840-07:00"},"s":"I", "c":"STORAGE", "id":22270, "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"C:/data/db/","storageEngine":"wiredTiger"}}
...
{"t":{"$date":"2021-03-22T11:34:59.300+05:30"},"s":"I", "c":"NETWORK", "id":23016, "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}
"msg":"Storage engine to use detected by data files","attr":{"dbpath":"C:/data/db/","storageEngine":"wiredTiger"}}
This whole example is based on windows 10. It runs successful on root directory cause it is inside C: disk. To get inside root directory :
Just run
sudo mkdir -p /data/db
On the machine running the mongoDB server
Before doing any of the other solutions see my answer here.
Maybe your conf file is being rejected due to outdated options or format changes.

MongoDB data/db not found

I do gave this path for data/db
/usr/local/Cellar/mongodb/3.2.6/data/db
The following step was made in order to create a bound to mongodb folder
sudo mongod --directoryperdb --dbpath /usr/local/Cellar/mongodb/3.2.6/data/db --logpath /usr/local/Cellar/mongodb/3.2.6/log/mongodb.log --logappend -rest
When initialize sudo mongod in terminal the following error appears:
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] MongoDB starting : pid=8107 port=27017 dbpath=/data/db 64-bit host=iMac-Krystyna-2.local
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] db version v3.2.6
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] allocator: system
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] modules: none
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] build environment:
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] distarch: x86_64
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] options: {}
2016-06-08T14:45:06.970+0200 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] dbexit: rc: 100
Can you please explain what is wrong and maybe show some common practice in order to work correctly with MongoDB?
You need to create this directory as root
Either you need to use sudo , e.g. sudo mkdir -p /data/db
Or you need to do su - to become superuser, and then create the directory with mkdir -p /data/db
You can also give this command sudo mongod --dbpath=/var/lib/mongodb.
Open another terminal and run your mongod.
It worked for me.
try: sudo service mongod start
I had the same issue. This worked for me:
sudo mongod --dbpath ~/data/db
In my case, an incorrect conf file caused Mongo to use default settings (i.e. using /data/db as the storage path. Because /data/db doesn't exist, it complains.
Possible sources of incorrect config include:
(1) Unquoted strings. E.g. storage.dbPath should be "some/path"
(2) Incorrect bindIp. It seems an array of IPs is not supported.
So my fix was simply to use quoted strings in those places:
storage:
dbPath: "/some/path"
net:
bindIp: "127.0.0.1"
Note: My "/some/path" has permissions drwxr-xr-x (755) and is owned by mongodb/mongodb. And it works.
MongoDB try to find data/db folder under root directory of your system. try to create folder under /data/db.

Mongodb not starting on ubuntu 14.04

I am trying to install and start mongodb locally:
I go through these steps (as shown in history):
1819 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
1820 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
1821 sudo apt-get update
1822 sudo apt-get install -y mongodb-org
1823 sudo service mongod start
But I get the following error log in /var/log/mongodb/mongodb.log
2016-01-05T22:51:21.869+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] MongoDB starting : pid=5394 port=27017 dbpath=/var/lib/mongodb 64-bit host=ip-172-31-45-129
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] db version v3.2.0
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] git version: 45d947729a0315accb6d4f15a6b06be6d9c19fe7
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] modules: none
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] build environment:
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] distarch: x86_64
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongodb.log" } }
2016-01-05T22:51:21.895+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-01-05T22:51:21.895+0000 I - [initandlisten] Fatal Assertion 28578
2016-01-05T22:51:21.895+0000 I - [initandlisten]
***aborting after fassert() failure
I previously had a mongodb installed which worked fine but stopped me from connecting to it after some changes I made to other services that were using mongodb. So I tried to remove that instance of mongodb and tried reinstalling, after which I am facing this issue.
I also try to look for the file: /tmp/mongodb-27017.sock but it does not exist on my system.
I had the same problem after installing MongoDB the same way, also got the error message 'Failed to unlink socket file /tmp/mongodb-27017.sock...'.
After doing a bit more digging I realised that the installation hadn't created the path /data/db, so here's what I did:
create the full path (the flag -p creates parent folders if they don't exist)
sudo mkdir -p /data/db
recursively change ownership of the folder /data/db to mongodb
sudo chown -R mongodb:mongodb /data/db
edit: if you're planning on running different instances of mongodb from different project folders, you, and not mongodb, should be the owner of the contents of /data/db, otherwise it will give you an error of the type exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock
Remove the temporary socket file
sudo rm /tmp/mongodb-27017.sock
Initialise the mongod service
sudo service mongod start
After this it was running smoothly in my system. I could start it or stop it and it would not give me any more errors.
Hope this helps :)

Cannot Run Mongo as Service

My Environment
CentOS (I'm not sure the exact version since it's on iPage's VPS server.)
My Goal
Start mongod as a service:
sudo service mongod start
(Once I get this working, I want to get mongod to start when the server reboots via chkconfig:
sudo /sbin/chkconfig --level 345 mongod on
)
What Happens
It comes back with [FAILED] and I get this message in my logs:
2014-08-27T03:17:40.126+0000 ***** SERVER RESTARTED *****
2014-08-27T03:17:40.132+0000 [initandlisten] MongoDB starting : pid=3950 port=27017 dbpath=/var/lib/mongo 64-bit host=162-144-108-42.ipage.com
2014-08-27T03:17:40.132+0000 [initandlisten] db version v2.6.4
2014-08-27T03:17:40.132+0000 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-08-27T03:17:40.132+0000 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-08-27T03:17:40.132+0000 [initandlisten] allocator: tcmalloc
2014-08-27T03:17:40.132+0000 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-08-27T03:17:40.133+0000 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2014-08-27T03:17:40.133+0000 [initandlisten] dbexit:
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to close listening sockets...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to flush diaglog...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to close sockets...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: waiting for fs preallocator...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: lock for final commit...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: final commit...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: closing all files...
2014-08-27T03:17:40.133+0000 [initandlisten] closeAllFiles() finished
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: removing fs lock...
2014-08-27T03:17:40.133+0000 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
2014-08-27T03:17:40.133+0000 [initandlisten] dbexit: really exiting now
What I've Tried:
Grepping the current processes doesn't find any mongod process:
ps aux | grep mongod
Removing the mongod.lock file doesn't help:
sudo rm mongod.lock
Changing the owner of the database doesn't help:
sudo chown -R my_username /var/lib/mongo
This looks like a permissions issue:
2014-08-27T03:17:40.133+0000 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Look if the user which mongo is running has the permission to write on that folder, assuming you're already removed the .lock file.
You are using chown with your username, but it seems that user must be mongo, not your username. Check the ownwer when the service tries to startup.
I was able to verify running sudo chown -R mongodb /var/lib/mongo works on my CentOS system. My /etc/init.d/mongod script runs the mongod process as user mongod. When I did a sudo chown -R root /var/lib/mongo I received the same Permission denied error, but when I set the directory permissions as mongod (sudo chown -R mongodb /var/lib/mongo) running sudo service mongod start works

Mongo daemon doesn't run by service mongod start

Recently I installed mongodb package by reading this page (http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/).
I use docker and ubuntu 14.04 image to deploy my server.
The problems start by first running the mongod service:
# service mongod start
I got the following:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mongod restart
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop mongod ; start mongod. The restart(8) utility is also available.
I've tried this:
# start mongod
But got no output.
Next I wanted to check the log, but there is no log!
ls /var/log/mongodb -a #empty
Ok, next I tried to start mongo shell:
# mongo
2014-08-12T17:42:44.431+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-08-12T17:42:44.432+0000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
Ok, after googling I checked (applaied) all answers from Mongodb in linux server and https://wiki.archlinux.org/index.php/MongoDB (section Troubleshooting), but still get nothing.
The mongo shell works only when I run mongod directly in background:
mongod --verbose &
[DataFileSync] BackgroundJob starting: DataFileSync
shardKeyTest passed
isInRangeTest passed
shardObjTest passed
[initandlisten] MongoDB starting : pid=451 port=27017 dbpath=/data/db 64-bit host=a9d816faea4c
[initandlisten] db version v2.6.4
[initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
[initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
[initandlisten] allocator: tcmalloc
[initandlisten] options: { systemLog: { verbosity: 1 } }
[initandlisten] flushing directory /data/db
[initandlisten] journal dir=/data/db/journal
[initandlisten] recover : no journal files present, no recovery needed
[initandlisten] flushing directory /data/db/journal
[initandlisten] flushing directory /data/db/journal
[initandlisten] opening db: local
[initandlisten] enter repairDatabases (to check pdfile version #)
[initandlisten] local
[initandlisten] done repairDatabases
[initandlisten] opening db: admin
[initandlisten] query admin.system.roles planSummary: EOF ntoreturn:0 ntoskip:0 keyUpdates:0 numYields:0 locks(micros) W:119 r:106 nreturned:0 reslen:20 0ms
[ClientCursorMonitor] BackgroundJob starting: ClientCursorMonitor
[PeriodicTaskRunner] BackgroundJob starting: PeriodicTaskRunner
[TTLMonitor] BackgroundJob starting: TTLMonitor
[initandlisten] fd limit hard:1048576 soft:524288 max conn: 419430
[IndexRebuilder] BackgroundJob starting: IndexRebuilder
[IndexRebuilder] opening db: local
[initandlisten] create collection local.startup_log { size: 10485760, capped: true }
[initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0 reslen:75 0ms
[initandlisten] insert local.startup_log ninserted:1 keyUpdates:0 numYields:0 0ms
[initandlisten] waiting for connections on port 27017
[IndexRebuilder] checking complete2014-08-12T17:48:29.837+0000 [DataFileSync] BackgroundJob starting: DataFileSync
Now I have the following:
/var/lib/mongodb (mongodb:mongodb) empty
/var/log/mongodb (mongodb:nogroup) empty
/data/db (mongo:nogroup) #useless
# mongod.conf
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongod.log
logappend=true
port = 27017
bind_ip = 0.0.0.0
...
What's going on here? I'm absolutely confused (
Docker containers typically does not have a full init system and interaction with upstart will not work inside a docker container. (In theory it is possible, but it defeats the purposes of having light weight stack)
What this implies is that you start a docker container, it would run a single command "/usr/bin/mongod"
Example of running mongodb inside a docker container:
https://docs.docker.com/samples/library/mongo/
Also since you are running installation commands using an interactive docker container, your shell interpreter is the single command as far as docker is considered. Once in interactive session, you can run mongod in background (As you did) and start mongo client session.
Another way would be to run these instructions as part of Dockerfile. You can refer to mongodb example.
You might also want to consider some of the official mongo db images already published in docker hub:
https://registry.hub.docker.com/_/mongo/

Resources