MongoDB can not start by the command `service mongod start` - mongodb

when i run the command sudo service mongod start the MongoDB cannot start and when i run the service mongod status it shows it has not been started, and the log shows:
2018-07-05T14:32:03.595+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] MongoDB starting : pid=15656 port=27017 dbpath=/var/lib/mongodb 64-bit host=iZbp1ik57sceo226yjpivxZ
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] db version v4.0.0-rc7
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] git version: 7230641bb09b1ceb04c3135cf83a5044c4838906
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] allocator: tcmalloc
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] modules: none
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] build environment:
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] distmod: ubuntu1604
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] distarch: x86_64
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-07-05T14:32:03.605+0800 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "0.0.0.0", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2018-07-05T14:32:03.605+0800 I STORAGE [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-07-05T14:32:03.605+0800 I STORAGE [initandlisten]
2018-07-05T14:32:03.605+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-07-05T14:32:03.605+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-07-05T14:32:03.605+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=488M,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),statistics_log=(wait=0),verbose=(recovery_progress),
2018-07-05T14:32:04.204+0800 E STORAGE [initandlisten] WiredTiger error (13) [1530772324:204155][15656:0x7fb5cb734a00], wiredtiger_open: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1530772324:204155][15656:0x7fb5cb734a00], wiredtiger_open: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied
2018-07-05T14:32:04.204+0800 E STORAGE [initandlisten] WiredTiger error (13) [1530772324:204458][15656:0x7fb5cb734a00], wiredtiger_open: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1530772324:204458][15656:0x7fb5cb734a00], wiredtiger_open: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied
2018-07-05T14:32:04.204+0800 E STORAGE [initandlisten] WiredTiger error (13) [1530772324:204610][15656:0x7fb5cb734a00], wiredtiger_open: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied Raw: [1530772324:204610][15656:0x7fb5cb734a00], wiredtiger_open: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied
2018-07-05T14:32:04.204+0800 F STORAGE [initandlisten] Failed to start up WiredTiger under any compatibility version.
2018-07-05T14:32:04.204+0800 F STORAGE [initandlisten] 13: Permission denied
2018-07-05T14:32:04.204+0800 F - [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 194
2018-07-05T14:32:04.204+0800 F - [initandlisten]
***aborting after fassert() failure
but when i tried mongod --auth -f /etc/mongod.conf the server can start and when visit the log file it shows that:
2018-07-05T14:35:34.228+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2018-07-05T14:35:34.239+0800 I CONTROL [initandlisten] MongoDB starting : pid=15665 port=27017 dbpath=/var/lib/mongodb 64-bit host=iZbp1ik57sceo226yjpivxZ
2018-07-05T14:35:34.239+0800 I CONTROL [initandlisten] db version v4.0.0-rc7
2018-07-05T14:35:34.239+0800 I CONTROL [initandlisten] git version: 7230641bb09b1ceb04c3135cf83a5044c4838906
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] allocator: tcmalloc
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] modules: none
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] build environment:
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] distmod: ubuntu1604
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] distarch: x86_64
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-07-05T14:35:34.240+0800 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "0.0.0.0", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2018-07-05T14:35:34.240+0800 I STORAGE [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-07-05T14:35:34.240+0800 I STORAGE [initandlisten]
2018-07-05T14:35:34.240+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-07-05T14:35:34.240+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-07-05T14:35:34.240+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=488M,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),statistics_log=(wait=0),verbose=(recovery_progress),
2018-07-05T14:35:35.005+0800 I STORAGE [initandlisten] WiredTiger message [1530772535:5560][15665:0x7f0ab9512a00], txn-recover: Main recovery loop: starting at 18/8960
2018-07-05T14:35:35.113+0800 I STORAGE [initandlisten] WiredTiger message [1530772535:113878][15665:0x7f0ab9512a00], txn-recover: Recovering log 18 through 19
2018-07-05T14:35:35.179+0800 I STORAGE [initandlisten] WiredTiger message [1530772535:179582][15665:0x7f0ab9512a00], txn-recover: Recovering log 19 through 19
2018-07-05T14:35:35.248+0800 I STORAGE [initandlisten] WiredTiger message [1530772535:248647][15665:0x7f0ab9512a00], txn-recover: Set global recovery timestamp: 0
2018-07-05T14:35:35.283+0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-07-05T14:35:35.311+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-07-05T14:35:35.311+0800 I CONTROL [initandlisten]
2018-07-05T14:35:35.312+0800 I CONTROL [initandlisten]
2018-07-05T14:35:35.312+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-07-05T14:35:35.312+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-07-05T14:35:35.312+0800 I CONTROL [initandlisten]
2018-07-05T14:35:35.312+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 7856 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2018-07-05T14:35:35.312+0800 I CONTROL [initandlisten]
2018-07-05T14:35:35.336+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2018-07-05T14:35:35.337+0800 I NETWORK [initandlisten] waiting for connections on port 27017
and the whole config file is as below:
# mongod.conf
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
So, what is the matter with it? why the first method can not run it but the second method can start it?

According to #Markus W Mahlberg, and after run these command, the problem has been solved.
[sudo] chown mongodb.mongodb -R /var/lib/mongodb

If you ran the command mongod as root on the server while testing your configuration file, as in:
$ mongod -f /etc/mongod.conf
The mongo server will generate the mongo.lock file and the WiredTiger.lock files and further files in the mongodb folder with root:root ownership as in:
-rw------- 1 mongodb mongodb 36864 Nov 25 12:03 index-95--8062076833940689665.wt
-rw------- 1 mongodb mongodb 45056 Nov 25 12:03 index-96--8062076833940689665.wt
-rw------- 1 mongodb mongodb 36864 Nov 25 12:03 index-99--8062076833940689665.wt
drwx------ 2 mongodb mongodb 4096 Nov 25 15:23 journal/
-rw------- 1 mongodb mongodb 45056 Nov 25 15:32 _mdb_catalog.wt
-rw------- 1 root root 0 Nov 25 15:32 mongod.lock
-rw------- 1 mongodb mongodb 36864 Nov 25 15:32 sizeStorer.wt
-rw------- 1 mongodb mongodb 114 Oct 17 17:41 storage.bson
-rw------- 1 mongodb mongodb 44 Oct 17 17:41 WiredTiger
-rw------- 1 mongodb mongodb 4096 Nov 25 15:32 WiredTigerLAS.wt
-rw------- 1 root root 21 Nov 25 15:22 WiredTiger.lock
-rw------- 1 mongodb mongodb 1201 Nov 25 15:32 WiredTiger.turtle
-rw------- 1 mongodb mongodb 188416 Nov 25 15:32 WiredTiger.wt
The service is most likely configured to run mongod with the mongodb user. which will not have permission to remove, or overwrite the WiredTiger.lock nor the mongod.lock or any other file that were created when mongod was running using the root user. In the case above the /var/lib/mongodb/WiredTiger.turtle
The solution is to reset the ownership of all the files in the folder in the case above the /var/lib/mongodb/ folder to the mongodb user:
$ sudo chown -R mongodb:mongodb /var/lib/mongodb/
That should solve the issue.

On a mac OS
Browse to the data directory you configured when installing mongodb. For ex: data/db where the mongod.lock and WiredTiger.lock are present
sudo chown -R {username}:{groupname} /data/db
Make sure you have stopped any mongo processes
run 'mongod' command
You should now see the prompt which is now ready to accept connections.

Related

Mongodb ERROR: child process failed, exited with error number 51

mongodb was closed by some reason. system shutdown abnormally.
when i try to restart mongodb use:
mongod -f /usr/local/mongodb/etc/mongo.conf
got
about to fork child process, waiting until server is ready for connections.
forked process: 28402
ERROR: child process failed, exited with error number 51
To see additional information in this output, start without the "--fork" option.
mongodb.log:
2019-02-19T13:22:24.105+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] MongoDB starting : pid=28131 port=27017 dbpath=/usr/local/mongodb/data/mongodata 64-bit host=nginx.xchs
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] db version v3.6.2
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] allocator: tcmalloc
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] modules: none
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] build environment:
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] distmod: rhel62
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] distarch: x86_64
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] target_arch: x86_64
2019-02-19T13:22:24.112+0800 I CONTROL [initandlisten] options: { config: "/usr/local/mongodb/etc/mongo.conf", net: { bindIp: "0.0.0.0" }, processManagement: { fork: true }, storage: { dbPath: "/usr/local/mongodb/data/mongodata" }, systemLog: { destination: "file", logAppend: true, path: "/usr/local/mongodb/data/log/mongolog/mongodb.log" } }
2019-02-19T13:22:24.112+0800 W - [initandlisten] Detected unclean shutdown - /usr/local/mongodb/data/mongodata/mongod.lock is not empty.
2019-02-19T13:22:24.113+0800 I - [initandlisten] Detected data files in /usr/local/mongodb/data/mongodata created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-02-19T13:22:24.113+0800 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
2019-02-19T13:22:24.113+0800 I STORAGE [initandlisten]
2019-02-19T13:22:24.113+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-02-19T13:22:24.113+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-02-19T13:22:24.113+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3424M,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),statistics_log=(wait=0),verbose=(recovery_progress),
2019-02-19T13:22:24.602+0800 E STORAGE [initandlisten] WiredTiger error (0) [1550553744:602025][28131:0x7f41a84cea80], file:WiredTiger.wt, WT_CURSOR.next: read checksum error for 24576B block at offset 1671168: block header checksum of 3727800471 doesn't match expected checksum of 605632
2019-02-19T13:22:24.602+0800 E STORAGE [initandlisten] WiredTiger error (0) [1550553744:602085][28131:0x7f41a84cea80], file:WiredTiger.wt, WT_CURSOR.next: WiredTiger.wt: encountered an illegal file format or internal value: (__wt_block_read_off, 227)
2019-02-19T13:22:24.602+0800 E STORAGE [initandlisten] WiredTiger error (-31804) [1550553744:602097][28131:0x7f41a84cea80], file:WiredTiger.wt, WT_CURSOR.next: the process must exit and restart: WT_PANIC: WiredTiger library panic
2019-02-19T13:22:24.602+0800 F - [initandlisten] Fatal Assertion 28558 at src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp 361
2019-02-19T13:22:24.602+0800 F - [initandlisten]
***aborting after fassert() failure
how to resolve this problem?
Open your config file in VIM or in a plain text editor,
got to this line:
storage:
dbPath: THE_PATH_TO_THE_DIRECTORY_YOU_STORE_YOUR_DB
for example:
/var/mongodb/db/mydb
Go to your terminal to confirm if the path under dbPath exists, type:
ls THE_PATH_TO_THE_DIRECTORY_YOU_STORE_YOUR_DB
for example for my case here:
ls /var/mongodb/db/mydb
If the result is directory does not exist, then just recreate it:
mkdir -p THE_PATH_TO_THE_DIRECTORY_YOU_STORE_YOUR_DB
for example:
mkdir -p /var/mongodb/db/mydb
If you found that the directory exists then it was corrupted during shutdown,as highlighted in the answere above.
Go to your terminal and run the following command:
mongod --dbpath /data/db --repair
Please Refer the above from the Mongo DB Offcial Docs
Please Try
mongod --repair --dbpath /path/to/data/db

Mongo won't start. Getting cryptic Assertion: 28595:13: Permission denied error

I tried to start up my computer's mongodb service and it wouldn't start. I spent over an hour trying to debug it during which time I tried many solutions. Trying all of them may have messed up my mongo install, but I tried reinstalling mongo to get a fresh start. That didn't work either. I now have the following error and cannot find anything on google about how to fix it.
2017-06-01T16:57:02.339-0400 I CONTROL [main] ***** SERVER RESTARTED *****
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] MongoDB starting : pid=15070 port=27017 dbpath=/var/lib/mongodb 64-bit host=moss-greenelab
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] db version v3.2.13
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] git version: 23899209cad60aaafe114f6aea6cb83025ff51bc
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] allocator: tcmalloc
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] modules: none
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] build environment:
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] distmod: ubuntu1604
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] distarch: x86_64
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] target_arch: x86_64
2017-06-01T16:57:02.343-0400 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-06-01T16:57:02.361-0400 I - [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-06-01T16:57:02.361-0400 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=18G,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-06-01T16:57:02.364-0400 E STORAGE [initandlisten] WiredTiger (13) [1496350622:364565][15070:0x7f80e0292c80], connection: /var/lib/mongodb/journal/WiredTigerPreplog.0000000002: file-remove: unlink: Permission denied
2017-06-01T16:57:02.383-0400 I - [initandlisten] Assertion: 28595:13: Permission denied
2017-06-01T16:57:02.383-0400 I STORAGE [initandlisten] exception in initAndListen: 28595 13: Permission denied, terminating
2017-06-01T16:57:02.383-0400 I CONTROL [initandlisten] dbexit: rc: 100
I'm running Ubuntu 16.04.
Here's the telling part of the log:
/var/lib/mongodb/journal/WiredTigerPreplog.0000000002: file-remove: unlink: Permission denied
So have a look at ls -la /var/lib/mongodb/journal and see what the permissions on those files are. I'm betting that those (an probably others) are not properly owned by the correct user, which is normally mongodb on Ubuntu.
Assuming you've got an issue with ownership there, you can just run chown -R mongodb:mongodb /var/lib/mongodb.
If that doesn't work, as a last resort you can always just wipe out your data directory (assuming you don't need your data!) by running rm -rf /var/lib/mongodb/*.

Mongo: data storage directory as read-only directory

I'm getting this error when I'm trying to start mongodb:
[initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /mnt/data/mng, terminating
I'm using centos 7.3 and I don't know if I can be an issue related with se_linux...
As you can see I'm set that mongo storage directory is on /mnt/data/mng. The problem seems to be related with some kind of permissions. I've took a look on there:
# ls -lha /mnt/data/
drwxr-xr-x. 3 root root 17 Jun 1 10:01 .
drwxr-xr-x. 3 root root 18 Jun 1 10:01 ..
drwxr-xr-x. 2 mongod mongod 6 Jun 1 10:01 mng
Here you can see the complete message:
I CONTROL [main] ***** SERVER RESTARTED *****
I CONTROL [initandlisten] MongoDB starting : pid=3373 port=30158 dbpath=/mnt/data/mng 64-bit host=localhost.localdomain
I CONTROL [initandlisten] db version v3.4.2
I CONTROL [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
I CONTROL [initandlisten] allocator: tcmalloc
I CONTROL [initandlisten] modules: none
I CONTROL [initandlisten] build environment:
I CONTROL [initandlisten] distmod: rhel70
I CONTROL [initandlisten] distarch: x86_64
I CONTROL [initandlisten] target_arch: x86_64
I CONTROL [initandlisten] options: { command: [ "run" ], config: "/etc/mongod.conf", net: { bindIp: "localhost", port: 30158 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, security: { authorization: "enabled" }, storage: { dbPath: "/mnt/data/mng", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
I STORAGE [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /mnt/data/mng, terminating
I NETWORK [initandlisten] shutdown: going to close listening sockets...
I NETWORK [initandlisten] shutdown: going to flush diaglog...
I CONTROL [initandlisten] now exiting
I CONTROL [initandlisten] shutting down with code:100

MongoDB Enterprise failing to start with Wired Tiger as service

I made the installation of WiredTiger, but find that I cannot start the DB using the standard:
sudo service mongod start
It seems when I look into the log file (tail /var/log/mongodb/mongod.log):
2016-08-01T14:48:12.029+0200 I CONTROL [main] ***** SERVER RESTARTED *****
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] MongoDB starting : pid=1238 port=27017 dbpath=/var/lib/mongodb 64-bit host=xxx
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] db version v3.2.8
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips 1 Mar 2016
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] allocator: tcmalloc
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] modules: enterprise
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] build environment:
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] distmod: ubuntu1604
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] distarch: x86_64
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-08-01T14:48:12.032+0200 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", engine: "wiredTiger", journ
al: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2016-08-01T14:48:12.052+0200 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /var/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already
running?, terminating
2016-08-01T14:48:12.052+0200 I CONTROL [initandlisten] dbexit: rc:
100
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
engine: wiredTiger
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
I have changed the permissions as follows on:
chmod -R 777 /var/log/mongodb
chown -R /var/log/mongodb
But nothing makes a difference. There is no service running. I can run from the command line:
mongod
which gives the following:
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] MongoDB starting : pid=5776 port=27017 dbpath=/data/db 64-bit host=brett
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] db version v3.2.8
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips 1 Mar 2016
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] allocator: tcmalloc
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] modules: enterprise
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] build environment:
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] distmod: ubuntu1604
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] distarch: x86_64
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-08-01T15:35:51.291+0200 I CONTROL [initandlisten] options: {}
2016-08-01T15:35:51.311+0200 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-08-01T15:35:51.311+0200 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=4G,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-08-01T15:35:51.722+0200 I CONTROL [initandlisten]
2016-08-01T15:35:51.722+0200 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-08-01T15:35:51.722+0200 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-08-01T15:35:51.722+0200 I CONTROL [initandlisten]
2016-08-01T15:35:51.722+0200 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-08-01T15:35:51.722+0200 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-08-01T15:35:51.722+0200 I CONTROL [initandlisten]
2016-08-01T15:35:51.722+0200 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-08-01T15:35:51.722+0200 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-08-01T15:35:51.723+0200 I NETWORK [initandlisten] waiting for connections on port 27017
But I cannot get mongod as a service! Trying permissions:
sudo chown -R mongodb:mongodb /var/lib/mongodb
or
sudo chown -R user:machine /var/lib/mongodb
or
sudo chown -R root:machine /var/lib/mongodb
If I run the following:
mongod --config /etc/mongod.conf
I can then connect to the DB with mongo
as follows:
MongoDB shell version: 3.2.8
connecting to: test
Server has startup warnings:
2016-08-09T19:46:31.583+0200 I CONTROL [initandlisten]
2016-08-09T19:46:31.583+0200 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-08-09T19:46:31.583+0200 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-08-09T19:46:31.583+0200 I CONTROL [initandlisten]
2016-08-09T19:46:31.583+0200 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-08-09T19:46:31.583+0200 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-08-09T19:46:31.583+0200 I CONTROL [initandlisten]
Here is the output from ls -la /var/lib/mongodb
total 216
drwxrwxrwx 4 xxx root 4096 Aug 19 12:37 .
drwxr-xr-x 78 root root 4096 Aug 9 15:05 ..
-rwxrwxrwx 1 xxx xxx 36864 Aug 10 11:22 collection-0--5694223804331577236.wt
drwxrwxrwx 2 xxx xxx 4096 Aug 10 11:22 diagnostic.data
-rwxrwxrwx 1 xxx xxx 36864 Aug 10 11:22 index-1--5694223804331577236.wt
drwxrwxrwx 2 xxx xxx 4096 Aug 9 19:46 journal
-rwxrwxrwx 1 xxx xxx 16384 Aug 10 11:22 _mdb_catalog.wt
-rwxrwxrwx 1 xxx xxx 36864 Aug 10 11:22 sizeStorer.wt
-rwxrwxrwx 1 xxx xxx 95 Aug 9 19:30 storage.bson
-rwxrwxrwx 1 xxx xxx 46 Aug 9 19:30 WiredTiger
-rwxrwxrwx 1 xxx xxx 4096 Aug 10 11:22 WiredTigerLAS.wt
-rwxrwxrwx 1 xxx xxx 21 Aug 9 19:30 WiredTiger.lock
-rwxrwxrwx 1 xxx xxx 918 Aug 10 11:22 WiredTiger.turtle
-rwxrwxrwx 1 xxx xxx 45056 Aug 10 11:22 WiredTiger.wt
I also tried removing the huge files as was suggested. But I can never find a way to get the service started.
Here is me running mongod:
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] MongoDB starting : pid=9030 port=27017 dbpath=/data/db 64-bit host=xxx
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] db version v3.2.8
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips 1 Mar 2016
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] allocator: tcmalloc
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] modules: enterprise
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] build environment:
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] distmod: ubuntu1604
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] distarch: x86_64
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-08-19T12:53:53.713+0200 I CONTROL [initandlisten] options: {}
2016-08-19T12:53:53.732+0200 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-08-19T12:53:53.733+0200 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2016-08-19T12:53:53.733+0200 I CONTROL [initandlisten] dbexit: rc: 100
here is:
ls -ld /data/db/
drwxr-xr-x 4 mongodb nogroup 4096 Aug 19 13:10 /data/db/
I can start mongo using
sudo mongod
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] MongoDB starting : pid=12360 port=27017 dbpath=/data/db 64-bit host=brett
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] db version v3.2.8
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips 1 Mar 2016
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] allocator: tcmalloc
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] modules: enterprise
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] build environment:
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] distmod: ubuntu1604
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] distarch: x86_64
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-08-19T13:13:47.117+0200 I CONTROL [initandlisten] options: {}
2016-08-19T13:13:47.137+0200 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-08-19T13:13:47.137+0200 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=4G,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-08-19T13:13:47.548+0200 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-08-19T13:13:47.548+0200 I CONTROL [initandlisten]
2016-08-19T13:13:47.549+0200 I CONTROL [initandlisten]
2016-08-19T13:13:47.549+0200 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-08-19T13:13:47.549+0200 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-08-19T13:13:47.549+0200 I CONTROL [initandlisten]
2016-08-19T13:13:47.549+0200 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-08-19T13:13:47.549+0200 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-08-19T13:13:47.549+0200 I CONTROL [initandlisten]
2016-08-19T13:13:47.549+0200 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-08-19T13:13:47.549+0200 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-08-19T13:13:47.550+0200 I NETWORK [initandlisten] waiting for connections on port 27017
But still no joy getting mongo as a service :(
Here is the /etc/init/mongod.conf
# Ubuntu upstart file at /etc/init/mongod.conf
# Recommended ulimit values for mongod or mongos
# See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
#
limit fsize unlimited unlimited
limit cpu unlimited unlimited
limit as unlimited unlimited
limit nofile 64000 64000
limit rss unlimited unlimited
limit nproc 64000 64000
kill timeout 300 # wait 300s between SIGTERM and SIGKILL.
pre-start script
DAEMONUSER=${DAEMONUSER:-mongodb}
if [ ! -d /var/lib/mongodb ]; then
mkdir -p /var/lib/mongodb && chown mongodb:mongodb /var/lib/mongodb
fi
if [ ! -d /var/log/mongodb ]; then
mkdir -p /var/log/mongodb && chown mongodb:mongodb /var/log/mongodb
fi
touch /var/run/mongodb.pid
chown $DAEMONUSER /var/run/mongodb.pid
end script
start on runlevel [2345]
stop on runlevel [06]
script
ENABLE_MONGOD="yes"
CONF=/etc/mongod.conf
DAEMON=/usr/bin/mongod
DAEMONUSER=${DAEMONUSER:-mongodb}
DAEMONGROUP=${DAEMONGROUP:-mongodb}
if [ -f /etc/default/mongod ]; then . /etc/default/mongod; fi
# Handle NUMA access to CPUs (SERVER-3574)
# This verifies the existence of numactl as well as testing that the command works
NUMACTL_ARGS="--interleave=all"
if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
then
NUMACTL="$(which numactl) -- $NUMACTL_ARGS"
DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"}
else
NUMACTL=""
DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"}
fi
if [ "x$ENABLE_MONGOD" = "xyes" ]
then
exec start-stop-daemon --start \
--chuid $DAEMONUSER:$DAEMONGROUP \
--pidfile /var/run/mongodb.pid \
--make-pidfile \
--exec $NUMACTL $DAEMON $DAEMON_OPTS
fi
end script
As others wrote... Error message points that problem is that process cannot create /var/lib/mongodb/mongod.lock
You need to understand that even you say (as root) 'service mongod start' (when you use sudo -command, command is executed as root), process (mongod) is started as user 'mongod'. So, that directory /var/lib/mongodb must be exist and be writable by userid mongod.
mkdir -p /var/lib/mongodb ; chown -R mongod: /var/lib/mongodb
sudo service mongod restart
(OR 'sudo -u mongod mongod -f /etc/mongod.conf')

PackStack fails with - Error: Unable to connect to mongodb server

Openstack - Kilo
OS - CentOS Linux release 7.2.1511 (Core)
Applying 10.xx.xxx.xx_mongodb.pp
Applying 10.xx.xxx.xx_redis.pp
10.xx.xxx.xx_mongodb.pp: [ ERROR ]
Applying Puppet manifests [ ERROR ]
ERROR : Error appeared during Puppet run: 10.xx.xxx.xx_mongodb.pp
Error: Unable to connect to mongodb server! (10.xx.xxx.xx:27017)
You will find full trace in log /var/tmp/packstack/20160101-065236-2OHqyr/manifests/10.xx.xxx.xx_mongodb.pp.log
Please check log file /var/tmp/packstack/20160101-065236-2OHqyr/openstack-setup.log for more information
Additional information:
* A new answerfile was created in: /root/packstack-answers-20160101-065237.txt
* Time synchronization installation was skipped. Please note that unsynchronized time on server instances might be problem for some OpenStack components.
* File /root/keystonerc_admin has been created on OpenStack client host 10.xx.xxx.xx. To use the command line tools you need to source the file.
* To access the OpenStack Dashboard browse to 10.xx.xxx.xx/dashboard .
Please, find your login credentials stored in the keystonerc_admin in your home directory.
* To use Nagios, browse to 10.xx.xxx.xx/nagios username: nagiosadmin, password: d11c096693bb44cd
mabgodb.log detail
2015-12-31T14:18:24.233-0500 [initandlisten] MongoDB starting : pid=34017 port=27017 dbpath=/var/lib/mongodb 64-bit host=vcswin01.samgpunb.symantec.com
2015-12-31T14:18:24.234-0500 [initandlisten]
2015-12-31T14:18:24.234-0500 [initandlisten] ** WARNING: You are running on a NUMA machine.
2015-12-31T14:18:24.234-0500 [initandlisten] ** We suggest launching mongod like this to avoid performance problems:
2015-12-31T14:18:24.234-0500 [initandlisten] ** numactl --interleave=all mongod [other options]
2015-12-31T14:18:24.234-0500 [initandlisten]
2015-12-31T14:18:24.234-0500 [initandlisten] db version v2.6.6
2015-12-31T14:18:24.234-0500 [initandlisten] git version: nogitversion
2015-12-31T14:18:24.234-0500 [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2015-12-31T14:18:24.235-0500 [initandlisten] build info: Linux c1bg.rdu2.centos.org 2.6.32-431.20.3.el6.x86_64 #1 SMP Thu Jun 19 21:14:45 UTC 2014 x86_64 BOOST_LIB_VERSION=1_53
2015-12-31T14:18:24.235-0500 [initandlisten] allocator: tcmalloc
2015-12-31T14:18:24.235-0500 [initandlisten] options: { command: [ "run" ], config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1", http: { enabled: false }, port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", path: "/var/log/mongodb/mongodb.log", quiet: true } }
2015-12-31T14:18:24.235-0500 [initandlisten]
2015-12-31T14:18:24.235-0500 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb is set to 4096KB
2015-12-31T14:18:24.235-0500 [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less
2015-12-31T14:18:24.235-0500 [initandlisten] ** http://dochub.mongodb.org/core/readahead
2015-12-31T14:18:24.236-0500 [initandlisten] journal dir=/var/lib/mongodb/journal
2015-12-31T14:18:24.237-0500 [initandlisten] recover : no journal files present, no recovery needed
2015-12-31T14:18:24.260-0500 [initandlisten] allocating new ns file /var/lib/mongodb/local.ns, filling with zeroes...
2015-12-31T14:18:24.293-0500 [FileAllocator] allocating new datafile /var/lib/mongodb/local.0, filling with zeroes...
2015-12-31T14:18:24.293-0500 [FileAllocator] creating directory /var/lib/mongodb/_tmp
2015-12-31T14:18:24.295-0500 [FileAllocator] done allocating datafile /var/lib/mongodb/local.0, size: 64MB, took 0 secs
2015-12-31T14:18:24.299-0500 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "id", ns: "local.startup_log" }
2015-12-31T14:18:24.299-0500 [initandlisten] added index to empty collection
2015-12-31T14:18:24.300-0500 [initandlisten] waiting for connections on port 27017
For now see "Hackery setting up RDO Kilo on CentOS 7.2 with Mongodb up and running as of 01/08/2016"
http://dbaxps.blogspot.com/2016/01/set-up-rdo-kilo-on-centos-72-with.html