测试验证replicate-ignore-table参数作用
来源:互联网 发布:java神经网络 编辑:程序博客网 时间:2024/06/11 08:06
1.基本信息
主库:
IP:10.16.24.107 port:3377
server-id = 1073377
data_dir:/data/MySQL/mysql3377/data/
base_dir:/usr/local/mysql
版本:mysql 5.6.29-log
gtid_mode =on
从库:
IP:10.16.24.108 port:3377
server-id = 1083377
data_dir:/data/mysql/mysql3377/data/
base_dir:/usr/local/mysql
版本:mysql 5.6.29-log
binlog_format:ROW
gtid_mode =on
2.从库上设置replicate-ignore-table参数
配置文件[mysqld]中有设置
replicate-ignore-table=lots.test
并有重启mysql后,登入查看:
(product)root@localhost [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.16.24.107
Master_User: repl
Master_Port: 3377
Connect_Retry: 60
Master_Log_File: mysql-bin.000018
Read_Master_Log_Pos: 191
Relay_Log_File: relay-bin.000009
Relay_Log_Pos: 401
Relay_Master_Log_File: mysql-bin.000018
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table: lots.test
Replicate_Wild_Do_Table:
3.验证参数作用
场景一:binlog_format=ROW,不跨库更新test表的记录
主库查询test表记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
从库查询test表记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
主库上update操作:
use lots;
update test set name='zeng3' where id=2;
(product)root@localhost [lots]> update test set name='zeng3' where id=2;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng3 |
+------+-------+
2 rows in set (0.00 sec)
(product)root@localhost [lots]>
从库查看test记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
说明从库test表的记录没有同步,设置参数忽略了表test的复制。
场景二:binlog_format=ROW,跨库更新test表的记录
将主库的记录更改回去
update test set name='zeng2' where id=2;
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
use mysql;
update lots.test set name='zeng3' where id=2;
(product)root@localhost [lots]> use mysql
Database changed
(product)root@localhost [mysql]> update lots.test set name='zeng3' where id=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
(product)root@localhost [mysql]> select * from lots.test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng3 |
+------+-------+
2 rows in set (0.00 sec)
查看从库记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
说明从库test表的记录没有同步,设置参数忽略了表test的复制。
场景三:binlog_format=statement,不跨库更新test表的记录
将主库的记录更改回去
update test set name='zeng2' where id=2;
(product)root@localhost [lots]> update test set name='zeng2' where id=2;
ERROR 1665 (HY000): Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to
row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ-COMMITTED or READ-UNCOMMITTED.
主从库分别执行:
set global tx_isolation='Repeatable-Read'
并重新连接mysql:
查看参数设置:
(product)root@localhost [lots]> show variables like '%ISOLATION%';
+---------------+----------------+
| Variable_name | Value |
+---------------+----------------+
| tx_isolation | REPEATABLE-READ |
+---------------+----------------+
1 row in set (0.00 sec)
主库查询test表记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
从库查询test表记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
主库上update操作:
use lots;
update test set name='zeng3' where id=2;
(product)root@localhost [lots]> update test set name='zeng3' where id=2;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng3 |
+------+-------+
2 rows in set (0.00 sec)
(product)root@localhost [lots]>
从库查看test记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
说明从库test表的记录没有同步,设置参数忽略了表test的复制。
场景四:binlog_format=statement,跨库更新test表的记录
将主库的记录更改回去
update test set name='zeng2' where id=2;
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
use mysql;
update lots.test set name='zeng3' where id=2;
(product)root@localhost [lots]> use mysql
Database changed
(product)root@localhost [mysql]> update lots.test set name='zeng3' where id=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
(product)root@localhost [mysql]> select * from lots.test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng3 |
+------+-------+
2 rows in set (0.00 sec)
查看从库记录:
(product)root@localhost [lots]> select * from test;
+------+-------+
| id | name |
+------+-------+
| 1 | zeng1 |
| 2 | zeng2 |
+------+-------+
2 rows in set (0.00 sec)
说明从库test表的记录没有同步,设置参数忽略了表test的复制。
- 测试验证replicate-ignore-table参数作用
- replicate-wild-ignore-table
- replicate_wild_do_table和replicate-wild-ignore-table
- 关于slave的replicate-ignore-db 参数 跨库问题
- 做Mysql主从时,注意使用replicate_wild_do_table和replicate-wild-ignore-table
- 做MySQL主从时,注意使用replicate_wild_do_table和replicate-wild-ignore-table
- 记1次未正确设置replicate-ignore-db参数导致MySQL主从同步异常的问题
- 验证中“参数”作用
- MySQL复制,replicate-ignore-db模式下 如何正常同步
- 设置MySQL复制时,replicate-ignore-db模式下如何正常工作
- 如何用mysqldump --ignore-table多个表
- alter ignore table add unique key
- alter ignore table 添加unique key
- tools:context和tools:ignore的作用
- tools:ignore="ExportedService" 的作用
- ignore ()
- Ignore
- 关于iconv容易忽略的参数IGNORE
- CentOS 7Install PrestaShop
- 【机房重构】【报表】异常处理
- LeetCode 245. Shortest Word Distance III
- Q&A: 你能不能迅速说出以下短语的英语?
- HDU-ACM2048
- 测试验证replicate-ignore-table参数作用
- ios开发学习笔记--数据持久化之偏好设置(NSUserDefault)
- poj2135 最小费用最大流模板
- Spark-Avro学习4之使用AvroWritePartitioned存储AVRO文件时进行划分
- 文章标题
- HDU-ACM2049--错排问题的应用
- Oracle 11g R2 RAC高可用性连接
- 网络仿真工具TOTEM之——环境配置
- 第一周编程题-逆序的三位数