2个linux下 mysql 复制环境, 有一个复制表特大(表名字ahistory )我准备在从机器上 执行这个sql
aLTER  TABLE ahistory RENAME TO ahistory_old;请问这样做可以吗  ? (印象中好像这样做容易导致SqL-IO 总是 失败 show slave status 每次总要重启mysql 服务才ok)现在我的想法 
从机器 slave stop 
truncate table ahistory;
insert ahistory select * from ahisotry_backup (这个来自prod1a最新数据)感觉这个可行.有复制在线业务经验的讨论下2 个方案
1 从机器上 执行这个sql
aLTER  TABLE ahistory RENAME TO ahistory_old;
aLTER  TABLE ahisotry_backupRENAME TO ahistory;
注意:ahisotry_backup (这个来自prod1a最新数据)2
从机器 slave stop 
truncate table ahistory;
insert ahistory select * from ahisotry_backup (这个来自prod1a最新数据)
之后再开启slave start  究竟哪个好 ,最好不要丢数据啦  (这个表 主机器几十万   从机器上千万)

解决方案 »

  1.   

    直接 用的 truncate table ahistory;
    insert ahistory select * from ahisotry_backup (这个来自新数据)仅仅丢失8条数据。 ----------散步是发现这个是最好的(不salve stop  ;  。start)
    现在发现新问题
    ahistory 字段  (id, ood, odate, flag,number1,number2)
    id不是主键 不是按照顺序排列  odate也不是按照循序排列现在只能这样  
    select count(1) from ahistory where (id, ood, odate, flag,number1,number2)
    not in (select id, ood, odate, flag,number1,number2 from ahistory-copy)2表都是17万的数据。有什么方法可以找到整条记录是。select sum(a) from 
    (select id, ood, odate, flag,number1,number2,count(1) a from ahistory-copy group by
    id, ood, odate, flag,number1,number2 having coutn(*)>1
    )r将近一半的冗余率 。数据增长踢啊太快 ,1小时1万只能用存储过程了