设为首页 加入收藏

TOP

MySQL高可用MMM安装部署以及故障转移详细资料汇总(五)
2015-11-21 01:54:49 来源: 作者: 【 】 浏览:8
Tags:MySQL 可用 MMM 安装 部署 以及 故障 转移 详细 资料 汇总
00:10:57] OK

db1 rep_threads [last change:2015/04/14 00:10:57] OK

db1 rep_backlog [last change: 2015/04/1400:10:57] OK: Backlog is null

?

[root@oraclem1 mysql-mmm]#

?

8.3 查看mmm_control日志

[root@oraclem1 mysql-mmm]# tail -f/var/log/mysql-mmm/mmm_mond.log

2015/04/14 00:55:29 FATAL Admin changedstate of 'db1' from AWAITING_RECOVERY to ONLINE

2015/04/14 00:55:29 INFO Orphaned role 'writer(192.168.52.120)'has been assigned to 'db1'

2015/04/14 00:55:29 INFO Orphaned role 'reader(192.168.52.131)'has been assigned to 'db1'

2015/04/14 00:55:29 INFO Orphaned role 'reader(192.168.52.129)'has been assigned to 'db1'

2015/04/14 00:55:29 INFO Orphaned role 'reader(192.168.52.128)'has been assigned to 'db1'

2015/04/14 00:58:15 FATAL Admin changedstate of 'db2' from AWAITING_RECOVERY to ONLINE

2015/04/14 00:58:15 INFO Moving role 'reader(192.168.52.131)'from host 'db1' to host 'db2'

2015/04/14 00:58:15 INFO Moving role 'reader(192.168.52.129)'from host 'db1' to host 'db2'

2015/04/14 00:58:18 FATAL Admin changedstate of 'db3' from AWAITING_RECOVERY to ONLINE

2015/04/14 00:58:18 INFO Moving role 'reader(192.168.52.131)'from host 'db2' to host 'db3'

?

8.4 mmm_control的命令

[root@oraclem1 ~]# mmm_control --help
Invalid command '--help'
 
Valid commands are:
    help                              - show this message
    ping                              - ping monitor
    show                              - show status
    checks [
  
   |all [
   
    |all]] - show checks status
   
  
    set_online 
  
                    - set host 
   
     online
   
  
    set_offline 
  
                   - set host 
   
     offline
   
  
    mode                              - print current mode.
    set_active                        - switch into active mode.
    set_manual                        - switch into manual mode.
    set_passive                       - switch into passive mode.
    move_role [--force] 
   
   
     - move exclusive role 
    
      to host 
     
    
   
  
                                        (Only use --force if you know what you are doing!)
    set_ip 
   
   
     - set role with ip 
    
      to host 
     
    
   
  
 
[root@oraclem1 ~]#

?

?

9,测试切换操作

9.1 mmm切换原理

slave agent收到new master发送的set_active_master信息后如何进行切换主库

源码 Agent\Helpers\Actions.pm

set_active_master($new_master)

Try to catch up with the old master as faras possible and change the master to the new host.

(Syncs to the master log if the old masteris reachable. Otherwise syncs to the relay log.)

?

?

(1)、获取同步的binlog和position

先获取new master的show slavestatus中的 Master_Log_File、Read_Master_Log_Pos

wait_log=Master_Log_File, wait_pos=Read_Master_Log_Pos

?

如果old master可以连接,再获取oldmaster的show master status中的File、Position

wait_log=File, wait_pos=Position # 覆盖new master的slave信息,以old master 为准

?

(2)、slave追赶old master的同步位置

SELECT MASTER_POS_WAIT('wait_log', wait_pos);

?

#停止同步

STOP SLAVE;

?

(3)、设置new master信息

#此时 new master已经对外提供写操作。

#(在main线程里new master先接收到激活的消息,new master 转换(包含vip操作)完成后,然后由_distribute_roles将master变动同步到slave上)

#在new master转换完成后,如果能执行flush logs,更方便管理

#获取new master的binlog数据。

SHOW MASTER STATUS;

?

#从配置文件/etc/mysql-mmm/mmm_common.conf 读取同步帐户、密码

replication_user、replication_password

?

#设置新的同步位置

CHANGE MASTER TO MASTER_HOST='$new_peer_host',MASTER_PORT=$new_peer_port

,MASTER_USER='$repl_user', MASTER_PASSWORD='$repl_password'

,MASTER_LOG_FILE='$master_log', MASTER_LOG_POS=$master_pos;

?

#开启同步

START SLAVE;

?

9.2 停止db1,看write是否会自动切换到db2

(1)在db1上执行service mysqlstop;

[root@data01 ~]# service mysql stop;

Shutting down MySQL..... SUCCESS!

[root@data01 ~]#

?

(2)在monitor用mmm_control查看状态

[root@oraclem1 ~]# mmm_control show

db1(192.168.52.129) master

首页 上一页 2 3 4 5 6 7 8 下一页 尾页 5/8/8
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MySQL连续数统计 下一篇MySQL查询结果为乱码

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: