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 數(shù)據(jù)庫名: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
具體參數(shù)參考命令行的幫助說明,如下:
#pt-online-schema-change --help
命令要點:
1、Usage: pt-online-schema-change [OPTIONS] DSN
OPTIONS:是可選項,命令必須帶DSN
2、 --dry-run and --execute are mutually exclusive.
OPTIONS參數(shù)中的--dry-run 和 --execute 參數(shù),同時只能選擇一個,--dry-run:不建立觸發(fā)器,不拷貝數(shù)據(jù),不替代原表;只是創(chuàng)建和更改新表。
3、DSN syntax is key=value[,key=value...]
關(guān)鍵字之前使用逗號分隔開,使用空格不能識別
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
想了解更多?現(xiàn)在就開始免費體驗