设为首页 加入收藏

TOP

MySQL 5.6不停机双主一从搭建(活跃双主一从基于日志点复制)(四)
2017-06-22 10:23:40 】 浏览:610
Tags:MySQL 5.6 停机 双主一 搭建 活跃 基于 日志 复制
1 |
+------+
1 row in set (0.00 sec) >一主一从同步成功!


##################################################
#至此A到B的复制已经配置完成,下面配置从B到A的复制。#
##################################################


声明> 下面操作中 新主库即为原从库(10.219.24.22) 新从库为原主库(10.219.24.25)


11、 新主库创建同步用户
mysql> GRANT replication slave ON *.* TO 'slave22'@'%' IDENTIFIED BY 'oracle';
Query OK, 0 rows affected (0.00 sec)


12、 新主库查看 binlog 文件号与 position 点
mysql> show master status;
+---------------+----------+--------------+------------------+------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+------------------------------------------+
| binlog.000010 | 120 | | | 29d68531-4cf9-11e7-8e1f-000c297c4100:1-4 |
+---------------+----------+--------------+------------------+------------------------------------------+
1 row in set (0.00 sec)


13、 新从库指定与主库同步的基本信息
mysql>
change master to
master_host='10.219.24.22',
master_port=3306,
master_user='slave22',
master_password='oracle',
master_log_file='binlog.000010',
master_log_pos=120;
Query OK, 0 rows affected, 2 warnings (0.04 sec)


14、新从库打开 slave 复制功能
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
15、 新从库检测同步复制状态
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.219.24.22
Master_User: slave22
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000010
Read_Master_Log_Pos: 120
Relay_Log_File: relay.000002
Relay_Log_Pos: 280
Relay_Master_Log_File: binlog.000010
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 120
Relay_Log_Space: 443
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 22
Master_UUID: 70023652-4dc7-11e7-9360-000c2944297a
Master_Info_File: /data/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: 29d68531-4cf9-11e7-8e1f-000c297c4100:1-4
Auto_Position: 0
1 row in set (0.00 sec)


ERROR:
No query specified


-- 新从库测试数据同步状态
mysql> create database mm_repl;
Query OK, 1 row affected (0.00 sec)
mysql> use mm_repl;
Database changed
mysql> create table mm_repl(id int auto_increment,name varchar(10), primary key(id));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into mm_repl(name) values("andy"),("taoYe");
Query OK, 1 row affected (0.00 sec)
mysql> select * from mm_repl;
+----+-------+
| id | name |
+----+-------+
| 1 | andy |
| 11 | taoYe |
+----+-------+
2 rows in set (0.00 sec)
-- 新主库测试数据同步状态
mysql> select * from mm_repl;
+---

首页 上一页 1 2 3 4 5 6 下一页 尾页 4/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL 5.6不停机主从搭建(一主一.. 下一篇MySQL无法远程访问的解决方案

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目