Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6545946
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Mysql/postgreSQL

2017-07-27 10:20:58


首先说明下我这里的环境,一个主库,三个备库,数据库存储的是采集日志,每天的数据量有近500G的日志,从库经常有延迟,从seconds_behind_master经常出现上千秒的延迟.
今天我试着在主库修改一个表字段属性,发现一直在等待,输出的日志如下

[dm@DM-DB01 ~]$pt-online-schema-change -h localhost -uxxxxx -pxxxxx --socket=/home/richdm/var/mysql/mysql.sock --alter='modify column id bigint auto_increment not null' D=oss03,t=tmp_id --execute --no-check-replication-filters
Cannot connect to D=oss03,S=/home/richdm/var/mysql/mysql.sock,h=10.217.109.61,p=...,u=richdm
Found 3 slaves:
  DM-ETL04
  DM-ETL03
  DM-DB02
Will check slave lag on:
  DM-ETL04
  DM-ETL03
  DM-DB02
Operation, tries, wait:
  analyze_table, 10, 1
  copy_rows, 10, 0.25
  create_triggers, 10, 1
  drop_triggers, 10, 1
  swap_tables, 10, 1
  update_foreign_keys, 10, 1
Altering `oss03`.`tmp_id`...
Creating new table...
Created new table oss03._______tmp_id_new OK.
Waiting forever for new table `oss03`.`_______tmp_id_new` to replicate to DM-ETL04...
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
Waiting for DM-ETL04:   0% 00:00 remain
这里没完没了的等下去。

后来查看pt-online-schema-change参数说明,其中一个参数是--recursion-method,该参数值如下:
METHOD       USES
===========  ==================
processlist  SHOW PROCESSLIST
hosts        SHOW SLAVE HOSTS
dsn=DSN      DSNs from a table
none         Do not find slaves

把该参数设置成none,让其不找salves,上面的问题即可解决:
[dm@DM-DB01 ~]$pt-online-schema-change -h localhost -uxxxx -pxxxx --socket=/home/richdm/var/mysql/mysql.sock --alter='modify column id bigint auto_increment not null' D=oss03,t=tmp_id --execute --no-check-replication-filters --recursion-method=none

-- The End --
阅读(3365) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~