设为首页 加入收藏

TOP

MySQL高可用解决方案MMM(二)
2017-04-14 10:23:25 】 浏览:387
Tags:MySQL 可用 解决方案 MMM
-----------------------+


| mysql-bin.000001 |      452 |              |          |                   |


+------------------+----------+--------------+------------------+-----------------------------------------------------+


在master2、slave1和slave2执行


mysql> change master to master_host='192.168.31.83',master_port=3306,master_user='rep',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=452;


mysql>slave start;


验证主从复制:


master2主机:


mysql> show slave status\G;


*************************** 1. row ***************************


Slave_IO_State: Waiting for master to send event


Master_Host: 192.168.31.83


Master_User: rep


Master_Port: 3306


Connect_Retry: 60


Master_Log_File: mysql-bin.000001


Read_Master_Log_Pos: 452


Relay_Log_File: relay-bin.000002


Relay_Log_Pos: 320


Relay_Master_Log_File: mysql-bin.000001


Slave_IO_Running: Yes


Slave_SQL_Running: Yes


slave1主机:


mysql> show slave status\G;


*************************** 1. row ***************************


Slave_IO_State: Waiting for master to send event


Master_Host: 192.168.31.83


Master_User: rep


Master_Port: 3306


Connect_Retry: 60


Master_Log_File: mysql-bin.000001


Read_Master_Log_Pos: 452


Relay_Log_File: relay-bin.000002


Relay_Log_Pos: 320


Relay_Master_Log_File: mysql-bin.000001


Slave_IO_Running: Yes


Slave_SQL_Running: Yes


slave2主机:


mysql> show slave status\G;


*************************** 1. row ***************************


Slave_IO_State: Waiting for master to send event


Master_Host: 192.168.31.83


Master_User: rep


Master_Port: 3306


Connect_Retry: 60


Master_Log_File: mysql-bin.000001


Read_Master_Log_Pos: 452


Relay_Log_File: relay-bin.000002


Relay_Log_Pos: 320


Relay_Master_Log_File: mysql-bin.000001


Slave_IO_Running: Yes


Slave_SQL_Running: Yes


如果Slave_IO_Running和Slave_SQL_Running都为yes,那么主从就已经配置OK了


把master1配置成master2的从库:


在master2上执行show master status ;获取binlog文件和Position点


mysql> show master status;


+------------------+----------+--------------+------------------+--------------------------------------------------+


| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |


+------------------+----------+--------------+------------------+---------------------------------------------------+


| mysql-bin.000001 |      452 |              |           |                   |


+------------------+----------+--------------+------------------+----------------------------------------------------+


在master1上执行:


mysql> change master to master_host='192.168.31.141',master_port=3306,master_user='rep',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=452;


mysql> start slave;


验证主从复制:


master1主机:


mysql> show slave status\G;


*************************** 1. row ***************************


Slave_IO_State: Waiting for master to send event


Master_Host: 192.168.31.141


Master_User: rep


Master_Port: 3306


Connect_Retry: 60


Master_Log_File: mysql-bin.000001


Read_Master_Log_Pos: 452


Relay_Log_File: relay-bin.000002


Relay_Log_Pos: 320


Relay_Mast

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL中的多表设计 下一篇MySQL主从复制与主主复制

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目