pt-table-sync 使用介绍

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: pt-table-sync 使用介绍

pt-table-sync:对两个库不一致的数据进行同步,他能够自动发现两个实例间不一致的数据,然后进行sync操作,pt-table-sync无法同步表结构,和索引等对象,只能同步数据

一、表没有主键
--print
./pt-table-sync --ignore-databases=mysql,sys --no-check-slave dsn=u=checkq,p=123456,h=192.168.56.108,P=3306 dsn=u=checkq,p=123456,h=192.168.56.101,P=3306 --databases=bhs --tables=pp --print
INSERT INTO bhs.pp(id, name) VALUES ('1', 'ee') /percona-toolkit src_db:bhs src_tbl:pp src_dsn:P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:pp dst_dsn:P=3306,h=192.168.56.101,p=...,u=checkq lock:0 transaction:1 changing_src:0 replicate:0 bidirectional:0 pid:3704 user:root host:managed/;

--execute
./pt-table-sync --ignore-databases=mysql,sys --no-check-slave h=192.168.56.108,u=checkq,p=123456,P=3306 h=192.168.56.101,u=checkq,p=123456,P=3306 --databases=bhs --tables=pp --execute --print
INSERT INTO bhs.pp(id, name) VALUES ('1', 'ee') /percona-toolkit src_db:bhs src_tbl:pp src_dsn:P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:pp dst_dsn:P=3306,h=192.168.56.101,p=...,u=checkq lock:0 transaction:1 changing_src:0 replicate:0 bidirectional:0 pid:3747 user:root host:managed/;

二、表有主键

--print
./pt-table-sync --sync-to-master --charset=utf8 --ignore-databases=mysql,sys --no-check-slave h=192.168.56.101,u=checkq,p=123456,P=3306 --databases=bhs --tables=test --print
REPLACE INTO bhs.test(id, name) VALUES ('3', 'd') /percona-toolkit src_db:bhs src_tbl:test src_dsn:A=utf8,P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:test dst_dsn:A=utf8,P=3306,h=192.168.56.101,p=...,u=checkq lock:1 transaction:1 changing_src:1 replicate:0 bidirectional:0 pid:3768 user:root host:managed/;

./pt-table-sync --execute --sync-to-master --charset=utf8 --ignore-databases=mysql,sys --no-check-slave h=192.168.56.101,u=checkq,p=123456,P=3306 --databases=bhs --tables=test --print
REPLACE INTO bhs.test(id, name) VALUES ('3', 'd') /percona-toolkit src_db:bhs src_tbl:test src_dsn:A=utf8,P=3306,h=192.168.56.108,p=...,u=checkq dst_db:bhs dst_tbl:test dst_dsn:A=utf8,P=3306,h=192.168.56.101,p=...,u=checkq lock:1 transaction:1 changing_src:1 replicate:0 bidirectional:0 pid:3775 user:root host:managed/;

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
4月前
|
关系型数据库 MySQL
MySQL 报错 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file
MySQL 报错 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file
312 0
|
1月前
|
SQL Oracle 关系型数据库
SYS_AUTO_SPM_EVOLVE_TASK
AUTO_STATS_ADVISOR_TASK SYS_AUTO_SPM_EVOLVE_TASK
18 0
|
SQL 关系型数据库 MySQL
pt-tools系列:pt-online-schema-change 最佳实践
pt的详细步骤 Step 1: Create the new table. Step 2: Alter the new, empty table. This should be very quick, or die if the user specified a bad alter statement.
4595 0
|
存储 关系型数据库 MySQL
|
关系型数据库 MySQL 数据库
MySQL新增字段报错:ERROR 1118 -- Row size too large. The maximum row size for the used table type
MySQL新增字段报错:ERROR 1118 -- Row size too large. The maximum row size for the used table type
1472 0
|
关系型数据库 MySQL
pt-table-checksum原理详解
环境 MySQL: MySQL 5.6.27 OS: centos 6.6 tool: pt-table-checksum 2.2.15 它能做什么 业界最流行的MySQL主从数据对比工具,数据一致性检测最好的的工具,没有之一 如何使用 ./pt-table-che
7333 0
|
3月前
|
关系型数据库 MySQL
mysql 5.5.62版本建表语句报错: Index column size too large. The maximum column size is 767 bytes
mysql 5.5.62版本建表语句报错: Index column size too large. The maximum column size is 767 bytes
|
9月前
|
测试技术
pg_rewind实例--could not find previous WAL record at %X/%X
pg_rewind实例--could not find previous WAL record at %X/%X
57 0
READ TABLE WITH KEY和READ TABLE WITH TABLE KEY的区别
READ TABLE WITH KEY和READ TABLE WITH TABLE KEY的区别
287 0
READ TABLE WITH KEY和READ TABLE WITH TABLE KEY的区别
|
关系型数据库 数据库 索引
pt-table-checksum
pt-table-checksum是目前可以说是最好的查看主从一致性的工具 先来个使用例子,有助快速上手使用 在主库执行:mysql>GRANT SELECT, PROCESS, SUPER, REPLICATION SLAVE,CREATE,DELETE,INSERT,UPDATE ON .
1643 0

热门文章

最新文章