堕落不振功业废,勤耕不辍日月新

MONGODB两个报错处理方法

Mongodb hailen 6℃

报错:

rico@ubuntu:~$ mongo
MongoDB shell version: 3.2.17
connecting to: test
2017-11-16T23:48:59.362+0800 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-11-16T23:48:59.362+0800 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

解决方法:

sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair --dbpath /var/lib/mongodb
sudo mongod --fork --logpath /var/lib/mongodb/mongodb.log --dbpath /var/lib/mongodb 
sudo service mongodb start

报错:

rico@ubuntu:/var/lib/mongodb$ sudo service mongodb start
Failed to start mongodb.service: Unit mongodb.service is masked.

解决方法:

rico@ubuntu:/var/lib/mongodb$ sudo chown -R mongodb:mongodb /var/lib/mongodb
rico@ubuntu:/var/lib/mongodb$ sudo systemctl start mongod

转载请注明:我是IT » MONGODB两个报错处理方法

喜欢 (0)or分享 (0)