3

I try to run MongoDB 3.2.4 on Ubuntu 14.04:

sudo service mongod start

And get the result:

mongod start/running, process 67725

But when I check the status I get:

mongod stop/waiting

I tried to reinstall MongoDB or to define the permissions for Mongo's folders (lib & log) as root or as mongodb. I also tried to repair the mongod.conf but nothing helps.

The content of log:

2016-04-09T23:56:28.349+0300 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-04-09T23:56:28.359+0300 I CONTROL  [initandlisten] MongoDB starting : pid=69120 port=27017 dbpath=/var/lib/mongodb 64-bit host=is-infomedia
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten] db version v3.2.4
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten] git version: e2ee9ffcf9f5a94fad76802e28cc978718bb7a30
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten] allocator: tcmalloc
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten] modules: none
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten] build environment:
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten]     distmod: ubuntu1404
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten]     distarch: x86_64
2016-04-09T23:56:28.360+0300 I CONTROL  [initandlisten]     target_arch: x86_64
2016-04-09T23:56:28.360+0300 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-04-09T23:56:28.393+0300 E NETWORK  [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-04-09T23:56:28.393+0300 I -        [initandlisten] Fatal Assertion 28578
2016-04-09T23:56:28.393+0300 I -        [initandlisten] 

***aborting after fassert() failure

Update:

After editing of /etc/mongod.conf:

#security:
authorization: enabled
enableEncryption: true
javascriptEnabled: false

and saving the file, and try to restart the mongod, I get the same error but MongoDB doesn't write any log file. I checked the permissions of /etc/mongod.conf, it is assigned to mongodb group. How can I restart mongod after editing its config file?

My questions:

  1. How can I run MongoDB as a service in Ubuntu?
  2. What I miss or do wrong?
3
  • 1
    sudo systemctl enable servicename - to run it as service. This issue looks like problems with premissions, try sudo chown whoami /tmp/mongodb-27017.sock to get premissions straight. If that wont help, can You remove the socket?
    – Eska
    Apr 9, 2016 at 20:59
  • @Eska, bingo! The sudo chown mongodb /tmp/mongodb-27017.sock fixed the issue. Please, arrange your comment as an answer in order to mark it as correct.
    – Mike
    Apr 9, 2016 at 21:10
  • Uncomment #security:, it should be security: authorization: "enabled"
    – tsveti_iko
    Aug 29, 2017 at 10:09

2 Answers 2

3

This looks like premissions issue, please do:

sudo chown whoami /tmp/mongodb-27017.sock

This will set premissions straight as You need.

8
  • One more moment, I just edited /etc/mongod.conf (added #security: authorization: enabled enableEncryption: true javascriptEnabled: false) saved the file, and tried to restart mongod and get the same error but MongoDB doesn't write any log file. I checked, the permissions, /etc/mongod.conf assigned to mongodb group. How can I restart mongod after editing its config file?
    – Mike
    Apr 10, 2016 at 7:45
  • 1
    You reset service by sudo systemctl restart servicename. If You want to check mongo status, do sudo systemctl status servicename.
    – Eska
    Apr 10, 2016 at 12:57
  • If You will hit tab after typing sudo systemctl You will get list of available commands for systemctl
    – Eska
    Apr 10, 2016 at 13:02
  • Thank you, the problem is that this package is not installed and in order to use it I have to reboot the system, which is not possible due to already running programs.
    – Mike
    Apr 10, 2016 at 13:04
  • Please try sudo systemctl daemon-reload, maybe that will do to avoid reboot.
    – Eska
    Apr 10, 2016 at 13:06
0

I had to change permission of the whole mongodb folder in /var/lib/. Gave it all permissions read and write and now my service starts.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .