MongoDB doesn't start - mongodb

A few days ago I decided to use mongodb for a project. but I still don't make it work.
If I'm try to start mongodb with the following command:
sudo mongod --config=/etc/mongod.conf
This is the result:
about to fork child process, waiting until server is ready for connections.
forked process: 4539
child process started successfully, parent exiting
this is my mongod.conf:
# mongod.conf
systemLog:
path: "/var/log/mongodb/mongod.log"
destination: file
timeStampFormat: iso8601-utc
logAppend: true
logRotate: reopen
net:
bindIp: 127.0.0.1
port: 27017
wireObjectCheck: true
serviceExecutor: adaptive
storage:
dbPath: "/home/juny/nodeBox/data/db"
processManagement:
fork: true
pidFilePath: "/run/mongod.pid"
security:
authorization: enabled
operationProfiling:
mode: slowOp
If I try to start mongod as service, the terminal display this:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-05-27 14:22:31 AST; 8s ago
Docs: https://docs.mongodb.org/manual
Process: 4861 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 4861 (code=exited, status=1/FAILURE)
May 27 14:22:31 LAPTOP-CJFC94N systemd[1]: Started MongoDB Database Server.
May 27 14:22:31 mongod[4861]: about to fork child process, waiting until server is ready for connections.
May 27 14:22:31 mongod[4861]: forked process: 4863
May 27 14:22:31 systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
May 27 14:22:31 systemd[1]: mongod.service: Unit entered failed state.
May 27 14:22:31 systemd[1]: mongod.service: Failed with result 'exit-code'.
And finally, this is a few lines on my log file:
2019-05-27T18:14:16.257Z I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-05-27T18:14:16.437Z I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-05-27T18:14:16.437Z I CONTROL [initandlisten]
2019-05-27T18:14:16.437Z I CONTROL [initandlisten]
2019-05-27T18:14:16.437Z I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-05-27T18:14:16.437Z I CONTROL [initandlisten] ** We suggest setting it to 'never'
2019-05-27T18:14:16.437Z I CONTROL [initandlisten]
2019-05-27T18:14:16.530Z I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/home/juny/nodeBox/data/db/diagnostic.data'
2019-05-27T18:14:16.531Z I EXECUTOR [initandlisten] No thread count configured for executor. Using number of cores / 2: 2
2019-05-27T18:14:16.531Z I EXECUTOR [worker-1] Started new database worker thread 1
2019-05-27T18:14:16.531Z I EXECUTOR [worker-2] Started new database worker thread 2
2019-05-27T18:14:16.531Z I NETWORK [initandlisten] waiting for connections on port 27017
2019-05-27T18:28:02.535Z I NETWORK [listener] connection accepted from 127.0.0.1:48610 #1 (1 connection now open)
2019-05-27T18:28:02.535Z I NETWORK [conn1] Error receiving request from client: ProtocolError: Client sent an HTTP request over a native MongoDB connection. Ending connection from 127.0.0.1:48610 (connection id: 1)
2019-05-27T18:28:02.535Z I NETWORK [worker-2] end connection 127.0.0.1:48610 (0 connections now open)
2019-05-27T18:28:02.585Z I NETWORK [listener] connection accepted from 127.0.0.1:48612 #2 (1 connection now open)
2019-05-27T18:28:02.585Z I NETWORK [conn2] Error receiving request from client: ProtocolError: Client sent an HTTP request over a native MongoDB connection. Ending connection from 127.0.0.1:48612 (connection id: 2)
2019-05-27T18:28:02.585Z I NETWORK [worker-1] end connection 127.0.0.1:48612 (0 connections now open)

Ok Ok, it works if I type the following command: mongo

Related

How to make mongodb listen on specific IP in Azure VM with Ubuntu 18.04?

I got the MongoDB (4.0.10) running on Azure VM with Ubuntu 18.04 using default localhost. Now, I want to add my IP address to bindIp in /etc/mongod.conf so that I can access the db from my machine. Based on document (also from this example), I just need to append it to bindIp line after a comma.
net:
port: 27017
bindIp: 127.0.0.1,70.123.39.234
ipv6: true
(Note, I added ipv6 based on my reading of the document, but it doesn't seem to have any effect).
However, it doesn't work for me because service fails to start. I got something like this:
$ sudo service mongod restart
$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2019-06-10 15:59:35 UTC; 2s ago
Docs: https://docs.mongodb.org/manual
Process: 8140 ExecStart=/usr/bin/mongod --auth --config /etc/mongod.conf (code=exited, status=48)
Main PID: 8140 (code=exited, status=48)
Jun 10 15:59:35 mllinux systemd[1]: Started MongoDB Database Server.
Jun 10 15:59:35 mllinux systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Jun 10 15:59:35 mllinux systemd[1]: mongod.service: Failed with result 'exit-code'.
I tried many ways like
bindIp: 127.0.0.1, 70.123.39.234
or
bindIp: "127.0.0.1,70.123.39.234"
or
bindIp: "127.0.0.1, 70.123.39.234"
I got the same error.
However if I use space instead of comma like
bindIp: 127.0.0.1 70.123.39.234
or
bindIp: "127.0.0.1 70.123.39.234"
Service seems to start ok because
$ sudo service mongod restart
$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-06-10 16:37:39 UTC; 3s ago
Docs: https://docs.mongodb.org/manual
Main PID: 14629 (mongod)
CGroup: /system.slice/mongod.service
└─14629 /usr/bin/mongod --auth --config /etc/mongod.conf
Jun 10 16:37:39 mllinux systemd[1]: Started MongoDB Database Server.
However, I still cannot connect to it from my laptop.
For testing, if I set
bindIp: 0.0.0.0
or
bindIpAll: true
Then, I can connect to it from my laptop.
What did I do wrong?
UPDATE: Appending db log
2019-06-10T02:52:27.682+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2019-06-10T02:52:27.684+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] MongoDB starting : pid=3757 port=27017 dbpath=/var/lib/mongodb 64-bit host=mllinux
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] db version v4.0.10
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] git version: c389e7f69f637f7a1ac3cc9fae843b635f20b766
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.0g 2 Nov 2017
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] modules: none
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] build environment:
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] distmod: ubuntu1804
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] distarch: x86_64
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,70.123.39.234", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, security: { authorizatio$2019-06-10T02:52:27.697+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] now exiting
2019-06-10T02:52:27.697+0000 I CONTROL [initandlisten] shutting down with code:48
2019-06-10T02:53:53.313+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2019-06-10T02:53:53.315+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] MongoDB starting : pid=3934 port=27017 dbpath=/var/lib/mongodb 64-bit host=mllinux
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] db version v4.0.10
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] git version: c389e7f69f637f7a1ac3cc9fae843b635f20b766
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.0g 2 Nov 2017
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] modules: none
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] build environment:
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] distmod: ubuntu1804
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] distarch: x86_64
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-06-10T02:53:53.324+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1 70.123.39.234", port: 27017 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, security: { authorizatio$2019-06-10T02:53:53.325+0000 I STORAGE [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-06-10T02:53:53.325+0000 I STORAGE [initandlisten]
2019-06-10T02:53:53.325+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-06-10T02:53:53.325+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-06-10T02:53:53.325+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1448M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=jou$2019-06-10T02:53:54.146+0000 I STORAGE [initandlisten] WiredTiger message [1560135234:146511][3934:0x7fe345319a40], txn-recover: Main recovery loop: starting at 2/6656 to 3/256
2019-06-10T02:53:54.249+0000 I STORAGE [initandlisten] WiredTiger message [1560135234:249632][3934:0x7fe345319a40], txn-recover: Recovering log 2 through 3
2019-06-10T02:53:54.317+0000 I STORAGE [initandlisten] WiredTiger message [1560135234:317186][3934:0x7fe345319a40], txn-recover: Recovering log 3 through 3
2019-06-10T02:53:54.366+0000 I STORAGE [initandlisten] WiredTiger message [1560135234:366900][3934:0x7fe345319a40], txn-recover: Set global recovery timestamp: 0
2019-06-10T02:53:54.485+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-06-10T02:53:54.504+0000 I CONTROL [initandlisten]
2019-06-10T02:53:54.504+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-06-10T02:53:54.504+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2019-06-10T02:53:54.504+0000 I CONTROL [initandlisten]
2019-06-10T02:53:54.515+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2019-06-10T02:53:54.517+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2019-06-10T02:56:27.392+0000 I CONTROL [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2019-06-10T02:56:27.392+0000 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2019-06-10T02:56:27.392+0000 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2019-06-10T02:56:27.395+0000 I CONTROL [signalProcessingThread] Shutting down free monitoring
2019-06-10T02:56:27.395+0000 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2019-06-10T02:56:27.397+0000 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2019-06-10T02:56:27.397+0000 I STORAGE [signalProcessingThread] Shutting down session sweeper thread
2019-06-10T02:56:27.397+0000 I STORAGE [signalProcessingThread] Finished shutting down session sweeper thread
2019-06-10T02:56:27.558+0000 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2019-06-10T02:56:27.558+0000 I CONTROL [signalProcessingThread] now exiting
2019-06-10T02:56:27.558+0000 I CONTROL [signalProcessingThread] shutting down with code:0
You cannot use bindip to limit access from the outside to the mongodb. bindip selects the desired server listen IPs, not the client IPs.
If you only want to be able to connect to the server from your IP address, you should use the Network Security Group feature of Azure. It is more secure than handling it via the software installed on the VM, since traffic does not even reach the VM.
For your issue, you should know what does the three IPs mean and then you will know what you need to do as you wish.
First one: 127.0.0.1
This IP is just for the test inside the machine, it cannot access outside. It's just a loop IP.
Second one: 0.0.0.0
Then this IP is set, then you can access outside and also can access inside. It means the localhost for all the application in this machine, no matter inside or outside.
Third one: private IP
This is the IP assigned in your private network, not the public IP. For example, it means the IP 192.168.1.100 in the document you provide. And for the Azure VM, it means the private IP assigned from the subnet. But it only works when you access this IP.
So, in your question, if you want to access both outside and inside. Then you can set the bind IP in the simplest way:
0.0.0.0
private IP
Note: do not forget to expose the port in the NSG associated with your Azure VM. If you do not have a special requirement, I will suggest you bind the IP 0.0.0.0, it's the best way.

Unable to run MongoDB server when using multiple IP addresses in bindIp configuration Option in Mongod version 3.6.5

I am trying to use multiple IP addresses in the bindIp configuration option and after saving the configuration changes, the mongodb server won't start. The same thing is working in MongoDB version 3.4
Here is the configuration settings:
# network interfaces
net:
port: 36784
bindIp: 127.0.0.1,10.0.0.226
Here 10.0.0.226 is the private IP address of the EC2 instance.
The same type of configuration was working in earliers versions of MongoDB more specifically in v3.4
If I use bindIp to 0.0.0.0, then of course it allows remote connections to all the IP addresses.
Once i restart the server, i am getting the following error:
mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-06-25 05:36:45 UTC; 15s ago
Docs: https://docs.mongodb.org/manual
Process: 1570 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
Main PID: 1570 (code=exited, status=48)
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: Stopped High-performance, schema-free document-oriented database.
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: Started High-performance, schema-free document-oriented database.
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: mongod.service: Unit entered failed state.
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: mongod.service: Failed with result 'exit-code'.
Here is the logs files content:
2018-06-25T05:07:38.842+0000 I CONTROL [initandlisten] now exiting
2018-06-25T05:07:38.842+0000 I CONTROL [initandlisten] shutting down with code:48
2018-06-25T05:13:43.192+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] MongoDB starting : pid=1390 port=36784 dbpath=/var/lib/mongodb 64-bit host=ip-10-0-1-69
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] db version v3.6.5
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] allocator: tcmalloc
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] modules: none
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] build environment:
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] distarch: x86_64
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] target_arch: x86_64
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,10.0.0.226", port: 36784 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2018-06-25T05:13:43.201+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] now exiting
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] shutting down with code:48
I have gone through the official docs and could not find any deprecation notices.
what might be the issue?
Thank you
When I understand this line from the log correctly
2018-06-25T05:13:43.201+0000 I CONTROL [initandlisten] MongoDB starting : pid=1390 port=36784 dbpath=/var/lib/mongodb 64-bit host=ip-10-0-1-69
the host's ip is 10.0.1.69 and not 10.0.0.226. That would explain the error.

Can't start MongoDB service with either mongod & mongo

Hello I have a problem with my MongoDB it was working just fine and after I restart the server and scrapping something this show up.
When I ran command
$ mongo
It respond with
MongoDB shell version: 3.2.13
connecting to: test
2017-05-29T01:11:42.948+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-05-29T01:11:42.948+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
I also ran this command
$ mongod
and it have me this error message
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] MongoDB starting : pid=2530 port=27017 dbpath=/data/db 64-bit host=something
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] db version v3.2.13
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] git version: 23899209cad60aaafe114f6aea6cb83025ff51bc
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] modules: none
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] build environment:
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] distarch: x86_64
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-05-29T01:17:58.441+0000 I CONTROL [initandlisten] options: {}
2017-05-29T01:17:58.469+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-05-29T01:17:58.469+0000 I - [initandlisten] Fatal Assertion 28578
2017-05-29T01:17:58.469+0000 I - [initandlisten]
***aborting after fassert() failure
Then I tried
sudo service mongod start
sudo service mongod status
and it give me this fail error
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2017-05-29 01:24:29 UTC; 1min 29s ago
Docs: https://docs.mongodb.org/manual
Process: 3200 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=100)
Main PID: 3200 (code=exited, status=100)
May 29 01:24:29 something systemd[1]: Started High-performance, schema-free document-oriented database.
May 29 01:24:29 something systemd[1]: mongod.service: Main process exited, code=exited, status=100/n/a
May 29 01:24:29 something systemd[1]: mongod.service: Unit entered failed state.
May 29 01:24:29 something systemd[1]: mongod.service: Failed with result 'exit-code'.
I've tried deleted the socket file and give it a try but didn't work.
Thank you in advanced! :)
I am not sure if this is the correct answer or not. However, it appears to me that
2017-05-29T01:17:58.469+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
is the main problem. Perhaps you could double check who owns this? also the permission?
It looks like this in my mongo:
Hopefully it helps
rm /var/lib/mongodb/mongod.lock
systemctl restart mongod
systemctl status mongod

Mongo database critical issue

We've got an emergency situation regarding a production website which had just been released. We just got hit by a heavy DDoS-attack and servers got overloaded by requests. Once the attack had stopped, we've restarted the server with the database and we noticed that the 'WiredTiger.wt' file had just disappeared and that Mongo no longer works. I'm wondering what could we do to restore the database and have Mongo running back, taking into account that the 'WiredTiger.wt' file is missing ?
We've got an instance which has it's MONGO_URL set to another instance where we have the database (here's where the DDoS-attack happened).
Here are some logs that you could check:
When I try on the database server to connect "mongo NAME_OF_DATABASE":
MongoDB shell version: 3.2.11
connecting to: NAME_OF_DATABASE
Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
When I check the logs "mongo log /var/log/mongodb/mongod.log":
2017-04-04T11:05:18.252+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2017-04-04T11:05:18.255+0000 I CONTROL [initandlisten] MongoDB starting : pid=2716 port=27017 dbpath=/var/lib/mongodb 64-bit host=ip-xxx-xxx-xxx-xxx
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] db version v3.2.11
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] git version: 009580ad490190ba33d1c6253ebd8d91808923e4
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] modules: none
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] build environment:
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] distarch: x86_64
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-04-04T11:05:18.256+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { port: 27017 }, security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2017-04-04T11:05:18.279+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-04-04T11:05:18.279+0000 I - [initandlisten] Fatal Assertion 28578
2017-04-04T11:05:18.279+0000 I - [initandlisten]
When I run "sudo service mongodb status":
mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2017-04-04 11:51:06 UTC; 8s ago
Process: 1384 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=14)
Main PID: 1384 (code=exited, status=14)
Apr 04 11:51:06 ip-172-31-42-103 systemd[1]: Started High-performance, schema-free document-oriented database.
Apr 04 11:51:06 ip-172-31-42-103 systemd[1]: mongodb.service: Main process exited, code=exited, status=14/n/a
Apr 04 11:51:06 ip-172-31-42-103 systemd[1]: mongodb.service: Unit entered failed state.
Apr 04 11:51:06 ip-172-31-42-103 systemd[1]: mongodb.service: Failed with result 'exit-code'.
Thank you!

mongodb cant start centos 7

I installed mongodb on Centos 7 and all works fine.
But if I reboot the system, mongodb can't start anymore. If I uninstall and install again, works fine. But after reboot, cant start anymore.
When I try systemctl status mongod.service shows:
mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Dom 2016-11-27 09:49:36 BRT; 12min ago
Docs: https://docs.mongodb.org/manual
Process: 1471 ExecStart=/usr/bin/mongod $OPTIONS run (code=exited, status=1/FAILURE)
Main PID: 1471 (code=exited, status=1/FAILURE)
Nov 27 09:49:19 localhost.localdomain systemd[1]: Started High-performance, schema-free document-oriented database.
Nov 27 09:49:19 localhost.localdomain systemd[1]: Starting High-performance, schema-free document-oriented database...
Nov 27 09:49:36 localhost.localdomain mongod[1471]: about to fork child process, waiting until server is ready for connections.
Nov 27 09:49:36 localhost.localdomain mongod[1471]: forked process: 2828
Nov 27 09:49:36 localhost.localdomain mongod[1471]: ERROR: child process failed, exited with error number 1
Nov 27 09:49:36 localhost.localdomain systemd[1]: mongod.service: main process exited, code=exited, status=1/FAILURE
Nov 27 09:49:36 localhost.localdomain systemd[1]: Unit mongod.service entered failed state.
Nov 27 09:49:36 localhost.localdomain systemd[1]: mongod.service failed.
I already tried:
*chcon -R -t mongod_var_lib_t /var/lib/mongo
*SElinux=disable
*chmod 7777 /var/lib/mongo
and nothing.
I remember when this error appeared before I format my pc, I needed to put permission on systemd with a simple command. But I cant find anymore.
here is the official bug report
https://jira.mongodb.org/browse/SERVER-27241
in
/usr/lib/systemd/system/mongod.service
update the systemd service with the following, till they fix it officially
[Service]
User=mongod
Group=mongod
Environment="OPTIONS=--quiet -f /etc/mongod.conf"
PermissionsStartOnly=true
ExecStartPre=/usr/bin/mkdir /var/run/mongodb
ExecStartPre=/usr/bin/chown -R mongod:mongod /var/run/mongodb
ExecStart=/usr/bin/mongod $OPTIONS run
PIDFile=/var/run/mongodb/mongod.pid
I remove and reinstall Mongodb 3.4
The server started with: sudo systemctl start mongod.service, and started ok.
Here's the /var/log/mongodb/mongod.log
2016-11-27T13:23:03.600-0300 I CONTROL [main] ***** SERVER RESTARTED
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] MongoDB
starting : pid=8247 port=27017 dbpath=/var/lib/mongo 64-bit
host=localhost.localdomain
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] db version
v3.4.0-rc5
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] git version:
7df8fe1099135d137516f1670d2a0091ace63ca0
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] OpenSSL
version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] allocator:
tcmalloc
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] modules: none
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] build
environment:
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] distmod:
rhel70
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] distarch:
x86_64
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten]
target_arch: x86_64
2016-11-27T13:23:03.612-0300 I CONTROL [initandlisten] options: {
command: [ "run" ], config: "/etc/mongod.conf", net: { bindIp:
"127.0.0.1", port: 27017 }, processManagement: { fork: true,
pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath:
"/var/lib/mongo", journal: { enabled: true } }, systemLog: {
destination: "file", logAppend: true, path:
"/var/log/mongodb/mongod.log", quiet: true } }
2016-11-27T13:23:03.971-0300 I - [initandlisten] Detected data
files in /var/lib/mongo created by the 'wiredTiger' storage engine,
so setting the active storage engine to 'wiredTiger'.
2016-11-27T13:23:03.971-0300 I STORAGE [initandlisten]
wiredtiger_open config:
create,cache_size=1329M,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-11-27T13:23:05.036-0300 I CONTROL [initandlisten]
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten] ** WARNING:
Access control is not enabled for the database.
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten] **
Read and write access to data and configuration is unrestricted.
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten]
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten]
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten] ** WARNING:
/sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten] ** We
suggest setting it to 'never'
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten]
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten] ** WARNING:
/sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten] ** We
suggest setting it to 'never'
2016-11-27T13:23:05.036-0300 I CONTROL [initandlisten]
2016-11-27T13:23:05.061-0300 I FTDC [initandlisten] Initializing
full-time diagnostic data capture with directory '/var/lib/monenter
code herego/diagnostic.data'
2016-11-27T13:23:05.061-0300 I NETWORK [thread1] waiting for
connections on port 27017
When i reboot the sytem, Mongodb wont start again.
Heres the log:
logAppend: true path: /var/log/mongodb/mongod.log
*# Where and how to store data.
2016-11-27T13:30:27.927-0300 I CONTROL [main] ***** SERVER RESTARTED
2016-11-27T13:30:28.279-0300 I CONTROL [main] ERROR: Cannot write pid
file to /var/run/mongodb/mongod.pid: No such file or directory
Here is my /etc/mongod.conf
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
*# engine:
*# mmapv1:
*# wiredTiger:
*# how the process runs
processManagement: fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
*# network interfaces net: port: 27017 bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
*# security:
*# operationProfiling:
*# replication:
*# sharding:
*## Enterprise-Only Options
*# auditLog:
*# snmp:
I also ran into that on CentOS 7 and mongodb 3.4. Here's how I solved it:
Edit /etc/mongod.conf file and change fork to false and pidFilePath to the same as dbPath (which for me is /var/lib/mongo):
/etc/mongod.conf:
storage:
dbPath: /var/lib/mongo
processManagement:
fork: false # fork and run in background
pidFilePath: /var/lib/mongo/mongod.pid # location of pidfile
net:
port: 27017
bindIp: 0.0.0.0
Don't forget to set firewall rules and reload:
firewall-cmd --zone=public --permanent --add-port=27017/tcp; firewall-cmd --reload
Follow log file and restart:
tail -f /var/log/mongodb/mongod.log &
systemctl restart mongod; systemctl status mongod
You should see in last line of log file:
NETWORK [thread1] waiting for connections on port 27017
It worked for me, I rebooted the system and I could connect to mongo straight away.