Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Pt-online-schema-change modifies the table structure online

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. The default value of the parameter describes-- host=xxx-- user=xxx-- password=xxx connection instance information, abbreviated-h xxx-u xxx-p xxx. The password can be entered manually using the parameter-- ask-pass. The alter structure change statement does not require the ALTER TABLE keyword. Like the original ddl, you can specify multiple changes, separated by commas. Max-load database _ name _ max-load _ table _ name specifies the database name and table name to be named-- database defaults to Threads_running=25. After each chunk is copied, the contents of the SHOW GLOBAL STATUS are checked to see if the metric exceeds the specified threshold. If it exceeds, pause it first. You can specify multiple conditions separated by commas, each in the format of status metric = MAX_VALUE or status metric: MAX_VALUE. If you do not specify MAX_VALUE, the tool will only make it 120% of the current value. -- max-lag defaults to 1s. "after each chunk copy is completed, the latency (Seconds_Behind_Master) of all replication Slave is checked." If the delay is greater than this value, data replication is paused until the lag of all followers is less than this value. -- check-interval is used together to specify how long the tool will sleep if the slave lag exceeds max-lag. Default is 1s, and then check again. Such as-- max-lag=5-- check-interval=2. -- chunk-time defaults to 0.5s, that is, when copying data rows, in order to copy a chunk within 0.5s as far as possible, dynamically adjust the size of the chunk-size to adapt to the changes in server performance. -- set-vars uses pt-osc for ddl to open a session to operate. Set-vars can set these variables before executing alter, such as the default setting-- set-vars "wait_timeout=10000,innodb_lock_wait_timeout=1,lock_wait_timeout=60". -- dry-run creates and modifies new tables, but does not create triggers, copy data, or replace original tables. Do not really execute, you can see the generated execution statement, understand its execution steps and details, and-- print works best. This parameter is specified if execute determines that the table is modified. Actually execute alter. -dry-run and-execute must specify one, and they are mutually exclusive.-- alter description

1. In most cases, a primary key or unique index is required on the table, because in order to ensure that the new table is up-to-date, the tool needs to create DELETE and UPDATE triggers on the old table, and it is faster to have a primary key when synchronizing to the new table. In rare cases, when the alter operation is to establish a primary key on the C1 column, the DELETE trigger will be based on the C1 column.

Clause does not support rename to rename the table. The alter command does not support renaming the index in the original table, it needs to be drop and then add, and it is the same in pt-osc. (mysql 5.7supports RENAME INDEX old_index_name TO new_index_name). But rename the field, do not drop-add, the whole column of data will be lost, use change col1 col1_new type constraint (keep the type and constraint consistent, otherwise it is equivalent to modifying column type, cannot online) clause if it is add column and not null is defined, then you must specify the default value, otherwise it will fail. If you want to delete a foreign key (name fk_foo), use the tool with an underscore, such as-- alter "DROP FOREIGN KEY _ fk_foo" 2. Usage restrictions do not allow triggers to exist on the original table. Disk capacity needs to be evaluated before use. Because the amount of data will double by 3. Use example 1. Add the field pt-online-schema-change-- user=user-- password=password-- host=10.0.201.34-- alter "ADD COLUMN f_id int default 0" DobsconfluenceMagazine tactisbtest3-- print-- execute

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report