Mongo ghostsync and slaveDelay

43
MongoDB ghost sync & slaveDelay

Transcript of Mongo ghostsync and slaveDelay

Page 1: Mongo ghostsync and slaveDelay

MongoDBghost sync & slaveDelay

Page 2: Mongo ghostsync and slaveDelay

-2 -

Have you ever seen the message of

“replica set ghost target no good”

Page 3: Mongo ghostsync and slaveDelay

What is GHOST ?

Page 4: Mongo ghostsync and slaveDelay

-4 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync target

Sync target

Page 5: Mongo ghostsync and slaveDelay

-5 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync fail

Sync target

Page 6: Mongo ghostsync and slaveDelay

-6 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync target

Sync target

Page 7: Mongo ghostsync and slaveDelay

-7 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync target

Sync target

Ghost slave

Ghost target

Page 8: Mongo ghostsync and slaveDelay

NO GOOD ?

Page 9: Mongo ghostsync and slaveDelay

-9 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync target

Sync target

Page 10: Mongo ghostsync and slaveDelay

-10 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync target

Sync fail

Page 11: Mongo ghostsync and slaveDelay

-11 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync target

Sync target

Page 12: Mongo ghostsync and slaveDelay

-12 -

replica set ghost target no good

Primary

Secondary

Secondary

Sync target

Sync target

“replica set ghost target no good”

Page 13: Mongo ghostsync and slaveDelay

NO GOOD !!(until 2.0.X )

Page 14: Mongo ghostsync and slaveDelay

-14 -

replica set ghost target no good

■ Ghost sync● Ghost sync can help replica set to improve availability– When temporary or partial network fault– When overflow the primary's oplog, only the nearest secondary can follow to the

primary and offer oplog to other secondaries by its large oplog space.– When new member of replica node joining.

● Ghost sync has the chance to ciclic sync between secondaries.– Secondaries specify the ghost target each other.(until 2.0.X)

Page 15: Mongo ghostsync and slaveDelay

Ghost sync on 2.3/2.4

Page 16: Mongo ghostsync and slaveDelay

-16 -

proper ghost sync

Primary

Secondary

Secondary

Sync fail

Sync target

Page 17: Mongo ghostsync and slaveDelay

-17 -

proper ghost sync

Primary

Secondary

Secondary

Sync target

Sync target

Page 18: Mongo ghostsync and slaveDelay

-18 -

proper ghost sync

Primary

Secondary

Secondary

Sync target

Sync target

Ghost slave

Ghost target

Page 19: Mongo ghostsync and slaveDelay

-19 -

proper ghost sync

Primary

Secondary

Secondary

Sync target

Sync target

Will change target as soon as possible

Page 20: Mongo ghostsync and slaveDelay

-20 -

Ghost sync on 2.3/2.4

■ Sync details● Sync from primary when “settings.chainingAllowed=false” since 2.2.2– syncFrom() is preferred for “settings.chainingAllowed”– The target is specifed by syncFrom() is saved on memory and cannot reset...

● Get primary's op time and choise the fresh nearest node to sync.– fresh : before me and behind within 30 seconds from Primary– nearest: by ping time– not slaveDelay and not hidden– not in the veto list

Page 21: Mongo ghostsync and slaveDelay

What is slaveDelay ?

Page 22: Mongo ghostsync and slaveDelay

-22 -

slaveDelay

Primary

SecondaryslaveDelay=60

Secondary

Sync target

Page 23: Mongo ghostsync and slaveDelay

-23 -

slaveDelay

Primary

SecondaryslaveDelay=60

Secondary

A

Inset A

Page 24: Mongo ghostsync and slaveDelay

-24 -

slaveDelay

Primary

SecondaryslaveDelay=60

Secondary

ASync immediately

A

Page 25: Mongo ghostsync and slaveDelay

-25 -

slaveDelay

Primary

SecondaryslaveDelay=60

Secondary

A AB

Inset B

Page 26: Mongo ghostsync and slaveDelay

-26 -

slaveDelay

Primary

SecondaryslaveDelay=60

Secondary

ASync immediately

AB B

Page 27: Mongo ghostsync and slaveDelay

-27 -

slaveDelay

Primary

SecondaryslaveDelay=60

Secondary

A

Sync A after 60 secs from “Insert A”

A

A

B B

Page 28: Mongo ghostsync and slaveDelay

-28 -

slaveDelay

■ When construct the replicaset● You can specify the slaveDelay=<seconds> attribute to make delay the SECONDARY node sync data from the PRIMARY.

●You MUST specify the priority=0 attribute with slaveDelay.– It means slaveDelay node cannot promote to the PRIMARY.

● You SHOULD specify the hidden=true with slaveDelay in many cases.– You would have to prevent the slaveDelay node from connecting with client.

● slaveDelay would be used as the realtime backup for human errors.ex >When you run the “db.dropDatabase()” command by MISS !!

All normal secondaries delete the data files immediately and never recover. But then you have a chance to recover datas from slaveDelay node, if you did the proper action. (Shutdown this node IN A HURRY !!! )

Page 29: Mongo ghostsync and slaveDelay

Ghost sync & slaveDelay

Page 30: Mongo ghostsync and slaveDelay

-30 -

Ghost sync & slaveDelay

Primary Secondary

Sync target

Sync target

Ghost slave

Ghost target

SecondaryslaveDelay=60

Page 31: Mongo ghostsync and slaveDelay

-31 -

Ghost sync & slaveDelay

Primary

SecondaryslaveDelay=60

Secondary

A

Inset A

Page 32: Mongo ghostsync and slaveDelay

-32 -

Primary

SecondaryslaveDelay=60

Secondary

ASync immediately

A

Ghost sync & slaveDelay

Page 33: Mongo ghostsync and slaveDelay

-33 -

Primary

SecondaryslaveDelay=60

Secondary

A AB

Inset B

Ghost sync & slaveDelay

Page 34: Mongo ghostsync and slaveDelay

-34 -

Primary

SecondaryslaveDelay=60

Secondary

ASync immediately

AB B

Ghost sync & slaveDelay

Page 35: Mongo ghostsync and slaveDelay

-35 -

Primary

SecondaryslaveDelay=60

Secondary

A AB B

Sync A after 60 secs from “Insert A”

A

Ghost sync & slaveDelay

Page 36: Mongo ghostsync and slaveDelay

It's OK !!

Page 37: Mongo ghostsync and slaveDelay

-37 -

Primary Secondary

SecondaryslaveDelay=60

Ghost sync & slaveDelay

Page 38: Mongo ghostsync and slaveDelay

-38 -

Primary

SecondaryslaveDelay=60

Secondary

A

Inset A

Ghost sync & slaveDelay

Page 39: Mongo ghostsync and slaveDelay

-39 -

Primary

SecondaryslaveDelay=60

Secondary

AB

Inset B

Ghost sync & slaveDelay

Page 40: Mongo ghostsync and slaveDelay

-40 -

Primary

SecondaryslaveDelay=60

Secondary

A

Sync A after 60 secs from “Insert A”

A

B A

Sync immediately

Ghost sync & slaveDelay

Page 41: Mongo ghostsync and slaveDelay

No good ...

Page 42: Mongo ghostsync and slaveDelay

-42 -

■ Ghost sync & slaveDelay are on bad teams... The slaveDelay node's oplog is always delay from PRIMARY

So slaveDelay node's should NOT be chosen as Ghost target.

Or the SECONDARY which chose the slaveDelay node as Ghost target SHOULD change its status MAINTAINANCE (or be treated as the HIDDEN)

Then, clients will get fresh datas from other SECONDARIES or PRIMARY !!

Ghost sync & slaveDelay

Page 43: Mongo ghostsync and slaveDelay

[slaveDelay with Ghostsync] https://jira.mongodb.org/browse/SERVER-8476

Sincerely.