VPS服务器最新优惠
云主机最新促销分享

宝塔面板mongodb无法启动连接不上的解决办法

宝塔面板mongodb安装v4.4.6面板上无法启动.service mongodb start命令行启动提示如下,打开配置文件找到fork改成false或直接注销,再次执行启动没有提示信息:

There doesn't seem to be a server running with dbpath: /www/server/mongodb/data
about to fork child process, waiting until server is ready for connections.
forked process: 10864
ERROR: child process failed, exited with 14
To see additional information in this output, start without the "--fork" option.

mongod服务未启动,启动客户端mongo报错:

[root@test bin]# ./mongo
MongoDB shell version v4.4.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

bindIp:0.0.0.0 不能是127.0.0.1
服务器上测试,一个窗口开启mongod:./mongod –dbpath /www/server/mongodb/data/,
另一个窗口开启mongo:./mongo是可以的,但这样肯定是不正常的。
sudo /etc/init.d/mongodb restart等各种方式都无法正常启动

最后发现是mongodb使用的端口27017未开放。宝塔卸载mongodb,删除/www/server/mongodb目录。阿里云开放入端口27017,源0.0.0.0/0,重新安装自动开启。

windows命令行开启mongodb:

D:\workplace\mongodb\bin>
mongod.exe --config D:\workplace\mongodb\mongodb.conf  --install   --serviceName "mongodb"  
  
D:\workplace\mongodb\bin>net start mongodb  
#或者
D:\workplace\mongodb\bin>sc start mongodb  
#打开windows服务查看
D:\workplace\mongodb\bin>services.msc

 

原文标题:宝塔面板mongodb无法启动连接不上的解决办法

原文地址:https://www.vpsjyz.com/490.html