- 基本
#查看
mysql> show slave status\G
在配置文件my.ini设定主从复制模式:
#binlog_format=STATEMENT
binlog_format=ROW
#binlog_format=MIXED
mysql>show variables like 'binlog%format%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW |
+---------------+-------+
1 row in set (0.00 sec)
[root@MYSQL ~]# service mysqld stop
mysql> show processlist \G;
mysql> show variables like '%sync_binlog%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sync_binlog | 1 |
+---------------+-------+
1 row in set (0.00 sec)
2.MySQL 的一次错误处理 Got fatal error 1236 from master when reading data from binary log
mysql> flush logs;
mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000020 | 154 | | | |
+---------------+----------+--------------+------------------+-------------------+
记下File, Position。
在target端,执行:
mysql> stop slave;
mysql> CHANGE MASTER TO MASTER_LOG_FILE='binlog.000010',MASTER_LOG_POS=154;
mysql> start slave;
再次查看
mysql> show slave status\G
------------------------------会损失数据--------------------------------------------
mysql> reset master;
mysql> change master to master_host='192.168.40.171',master_port=3306,master_user='repl',master_password='123456';
CHANGE MASTER TO MASTER_HOST='192.168.40.172', MASTER_PORT=3306, MASTER_LOG_FILE='binlog.000001', MASTER_LOG_POS=154, MASTER_USER='repl', MASTER_PASSWORD='123456';
Query OK, 0 rows affected, 2 warnings (0.08 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G;