LoginSignup
2
2

More than 5 years have passed since last update.

レプリカセット作成する時にメンバーのポート指定しない俺に死を

Posted at

俺です。

どうでもいいことに詰まって禿げてたけど解決したので自戒を込めてメモ

mongodbのレプリカセット作成時に、ホスト名とポート番号を指定するの忘れないように。

デフォルトポート27017ではないmongodbを作る時にハマります。俺が。

- エラーケース

No host described in new configuration 1 for replica set orenoreplicaset maps to this node

> config = {
...   "_id": "orenoreplicaset",
...   "members": [
...     { "_id": 0, "host": '172.16.10.21'},
...     { "_id": 1, "host": '172.16.10.22'},
...     { "_id": 2, "host": '172.16.10.23'}
...     ]
... }
> rs.initiate(config){
        "ok" : 0,
        "errmsg" : "No host described in new configuration 1 for replica set orenoreplicaset maps to this node",
        "code" : 93
}

- 正しくはこれ

config = {
  "_id": "orenoreplicaset",
  "members": [
    { "_id": 0, "host": '172.16.10.21:37017'},
    { "_id": 1, "host": '172.16.10.22:37017'},
    { "_id": 2, "host": '172.16.10.23:37017'}
    ]
}
rs.initiate(config);
{ "ok" : 1 }
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2