1, installing DBD perl-io-socket-ssl percona-toolkitYum list|grep dbdyum list|grep socket|grep SSL yum-y install perl-dbd-mysql.x86_64yum-y install Perl-io-socket-ssl.noarc Hyum-y Install "Perl (term::readkey)" Wget https://www.percona.com/downloads/percona-toolkit/2.2.17/RPM/ PERCONA-TOOLKIT-2.2.17-1.NOARCH.RPMRPM-IVH percona-toolkit-2.2.17-1.noarch.rpm
2. View Character SetShow variables like ' character% ';
3, start adding fields:Pt-online-schema-change \--user=root \--password= ' [email protected]%[email protected]# ' \--host=127.0.0.1 \--port= 3306 \--charset=utf8 \--alter= "Add index Idx_url_date (mg_url, Mg_datetime)" \d=spider,t=js_mogu_goods \--exec \-- Max-load threads_running=1000 \--critical-load= "threads_running:200" Related parameters:--nodrop-old-table do not delete table--max-load Threads _running= exceeding this value will pause--critical-load threads_running= more than this value will stop
the values for 4,--alter-foreign-keys-method can be: auto, rebuild_constraints, Drop_swap, none1, when the business volume is large, the modification operation will wait for no data modification, and then perform the final rename operation. Therefore, when you modify the table structure, you should try to choose to perform more appropriately when the business is relatively idle, at least when the data operation on the table is low. 2, if the foreign key table operation, four kinds of foreign key operation types need to be based on the data volume and reliability of the table to choose. For reasons of reliability, use the rebuild_constraints type as much as possible and use the auto type if there is no reliability requirement. 3, when the--alter-foreign-keys-method=none, the foreign key index will be invalidated, the need to rebuild the foreign key index, can be used again 4, because there may be a certain risk, before the operation, the proposed data table backup, can make the operation more secure and reliable.
MySQL plus field Pt-online-change-schema