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-table-sync Common referenc

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Pt-table-sync is an excellent tool to solve the inconsistency between master and slave data. It can also be used to synchronize data between two non-master-slave databases. Ddl cannot be synchronized, but data can only be synchronized. The following are common examples:

Where hackers 192.168.56.101 is the source end, and hackers 192.168.56.102 is the destination side:

1.sync two separate databases, no master-slave replication relationship, synchronize all tables in the database, and exclude specific databases:

Pt-table-sync-- charset=utf8-- ignore-databases=mysql,sys upright admin dsn=u=admin,p=admin,h=192.168.56.103,P=3306-- execute-- print

If master-slave can be used-- no-check-slave ignores master-slave relationship, it is recommended that you first use-- print to see if there are any inconsistencies, and then use-- execute to synchronize:

Print out inconsistent data:

Pt-table-sync-- charset=utf8-- ignore-databases=mysql,sys-- no-check-slave upright admin dsn=u=admin,p=admin,h=192.168.56.102,P=3306 print

Synchronize the data and print out the synchronization statement:

Pt-table-sync-- charset=utf8-- ignore-databases=mysql,sys-- no-check-slave upright admin dsn=u=admin,p=admin,h=192.168.56.102,P=3306 execute-- print

Synchronize the specified library or table

Only data sync is performed on the specified library:

Pt-table-sync-- charset=utf8-- ignore-databases=mysql,sys-- databases=data upright admin dsn=u=admin,p=admin,h=192.168.56.102,P=3306 execute-- print

Data sync is performed on only the specified tables, with multiple tables separated by commas:

Pt-table-sync-- charset=utf8-- ignore-databases=mysql,sys-- databases=data-- tables=t_shop_order,t_shop_order_detail upright admin dsn=u=admin,p=admin,h=192.168.56.102,P=3306 execute-- print

-- tables can also use database names and tables:

-- tables=database_name.table_name

Ignore some libraries or ignore some tables

-- ignore-databases= specifies the libraries to ignore

-- ignore-tables=database_name.table_name specifies the table to ignore

3. If it is a master-slave replication, you can add-- sync-to-master parameter to sync the data:

The tables that need to be synchronized have primary keys or unique keys, of which 192.168.56.102 is the standby database:

Pt-table-sync-- sync-to-master-- charset=utf8-- ignore-databases=mysql,sys upright admins, packs admins, pamphlets, 192.168.56.102, execute 3306-- print.

Sync synchronizes multiple slave repositories, of which hackers 192.168.56.102 and hackers 192.168.56.103 are backup libraries:

Pt-table-sync-- sync-to-master-- charset=utf8-- ignore-databases=mysql,sys upright adminary execute-- print 192.168.56.102 pamphlet 3306

4.pt-table-sync help instructions:

Pt-table-sync-help

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