zoukankan      html  css  js  c++  java
  • 因为下游MySQL的sql_mode设置与上游TiDB的sql_mode不一样,导致drainer同步状态下线。

    因为下游MySQL的sql_mode设置与上游TiDB的sql_mode不一样,导致drainer同步状态下线。
    
    
    运维排查:
    [tidb@ip-10-0-0-15 ~]$ cd /tidb_data/tidb_binlog/drainer-8250/log/
    [tidb@ip-10-0-0-15 log]$ tail -f drainer.log
    报错内容:error="Error 1366: Incorrect string value: '\xC9\xF2\xD1\xF4' for column 'mechanism_name' at row 1"
    commit_ts值:commit_ts=422377239451795457
    
    
    排查上下游表结构,发现表结构一样。
    -- 上游TiDB表结构
    [root@10.0.0.11:4000] [app01]> show create table t1G
    
    -- 下游MySQL表结构
    [sync@10.0.0.11:3306] [app01]> show create table t1G
    
    
    排查上下游sql_mode值是否一样。
    在绝大部分情况下,TiDB 和 MySQL 的语句都是兼容的。用户需要注意的是上下游的 sql_mode 应当保持一致。
    发现上下游sql_mode值不一样。
    [root@10.0.0.11:4000] [app01]> select @@sql_mode;
    +-----------------------------------------------------------------------------------------------------------------------+
    | @@sql_mode                                                                                                            |
    +-----------------------------------------------------------------------------------------------------------------------+
    | ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
    +-----------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    [sync@10.0.0.11:3306] [app01]> select @@sql_mode;
    +-------------------------------------------------------------------------------------------------------------------------------------------+
    | @@sql_mode                                                                                                                                |
    +-------------------------------------------------------------------------------------------------------------------------------------------+
    | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
    +-------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.01 sec)
    
    STRICT_TRANS_TABLES:在该模式下,如果一个值不能插入到一个事务表中,则中断当前的操作,对非事务表不做限制。
    
    
    -- 设置下游MySQL的sql_mode值与上游TiDB的sql_mode值一样。
    [sync@10.0.0.11:3306] [app01]> set global sql_mode='ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    
    -- 根据考虑数据问题是否commit_ts加入ignore-txn-commit-ts
    [tidb@ip-10-0-0-15 ~]$ cd /tidb_data/tidb_binlog/drainer-8250/conf
    [tidb@ip-10-0-0-15 conf]$ vim drainer.toml
    ignore-txn-commit-ts = [422377239451795457]
    
    
    -- 启动下线的drainer
    [tidb@ip-10-0-0-11 ~]$ tiup cluster start tidb-gg -R drainer -N 10.0.0.15:8250
    [tidb@ip-10-0-0-11 ~]$ tiup cluster display tidb-gg
    
    
    -- drainer同步下游运行状态正常。
    [tidb@ip-10-0-0-15 log]$ tail -f drainer.log
  • 相关阅读:
    PAT (Advanced Level) 1080. Graduate Admission (30)
    PAT (Advanced Level) 1079. Total Sales of Supply Chain (25)
    PAT (Advanced Level) 1078. Hashing (25)
    PAT (Advanced Level) 1077. Kuchiguse (20)
    PAT (Advanced Level) 1076. Forwards on Weibo (30)
    PAT (Advanced Level) 1075. PAT Judge (25)
    PAT (Advanced Level) 1074. Reversing Linked List (25)
    PAT (Advanced Level) 1073. Scientific Notation (20)
    PAT (Advanced Level) 1072. Gas Station (30)
    PAT (Advanced Level) 1071. Speech Patterns (25)
  • 原文地址:https://www.cnblogs.com/zhouwanchun/p/14313001.html
Copyright © 2011-2022 走看看