我无法在我的ubuntu机器上运行 mongod 。我读了一些博客和stackoverflow线程建议更改/var/lib/mongodb
和/var/log/mongodb
文件夹的所有权,
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
但我仍然无法运行mongod并收到以下错误消息。
vinayak@vinayak-Lenovo-G500:~$ mongod
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] MongoDB starting : pid=3211 port=27017 dbpath=/data/db 64-bit host=vinayak-Lenovo-G500
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] db version v3.2.3
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] modules: none
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] build environment:
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] distarch: x86_64
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-03-04T09:31:29.942+0530 I CONTROL [initandlisten] options: {}
2016-03-04T09:31:29.968+0530 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2016-03-04T09:31:29.968+0530 E NETWORK [initandlisten] addr already in use
2016-03-04T09:31:29.968+0530 E STORAGE [initandlisten] Failed to set up sockets during startup.
2016-03-04T09:31:29.968+0530 I CONTROL [initandlisten] dbexit: rc: 48
vinayak@vinayak-Lenovo-G500:~$
..我不这么认为,我的mongodb已经损坏,因为它是全新安装的,我还没有调整其中的任何东西。
请建议任何解决方案。谢谢。
答案 0 :(得分:0)
通过堆栈跟踪错误"已经在socket中使用的地址:0.0.0.0:27017" 您可以尝试在其他端口上运行 例如 mongod --port 12345
答案 1 :(得分:0)
在终端中写下以下内容,它肯定会起作用(它在macbook中对我有用)。
sudo killall -15 mongod