MongoDB Failed to unlink socket file /tmp/mongodb-27017
By:Roy.LiuLast updated:2019-08-11
Upgraded MongoDB and unable to start the mongod process, review the /var/log/mongodb/mongod.log file, and found the following error messages :
Terminal
2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] MongoDB starting : pid=31927 port=27017 dbpath=/var/lib/mongodb3 64-bit host=hcompass 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] db version v3.2.16 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] git version: 056bf45128114e44c5358c7a8776fb582363e094 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] allocator: tcmalloc 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] modules: none 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] build environment: 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] distmod: debian71 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] distarch: x86_64 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] target_arch: x86_64 2017-08-24T03:57:21.289-0400 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,192.168.x.x" }, storage: { dbPath: "/var/lib/mongodb3" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } 2017-08-24T03:57:21.311-0400 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted 2017-08-24T03:57:21.311-0400 I - [initandlisten] Fatal Assertion 28578 2017-08-24T03:57:21.311-0400 I - [initandlisten] ***aborting after fassert() failure
Check the /tmp/mongodb-27017.sock permission, owner is root?
Terminal
$ ls -ls /tmp/mongodb-27017.sock 0 srwx------ 1 root root 0 Aug 24 03:56 /tmp/mongodb-27017.sock
P.S Debian 7 and MongoDB 2.6 –> upgraded to –> 3.2.16
Solution
To fix it, delete the /tmp/mongodb-27017.sock file manually and start the mongod process. Check the /tmp/mongodb-27017.sock permission again, the ownership is changed to the ‘mongodb’ user.
$ sudo rm -rf /tmp/mongodb-27017.sock $ sudo service mongod start [ok] $ ls -lsah /tmp/mongodb-27017.sock 0 srwx------ 1 mongodb mongodb 0 Aug 24 04:01 /tmp/mongodb-27017.sock
Common error
While sudo apt-get upgrade, Debian helps to upgrade the MongoDB automatically, and changed the mongodb-27017.sock ownership to root, and normally we start the ‘mongod’ process with user ‘mongodb’, and caused this “Operation not permitted”.
While sudo apt-get upgrade, Debian helps to upgrade the MongoDB automatically, and changed the mongodb-27017.sock ownership to root, and normally we start the ‘mongod’ process with user ‘mongodb’, and caused this “Operation not permitted”.
From:一号门
COMMENTS