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

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

MHA實(shí)現(xiàn)mysql主從切換之主故障

2024-07-24 12:39:25
字體:
供稿:網(wǎng)友

下面來給各位同學(xué)介紹一個(gè)MHA實(shí)現(xiàn)mysql主從切換之主故障,手動(dòng)指定Master到從節(jié)點(diǎn),希望例子能幫助各位解決問題.

本文主要模擬實(shí)現(xiàn)主Master故障后,手動(dòng)指定Master到從節(jié)點(diǎn).

  1. #masterha_master_switch --master_state=dead --conf=/etc/masterha/app1.cnf  --dead_master_host=10.1.1.231 --dead_master_ip=10.1.1.231 --dead_master_port=63306  --new_master_host=10.1.1.234 --new_master_ip=10.1.1.234 --new_master_port=63306 

只顯示如下日志,部分信息在附件,利用MHA實(shí)現(xiàn)mysql主從切換之主故障–手動(dòng)指定Master到從節(jié)點(diǎn)的照片:

  1. ----- Failover Report ----- 
  2.  
  3. app1: MySQL Master failover 10.1.1.231 to 10.1.1.234 succeeded 
  4.  
  5. Master 10.1.1.231 is down! 
  6.  
  7. Check MHA Manager logs at compute-0-52.local for details. 
  8.  
  9. Started manual(interactive) failover. 
  10.  
  11. The latest slave 10.1.1.234(10.1.1.234:63306) has all relay logs for recovery. 
  12.  
  13. Selected 10.1.1.234 as a new master. 
  14.  
  15. 10.1.1.234: OK: Applying all logs succeeded. 
  16.  
  17. Generating relay diff files from the latest slave succeeded. 
  18.  
  19. 10.1.1.234: Resetting slave info succeeded. 
  20. --Vevb.com 
  21. Master failover to 10.1.1.234(10.1.1.234:63306) completed successfully. 

此時(shí)從庫已經(jīng)變成主庫,到10.1.1.234上查看如下信息:

  1. mysql> show master status; 
  2.  
  3. +------------------------+----------+--------------+--------------------------------------+-------------------+ 
  4.  
  5. | File                   | Position | Binlog_Do_DB | Binlog_Ignore_DB                     | Executed_Gtid_Set | 
  6.  
  7. +------------------------+----------+--------------+--------------------------------------+-------------------+ 
  8.  
  9. | mysql-slave-bin.000011 |      120 | denovo_ng    | mysql,denovo,test,information_schema |                   | 
  10.  
  11. +------------------------+----------+--------------+--------------------------------------+-------------------+ 
  12.  
  13. 1 row in set (0.00 sec) 
  14.  
  15. mysql> 

原主庫恢復(fù)以后,添加它為Slave到Master/Slave集群里面,具體操作如下:

1、10.1.1.234(新主庫)執(zhí)行如下,可參考:

centos5.6下mysql5.6主從環(huán)境安裝配置,http://www.diyoms.com/website/1318.html

grant replication slave on *.* to 'jpsync'@'10.1.1.231' identified by 'jppasswd';

flush privileges;

同時(shí)修改/etc/my.cnf添加如下:

skip_slave_start

注意:防止重啟數(shù)據(jù)庫,啟動(dòng)slave進(jìn)程,導(dǎo)致數(shù)據(jù)不一致.

并刪除master.info和relay-log.info.

2、10.1.1.231(新從庫)上執(zhí)行:

  1. change master to master_host='10.1.1.234',master_port=63306,master_user='jpsync'
  2. master_password='jppasswd', master_log_file='mysql-master-bin.000011',master_log_pos=120; 

這個(gè)時(shí)候再執(zhí)行show slave statusG;后出現(xiàn)如下結(jié)果說明主從復(fù)制已經(jīng)恢復(fù).

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 拉萨市| 辽中县| 枞阳县| 绥宁县| 宜阳县| 黔西县| 纳雍县| 留坝县| 富平县| 新民市| 宜宾市| 西充县| 治多县| 淄博市| 永德县| 沙田区| 阳东县| 库车县| 门源| 德昌县| 习水县| 元谋县| 梁山县| 泰州市| 弋阳县| 大冶市| 临邑县| 外汇| 马龙县| 山阳县| 赣榆县| 普兰店市| 孟村| 济阳县| 黄冈市| 南开区| 巫山县| 乌拉特后旗| 卢湾区| 肇庆市| 阜平县|