MySQL 5.6使用pt-online-schema-change線上修改大表欄位長度
業務需求:
線上修改一張2000W行表的欄位長度。
[root@21db01 ~]# pt-online-schema-change --alter="modify id VARCHAR(64) CHARSET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT 'ID';" --user=root --password=XXXX --host='127.0.0.1' D=users,t=users_dt --charset=utf8 --execute --no-check-alter --no-check-replication-filters
Cannot connect to A=utf8,D=users,h=10.1.4.80,p=...,u=root
Cannot connect to A=utf8,D=users,h=10.1.4.82,p=...,u=root
Cannot connect to A=utf8,D=users,h=10.1.6.7,p=...,u=root
Cannot connect to A=utf8,D=users,h=10.1.4.97,p=...,u=root
Cannot connect to A=utf8,D=users,h=10.1.6.8,p=...,u=root
Cannot connect to A=utf8,D=users,h=10.1.4.81,p=...,u=root
Cannot connect to A=utf8,D=users,h=10.1.4.79,p=...,u=root
No slaves found. See --recursion-method if host 21db01 has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
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 `users`.`users_dt`...
Creating new table...
Created new table users._users_dt_new OK.
Altering new table...
Altered `users`.`_users_dt_new` OK.
2020-09-21T14:17:27 Creating triggers...
2020-09-21T14:17:27 Created triggers OK.
2020-09-21T14:17:27 Copying approximately 26345605 rows...
Copying `users`.`users_dt`: 0% 01:12:38 remain
Copying `users`.`users_dt`: 1% 01:13:24 remain
Copying `users`.`users_dt`: 1% 01:20:53 remain
Copying `users`.`users_dt`: 2% 01:27:24 remain
Copying `users`.`users_dt`: 2% 01:31:22 remain
Copying `users`.`users_dt`: 3% 01:32:27 remain
Copying `users`.`users_dt`: 10% 01:58:39 remain
Copying `users`.`users_dt`: 10% 01:58:30 remain
Copying `users`.`users_dt`: 10% 01:59:12 remain
Copying `users`.`users_dt`: 46% 01:20:35 remain
Copying `users`.`users_dt`: 46% 01:20:22 remain
Copying `users`.`users_dt`: 83% 24:06 remain
Copying `users`.`users_dt`: 98% 01:23 remain
Copying `users`.`users_dt`: 99% 00:37 remain
Copying `users`.`users_dt`: 99% 00:03 remain
2020-09-21T16:49:13 Copied rows OK.
2020-09-21T16:49:13 Analyzing new table...
2020-09-21T16:49:13 Swapping tables...
2020-09-21T16:49:13 Swapped original and new tables OK.
2020-09-21T16:49:13 Dropping old table...
2020-09-21T16:49:50 Dropped old table `users`.`_users_dt_old` OK.
2020-09-21T16:49:50 Dropping triggers...
2020-09-21T16:49:50 Dropped triggers OK.
Successfully altered `users`.`users_dt`.
總共耗時2小時多,普通磁碟。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22996654/viewspace-2722966/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql的text欄位長度MySql
- MySQL 5.7使用pt-online-schema-change對大表加欄位MySql
- oracle 修改表欄位的長度Oracle
- MySQL的欄位數量以及長度限制MySql
- MySQL修改大表工具pt-online-schema-change原理MySql
- MySQL 如何儲存長度很長的資料欄位MySql
- DDL操作導致欄位長度變更修復方案
- MySQL 分割槽表 partition線上修改分割槽欄位MySql
- MySQL中需要注意的欄位長度問題MySql
- mysql的varchar欄位最大長度真的是65535嗎?MySql
- mysql表最多欄位數MySql
- MySQL中欄位型別與合理的選擇欄位型別;int(11)最大長度是多少?varchar最大長度是多少?MySql型別
- Oracle 修改欄位型別和長度Oracle型別
- mysql表操作(alter)/mysql欄位型別MySql型別
- Sqlserver修改線上表的表欄位型別SQLServer型別
- [原創] mysql表欄位多少限定MySql
- MySQL使用pt-online-change-schema實現線上加欄位MySql
- SQL SERVER 查詢表的欄位名、資料型別和最大長度SQLServer資料型別
- MySQL線上新增欄位的幾種方案介紹MySql
- MySQL 更新同一個表不同欄位MySql
- mysql修改表欄位學習筆記MySql筆記
- 5_MySQL 表的欄位約束MySql
- SAP主資料的欄位長度(ECC6.0)
- 欄位長度前後端是否都需要做限制?後端
- MySQL 更新一個表裡的欄位等於另一個表某欄位的值MySql
- NRIV表欄位的設定使用
- oracle刪除表欄位和oracle表增加欄位Oracle
- mysql修改表、欄位、庫的字符集MySql
- 更改MySql表和欄位區分大小寫MySql
- MySQL 5.7使用pt-online-schema-change對大表加索引MySql索引
- 觸發器—一個表插入資料時其他欄位同步自增長欄位觸發器
- oracle分割槽表線上重定義欄位not null問題OracleNull
- 一個 MySQL 線上 DDL 工具 — pt-online-schema-changeMySql
- mysql 5.7 新特性中線上in-place 修改欄位的大小MySql
- MySQL中JSON欄位的使用技巧MySqlJSON
- MySQL 中 JSON 欄位的使用技巧MySqlJSON
- MySQL 5.6的表壓縮MySql
- mysql 資料庫 表 欄位 編碼修改 方法MySql資料庫