Can't start MongoDB, mongod is always stop/waiting

12,570

This looks like premissions issue, please do:

sudo chown whoami /tmp/mongodb-27017.sock

This will set premissions straight as You need.

Share:
12,570

Related videos on Youtube

Mike
Author by

Mike

Updated on September 18, 2022

Comments

  • Mike
    Mike over 1 year

    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?
    • Eska
      Eska about 8 years
      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?
    • tsveti_iko
      tsveti_iko over 6 years
      Uncomment #security:, it should be security: authorization: "enabled"
  • Mike
    Mike about 8 years
    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?
  • Eska
    Eska about 8 years
    You reset service by sudo systemctl restart servicename. If You want to check mongo status, do sudo systemctl status servicename.
  • Eska
    Eska about 8 years
    If You will hit tab after typing sudo systemctl You will get list of available commands for systemctl
  • Mike
    Mike about 8 years
    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.
  • Eska
    Eska about 8 years
    Please try sudo systemctl daemon-reload, maybe that will do to avoid reboot.
  • Eska
    Eska about 8 years
    On the other hand, if system requires to restart for the proper run of the app, i wouldn't recommend to try to avoid/bypass this action. May i ask whats the machine duty? (I mean, is it some kind of server machine connected to production process in facility or something like that?)
  • Mike
    Mike about 8 years
    It's a local workstation, which is used by multiple persons and, thus, it's problematical to restart the system.
  • Eska
    Eska about 8 years
    I don't think there is a safe way to achieve what You need. I may be mistaken, but if linux need a reboot for something, that actually probably means something bigger than just a reload of the config files. I was installing php7-fpm, mariadb, nginx all together 2 days ago on Debian Stretch - there was no need to reboot to get them working straight away as systemctl services.