Mongo ghostsync and slaveDelay (Japanease)
-
Upload
hiroaki-kubota -
Category
Technology
-
view
702 -
download
1
Transcript of Mongo ghostsync and slaveDelay (Japanease)
MongoDBghost sync & slaveDelay
-2 -
こんなログ見たことある?“replica set ghost target no good”
What is GHOST ?
-4 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync target
Sync target
-5 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync fail
Sync target
-6 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync target
Sync target
-7 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync target
Sync target
Ghost slave
Ghost target
NO GOOD ?
-9 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync target
Sync target
-10 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync target
Sync fail
-11 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync target
Sync target
-12 -
replica set ghost target no good
Primary
Secondary
Secondary
Sync target
Sync target
“replica set ghost target no good”
NO GOOD !!(2.0.X系 )
-14 -
replica set ghost target no good
■ Ghost sync● Replica-Setの可用性を向上する為のユニークな機能– ネットワーク部分障害時などに威力を発揮– primary oplog 溢れ対策に一部のsecondaryに巨大なoplogを用意し ピーク時間帯をやり過ごしたり
– 新規secondaryをjoinする際の大量同期に使ったり
● ただ2.0系には循環参照のバグあり!!– 2.2系を使うこと
Ghost sync on 2.3/2.4
-16 -
proper ghost sync
Primary
Secondary
Secondary
Sync fail
Sync target
-17 -
proper ghost sync
Primary
Secondary
Secondary
Sync target
Sync target
-18 -
proper ghost sync
Primary
Secondary
Secondary
Sync target
Sync target
Ghost slave
Ghost target
-19 -
proper ghost sync
Primary
Secondary
Secondary
Sync target
Sync target
経路が復旧すれば直ちに同期先が戻る
-20 -
Ghost sync on 2.3/2.4
■ Sync details● “settings.chainingAllowed=false” (2.2系以上)の場合 常にPrimaryから同期する– syncFrom()による指定はchainingAllowedより優先– syncFrom()の設定は単にonメモリに保存され、クリアできない。(要再起動)– syncForm()の設定は同期に失敗するとクリアされる。
● PrimaryのopTimeをチェックし 新鮮で近いノードを同期ターゲットとして選択する– 新鮮:自ノードより新しくPrimaryから30秒以内の鮮度– 近い:ping の応答時間– slaveDelayやhiddenではない– vetoリスト(拒否リスト)に入っていない
What is slaveDelay ?
-22 -
slaveDelay
Primary
SecondaryslaveDelay=60
Secondary
Sync target
-23 -
slaveDelay
Primary
SecondaryslaveDelay=60
Secondary
A
Inset A
-24 -
slaveDelay
Primary
SecondaryslaveDelay=60
Secondary
ASync immediately
A
-25 -
slaveDelay
Primary
SecondaryslaveDelay=60
Secondary
A AB
Inset B
-26 -
slaveDelay
Primary
SecondaryslaveDelay=60
Secondary
ASync immediately
AB B
-27 -
slaveDelay
Primary
SecondaryslaveDelay=60
Secondary
A
Sync A after 60 secs from “Insert A”
A
A
B B
-28 -
slaveDelay
■ Replica-Set コンフィグで指定する● slaveDelay=<seconds> を指定したノードはPRIMARYから 指定秒遅れたコピーを持つ様に動作する。
● priority=0 を同時に指定しなければならない。– これはslaveDelayノードはPRIMARYに成れない事を意味する
● 殆どの場合hidden=true と併用した方が良い。– 大抵、クライアント(アプリ)は最新のデータを読みたいはず。
● slaveDelayはヒューマンエラー対策として有用! 例えば、間違えて“db.dropDatabase()” を発行してしまった場合
通常、全てのsecondary達は直ちにデータファイルを削除してしまう。 よって、データは完全に失われてしまう。 しかしslaveDelayノードでは遅延期間内はまだ消えてない! 急いでslaveDelayノードを落とせ!!(同期を防ぐ)
Ghost sync & slaveDelay
-30 -
Ghost sync & slaveDelay
Primary Secondary
Sync target
Sync target
Ghost slave
Ghost target
SecondaryslaveDelay=60
-31 -
Ghost sync & slaveDelay
Primary
SecondaryslaveDelay=60
Secondary
A
Inset A
-32 -
Primary
SecondaryslaveDelay=60
Secondary
ASync immediately
A
Ghost sync & slaveDelay
-33 -
Primary
SecondaryslaveDelay=60
Secondary
A AB
Inset B
Ghost sync & slaveDelay
-34 -
Primary
SecondaryslaveDelay=60
Secondary
ASync immediately
AB B
Ghost sync & slaveDelay
-35 -
Primary
SecondaryslaveDelay=60
Secondary
A AB B
Sync A after 60 secs from “Insert A”
A
Ghost sync & slaveDelay
It's OK !!
-37 -
Primary Secondary
SecondaryslaveDelay=60
Ghost sync & slaveDelay
-38 -
Primary
SecondaryslaveDelay=60
Secondary
A
Inset A
Ghost sync & slaveDelay
-39 -
Primary
SecondaryslaveDelay=60
Secondary
AB
Inset B
Ghost sync & slaveDelay
-40 -
Primary
SecondaryslaveDelay=60
Secondary
A
Sync A after 60 secs from “Insert A”
A
B A
Sync immediately,but delayed implicitly
Ghost sync & slaveDelay
No good ...
-42 -
■ Ghost syncとslaveDelayは相性が悪い
slaveDelay ノードはPRIMARYノードから遅れているので同期元として選ばれるべきでは無い。
slaveOkで動作しているクライアントはPrimaryのデータ更新してもsecondaryからはからは古いデータしか読めない状況になる!!
slaveDelayノードを同期元として選んでしまったノードは、クライアント(アプリ)からリクエストを受けてはならない。( MAINTAINANCE か HIDDENとして扱われるべき)
Ghost sync & slaveDelay
[slaveDelay with Ghostsync] https://jira.mongodb.org/browse/SERVER-8476
対策よろ。。
補足.
-45 -
Primary Secondary
Vote with ghost sync
Secondary SecondarySecondary
-46 -
Primary Secondary
Vote with ghost sync
Secondary SecondarySecondary
-47 -
Primary Secondary
Vote with ghost sync
Secondary SecondarySecondary
-48 -
Primary Secondary
Vote with ghost sync
Secondary SecondarySecondary
-49 -
PrimarySecondary
Vote with ghost sync
Secondary SecondarySecondary
-50 -
Primary
Secondary
Vote with ghost sync
Secondary
SecondarySecondary