Help us understand the problem. What is going on with this article?

MongoDB 起動エラー「Failed to set up sockets during startup.」「Failed to set up listener: InternalError: Failed to set up sockets」

More than 1 year has passed since last update.

MongoDB の起動時のエラーに対処する彼是。

環境

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

Failed to set up sockets during startup. Failed to set up listener: InternalError: Failed to set up sockets この辺りが怪しい。ソケットが上手く設定できていない模様。

原因

MongoDB が使用するポートが既に使用されていること原因で、以前のゴミが残ってしまっている状態。これを消せばおk。

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

参考記事

maecha
インターネットムズカシイ
https://maecha.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした