Fatal Assertion in MongoDB - mongodb

I have been uninstalling and reinstalling Mongodb on Ubuntu 14.04 following the official documentation for few times now. However, I keep getting this:
2015-12-22T12:46:32.091+0000 I CONTROL ***** SERVER RESTARTED *****
2015-12-22T12:46:32.096+0000 I CONTROL [initandlisten] MongoDB starting : pid=7039 port=27017 dbpath=/var/lib/mongodb 64-bit host=server-04
2015-12-22T12:46:32.096+0000 I CONTROL [initandlisten] db version v3.0.8
2015-12-22T12:46:32.096+0000 I CONTROL [initandlisten] git version: 83d8cc25e00e42856924d84e220fbe4a839e605d
2015-12-22T12:46:32.096+0000 I CONTROL [initandlisten] build info: Linux ip-10-187-89-126 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-12-22T12:46:32.096+0000 I CONTROL [initandlisten] allocator: tcmalloc
2015-12-22T12:46:32.096+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, syste$
2015-12-22T12:46:32.120+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2015-12-22T12:46:32.120+0000 I - [initandlisten] Fatal Assertion 28578
2015-12-22T12:46:32.120+0000 I - [initandlisten]
***aborting after fassert() failure
I am expecting to see: [initandlisten] waiting for connections on port <port> but can't see it. What can cause it?

remove everything from /tmp directory
sudo rm -rf /tmp/mongod*.sock
change the ownership of the db path and log path
chown -R mongodb:mongodb /var/lib/mongodb/
chown -R mongodb:mongodb /var/log/monogdb/
restart your mongo
sudo service mongod start

Related

Mongodb on macOS Catalina still using /data/db, despite new path specified in config file

On mac Catalina, /data/db is no longer writeable, and so the new brew install of mongodb-community uses a new path, /usr/local/var/mongodb. I upgraded, following these instructions:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/#install-mongodb-community-edition
and to confirm:
$ ls -al /usr/local/bin/mongod
lrwxr-xr-x 1 rkohr admin 44 Feb 5 10:49 /usr/local/bin/mongod -> ../Cellar/mongodb-community/4.2.3/bin/mongod
$ cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
But it seems that the config is being ignored since it is still trying to use the old /data/db path:
$ mongod
2020-02-05T10:55:42.210-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] MongoDB starting : pid=1518 port=27017 dbpath=/data/db 64-bit host=Robs-MacBook-Pro.local
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] allocator: system
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] modules: none
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] build environment:
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] options: {}
2020-02-05T10:55:42.216-0500 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied
2020-02-05T10:55:42.216-0500 F - [initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 683
2020-02-05T10:55:42.216-0500 F - [initandlisten]
***aborting after fassert() failure
#RobKohr To make it works, you have to run following command:
mongod --config /usr/local/etc/mongod.conf
See: https://docs.mongodb.com/manual/reference/configuration-options/#use-the-configuration-file

Mongo Shell from local is not getting connected to mongo server running in docker

I ran mongo server in docker and the logs came up just fine.
2019-04-12T10:39:51.334+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=8a03346e57d7
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] db version v3.2.22
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] modules: none
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] build environment:
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] distmod: rhel70
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] distarch: x86_64
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] options: { net: { port: 27017 }, processManagement: { pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/data/db" } }
2019-04-12T10:39:51.339+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,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),verbose=(recovery_progress),
2019-04-12T10:39:51.389+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-04-12T10:39:51.389+0000 I CONTROL [initandlisten]
2019-04-12T10:39:51.406+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2019-04-12T10:39:51.406+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-04-12T10:39:51.406+0000 I NETWORK [initandlisten] waiting for connections on port 27017
But, while connecting the mongodb server from local shell, the connection is getting timedout.
~/mongodb/bin/mongo --host 172.17.0.2
MongoDB shell version v3.6.11
connecting to: mongodb://172.17.0.2:27017/?gssapiServiceName=mongodb
2019-04-12T16:04:45.750+0530 W NETWORK [thread1] Failed to connect to 172.17.0.2:27017 after 5000ms milliseconds, giving up.
2019-04-12T16:04:45.753+0530 E QUERY [thread1] Error: couldn't connect to server 172.17.0.2:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:263:13
#(connect):1:6
exception: connect failed
where 172.17.0.2 is the IP obtained by running docker inspect <container-id
I was able to connect mongo shell with in the docker using the command docker exec --it <container-id> bash.
Here's the Docker file for refrence.
RUN echo -e "\
[mongodb]\n\
name=MongoDB Repository\n\
baseurl=https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/3.2/x86_64/\n\
gpgcheck=0\n\
enabled=1\n" >> /etc/yum.repos.d/mongodb.repo
# Install mongodb
RUN yum update -y && yum install -y mongodb-org
# Set up directory requirements
RUN mkdir -p /data/db /var/log/mongodb /var/run/mongodb
VOLUME ["/data/db", "/var/log/mongodb"]
# Expose port 27017 from the container to the host
EXPOSE 27017
# Start mongodb
ENTRYPOINT ["/usr/bin/mongod"]
CMD ["--port", "27017", "--dbpath", "/data/db", "--pidfilepath", "/var/run/mongodb/mongod.pid"]
Let me know if I am missing something.
Using MacOS

[Error]MongoDB not starting

Im trying to start mongodb it returns me this error, i already tried to repair mongo reinstall using brew uninstalling and installing again and nothing happens.
This problem occurred after Mac OS High Sierra Update.
Here's the error:
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] MongoDB starting : pid=11915 port=27017 dbpath=/data/db 64-bit host=Luizs-MacBook-Pro.local
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] db version v3.4.9
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2l 25 May 2017
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] allocator: system
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] modules: none
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] build environment:
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] distarch: x86_64
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] target_arch: x86_64
2017-09-27T20:55:54.834-0300 I CONTROL [initandlisten] options: {}
2017-09-27T20:55:54.835-0300 E NETWORK [initandlisten] listen(): bind() failed No such file or directory for socket: /tmp/mongodb-27017.sock
2017-09-27T20:55:54.836-0300 E NETWORK [initandlisten] Failed to set up sockets during startup.
2017-09-27T20:55:54.836-0300 E STORAGE [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2017-09-27T20:55:54.836-0300 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-09-27T20:55:54.836-0300 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-09-27T20:55:54.836-0300 I CONTROL [initandlisten] now exiting
2017-09-27T20:55:54.836-0300 I CONTROL [initandlisten] shutting down with code:48
What i already tried:
mongod --dbpath /data/db --repair
rm -rf /tmp/mongodb-27017.sock
rm -rf /data/db
Try :
1: sudo mongod --dbpath /data/db
Replace /data/db by your mongodb location same as :
sudo mongod --dbpath /var/lib/mongodb
2: Check Port Status
sudo netstat -tlnp | grep 27017
netstat -an |grep 27017
3: Kill ID
sudo killall mongod
sudo killall -15 mongod
sudo kill < Process ID >

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/*.

MongoDB centos7 unable to run with a non standard port as a service

I installed mongodb on a fresh centos 7
I run sudo service mongod start without any problem
When I change the port in /etc/mongod.conf and I restart the mongod service I get the following error
From /var/log/mongodb/mongod.log
2014-11-11T07:38:29.495+0000 [initandlisten] MongoDB starting : pid=12401 port=27022 dbpath=/var/lib/mongo 64-bit host=awscm001
2014-11-11T07:38:29.495+0000 [initandlisten] db version v2.6.5
2014-11-11T07:38:29.495+0000 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-11-11T07:38:29.495+0000 [initandlisten] build info: Linux build8.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-11-11T07:38:29.495+0000 [initandlisten] allocator: tcmalloc
2014-11-11T07:38:29.495+0000 [initandlisten] options: { config: "/etc/mongod.conf", net: { port: 27021 }, 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-11-11T07:38:29.497+0000 [initandlisten] journal dir=/var/lib/mongo/journal
2014-11-11T07:38:29.497+0000 [initandlisten] recover : no journal files present, no recovery needed
2014-11-11T07:38:29.679+0000 [initandlisten] ERROR: listen(): bind() failed errno:13 Permission denied for socket: 0.0.0.0:27022
2014-11-11T07:38:29.680+0000 [initandlisten] now exiting
2014-11-11T07:38:29.680+0000 [initandlisten] dbexit:
2014-11-11T07:38:29.680+0000 [initandlisten] shutdown: going to close listening sockets...
2014-11-11T07:38:29.680+0000 [initandlisten] shutdown: going to flush diaglog...
I am able though to run with a different port with the following command
sudo mongod -f /etc/mongod.conf
When I run as a service user mongod runs mongodb
When I run from command line root runs mongodb
How can run the mongodb service with a different port?
By the way I succeeded on centos 6.5
Thanks
for those people having problem like me.. my fix is allow mongodb custom port on semanage
semanage port --list | grep mongo
mongod_port_t tcp 27017-27019, 28017-28019
as you can see, only 27017-27019, 28017-28019 is allowed.
in order to add a custom port for mongodb
semanage port -a -t mongod_port_t -p tcp 21010
you now have added the custom port
semanage port --list | grep mongo
mongod_port_t tcp 21010, 27017-27019, 28017-28019
make sure to restart mongodb