FAQ

[mongodb-user] How to change the slave IP in replica config

Ddeepak
Apr 18, 2012 at 7:53 am
Hi

I am new to MongoDB.

I have setup a replica of 3 nodes with one arbiter on EC2. In My test
setup only primary and arbiter has elastic ip and the secondary has dynamic
ip generated by EC2.

Now when I restarted the setup, IP of secondary has been changed . And I
am not able to update the config .

I tried changing the config :

config = {_id: 'ticklereplica', members: [
{_id: 0, host: 'Primary:27017'},
{_id: 1, host: 'Changed_secondary:27017'},
{_id: 2, host: 'arbiter:27017', arbiterOnly: true}]
}

And then ran rs.reconfig(config).
It is not working out. It is throwing following error: -
{
"startupStatus" : 1,
"errmsg" : "loading local.system.replset config (LOADINGCONFIG)",
"ok" : 0
}


I also tried adding adding the new IP and then thought to remove the older
one. using rs.add() and then rs.remove() .
But again same issue .


Appreciate your help.

Thanks Deepak

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/fvf_CxepL1sJ.
To post to this group, send email to mongodb-user@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
reply

Search Discussions

10 responses

  • Gregor at Apr 18, 2012 at 8:21 am
    Is one of the nodes still a primary ? You should be able to reconfigure by
    sending it commands
    http://www.mongodb.org/display/DOCS/Reconfiguring+a+replica+set+when+members+are+down

    On Wednesday, April 18, 2012 6:25:30 AM UTC+1, ddeepak wrote:


    Hi

    I am new to MongoDB.

    I have setup a replica of 3 nodes with one arbiter on EC2. In My test
    setup only primary and arbiter has elastic ip and the secondary has dynamic
    ip generated by EC2.

    Now when I restarted the setup, IP of secondary has been changed . And I
    am not able to update the config .

    I tried changing the config :

    config = {_id: 'ticklereplica', members: [
    {_id: 0, host: 'Primary:27017'},
    {_id: 1, host: 'Changed_secondary:27017'},
    {_id: 2, host: 'arbiter:27017', arbiterOnly: true}]
    }

    And then ran rs.reconfig(config).
    It is not working out. It is throwing following error: -
    {
    "startupStatus" : 1,
    "errmsg" : "loading local.system.replset config (LOADINGCONFIG)",
    "ok" : 0
    }


    I also tried adding adding the new IP and then thought to remove the older
    one. using rs.add() and then rs.remove() .
    But again same issue .


    Appreciate your help.

    Thanks Deepak
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/OZdH03KErwsJ.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Deepak Diwakar at Apr 18, 2012 at 12:42 pm
    Nope. Both nodes showing status "STRATUP2".

    Also I would like to know whether we can give "hostname" as a host
    option instead of giving DNS or IP-address similar to what we do in HDFS
    setting . I am trying it and its not working out .

    Any suggestion to have best practice to put host in config so that there
    would be a minimal change in case of a node is getting replaced.

    Thanks
    - Deepak Diwakar,



    On 18 April 2012 13:51, gregor wrote:

    Is one of the nodes still a primary ? You should be able to reconfigure by
    sending it commands

    http://www.mongodb.org/display/DOCS/Reconfiguring+a+replica+set+when+members+are+down

    On Wednesday, April 18, 2012 6:25:30 AM UTC+1, ddeepak wrote:


    Hi

    I am new to MongoDB.

    I have setup a replica of 3 nodes with one arbiter on EC2. In My test
    setup only primary and arbiter has elastic ip and the secondary has dynamic
    ip generated by EC2.

    Now when I restarted the setup, IP of secondary has been changed . And I
    am not able to update the config .

    I tried changing the config :

    config = {_id: 'ticklereplica', members: [
    {_id: 0, host: 'Primary:27017'},
    {_id: 1, host: 'Changed_secondary:27017'},
    {_id: 2, host: 'arbiter:27017', arbiterOnly: true}]
    }

    And then ran rs.reconfig(config).
    It is not working out. It is throwing following error: -
    {
    "startupStatus" : 1,
    "errmsg" : "loading local.system.replset config (LOADINGCONFIG)",
    "ok" : 0
    }


    I also tried adding adding the new IP and then thought to remove the
    older one. using rs.add() and then rs.remove() .
    But again same issue .


    Appreciate your help.

    Thanks Deepak
    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/OZdH03KErwsJ.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Deepak Diwakar at Apr 18, 2012 at 12:45 pm
    "Hostname" funda similar to HDFS is worked out here :)

    Would still appreciate if someone suggest me how to recover form STARTUP2
    mode , and get one node as primary and other as arbiter .


    Thanks
    - Deepak Diwakar,



    On 18 April 2012 18:11, Deepak Diwakar wrote:


    Nope. Both nodes showing status "STRATUP2".

    Also I would like to know whether we can give "hostname" as a host
    option instead of giving DNS or IP-address similar to what we do in HDFS
    setting . I am trying it and its not working out .

    Any suggestion to have best practice to put host in config so that there
    would be a minimal change in case of a node is getting replaced.

    Thanks
    - Deepak Diwakar,




    On 18 April 2012 13:51, gregor wrote:

    Is one of the nodes still a primary ? You should be able to reconfigure
    by sending it commands

    http://www.mongodb.org/display/DOCS/Reconfiguring+a+replica+set+when+members+are+down

    On Wednesday, April 18, 2012 6:25:30 AM UTC+1, ddeepak wrote:


    Hi

    I am new to MongoDB.

    I have setup a replica of 3 nodes with one arbiter on EC2. In My test
    setup only primary and arbiter has elastic ip and the secondary has dynamic
    ip generated by EC2.

    Now when I restarted the setup, IP of secondary has been changed . And
    I am not able to update the config .

    I tried changing the config :

    config = {_id: 'ticklereplica', members: [
    {_id: 0, host: 'Primary:27017'},
    {_id: 1, host: 'Changed_secondary:27017'},
    {_id: 2, host: 'arbiter:27017', arbiterOnly: true}]
    }

    And then ran rs.reconfig(config).
    It is not working out. It is throwing following error: -
    {
    "startupStatus" : 1,
    "errmsg" : "loading local.system.replset config (LOADINGCONFIG)",
    "ok" : 0
    }


    I also tried adding adding the new IP and then thought to remove the
    older one. using rs.add() and then rs.remove() .
    But again same issue .


    Appreciate your help.

    Thanks Deepak
    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/OZdH03KErwsJ.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Gregor at Apr 18, 2012 at 4:58 pm
    Can you run & paste rs.status() and rs.config() please ?

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/yccRknOual4J.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Deepak Diwakar at Apr 19, 2012 at 5:24 am
    Here is rs.status: -
    rs.status();
    {
    "set" : "ticklereplica",
    "date" : ISODate("2012-04-19T05:17:27Z"),
    "myState" : 5,
    "members" : [
    {
    "_id" : 0,
    "name" : "Node-1:27017",
    "health" : 1,
    "state" : 5,
    "stateStr" : "STARTUP2",
    "optime" : {
    "t" : 0,
    "i" : 0
    },
    "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
    "self" : true
    },
    {
    "_id" : 1,
    "name" : "Node-2:27017",
    "health" : -1,
    "state" : 6,
    "stateStr" : "UNKNOWN",
    "uptime" : 0,
    "optime" : {
    "t" : 0,
    "i" : 0
    },
    "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
    "lastHeartbeat" : ISODate("1970-01-01T00:00:00Z"),
    "pingMs" : -603979656
    },
    {
    "_id" : 2,
    "name" : "Arbiter:27017",
    "health" : 1,
    "state" : 5,
    "stateStr" : "STARTUP2",
    "uptime" : 15,
    "optime" : {
    "t" : 1334669447000,
    "i" : 1
    },
    "optimeDate" : ISODate("2012-04-17T13:30:47Z"),
    "lastHeartbeat" : ISODate("2012-04-19T05:17:26Z"),
    "pingMs" : 54978
    }
    ],
    "ok" : 1
    }

    And rs.conf() is : ---

    rs.conf()
    {
    "_id" : "ticklereplica",
    "version" : 1,
    "members" : [
    {
    "_id" : 0,
    "host" : "Node-1:27017"
    },
    {
    "_id" : 1,
    "host" : "Node-2:27017"
    },
    {
    "_id" : 2,
    "host" : "Arbiter:27017",
    "arbiterOnly" : true
    }
    ]
    }



    - Deepak Diwakar,



    On 18 April 2012 22:28, gregor wrote:

    Can you run & paste rs.status() and rs.config() please ?


    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/yccRknOual4J.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Nat at Apr 19, 2012 at 5:42 am
    Did you make sure that each name you put into replconfig can be resolved into ip address from each box?
    -----Original Message-----
    From: Deepak Diwakar <ddeepak4u@gmail.com>
    Sender: mongodb-user@googlegroups.com
    Date: Thu, 19 Apr 2012 10:53:46
    To: <mongodb-user@googlegroups.com>
    Reply-To: mongodb-user@googlegroups.com
    Subject: Re: [mongodb-user] Re: How to change the slave IP in replica config

    Here is rs.status: -
    rs.status();
    {
    "set" : "ticklereplica",
    "date" : ISODate("2012-04-19T05:17:27Z"),
    "myState" : 5,
    "members" : [
    {
    "_id" : 0,
    "name" : "Node-1:27017",
    "health" : 1,
    "state" : 5,
    "stateStr" : "STARTUP2",
    "optime" : {
    "t" : 0,
    "i" : 0
    },
    "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
    "self" : true
    },
    {
    "_id" : 1,
    "name" : "Node-2:27017",
    "health" : -1,
    "state" : 6,
    "stateStr" : "UNKNOWN",
    "uptime" : 0,
    "optime" : {
    "t" : 0,
    "i" : 0
    },
    "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
    "lastHeartbeat" : ISODate("1970-01-01T00:00:00Z"),
    "pingMs" : -603979656
    },
    {
    "_id" : 2,
    "name" : "Arbiter:27017",
    "health" : 1,
    "state" : 5,
    "stateStr" : "STARTUP2",
    "uptime" : 15,
    "optime" : {
    "t" : 1334669447000,
    "i" : 1
    },
    "optimeDate" : ISODate("2012-04-17T13:30:47Z"),
    "lastHeartbeat" : ISODate("2012-04-19T05:17:26Z"),
    "pingMs" : 54978
    }
    ],
    "ok" : 1
    }

    And rs.conf() is : ---

    rs.conf()
    {
    "_id" : "ticklereplica",
    "version" : 1,
    "members" : [
    {
    "_id" : 0,
    "host" : "Node-1:27017"
    },
    {
    "_id" : 1,
    "host" : "Node-2:27017"
    },
    {
    "_id" : 2,
    "host" : "Arbiter:27017",
    "arbiterOnly" : true
    }
    ]
    }



    - Deepak Diwakar,



    On 18 April 2012 22:28, gregor wrote:

    Can you run & paste rs.status() and rs.config() please ?


    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/yccRknOual4J.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Gregor at Apr 19, 2012 at 9:30 am
    It's not clear why you don't have a primary. I would perhaps suggest that
    you should reconfigure the set to only include Node-1 which will force it
    to be primary and then add in the other nodes.
    But first take a look at the log files for Node-1 - are there any warning
    or error messages that suggest why it is not becoming the primary? Can it
    not contact the arbiter perhaps? If so it wouldn't be able to elect itself.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/e3dyrt0anA4J.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Deepak Diwakar at Apr 19, 2012 at 6:03 pm
    Thanks for the suggestion.
    And Yes I had done re-setup the replica using only hostname to avoid
    config changes and its perfectly working .

    But for the old setup : -
    Looking into the log I found that - There was one point of time when
    arbiter was not reachable from node-1 and hence node-1 got only 1 vote and
    changed into STARTUP2 mode.

    My point is if all the nodes are communicating with each other over desired
    port and if one restarts the cluster, shouldn't it recover from that
    (read-only)mode ?

    Since both the nodes are in STARTUP-2 mode, reconfiguring through mongo
    console was not happening . There should have a safe-mode to recover
    from this situation?

    Help me to understand how to reconfigure the same set of node for replica
    in a given situation.

    Thanks
    - Deepak Diwakar,



    On 19 April 2012 14:59, gregor wrote:

    It's not clear why you don't have a primary. I would perhaps suggest that
    you should reconfigure the set to only include Node-1 which will force it
    to be primary and then add in the other nodes.
    But first take a look at the log files for Node-1 - are there any warning
    or error messages that suggest why it is not becoming the primary? Can it
    not contact the arbiter perhaps? If so it wouldn't be able to elect itself.
    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/e3dyrt0anA4J.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Gregor at Apr 24, 2012 at 10:27 am
    Before you started using Node-2:27017 as the host in your config you were
    using IP addresses?
    I wonder if somehow you ended up with 4 nodes in your replica set - the old
    node 2 IP and the new node 2 IP.
    And that's why the host 1 and arbiter couldn't elect a primary.
    On Thursday, April 19, 2012 7:02:47 PM UTC+1, ddeepak wrote:

    Thanks for the suggestion.
    And Yes I had done re-setup the replica using only hostname to avoid
    config changes and its perfectly working .

    But for the old setup : -
    Looking into the log I found that - There was one point of time when
    arbiter was not reachable from node-1 and hence node-1 got only 1 vote and
    changed into STARTUP2 mode.

    My point is if all the nodes are communicating with each other over
    desired port and if one restarts the cluster, shouldn't it recover from
    that (read-only)mode ?

    Since both the nodes are in STARTUP-2 mode, reconfiguring through mongo
    console was not happening . There should have a safe-mode to recover
    from this situation?

    Help me to understand how to reconfigure the same set of node for replica
    in a given situation.

    Thanks
    - Deepak Diwakar,



    On 19 April 2012 14:59, gregor wrote:

    It's not clear why you don't have a primary. I would perhaps suggest that
    you should reconfigure the set to only include Node-1 which will force it
    to be primary and then add in the other nodes.
    But first take a look at the log files for Node-1 - are there any warning
    or error messages that suggest why it is not becoming the primary? Can it
    not contact the arbiter perhaps? If so it wouldn't be able to elect itself.
    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/e3dyrt0anA4J.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/I11Qn08lOOYJ.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Gregor at Apr 24, 2012 at 2:23 pm
    What version are you using? There was an issue in 2.0.0 that was fixed in
    2.0.2
    https://jira.mongodb.org/browse/SERVER-3899
    On Tuesday, April 24, 2012 11:27:28 AM UTC+1, gregor wrote:

    Before you started using Node-2:27017 as the host in your config you were
    using IP addresses?
    I wonder if somehow you ended up with 4 nodes in your replica set - the
    old node 2 IP and the new node 2 IP.
    And that's why the host 1 and arbiter couldn't elect a primary.
    On Thursday, April 19, 2012 7:02:47 PM UTC+1, ddeepak wrote:

    Thanks for the suggestion.
    And Yes I had done re-setup the replica using only hostname to avoid
    config changes and its perfectly working .

    But for the old setup : -
    Looking into the log I found that - There was one point of time when
    arbiter was not reachable from node-1 and hence node-1 got only 1 vote and
    changed into STARTUP2 mode.

    My point is if all the nodes are communicating with each other over
    desired port and if one restarts the cluster, shouldn't it recover from
    that (read-only)mode ?

    Since both the nodes are in STARTUP-2 mode, reconfiguring through mongo
    console was not happening . There should have a safe-mode to recover
    from this situation?

    Help me to understand how to reconfigure the same set of node for
    replica in a given situation.

    Thanks
    - Deepak Diwakar,



    On 19 April 2012 14:59, gregor wrote:

    It's not clear why you don't have a primary. I would perhaps suggest
    that you should reconfigure the set to only include Node-1 which will force
    it to be primary and then add in the other nodes.
    But first take a look at the log files for Node-1 - are there any
    warning or error messages that suggest why it is not becoming the primary?
    Can it not contact the arbiter perhaps? If so it wouldn't be able to elect
    itself.
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/e3dyrt0anA4J.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/VlDRH3Td-FMJ.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Related Discussions

Discussion Navigation
viewthread | post

3 users in discussion

Deepak Diwakar: 5 posts Gregor: 5 posts Nat: 1 post