S
S
Sveratum2013-11-15 11:54:30
MongoDB
Sveratum, 2013-11-15 11:54:30

MongoDB replication help me figure it out?

I check and get:


rs0:PRIMARY> rs.status()
{
        "set" : "rs0",
        "date" : ISODate("2013-11-15T08:47:30Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "IP:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 186686,
                        "optime" : Timestamp(1384505195, 1),
                        "optimeDate" : ISODate("2013-11-15T08:46:35Z"),
                        "self" : true
                },
                {
                        "_id" : 1,
                        "name" : "IP:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 822,
                        "optime" : Timestamp(1384322313, 1),
                        "optimeDate" : ISODate("2013-11-13T05:58:33Z"),
                        "lastHeartbeat" : ISODate("2013-11-15T08:47:29Z"),
                        "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
                        "pingMs" : 0
                },
                {
                        "_id" : 2,
                        "name" : "IP:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 822,
                        "optime" : Timestamp(1384322411, 1),
                        "optimeDate" : ISODate("2013-11-13T06:00:11Z"),
                        "lastHeartbeat" : ISODate("2013-11-15T08:47:28Z"),
                        "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
                        "pingMs" : 0
                }
        ],
        "ok" : 1
}
Why are all members of the replica PRIMARY, how to make one master and two slaves?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sveratum, 2013-11-19
@srsd

In general, for those who are interested:
On the main (master) in the shell, deleted the members of the replica, restarted mongo (otherwise, when adding, he cursed that such machines had already been added).
Restarted mongo on other machines.
From the main one, I added one host at a time and checked it from two machines, then added a third machine. Set priorities.
As I understand it, the whole cant was that I added all the members of the replica at once, and when I did one at a time and after each rs.reconfig everything worked.

R
Rpsl, 2013-11-15
@Rpsl

Try to initialize.


rs.initiate()

S
Sveratum, 2013-11-15
@srsd

Did. These are the conclusions after it. If I do it again I get "already initialized" and nothing else.

R
Rpsl, 2013-11-15
@Rpsl

It seems to me that the replica is not assembled correctly. Try to parse it, then on one first member do rs.initiate() and after that add the rest via rs.add()

http://docs.mongodb.org/manual/tutorial/deploy-replica-set/

S
Sveratum, 2013-11-15
@srsd

According to this document, it was made.
Let's go through the steps:
I edit the config file on each machine. Well, accordingly, I check the availability of cars for each other.
Then on the first machine I do rs.initiate() and then rs.add() and add the other two.
How to parse a replica?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question