[SERVER-31464] replSetInitiate with no explicit configuration should generate config with localhost by default Created: 09/Oct/17  Updated: 30/Oct/23  Resolved: 14/Oct/17

Status: Closed
Project: Core Server
Component/s: Networking, Replication
Affects Version/s: None
Fix Version/s: 3.6.0-rc1

Type: Improvement Priority: Major - P3
Reporter: Spencer Brody (Inactive) Assignee: Sara Golemon
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
causes SERVER-31808 HostAndPort for replSetInitiate() no ... Closed
Related
is related to SERVER-31454 rs.initiate() does not load default c... Closed
Backwards Compatibility: Fully Compatible
Sprint: Platforms 2017-10-23
Participants:

 Description   

Currently if you run replSetInitiate without providing an initial config, mongod will attempt to deduce its hostname by inspecting the available network interfaces, and then will generate a default configuration with itself as the only member, addressed by the hostname it discovered. Now that mongods bind only to localhost by default (SERVER-28229), this breaks the bootstrapping technique that is common for setting up initial deployments, since running replSetInitiate with no config will default to a hostname based config, but then be unable to find itself in the config since it only accepts connections over localhost. Instead of trying to guess the host machine's hostname we should just generate the default config using localhost.



 Comments   
Comment by Githook User [ 15/Oct/17 ]

Author:

{'email': 'sara.golemon@mongodb.com', 'name': 'Sara Golemon', 'username': 'sgolemon'}

Message: SERVER-31464 Use localhost for default rs.initiate() configuration when only binding localhost
Branch: master
https://github.com/mongodb/mongo/commit/7efbb340cd781d097c153c48c64fb442bbe2a22b

Comment by Eric Milkie [ 09/Oct/17 ]

SGTM.

Comment by Spencer Brody (Inactive) [ 09/Oct/17 ]

And if the node is on a different machine, yes you'd have to do a manual reconfig to switch over from localhost to hostname

Comment by Spencer Brody (Inactive) [ 09/Oct/17 ]

You pass the hostname to rs.add(), you'd just have to specify a localhost name to rs.add()

Comment by Eric Milkie [ 09/Oct/17 ]

If you generate a default config using "localhost", I don't think you'll be able to subsequently add a node to such a configuration with the rs.add() helper. (You would have to edit the config by hand to use real hostnames, for that to work.)

Generated at Thu Feb 08 04:27:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.