I am trying to install and start mongodb locally:
I go through these steps (as shown in history):
1819 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
1820 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
1821 sudo apt-get update
1822 sudo apt-get install -y mongodb-org
1823 sudo service mongod start
But I get the following error log in /var/log/mongodb/mongodb.log
2016-01-05T22:51:21.869+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] MongoDB starting : pid=5394 port=27017 dbpath=/var/lib/mongodb 64-bit host=ip-172-31-45-129
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] db version v3.2.0
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] git version: 45d947729a0315accb6d4f15a6b06be6d9c19fe7
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] modules: none
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] build environment:
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] distarch: x86_64
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongodb.log" } }
2016-01-05T22:51:21.895+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-01-05T22:51:21.895+0000 I - [initandlisten] Fatal Assertion 28578
2016-01-05T22:51:21.895+0000 I - [initandlisten]
***aborting after fassert() failure
I previously had a mongodb installed which worked fine but stopped me from connecting to it after some changes I made to other services that were using mongodb. So I tried to remove that instance of mongodb and tried reinstalling, after which I am facing this issue.
I also try to look for the file: /tmp/mongodb-27017.sock
but it does not exist on my system.
I had the same problem after installing MongoDB the same way, also got the error message 'Failed to unlink socket file /tmp/mongodb-27017.sock...'.
After doing a bit more digging I realised that the installation hadn't created the path /data/db
, so here's what I did:
create the full path (the flag -p
creates parent folders if they don't exist)
sudo mkdir -p /data/db
recursively change ownership of the folder /data/db
to mongodb
sudo chown -R mongodb:mongodb /data/db
edit : if you're planning on running different instances of mongodb from different project folders, you, and not mongodb, should be the owner of the contents of /data/db
, otherwise it will give you an error of the type exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock
Remove the temporary socket file
sudo rm /tmp/mongodb-27017.sock
Initialise the mongod service
sudo service mongod start
After this it was running smoothly in my system. I could start it or stop it and it would not give me any more errors.
Hope this helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.