1

I am trying to add the second replica set to primary.

Primary = 192.168.56.52:27017
Secondary = 192.168.56.136:27017

    # mongod.conf

    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/

    # Where and how to store data.
    storage:
      dbPath: **mypath**\DBs
      journal:
        enabled: true
    #  engine:
    #  mmapv1:
    #  wiredTiger:

    # where to write logging data.
    systemLog:
      destination: file
      logAppend: true
      path:  **mypath**\mongod.log

    # network interfaces
    net:
      port: 27017
      bindIp: 0.0.0.0


    #processManagement:

    #security:
    #operationProfiling:

    replication:
      replSetName: configServers

    #sharding:

    ## Enterprise-Only Options:

    #auditLog:

    #snmp:
    #mp:

But when I try I add
rs.add("192.168.56.136:27017") It shows as picture . result
Please help to get run replicaset. Thanks.
I run on windows and start replicaset with service .

1 Answer 1

0

As per the error message says, you have added the Primary node of the replica set as localhost. The rule is all nodes of the replica set should be localhost or all should be hostname/ip address.

If you run rs.status() from primary, you will see the primary replica set member as localhost. So when you try to add a secondary with rs.add("192.168.56.136:27017") the system will throw an error.

How to correct this?

conf = rs.conf()

update the hostname of primary member in conf variable

then run

rs.reConfig(conf)

Now add the secondary member.

1
  • Thank you so much. You saved me a lot. Commented Mar 24, 2019 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.