首先说明下我这里的环境,一个主库,三个备库,数据库存储的是采集日志,每天的数据量有近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 --
阅读(3424) | 评论(0) | 转发(0) |