pt-online-schema-change使用
pt-online-schema-change工具需要先安装percona-toolkit 工具包(下载地址:https://www.percona.com/downloads/percona-toolkit/),
示例:(验证通过)
IP地址:112.74.194.66 mysql用户名:root mysql密码:123456 数据库名:998pu 表名称:t_sys_params
#pt-online-schema-change -h 112.74.194.66 -P 3306 -u root -p 123456 --alter="add column c1 int" --execute D=998pu,t=t_sys_params
具体参数参考命令行的帮助说明,如下:
#pt-online-schema-change --help
命令要点:
1、Usage: pt-online-schema-change [OPTIONS] DSN
OPTIONS:是可选项,命令必须带DSN
2、 --dry-run and --execute are mutually exclusive.
OPTIONS参数中的--dry-run 和 --execute 参数,同时只能选择一个,--dry-run:不建立触发器,不拷贝数据,不替代原表;只是创建和更改新表。
3、DSN syntax is key=value[,key=value...]
关键字之前使用逗号分隔开,使用空格不能识别
allowable DSN keys:
KEY COPY MEANING
=== ==== =============================================
A yes Default character set
D yes Database for the old and new table
F yes Only read default options from the given file
P yes Port number to use for connection
S yes Socket file to use for connection
h yes Connect to host
p yes Password to use when connecting
t no Table to alter
u yes User for login if not current user
想了解更多?现在就开始免费体验