zoukankan      html  css  js  c++  java
  • MySQL 主从同步架构中你不知道的“坑”(2)

    指定同步库情况

    1、binlog_format= ROW模式‍

    mysql> use testdb;

    Database changed

    mysql> show tables;

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

    | Tables_in_testdb |

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

    | test01      |

    | test1      |

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

    3 rows in set (0.00 sec)

    mysql> insert into test1 values('zhng','man');

    Query OK, 1 row affected (0.05 sec)

    mysql> insert into test1 values('meimei','woman');

    Query OK, 1 row affected (0.04 sec)

    mysql> select * from test1;

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

    | id  | name  |

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

    | zhang | man  |

    | zhng | man   |

    | meimei | woman |

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

    3 rows in set (0.00 sec)

    从库查看

    mysql> use testdb;

    Database changed

    mysql> show tables;

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

    | Tables_in_testdb |

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

    | test01      |

    | test1      |

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

    2 rows in set (0.01 sec)

    mysql> select * from test1;

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

    | id  | name  |

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

    | zhang | man  |

    | zhng | man  |

    | meimei | woman |

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

    3 rows in set (0.01 sec)

    2、binlog_format= STATEMENT模式‍

    主库配置如下

    binlog-do-db = testdb

    从库配置如下

    replicate-wild-do-table = testdb.%

    主库操作

    mysql> create database testdb;

    Query OK, 1 row affected (0.01 sec)

    mysql> use testdb;

    Database changed

    mysql> create table test01 (

        -> id varchar(10) not null,

        -> name varchar(10) not null

        -> );

    Query OK, 0 rows affected (0.04 sec)

    mysql> insert into test01 values('zhang','man');

    Query OK, 1 row affected (0.01 sec)

    mysql> select * from testdb.test01;

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

    | id  | name |

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

    | zhang | man  |

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

    1 row in set (0.00 sec)

    从库查看

    mysql> use testdb;

    Database changed

    mysql> select * from test01;

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

    | id  | name |

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

    | zhang | man  |

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

    1 row in set (0.00 sec)

    测试在不指定忽略库的情况下默认库是否会同步数据

    mysql> create user testdb_user;

    Query OK, 0 rows affected (0.03 sec)

    mysql> select user from mysql.user;

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

    | user    |

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

    | testdb_user |

    | mysql.sys |

    | root    |

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

    [root@mysql-s ~]# mysql -uroot -p -e "select user from mysql.user;"

    Enter password:

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

    | user   |

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

    | mysql.sys |

    | root   |

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

    注:默认的库的数据没有被同步

  • 相关阅读:
    通过git命令行从github或服务器上克隆、修改和更新项目
    将项目部署到 github上(部署到码云操作一样,前提是有码云账号)
    tp5中代替tp3.2中的一些方法
    关于ThinkPHP下使用Uploadify插件 仅有火狐提示HTTP Error (302)错误的解决办法
    nginx轮询宕机解决
    nginx实现动静分离
    nginx实现负载均衡
    nginx实现反向代理
    解决表单重复提交
    解决跨域问题
  • 原文地址:https://www.cnblogs.com/duanlinxiao/p/10923118.html
Copyright © 2011-2022 走看看