3 3.98 全表归档,源表不删除,批量插入 [mysql@mysqlt1 bin]$ ./pt-archiver --source u=system,p=**,h=10.15.7.114,P=3306,D=test,t=t1 --dest u=system,p=**,h=192.168.19.145,P=3306,D=test,t=t37 \ > --where="1=1" --limit=1000 --statistics --bulk-insert --txn-size=1000 --no-delete --no-check-charset Started at 2019-03-26T02:22:48, ended at 2019-03-26T02:22:48 Source: D=test,P=3306,h=10.15.7.114,p=...,t=t1,u=system Dest: D=test,P=3306,h=192.168.19.145,p=...,t=t37,u=system SELECT 1000 INSERT 1000 DELETE 0 Action Count Time Pct bulk_inserting 1 0.0544 61.78 commit 4 0.0034 3.84 select 2 0.0015 1.69 print_bulkfile 1000 -0.0017 -1.91 other 0 0.0304 34.61 5全表归档,源表删除,批量插入,批量删除 ./pt-archiver --source u=system,p=**,h=10.15.7.114,P=3306,D=test,t=t1 --dest u=system,p=**,h=192.168.19.145,P=3306,D=test,t=t37 \ --where="1=1" --limit=1000 --statistics --bulk-insert --bulk-delete --txn-size=1000 --no-delete --no-check-charset 6指定条件归档,源表删除,批量(每1000个插入提交一次) ./pt-archiver --source u=system,p=**,h=10.15.7.114,P=3306,D=test,t=t1 --dest u=system,p=**,h=192.168.19.145,P=3306,D=test,t=t37 \ --where="id<=49999" --limit=1000 --statistics --bulk-insert --bulk-delete --txn-size=1000 --no-delete --no-check-charset 7指定索引的归档,不走自增主键索引。参数:i ./pt-archiver --source u=system,p=**,h=10.15.7.114,P=3306,D=test,t=t1,i=a --dest u=system,p=***,h=192.168.19.145,P=3306,D=test,t=t37 \ --where="a >=80000 and a<100000" --limit=1000 --statistics --bulk-insert --bulk-delete --txn-size=1000 --no-delete --no-check-charset 8有从库的归档 ./pt-archiver --source u=system,p=**,h=10.15.7.114,P=3306,D=test,t=t1,i=a --dest u=system,p=**,h=192.168.19.145,P=3306,D=test,t=t37 \ --where="a >=80000 and a<100000" --limit=1000 --statistics --bulk-insert --bulk-delete --txn-size=1000 --no-delete --no-check-charset \ --max-lag=1 --check-slave-lag u=system,p=**,h=10.15.7.115,P=3306 9不做任何操作,只打印要执行的查询语句 [mysql@mysqlt1 bin]$ ./pt-archiver --source u=system,p=**,h=10.15.7.114,P=3306,D=test,t=t1,i=a --dest u=system,p=**,h=192.168.19.145,P=3306,D=test,t=t37 \> --where="a >=1000 and a<3000" --limit=1000 --replace --statistics --txn-size=1000 --no-delete --no-check-charset --dry-run SELECT /*!40001 SQL_NO_CACHE */ `id`,`a`,`b` FROM `test`.`t1` FORCE INDEX(`a`) WHERE (a >=1000 and a<3000) ORDER BY `a` LIMIT 1000 SELECT /*!40001 SQL_NO_CACHE */ `id`,`a`,`b` FROM `test`.`t1` FORCE INDEX(`a`) WHERE (a >=1000 and a<3000) AND ((((? IS NULL AND `a` IS NOT NULL) OR (`a` > ?)))) ORDER BY `a` LIMIT 1000 REPLACE INTO `test`.`t37`(`id`,`a`,`b`) VALUES (?,?,?) 10常用的命令:归档到另一个数据库,源表删除,批量删除和插入,每1000次修改进行提交。跳过错误并且指定字符集连接 [mysql@mysqlt1 bin]$ ./pt-archiver --source u=system,p=**,h=10.15.7.114,P=3306,D=test,t=t1,i=a --dest u=system,p=**,h=192.168.19.145,P=3306,D=test,t=t37 --no-version-check\ > --where="a >=500 and a<800" --ignore --txn-size=200 --limit=200 --bulk-delete --bulk-insert --progress=5000 --statistics --why-quit --no-check-charset TIME ELAPSED COUNT 2019-03-26T03:13:10 0 0 2019-03-26T03:13:11 0 300 Started at 2019-03-26T03:13:10, ended at 2019-03-26T03:13:11 Source: D=test,P=3306,h=10.15.7.114,i=a,p=...,t=t1,u=system Dest: D=test,P=3306,h=192.168.19.145,i=a,p=...,t=t37,u=system SEL |