Why isn't my mongodb install working correctly? - mongodb

I am trying to install MEAN stack components. So I tried to install mongodb. The packages from the repository installed correctly but running it seems to have issues.
Post installation I tried:
sudo systemctl enable mongodb
which is resulted in:
● mongodb.service
Loaded: masked (/dev/null)
Active: failed (Result: exit-code) since Thu 2016-10-27 15:22:36 EDT; 17min ago
Main PID: 22947 (code=exited, status=14)
Hint: Some lines were ellipsized, use -l to show in full.
and then I tried: sudo systemctl enable mongodb
Executing /usr/sbin/update-rc.d mongodb defaults
Executing /usr/sbin/update-rc.d mongodb enable
Failed to execute operation: Operation not supported
Any idea why it is not starting? I can't figure it out. I am using Xubuntu 15.04.
Log File says:
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] MongoDB starting : pid=26138 port=27017 dbpath=/var/lib/mongodb 64-bit host=System-Product-Name
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] db version v3.2.10
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] allocator: tcmalloc
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] modules: none
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] build environment:
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] distmod: ubuntu1404
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] distarch: x86_64
2016-10-27T15:47:02.747-0400 I CONTROL [initandlisten] target_arch: x86_64
2016-10-27T15:47:02.747-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" } }
2016-10-27T15:47:02.764-0400 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-10-27T15:47:02.883-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten]
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten]
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten]
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-10-27T15:47:02.883-0400 I CONTROL [initandlisten]
2016-10-27T15:47:02.884-0400 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2016-10-27T15:47:02.884-0400 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-10-27T15:47:02.918-0400 I NETWORK [initandlisten] waiting for connections on port 27017
2016-10-27T15:48:23.409-0400 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends
2016-10-27T15:48:23.409-0400 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2016-10-27T15:48:23.413-0400 I CONTROL [signalProcessingThread] now exiting
2016-10-27T15:48:23.413-0400 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2016-10-27T15:48:23.413-0400 I NETWORK [signalProcessingThread] closing listening socket: 6
2016-10-27T15:48:23.413-0400 I NETWORK [signalProcessingThread] closing listening socket: 7
2016-10-27T15:48:23.413-0400 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2016-10-27T15:48:23.413-0400 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog...
2016-10-27T15:48:23.413-0400 I NETWORK [signalProcessingThread] shutdown: going to close sockets...
2016-10-27T15:48:23.413-0400 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2016-10-27T15:48:23.511-0400 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2016-10-27T15:48:23.512-0400 I CONTROL [signalProcessingThread] dbexit: rc: 0

Related

Error while restarting Mongodb

I tried to restart MongoDB on my server, but I got an error. The error log:
2018-05-24T12:22:08.308+0200 I CONTROL [main] ***** SERVER RESTARTED *****
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] MongoDB starting : pid=13662 port=27017 dbpath=/var/lib/mongodb 64-bit host=Challenger
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] db version v3.6.5
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] allocator: tcmalloc
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] modules: none
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] build environment:
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] distmod: ubuntu1604
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] distarch: x86_64
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] target_arch: x86_64
2018-05-24T12:22:08.422+0200 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb",$
2018-05-24T12:22:08.424+0200 I - [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-05-24T12:22:08.424+0200 I STORAGE [initandlisten]
2018-05-24T12:22:08.424+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-05-24T12:22:08.424+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-05-24T12:22:08.424+0200 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=256M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),cache_cursors=false,log=(enabled=true,ar$
2018-05-24T12:22:09.379+0200 E STORAGE [initandlisten] WiredTiger error (1) [1527157329:379309][13662:0x7f6ea10839c0], file:WiredTiger.wt, connection: /var/lib/mongodb/WiredTiger.wt: handle-open: open: Operation not permitted
2018-05-24T12:22:09.380+0200 E - [initandlisten] Assertion: 28595:1: Operation not permitted src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 416
2018-05-24T12:22:09.402+0200 I STORAGE [initandlisten] exception in initAndListen: Location28595: 1: Operation not permitted, terminating
2018-05-24T12:22:09.402+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-05-24T12:22:09.402+0200 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2018-05-24T12:22:09.402+0200 I CONTROL [initandlisten] now exiting
2018-05-24T12:22:09.402+0200 I CONTROL [initandlisten] shutting down with code:100
can anyone tell me what the bug is?

Mongod unclean shutdown

new to this ..so my MONGOD unexpectedly shutdown and i can't seem to repair it ..this is what i see when i try to start up ./mongod
**2018-04-21T19:59:06.237+0000 ** WARNING: --rest is specified without --httpinterface,
2018-04-21T19:59:06.238+0000 ** enabling http interface
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
2018-04-21T19:59:06.241+0000 [initandlisten] MongoDB starting : pid=2848 port=27017 dbpath=data 64-bit host=omarr11-webdevbootcamp-5900192
2018-04-21T19:59:06.241+0000 [initandlisten] db version v2.6.12
2018-04-21T19:59:06.241+0000 [initandlisten] git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a
2018-04-21T19:59:06.241+0000 [initandlisten] build info: Linux build5.ny.cbi.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
2018-04-21T19:59:06.241+0000 [initandlisten] allocator: tcmalloc
2018-04-21T19:59:06.241+0000 [initandlisten] options: { net: { bindIp: "0.0.0.0", http: { RESTInterfaceEnabled: true, enabled: true } }, storage: { dbPath: "data", journal: { enabled: false } } }
**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
2018-04-21T19:59:06.241+0000 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
2018-04-21T19:59:06.241+0000 [initandlisten] dbexit:
2018-04-21T19:59:06.241+0000 [initandlisten] shutdown: going to close listening sockets...
2018-04-21T19:59:06.241+0000 [initandlisten] shutdown: going to flush diaglog...
2018-04-21T19:59:06.241+0000 [initandlisten] shutdown: going to close sockets...
2018-04-21T19:59:06.241+0000 [initandlisten] shutdown: waiting for fs preallocator...
2018-04-21T19:59:06.242+0000 [initandlisten] shutdown: closing all files...
2018-04-21T19:59:06.242+0000 [initandlisten] closeAllFiles() finished
2018-04-21T19:59:06.242+0000 [initandlisten] dbexit: really exiting now**
can someone help me repair this please?
You should look for the lock file (mongod.lock) in the data folder of
the mongodb and you need to delete it and try to start again.
In case you have some data corruption issue you can try repair option https://docs.mongodb.com/manual/tutorial/recover-data-following-unexpected-shutdown/ . But in case it is just normal course of learning deleting the mongod.lock file should start the mongod process again...

Trouble Starting MongoDB (Mac) - Code: 100

I installed MongoDB via Homebrew and seem to be having some trouble starting when I run the mongod command. I have tried setting a up the data/db directory correctly and viewed a few other answers on stackoverflow, but haven't been able to figure this out. Here is what I keep getting (sorry I am new to this):
2017-01-02T23:45:53.444-0500 I CONTROL [initandlisten] MongoDB starting : pid=1419 port=27017 dbpath=/data/db 64-bit host=Johns-MacBook-Pro-3.local
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] db version v3.4.0
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] git version: f4240c60f005be757399042dc12f6addbc3170c1
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] allocator: system
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] modules: none
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] build environment:
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] distarch: x86_64
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] target_arch: x86_64
2017-01-02T23:45:53.445-0500 I CONTROL [initandlisten] options: {}
2017-01-02T23:45:53.446-0500 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,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),
2017-01-02T23:45:53.447-0500 E STORAGE [initandlisten] WiredTiger error (2) [1483418753:447985][1419:0x7fffe84c03c0], file:WiredTiger.wt, connection: /data/db/WiredTiger.wt: handle-open: open: No such file or directory
2017-01-02T23:45:53.457-0500 I - [initandlisten] Assertion: 28595:2: No such file or directory src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
2017-01-02T23:45:53.458-0500 I STORAGE [initandlisten] exception in initAndListen: 28595 2: No such file or directory, terminating
2017-01-02T23:45:53.458-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-01-02T23:45:53.458-0500 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2017-01-02T23:45:53.458-0500 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-01-02T23:45:53.458-0500 I CONTROL [initandlisten] now exiting
2017-01-02T23:45:53.458-0500 I CONTROL [initandlisten] shutting down with code:100
Just create directory - /data/db/ on system hdd
This worked for me: sudo mongod --dbpath ~/data/db

Unable to start mongod service

I installed mongodb using the information in this link. However, when I user the service mongod start command I get the following error. Can someone help me troubleshoot?
[Piyush#localhost ~]$ service mongod start
/etc/init.d/mongod: line 54: ulimit: open files: cannot modify limit: Operation not permitted
/etc/init.d/mongod: line 56: ulimit: max user processes: cannot modify limit: Operation not permitted
Starting mongod: runuser: using restricted shell /bin/false
runuser: cannot set groups: Operation not permitted
[FAILED]
[Piyush#localhost ~]$ sudo service mongod start
[sudo] password for Piyush:
Starting mongod: [FAILED]
I tried using --repair command. I get the following output for that:
[Piyush#localhost ~]$ sudo mongod --repair
2014-09-24T00:05:06.089-0400 [initandlisten] MongoDB starting : pid=2807 port=27017 dbpath=/data/db 64-bit host=localhost.localdomain
2014-09-24T00:05:06.089-0400 [initandlisten] db version v2.6.4
2014-09-24T00:05:06.089-0400 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-09-24T00:05:06.089-0400 [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-09-24T00:05:06.089-0400 [initandlisten] allocator: tcmalloc
2014-09-24T00:05:06.090-0400 [initandlisten] options: { repair: true }
2014-09-24T00:05:06.106-0400 [initandlisten] finished checking dbs
2014-09-24T00:05:06.106-0400 [initandlisten] dbexit:
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: going to close listening sockets...
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: going to flush diaglog...
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: going to close sockets...
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: waiting for fs preallocator...
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: closing all files...
2014-09-24T00:05:06.106-0400 [initandlisten] closeAllFiles() finished
2014-09-24T00:05:06.107-0400 [initandlisten] shutdown: removing fs lock...
2014-09-24T00:05:06.107-0400 [initandlisten] dbexit: really exiting now
[EDIT 1]_____________________________________________________________________________
In the log file I see:
[root#localhost ~]# cat /var/log/mongodb/mongod.log.2014-09-24T16-00-32
2014-09-24T11:54:23.636-0400 ***** SERVER RESTARTED *****
2014-09-24T11:54:23.665-0400 [initandlisten] MongoDB starting : pid=3004 port=27017 dbpath=/var/lib/mongo 64-bit host=localhost.localdomain
2014-09-24T11:54:23.665-0400 [initandlisten] db version v2.6.4
2014-09-24T11:54:23.665-0400 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-09-24T11:54:23.665-0400 [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-09-24T11:54:23.665-0400 [initandlisten] allocator: tcmalloc
2014-09-24T11:54:23.665-0400 [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-09-24T11:54:23.680-0400 [initandlisten] journal dir=/var/lib/mongo/journal
2014-09-24T11:54:23.680-0400 [initandlisten] recover : no journal files present, no recovery needed
2014-09-24T11:54:23.680-0400 [initandlisten]
2014-09-24T11:54:23.680-0400 [initandlisten] ERROR: Insufficient free space for journal files
2014-09-24T11:54:23.680-0400 [initandlisten] Please make at least 3379MB available in /var/lib/mongo/journal or use --smallfiles
2014-09-24T11:54:23.680-0400 [initandlisten]
2014-09-24T11:54:23.681-0400 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2014-09-24T11:54:23.681-0400 [initandlisten] dbexit:
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: going to close listening sockets...
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: going to flush diaglog...
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: going to close sockets...
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: waiting for fs preallocator...
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: lock for final commit...
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: final commit...
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: closing all files...
2014-09-24T11:54:23.681-0400 [initandlisten] closeAllFiles() finished
2014-09-24T11:54:23.681-0400 [initandlisten] journalCleanup...
2014-09-24T11:54:23.681-0400 [initandlisten] removeJournalFiles
2014-09-24T11:54:23.684-0400 [initandlisten] shutdown: removing fs lock...
2014-09-24T11:54:23.684-0400 [initandlisten] dbexit: really exiting now
The --repair flag is meant to repair a corrupt database, not to solve any permission problems
You obviously didn't follow the instructions of the link too closely, because he did start the service as root. ;) sudo may only allow certain parts of the init scripts to be executed with superuser rights by the user calling it. Others may (though they shouldn't) silently fail. As for init scripts at least: sudo != being root.
To fix the problem: sudo chown mongod -R /var/log/mongodb/ && sudo chown mongod -R /var/run/mongodb && sudo chown mongod -R /var/lib/mongo Then become root and try to run mongo manually with sudo -u mongod mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log. In case there are other problems left, mongodb will tell you. Fix those until starting mongodb manually as written above works flawless, then use the initscript from that point on.
Edit: corrected the --dbpath option as per comment

mongodb: Is there any way of stoping mongod from trying to set a lock on mongod.lock?

Because of the size of the mongodb database I'm trying to build and because I needed a filesystem that can handle parallel writes, I moved it on a cluster that has lustreFS, which fulfills these needs.
The problem is that I can't start mongod, so I can't connect anything to the database, because mongod can't get a lock on mongod.lock. I don't have root or sudo permissions but this does not seem to be the problem here because permissions are not mentioned, as you can see:
[user#host mongo]$ ./mongod --dbpath=path-to-db
2014-07-28T20:29:58.600+0300 [initandlisten] MongoDB starting : pid=54974 port=27017 dbpath=path-to-db 64-bit host=hostname
2014-07-28T20:29:58.600+0300 [initandlisten]
2014-07-28T20:29:58.600+0300 [initandlisten] ** WARNING: /proc/sys/vm/zone_reclaim_mode is 1
2014-07-28T20:29:58.600+0300 [initandlisten] ** We suggest setting it to 0
2014-07-28T20:29:58.600+0300 [initandlisten] ** http://www.kernel.org/doc/Documentation/sysctl/vm.txt
2014-07-28T20:29:58.600+0300 [initandlisten] db version v2.6.3
2014-07-28T20:29:58.601+0300 [initandlisten] git version: 255f67a66f9603c59380b2a389e386910bbb52cb
2014-07-28T20:29:58.601+0300 [initandlisten] build info: Linux build12.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-07-28T20:29:58.601+0300 [initandlisten] allocator: tcmalloc
2014-07-28T20:29:58.601+0300 [initandlisten] options: { storage: { dbPath: "path-to-db" } }
2014-07-28T20:29:58.614+0300 [initandlisten] exception in initAndListen: 10310 Unable to lock file: path-to-db/mongod.lock. Is a mongod instance already running?, terminating
2014-07-28T20:29:58.615+0300 [initandlisten] dbexit:
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: going to close listening sockets...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: going to flush diaglog...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: going to close sockets...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: waiting for fs preallocator...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: lock for final commit...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: final commit...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: closing all files...
2014-07-28T20:29:58.615+0300 [initandlisten] closeAllFiles() finished
2014-07-28T20:29:58.615+0300 [initandlisten] dbexit: really exiting now
Could you please tell me if there's any way around that lock? And no, there weren't any other mongod instances running.
Solution: File locking was being disabled by cluster admins. After file locking was enabled, mongod started and accepted connections as it should.