Home  >  Article  >  Backend Development  >  如何给线上数据库添加字段或者添加索引等操作?

如何给线上数据库添加字段或者添加索引等操作?

WBOY
WBOYOriginal
2016-06-06 20:47:042404browse

线上数据库约百万条记录,添加字段或者添加索引会导致长时间LOCKED,怎么办?

回复内容:

线上数据库约百万条记录,添加字段或者添加索引会导致长时间LOCKED,怎么办?

可以考虑用percona toolkit里面的online-schema-change, 这个工具可以用一个相当长但是没有锁的时间来完成这个工作

当然,这个操作是相当危险的,一定要在线上操作之前做足够的测试和模拟,尤其是每一个chunk之间的sleep时间之类的,设定的不太好,也是一个对线上影响非常大的东西

具体文档参考 http://www.percona.com/doc/percona-toolkit/2.2/pt-online-schema-change.html

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn