MongoDB 启动错误:“启动过程中未能设置好套接字。” “未能设置监听器:内部错误:套接字设置失败。”
他正在解决启动 MongoDB 时的错误。
环境
-
- AWS AMI MongoDB 3.4
MongoDB启动错误
$ restart mongodb
/jet/etc/init/mongodb: not running (no pid-file)
/jet/etc/init/mongodb: no process started
$ start mongodb
/jet/etc/init/mongodb: no process started
不允许启动或重新启动。
查看日志
$ cat mongodb.log.2018-07-05T05-59-44
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] MongoDB starting : pid=4021 port=27017 dbpath=/jet/prs/mongodb/db 64-bit host=ip-10-0-10-119
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] db version v3.4.4
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] allocator: tcmalloc
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] modules: none
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] build environment:
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] distarch: x86_64
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] target_arch: x86_64
2018-07-05T05:59:41.533+0000 I CONTROL [initandlisten] options: { config: "/jet/etc/mongodb/mongodb.conf", net: { bindIp: "0.0.0.0", port: 27017, unixDomainSocket: { pathPrefix: "/jet/run/mongodb" } }, storage: { dbPath: "/jet/prs/mongodb/db" }, systemLog: { destination: "file", path: "/jet/log/mongodb/mongodb.log" } }
2018-07-05T05:59:41.579+0000 E NETWORK [initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017
2018-07-05T05:59:41.580+0000 E NETWORK [initandlisten] addr already in use
2018-07-05T05:59:41.580+0000 E NETWORK [initandlisten] Failed to set up sockets during startup.
2018-07-05T05:59:41.580+0000 E STORAGE [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2018-07-05T05:59:41.580+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-07-05T05:59:41.580+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2018-07-05T05:59:41.580+0000 I CONTROL [initandlisten] now exiting
2018-07-05T05:59:41.580+0000 I CONTROL [initandlisten] shutting down with code:48
启动过程中无法设置套接字。无法设置监听器:内部错误:无法设置套接字,这一点可疑。套接字设置似乎未成功。
原因
由于MongoDB使用的端口已经被占用,导致之前的垃圾仍然存在。如果清除这个问题,那就可以了。
在使用ps命令确认进程后,使用kill命令删除进程。
$ ps aux | grep mongo
ec2-user 3201 0.2 5.2 303824 53672 ? Sl 05:48 0:02 mongod --config /jet/etc/mongodb/mongodb.conf --logpath /jet/log/mongodb/mongodb.log --dbpath /jet/prs/mongodb/db --unixSocketPrefix /jet/run/mongodb --port 27017 --bind_ip 0.0.0.0
ec2-user 4083 0.0 0.0 10856 944 pts/0 D+ 06:01 0:00 grep --color=auto mongo
$ kill -9 3201
请提供更多的上下文或具体的句子,以便我能够更准确地为您提供翻译。
- https://stackoverflow.com/questions/34709062/failed-to-set-up-sockets-during-startup-dbexit-rc-48-error-in-mongodb/37954282