想法是先把 MySQL 的寫入動作擋住,然後把資料 sync 回 filesystem,這時候到備援機上 disconnect DRBD,再回到原來的 MySQL server 上開放寫入的動作。這時候備援機上的 DRBD 就是一份完整的 data。
詳細的指令大致上是這樣:
- 先在 DRBD primary 上的 MySQL 上跑
FLUSH TABLE WITH READ LOCK;,然後跑SHOW MASTER STATUS;把 binlog position 記起來。 - 在同一台機器上跑
sync; sync; sync把 buffer 裡的東西都寫回硬碟。 - 到 DRBD secondary 上跑
drbdadm disconnect [drbd_resource],其中 [drbd_resource] 要記得換成你自己在用的 resource name。 - 回到 DRBD primary 上直接 Ctrl-C,或是下
UNLOCK TABLES;釋放鎖定。 - 這時候到 DRBD secondary 上先把 monitor program 停掉,以免他亂來。
- 接下來還是在 DRBD secondary 上,要「催眠」這台主機的 DRBD 是 primary:
drbdadm primary [drbd_resource]。 - 「催眠」完後跑
mount -o ro /dev/drbd0 /mnt,用 read-only 狀態掛到 /mnt。如果不小心掛成非 read-only 也沒關係,等下記得重新 resync 就可以了。 - 把掛上來的 /mnt 整份資料複製出來,丟到預定要當 MySQL slave 的機器上。
- 複製完成後
unmount /mnt,然後告訴 DRBD「其實你是 secondary」:drbdadm secondary [drbd_resource]。 - 然後告訴 DRBD 需要重新 sync 檢查:
drbdadm -- --discard-my-data connect [drbd_resource]。 - 理論上這樣就完成了。接下來就是第一次如何設定 MySQL slave 的步驟,講 MySQL replication 的書籍應該都有說。
請教, 架構 DRBD, 是否一定要是分割區, 可以是某一個資料夾嗎? 因為我的電腦已經切好分割區並正在運作中, 如果要重新切割磁區, 就很麻煩......
回覆刪除In terms of banking options, most cards and cryptocurrencies are accepted. Wire transfer is also be|can be} an choice, 샌즈 카지노 nevertheless it usually carries a 3% fee. For those that do choose to join, heaps of|there are numerous} spectacular welcome bonuses and promotions which they'll benefit from. Not solely that, however BetMGM Casino is completely safe and safe, and your info will never be shared with any third-party distributors. We have assist on standby 24/7 to make sure you|ensure you|be positive to} have a seamless experience. Do not consider playing as a method of incomes cash, and solely play with cash you could afford to lose.
回覆刪除