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!
Related
I installed the MongoDB using the following commands:
sudo apt update
sudo apt install mongodb
and when I checked the status of the service:
mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-11-06 10:25:11 PST; 54min ago
Docs: man:mongod(1)
Process: 1030 ExecStart=/usr/bin/mongod --unixSocketPrefix=${SOCKETPATH} --config ${CONF} $DAEMON_OPTS (code=exited, status=100)
Main PID: 1030 (code=exited, status=100)
Nov 06 10:25:09 JDL systemd[1]: Started An object/document-oriented database.
Nov 06 10:25:11 JDL systemd[1]: mongodb.service: Main process exited, code=exited, status=100/n/a
Nov 06 10:25:11 JDL systemd[1]: mongodb.service: Failed with result 'exit-code'.
I tried creating /data/db and changed its permission.
I was also able to run the mongod command and even restarted the PC. I also tried deleting lock file and did repair in MongoDB but the result was still the same.
How can I fix this one? I tried to search for solutions but none of it seemed to work for me.
Additional Info
running sudo tail -n 20 /var/log/mongodb/mongod.log showed me this
2019-11-05T22:17:52.153+0800 I CONTROL [initandlisten] build environment:
2019-11-05T22:17:52.153+0800 I CONTROL [initandlisten] distarch: x86_64
2019-11-05T22:17:52.153+0800 I CONTROL [initandlisten] target_arch: x86_64
2019-11-05T22:17:52.153+0800 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", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2019-11-05T22:17:52.154+0800 I - [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten]
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-11-05T22:17:52.154+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=5431M,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-11-05T22:17:52.723+0800 E STORAGE [initandlisten] WiredTiger error (-31802) [1572963472:723937][2926:0x7f9a371b00c0], txn-recover: unsupported WiredTiger file version: this build only supports versions up to 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (0) [1572963472:724065][2926:0x7f9a371b00c0], txn-recover: WiredTiger is unable to read the recovery log.
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (0) [1572963472:724099][2926:0x7f9a371b00c0], txn-recover: This may be due to the log files being encrypted, being from an older version or due to corruption on disk
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (0) [1572963472:724124][2926:0x7f9a371b00c0], txn-recover: You should confirm that you have opened the database with the correct options including all encryption and compression options
2019-11-05T22:17:52.724+0800 E STORAGE [initandlisten] WiredTiger error (-31802) [1572963472:724152][2926:0x7f9a371b00c0], txn-recover: Recovery failed: WT_ERROR: non-specific WiredTiger error
2019-11-05T22:17:52.759+0800 E - [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 413
2019-11-05T22:17:52.759+0800 I STORAGE [initandlisten] exception in initAndListen: Location28595: -31802: WT_ERROR: non-specific WiredTiger error, terminating
2019-11-05T22:17:52.759+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-11-05T22:17:52.759+0800 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-05T22:17:52.759+0800 I CONTROL [initandlisten] now exiting
2019-11-05T22:17:52.759+0800 I CONTROL [initandlisten] shutting down with code:100
If you don't need database then remove all the files in database folder (in Ubuntu path will be /usr/lib/mongodb) using rm -rf /usr/lib/mongodb and if you require database then follow this steps:
When you upgrade MongoDB Server, let's say from 3.4 to 3.6. You also need to set database feature compatibility version using this command before upgrading.
This command must be run in MongoDB Server v3.4
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
and then upgrade to the next major release.
For eg., you must upgrade your MongoDB server from 3.4 to 3.6 not directly to 4.0
for more details follow MongoDB Docs
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.
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
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.
I've just installed mongodb on ubuntu using these instructions:
https://askubuntu.com/questions/724749/install-mongo-3-2-on-ubuntu-15-10
When I try to start it, I see this error:
me#devbox:/usr/bin$ service mongod start
Failed to start mongod.service: Unit mongod.service is masked.
me#devbox:~$ mongod
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] MongoDB starting : pid=4343 port=27017 dbpath=/data/db 64-bit host=mydev
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] db version v3.2.5
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] git version: 34e65e5383f7ea1726332cb175b73077ec4a1b02
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2d 9 Jul 2015
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] allocator: tcmalloc
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] modules: none
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] build environment:
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] distmod: ubuntu1404
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] distarch: x86_64
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] target_arch: x86_64
2016-04-15T11:24:01.941-0400 I CONTROL [initandlisten] options: {}
2016-04-15T11:24:02.031-0400 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-04-15T11:24:02.031-0400 I CONTROL [initandlisten] dbexit: rc: 100
When i try to check status, it says this:
me#devbox:~$ service mongod status
● mongod.service
Loaded: masked (/lib/systemd/system/mongod.service; masked; vendor preset: enabled)
Active: inactive (dead)
And when I try to start command line it says this:
me#devbox:/usr/bin$ mongo
MongoDB shell version: 3.2.5
connecting to: test
2016-04-15T11:32:11.828-0400 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-04-15T11:32:11.828-0400 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
Not sure how to get this started