我最近开始使用mongoDB,并且一次又一次地遇到此问题。我想我错过了一些东西,但无法确切找到问题所在。我正在开发最新的mongo db 4.0.1版本。请帮我解决这个问题。
iron@iron-System-Product-Name:/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/codesnippets$ sudo mongod --dbpath db
2018-08-24T09:30:26.351+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] MongoDB starting : pid=5994 port=27017 dbpath=db 64-bit host=iron-System-Product-Name
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] db version v4.0.1
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] git version: 54f1582fc6eb01de4d4c42f26fc133e623f065fb
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] allocator: tcmalloc
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] modules: none
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] build environment:
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] distmod: ubuntu1604
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] distarch: x86_64
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "db" } }
2018-08-24T09:30:26.354+0530 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] now exiting
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] shutting down with code:48
谢谢!
答案 0 :(得分:3)
sudo lsof -iTCP -sTCP:LISTEN -n -P
sudo kill <mongo_command_pid>
mongod
尝试这三个命令,您肯定会摆脱它。