Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在我的生产环境中防止mongoDB shell错误_Php_Mongodb_Ubuntu - Fatal编程技术网

Php 在我的生产环境中防止mongoDB shell错误

Php 在我的生产环境中防止mongoDB shell错误,php,mongodb,ubuntu,Php,Mongodb,Ubuntu,如何从mongoDB shell或当我尝试从php连接到它时防止这些错误 Message: Failed to connect to: localhost:27017: Remote server has closed the connection JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112 exception:

如何从mongoDB shell或当我尝试从php连接到它时防止这些错误

Message: Failed to connect to: localhost:27017: Remote server has closed the connection 

JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112 exception: connect failed

couldn't connect to server 127.0.0.1 shell/mongo.js
每次出现这些错误中的一个时,我每次都必须运行此命令

sudo rm /var/lib/mongodb/mongod.lock   
sudo -u mongodb mongod -f /etc/mongodb.conf --repair 
sudo service mongodb start
如何在我的生产环境中永远防止和解决这些错误


谢谢

你为什么要将MongoShell连接到php???我连接到mongoDB不是使用php连接到shell,而是使用shell进行一些查询看起来mongoDB的服务可能会崩溃?你看过任何日志了吗?