【20180626】 pt-table-sync 和slave中的table中的字段存在表情包乱码

基于MySQL主从数据不一致

  1. MySQL5.6 binlog statment格式 主从架构,table的字符集是utf8mb4 插入表情符号的时候,slave无法识别,显示乱码

    • 猜想可能是因为binlog字符集默认是utf8格式的。写入binlog的时候就已经乱码
  2. table的字符集是utf8,并且设置某个字段的字符集类型是utf8mb4。在这个字段插入表情,并且进行pt2.2.19 主从数据同步的时候生成的DML语句也无法识别表情包显示乱码。

实验结果

  1. 猜想1不成立,因为binlog的写入都是二进制。从库出现字段先睡表情是乱码的现象猜测可能是因为在做逻辑备份的时候mysqldump默认的字符集是utf8导致的。

    • mysqldump备份的时候默认的是utf8字符集,导致在备份字符集是utf8mb4的table里面有些数据是表情包的字段显示乱码。在导入数据进入的时候还是乱码。
  2. 猜想2成立。
    • table的字符集是utf8
    • table的某个column字符集是utfbmb4
    • table中字符集是utf8mb4的字段有存在表情包
    • 主从复制中这个slave的table的中字段表情包是乱码
    • 在进行正常的主从同步的时候(即正常的通过binlog传输和回放)不会出现slave的表情包显示是乱码现象
    • 在pt-table-sync主从数据同步的时候生成的SQL显示的还是表情包乱码现象。
    • 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
    • 在使用pt-table-sync的时候直接使用execute这个参数的时候,假如slave不能同步master,则会修改master的数据使得master同步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

原文地址:http://blog.51cto.com/11819159/2108253

时间: 2024-08-30 16:26:56

【20180626】 pt-table-sync 和slave中的table中的字段存在表情包乱码的相关文章

thinkphp中SQLSTATE[42S02]: Base table or view not found: 1146 Table错误解决方法

随手记录下今天在thinkphp3.2.3中遇到的错误SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.file_info' doesn't exist,之前用pdo连接数据库一直没有问题,今天突然发现报了上述错误,查看了别人的解决方法,都没有解决,后来看了下之前的表名都是小写的,我现在的表名是"file_Info",改为"file_info"后就不报异常了

css样式表中设置table的第一列的宽度是固定值

table{table-layout:fixed;}table tr td:first-child,table tr td:first-child{width:120px;} 首行第一个td定宽同列的宽度都会和他一样. *注意 第一行 第一个用的是 td 还是 th css样式表中设置table的第一列的宽度是固定值,布布扣,bubuko.com

获得sql server的table的表结构 -- 转到word中

SQL语句: select syscolumns.name,systypes.name,syscolumns.length from syscolumns join sysobjects on syscolumns.id=sysobjects.id and sysobjects.xtype='U' join systypes on systypes.xtype=syscolumns.xtype where sysobjects.name='master_location' order by sy

递归打印lua中的table

递归打印lua中的table,并写到文件里: 1 local pairs_by_keys = function(inTable) 2 local temp = {} 3 for k, v in pairs(inTable) do 4 temp[#temp + 1] = k 5 end 6 7 local compare = function(a, b) 8 if type(a) == type(b) then 9 return a < b 10 elseif type(a) == "num

mysql中OPTIMIZE TABLE的作用及使用

来看看手册中关于 OPTIMIZE 的描述: OPTIMIZE [LOCAL | NO_WRITE_TO_BINLOG] TABLE tbl_name [, tbl_name] ... 如果您已经删除了表的一大部分,或者如果您已经对含有可变长度行的表(含有VARCHAR, BLOB或TEXT列的表)进行了很多更改,则应使用OPTIMIZE TABLE.被删除的记录被保持在链接清单中,后续的INSERT操作会重新使用旧的记录位置.您可以使用OPTIMIZE TABLE来重新利用未使用的空间,并整理

【翻译自mos文章】控制OGG Director 中Repository Table 保留几天记录的参数

控制OGG Director 中Repository Table  保留几天记录的参数 翻译自mos文章: Can I Purge The Director "STATSENTRYB" Repository Table? (Doc ID 971709.1) QUESTION My Director Repository Table "STATSENTRYB" has grown to more than 100,000 rows. Is there a way to

MySQL中create table as 与like的区别分析

这篇文章主要介绍了MySQL中create table as 与like的区别,结合实例分析了二者在使用中的具体区别与主要用途,需要的朋友可以参考下,具体如下: 对于mysql的复制相同表结构方法,有create table as 和create table like 两种,区别是什么呢? 代码如下: create table t2 as select * from t1 where 1=2; as创建出来的t2表(新表)缺少t1表(源表)的索引信息,只有表结构相同,没有索引. 代码如下: cr

DDL中drop-alter table

一.DROP TABLE语句:用于删除数据表 DROP TABLE removes one or more tables. You must have the DROP privilege for each table. All table data and the table definition are removed, so be careful with this statement! 基本格式: drop table <table_name> DROP [TEMPORARY] TAB

Lua中的table函数库

table.concat(table, sep,  start, end) concat是concatenate(连锁, 连接)的缩写. table.concat()函数列出参数中指定table的数组部分从start位置到end位置的所有元素, 元素间以指定的分隔符(sep)隔开.除了table外, 其他的参数都不是必须的, 分隔符的默认值是空字符, start的默认值是1, end的默认值是数组部分的总长. sep, start, end这三个参数是顺序读入的, 所以虽然它们都不是必须参数,