国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > 文庫 > 正文

非中斷業務數據庫移動一例

2024-09-07 22:12:51
字體:
來源:轉載
供稿:網友
  下面是某業務庫的遷移過程, 從Source Master/Slave集群遷移至Target MHA集群.
 
  前期準備, 配置數據從Source Master復制到Target Master, 即Target Master成為Source Master的Slave(若Target Master是新庫的話, 還可添加replicate-do-db=name過濾條件).
 
  遷移開始時, 在Source Master上執行flush no_write_to_binlog tables, 和flush tables with read lock.
 
  在Target Master上查看延時為0時, 執行flush binary logs. 然后stop slave, 和reset slave all, 清除Source Master至Target Master的復制關系.
 
  再后, 依次重啟各應用節點, 切換至Target Master新數據源.
 
  最后在Source Master上unlock tables, 至此遷移結束.
 
  該過程中的主角flush tables with read lock, 其含義為Closes all open tables and locks all tables for all databases with a global read lock, 即在MySQL數據庫Server層, 獲取一個全局讀鎖.
 
  那么配角flush no_write_to_binlog tables, 其含義為Closes all open tables, forces all tables in use to be closed, 起到加速flush tables with read lock操作完成的作用.
 
  在數據庫管理的過程中, 經常會見到flush tables with read lock的身影.
 
  如mysqldump備份時, 通過general log會看到如下輸出.
 
  mysqldump --login-path=mytest --default-character-set=utf8mb4 --single-transaction --routines --triggers --events --quick --force --master-data=2 --hex-blob --all-databases > full.sql
 
  25 Query FLUSH /*!40101 LOCAL */ TABLES
 
  25 Query FLUSH TABLES WITH READ LOCK
 
  25 Query SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
 
  25 Query START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */
 
  25 Query SHOW VARIABLES LIKE 'gtid/_mode'
 
  25 Query SELECT @@GLOBAL.GTID_EXECUTED
 
  25 Query SHOW MASTER STATUS
 
  25 Query UNLOCK TABLES
 
  又如xtrabackup備份時, 也可見類似日志.
 
  xtrabackup --defaults-file=/etc/my.cnf --user=abc --password=xyz --socket=/3306/mysql.sock --target-dir=./pxb_full --backup
 
  MHA在線手動切換時, 也用到了flush tables with read lock, 詳見如下輸出.
 
  masterha_master_switch --conf=/etc/masterha/app2/app2.cnf --master_state=alive --orig_master_is_new_slave
 
  ...
 
  It is better to execute FLUSH NO_WRITE_TO_BINLOG TABLES on the master before switching. Is it ok to execute on 192.168.4.33(192.168.4.33:3307)? (YES/no): yes
 
  Wed Feb 28 21:58:41 2018 - [info] Executing FLUSH NO_WRITE_TO_BINLOG TABLES. This may take long time..
 
  Wed Feb 28 21:58:41 2018 - [info]  ok.
 
  ...
 
  Wed Feb 28 21:58:43 2018 - [info] Locking all tables on the orig master to reject updates from everybody (including root):
 
  Wed Feb 28 21:58:43 2018 - [info] Executing FLUSH TABLES WITH READ LOCK..
 
  Wed Feb 28 21:58:43 2018 - [info]  ok.

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高唐县| 色达县| 南溪县| 沾益县| 六安市| 察隅县| 新宾| 成安县| 岐山县| 滦平县| 枝江市| 饶河县| 民县| 长丰县| 靖江市| 浦东新区| 利津县| 天长市| 浮梁县| 东辽县| 商水县| 隆安县| 江陵县| 乃东县| 凌云县| 长白| 黄陵县| 睢宁县| 凤城市| 周口市| 灵宝市| 罗平县| 泉州市| 明溪县| 北海市| 黄山市| 长垣县| 灯塔市| 吉首市| 普定县| 维西|