突然之间,我无法让mongodb工作。
通常我会从
开始mongo
然而,当我尝试开始时,我得到了这个。
MongoDB shell version: 3.0.6
connecting to: test
2016-10-11T15:36:56.462+0100 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-10-11T15:36:56.464+0100 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
我还没有在服务器上更新任何内容,甚至在网站崩溃之前都已登录。任何想法为什么会这样?我试图注释掉bind_ip,但我不明白为什么它会停止工作并且无法启动。
我也试过
sudo service mongo start
mongod start/running, process 1529
然后当我尝试 -
sudo service mongod status
mongod stop/waiting.
我无法启动我的nodejs应用,因为它会返回
/node_modules/mongoose/node_modules/mongodb/lib/server.js:228 process.nextTick(function() { throw err; }) ^ Error: connect ECONNREFUSED at exports._errnoException (util.js:746:11) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
我认为这是因为mongodb没有正确启动但不确定。
错误产生此
2016-10-11T15:40:30.400+0100 E JOURNAL [initandlisten] Insufficient free space for journal files
2016-10-11T15:40:30.400+0100 I JOURNAL [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
2016-10-11T15:40:30.400+0100 I JOURNAL [initandlisten]
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2016-10-11T15:40:30.402+0100 I CONTROL [initandlisten] now exiting
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2016-10-11T15:40:30.402+0100 I NETWORK [initandlisten] shutdown: going to close sockets...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] shutdown: final commit...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] shutdown: closing all files...
2016-10-11T15:40:30.402+0100 I STORAGE [initandlisten] closeAllFiles() finished
2016-10-11T15:40:30.402+0100 I CONTROL [initandlisten] dbexit: rc: 100
2016-10-11T15:45:36.614+0100 I CONTROL ***** SERVER RESTARTED *****
2016-10-11T15:45:36.642+0100 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-10-11T15:45:36.642+0100 I - [initandlisten] Fatal Assertion 28578
2016-10-11T15:45:36.642+0100 I - [initandlisten]
***aborting after fassert() failure
2016-10-11T15:46:21.636+0100 I CONTROL ***** SERVER RESTARTED *****
2016-10-11T15:46:21.663+0100 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-10-11T15:46:21.663+0100 I - [initandlisten] Fatal Assertion 28578
2016-10-11T15:46:21.663+0100 I - [initandlisten]
我向那个dir扫了一眼,看到了这个!为什么这些文件如此庞大?
答案 0 :(得分:1)
您的错误似乎与this
相似删除/tmp/mongodb-27017.sock
文件应该可以解决问题。
同时检查你的磁盘空间,因为似乎进程没有启动,因为你缺少日志文件的空间(请查看下面的@ dave-v评论)
答案 1 :(得分:1)
我打开文件/etc/mongodb.conf
并在行bind_ip
= 127.0.0.1 (#bind_ip = 127.0.0.1)
的开头放一个#。然后重新启动 mongodb ,它再次正常工作!
警告:如果您在在线服务器中使用mongodb,请不要这样做。黑客可以攻击这个端口!
答案 2 :(得分:0)
我遇到同样的问题,解决方案就在这里
1)通过下载或yum安装完成mongo安装 2)在/ home / scc-dev / data / db /下创建文件夹db 3)转到bin下的mongo文件夹,打开终端运行以下命令 sudo ./mongod dbpath / home / scc-dev / data / db 4)检查控制台中运行的几行命令 5)在bin下打开新终端运行以下命令 sudo ./mongo 6)类型命令 - >显示dbs(它应该显示默认的dbs,如本地..)然后它工作正常
7)如果收到如连接到127.0.0.1:27017失败的错误,原因:错误:61连接被拒绝然后 8)重启linux m / c命令 - > / sbin / reboot(从3开始执行步骤 - 问题将得到解决)
打开linux m / c中的任何端口 sudo iptables -I INPUT -p tcp -m tcp --dport 27017 -j ACCEPT sudo iptables-save