Chinaunix首页 | 论坛 | 博客
  • 博客访问: 409837
  • 博文数量: 43
  • 博客积分: 613
  • 博客等级: 中士
  • 技术积分: 756
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-01 11:25
文章分类

全部博文(43)

文章存档

2016年(1)

2015年(5)

2014年(5)

2013年(14)

2012年(18)

分类: Mysql/postgreSQL

2013-04-26 14:21:25

      前几天使用pt-table-checksum检查主从数据库一致性,发现有些数据不一致,于是使用pt-table-sync来做修复。
      在修复的过程中没提示任何的错误,也没有异常情况出现。但是悲剧发生了。
      首先,在web页面中很多中文的地方变成了乱码。开始还没意识到是pt-table-sync工具做数据一直修复时产生的。后来查询binlog日志才发现,在执行修复过程中replace语句中的很多中文都变成了乱码。
如下所示中出现大量?

EPLACE INTO `phpcmsv9`.`v9_hd_course`(`id`, `catid`, `typeid`, `title`, `style`, `thumb`, `keywords`, `description`, `posids`, `ven_posids`, `url`, `listorder`, `status`, `sysadd`, `islink`, `username`, `inputtime`, `updatetime`, `userid`, `envid`, `cour_cat`, `cour_cat_text`, `cour_type`, `reg_endtime`, `starttime`, `endtime`, `is_weekend`, `district`, `district_code`, `address`, `longitude`, `latitude`, `org`, `teacher`, `teacher_id`, `max_reg_num`, `fea`, `promotion`, `promotion_state`, `promotion_desc`, `adv_url`, `linkman`, `mobile`, `qq`, `validation_state`, `visiable`, `abolish`, `reg_num`, `view_num`, `total_score`, `desc_score`, `env_score`, `eff_score`, `eval_num`, `msg_num`, `env_validation_state`) VALUES ('162', '0', '0', '???????????', '', 'xxxxxxxxxxxxxxxxxxx', '', '', '0', '0', '', '0', '1', '0', '0', 'yyyyyyyy', '1334122365', '4234', '4324', '53', ',53,423,', '???? / ??', '66', '42', '4242', '4234', '0', '??????', ',1,2,10', '?????', '1', '1', '??????????????', '????', '0', '0', '4234', '0', '2', '??????????????????????????????????????????????????', 'xxxxxxxxxxxxx/statics/images/v20/page/venues/preset-img/pre-img32.jpg', '', '', '', '1', '0', '1', '0', '534', '0', '0', '0', '0', '0', '0', '1') /*percona-toolkit src_db:phpcmsv9 src_tbl:v9_hd_course src_dsn:P=9999,h=0.0.0.0,p=...,u=xxx dst_db:phpcmsv9 dst_tbl:v9_hd_course dst_dsn:h=0.0.0.0,p=...,u=xxx lock:1 transaction:1 changing_src:1 replicate:0 bidirectional:0 pid:6871 user:xxx host:dbslave1-zs*/

      检查了主从库的字符集,都是使用的utf8,而且在这次事故中有另外的表中的中文又是正常处理的,没有显示为乱码。最后还是没找到出现问题的原因。

     只能说在做数据修复前,一定要使用print参数将修复的sql打印出来确认后再执行修复。

     在此做个记录,也希望高手指点迷津。


########################################################################################################

     最近又试了下,多加个参数--charset=utf8就可以解决了。。


阅读(3545) | 评论(4) | 转发(0) |
给主人留下些什么吧!~~

wangjj202013-10-23 09:32:33

eloops:我指定了--charset=utf8也不可以;db的字符集都设置的utf8; 求指导

什么不可以呢??能否说的具体点。

回复 | 举报

eloops2013-10-18 15:16:59

我指定了--charset=utf8也不可以;db的字符集都设置的utf8; 求指导

wangjj202013-05-09 09:28:27

gladness:表的字符集?字段的字符集?

表和字段的字符集都是没问题的。
最近测试了下,在运行pt-table-sync的时候指定一个--charset=utf8的参数就正常了。

回复 | 举报

gladness2013-05-03 15:48:46

表的字符集?字段的字符集?