【20180626】 The fields in the table in pt-table-sync and slave have garbled expression packs

Inconsistent master-slave data based on MySQL

  1. MySQL5.6 binlog statment format master-slave architecture, the character set of the table is utf8mb4 When inserting emoji, the slave cannot recognize it and display garbled characters
    • Guess it may be because the binlog character set is in utf8 format by default. When writing to binlog, it is already garbled
  2. The character set of the table is utf8, and the character set type of a field is set to utf8mb4. Insert emoji in this field, and the DML statement generated when pt2.2.19 master-slave data synchronization is performed cannot recognize the emoticon package and display garbled characters.

Experimental results

  1. Conjecture 1 does not hold, because binlog writes are all binary. The phenomenon that the sleep first expression in the field appears from the library is garbled. It is guessed that the default character set of mysqldump is utf8 when doing logical backup.
    • When mysqldump is backing up, the default character set is utf8, which results in garbled characters in the fields where some data are emoticons in the table whose backup character set is utf8mb4. When importing data, it is still garbled.
  2. Conjecture 2 is established.
    • The character set of the table is utf8
    • A column character set of the table is utfbmb4
    • There are emojis in the fields whose character set is utf8mb4 in the table
    • In master-slave replication, the middle field emoji of this slave table is garbled
    • When performing normal master-slave synchronization (that is, normal transmission and playback through binlog), there will be no garbled display of slave emoticons.
    • When pt-table-sync master-slave data is synchronized, the generated SQL still shows garbled expression packs.
    • pt-table-sync --print --charset=utf8 --sync-to-master h=slave_host,u=username,p='password',P=3306 --databases=schema_name --tables=tables_1,tables_2
    • When using the execute parameter directly when using pt-table-sync, if the slave cannot synchronize the master, the data of the master will be modified so that the master synchronizes the data of the slave.
    • pt-table-sync --print --charset=utf8 --execute --sync-to-master h=slave_host,u=username,p='password',P=3306 --databases=schema_name --tables=tables_1,tables_2

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324899939&siteId=291194637