{"id":2643,"date":"2018-09-06T06:20:42","date_gmt":"2018-09-06T06:20:42","guid":{"rendered":"http:\/\/dbtut.com\/?p=2643"},"modified":"2018-11-24T17:14:03","modified_gmt":"2018-11-24T17:14:03","slug":"archive-data-using-pt-archiver","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/","title":{"rendered":"Archive data using pt-archiver"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>The Percona Toolkit contains many tools for MySQL. Usually, we use the <strong>pt-archive<\/strong> to archive our data. Pt-archive can archive the table data to a table or file, also can be used to purge data.<\/p>\n<h2>First of all, how to install the Percona-Toolkit?<\/h2>\n<p>1. Download a suitable package at <a href=\"https:\/\/www.percona.com\/downloads\/percona-toolkit\/LATEST\/\">https:\/\/www.percona.com\/downloads\/percona-toolkit\/LATEST\/<\/a> , for example, i choose the percona-toolkit-3.0.11-1.el6.x86_64.rpm.<\/p>\n<p>2. Use <code>rpm<\/code>\u00a0to install<\/p>\n<pre class=\"lang:default decode:true \">rpm -ivh\u00a0percona-toolkit-3.0.11-1.el6.x86_64.rpm<\/pre>\n<p>&nbsp;<\/p>\n<p>You may need to install the dependencies:<\/p>\n<pre class=\"lang:default decode:true \">yum install\u00a0perl-DBI\r\n\r\nyum install\u00a0perl-DBD-MySQL\r\n\r\nyum install\u00a0perl-IO-Socket-SSL\r\n\r\nyum install\u00a0perl-Digest-MD5<\/pre>\n<p>&nbsp;<\/p>\n<p>3. Check if the installation is successful<\/p>\n<pre class=\"lang:default decode:true \">pt-archiver --help<\/pre>\n<p>&nbsp;<\/p>\n<p>If it shows the help information, then the installation is finished.<\/p>\n<p>&nbsp;<\/p>\n<p>4. Create users for the archiving<\/p>\n<p>At the source side, the user should have at least SELECT, DELETE privileges.<\/p>\n<p>At the target side, the user should have at least INSERT privilege.<\/p>\n<p>We can know why it needs these privileges from the general log below.<\/p>\n<p>&nbsp;<\/p>\n<h2>Secondly, how to archive data?<\/h2>\n<h3>(1) Archive data<\/h3>\n<p>Now, i&#8217;ll archive my table &#8216;testarchive.sourcetb&#8217; to the target table,<\/p>\n<p><strong>Source database info: 192.168.100.184:8001\u00a0 \u00a0testarchive.sourcetb<\/strong><\/p>\n<p><strong>Target database info: 192.168.100.103:4001\u00a0 \u00a0destdb.targettb<\/strong><\/p>\n<p><strong>Source info:<\/strong><\/p>\n<pre class=\"lang:default decode:true \">mysql&gt; show create table sourcetb \\G\r\n\r\n*************************** 1. row ***************************\r\n\r\nTable: sourcetb\r\n\r\nCreate Table: CREATE TABLE `sourcetb` (\r\n\r\n`id` int(11) NOT NULL,\r\n\r\n`name` varchar(30) DEFAULT NULL,\r\n\r\nPRIMARY KEY (`id`)\r\n\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"lang:default decode:true \">mysql&gt; select * from sourcetb;\r\n\r\n+----+------+\r\n\r\n| id | name |\r\n\r\n+----+------+\r\n\r\n| 1 | aaa |\r\n\r\n| 2 | bbb |\r\n\r\n| 3 | ccc |\r\n\r\n+----+------+<\/pre>\n<p>&nbsp;<\/p>\n<p>Because PT-ARCHIVE won&#8217;t create the table automatically, so i have to create a same table on the target database:<\/p>\n<pre class=\"lang:default decode:true \">CREATE TABLE `targettb` (\r\n\r\n`id` int(11) NOT NULL,\r\n\r\n`name` varchar(30) DEFAULT NULL,\r\n\r\nPRIMARY KEY (`id`)\r\n\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8<\/pre>\n<p>&nbsp;<\/p>\n<p>Then executing as follows:<\/p>\n<pre class=\"lang:default decode:true \">pt-archiver --source h=192.168.100.184,P=8001,D=testarchive,t=sourcetb,u=archive,p=archivepwd --where 'id &lt; 3' --dest h=192.168.100.103,P=4001,u=archive_wr,p=wrpwd,D=destdb,t=targettb --limit=1 --no-delete --why-quit 2&gt;&amp;1 &gt;&gt; archive.log<\/pre>\n<p>&nbsp;<\/p>\n<p>&#8211;source: DSN specifying the table to archive from (required)<\/p>\n<p>&#8211;dest: DSN specifying the table to archive to<\/p>\n<p>&#8211;where: limit which rows to archive<\/p>\n<p>&#8211;no-delete: Do not delete archived rows<\/p>\n<p>&#8211;limit: Number of rows to fetch and archive per statement (default 1)<\/p>\n<p>&#8211;why-quit: Print reason for exiting unless rows exhausted<\/p>\n<p>The execution log was printed into archive.log<\/p>\n<p>&nbsp;<\/p>\n<h3>(2)Check the result<\/h3>\n<p>After that, check the source table:<\/p>\n<pre class=\"lang:default decode:true \">mysql&gt; select * from testarchive.sourcetb;\r\n\r\n+----+------+\r\n\r\n| id | name |\r\n\r\n+----+------+\r\n\r\n| 1 | aaa |\r\n\r\n| 2 | bbb |\r\n\r\n| 3 | ccc |\r\n\r\n+----+------+<\/pre>\n<p>&nbsp;<\/p>\n<p>Check the target table:<\/p>\n<pre class=\"lang:default decode:true \">mysql&gt; select * from destdb.targettb;\r\n\r\n+----+------+\r\n\r\n| id | name |\r\n\r\n+----+------+\r\n\r\n| 1 | aaa |\r\n\r\n| 2 | bbb |\r\n\r\n+----+------+<\/pre>\n<p>&nbsp;<\/p>\n<p>It shows that the rows(&#8221; id &lt; 3 &#8220;) have been archived to the target table, and the source rows are still exist(&#8221; &#8211;no-delete &#8220;).<\/p>\n<p>&nbsp;<\/p>\n<h3>(3)What the PT-ARCHIVE did?<\/h3>\n<p>What the pt-archive actually did in MySQL? As we know, the general log of MySQL can show all the queries, so we can get the details from the general log( turn it on before archiving data):<\/p>\n<pre class=\"lang:default decode:true \">mysql&gt; show variables like '%general_log%';\r\n\r\n+------------------+-----------------------------------+\r\n\r\n| Variable_name | Value |\r\n\r\n+------------------+-----------------------------------+\r\n\r\n| general_log | ON |\r\n\r\n| general_log_file | \/data\/mysql8001\/mysql-general.log |\r\n\r\n+------------------+-----------------------------------+<\/pre>\n<p>&nbsp;<\/p>\n<p>If the general_log is OFF, use <code>set global\u00a0general_log=on;<\/code> to turn it on, and then open the &#8220;<strong>general_log_file<\/strong>&#8220;.<\/p>\n<p><strong>Source side:<\/strong><\/p>\n<blockquote>\n<pre class=\"lang:default decode:true \">2018-09-05T18:43:32.696341+08:00 54 Connect archive@192.168.100.184 on testarchive using TCP\/IP\r\n\r\n2018-09-05T18:43:32.696705+08:00 54 Query set names utf8\r\n\r\n2018-09-05T18:43:32.696873+08:00 54 Query set autocommit=0\r\n\r\n2018-09-05T18:43:32.697653+08:00 54 Query SHOW VARIABLES LIKE 'wait\\_timeout'\r\n\r\n2018-09-05T18:43:32.699146+08:00 54 Query SET SESSION wait_timeout=10000\r\n\r\n2018-09-05T18:43:32.699466+08:00 54 Query SELECT @@SQL_MODE\r\n\r\n2018-09-05T18:43:32.700519+08:00 54 Query SET @@SQL_QUOTE_SHOW_CREATE = 1\/*!40101, @@SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'*\/\r\n\r\n2018-09-05T18:43:32.700826+08:00 54 Query SELECT version()\r\n\r\n2018-09-05T18:43:32.701067+08:00 54 Query \/*!40101 SET character_set_connection = utf8mb4 *\/\r\n\r\n2018-09-05T18:43:32.701433+08:00 54 Query SHOW VARIABLES LIKE 'version%'\r\n\r\n2018-09-05T18:43:32.703496+08:00 54 Query SHOW ENGINES\r\n\r\n2018-09-05T18:43:32.704993+08:00 54 Query SHOW VARIABLES LIKE 'innodb_version'\r\n\r\n2018-09-05T18:43:32.708559+08:00 54 Query show variables like 'innodb_rollback_on_timeout'\r\n\r\n2018-09-05T18:43:32.711276+08:00 54 Query \/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, @@SQL_MODE := '', @OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, @@SQL_QUOTE_SHOW_CREATE := 1 *\/\r\n\r\n2018-09-05T18:43:32.711539+08:00 54 Query USE `testarchive`\r\n\r\n2018-09-05T18:43:32.712462+08:00 54 Query SHOW CREATE TABLE `testarchive`.`sourcetb`\r\n\r\n2018-09-05T18:43:32.713398+08:00 54 Query \/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, @@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE *\/\r\n\r\n2018-09-05T18:43:32.746212+08:00 54 Query SHOW VARIABLES LIKE 'wsrep_on'\r\n\r\n2018-09-05T18:43:32.749376+08:00 54 Query SHOW VARIABLES LIKE 'wsrep_on'\r\n\r\n2018-09-05T18:43:32.752939+08:00 54 Query SHOW VARIABLES LIKE 'version%'\r\n\r\n2018-09-05T18:43:32.754563+08:00 54 Query SHOW ENGINES\r\n\r\n2018-09-05T18:43:32.755286+08:00 54 Query SHOW VARIABLES LIKE 'innodb_version'\r\n\r\n2018-09-05T18:43:32.759183+08:00 54 Query SELECT CONCAT(@@hostname, @@port)\r\n\r\n2018-09-05T18:43:32.761297+08:00 54 Query SELECT \/*!40001 SQL_NO_CACHE *\/ `id`,`name` FROM `testarchive`.`sourcetb` FORCE INDEX(`PRIMARY`) WHERE (id &lt; 3) ORDER BY `id` LIMIT 1\r\n\r\n2018-09-05T18:43:32.768565+08:00 54 Query commit\r\n\r\n2018-09-05T18:43:32.769014+08:00 54 Query SELECT \/*!40001 SQL_NO_CACHE *\/ `id`,`name` FROM `testarchive`.`sourcetb` FORCE INDEX(`PRIMARY`) WHERE (id &lt; 3) AND ((`id` &gt; '1')) ORDER BY `id` LIMIT 1\r\n\r\n2018-09-05T18:43:32.788186+08:00 54 Query commit\r\n\r\n2018-09-05T18:43:32.788530+08:00 54 Query SELECT \/*!40001 SQL_NO_CACHE *\/ `id`,`name` FROM `testarchive`.`sourcetb` FORCE INDEX(`PRIMARY`) WHERE (id &lt; 3) AND ((`id` &gt; '2')) ORDER BY `id` LIMIT 1\r\n\r\n2018-09-05T18:43:32.789915+08:00 54 Query commit\r\n\r\n2018-09-05T18:43:32.790269+08:00 54 Quit<\/pre>\n<p>&nbsp;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><strong>Target side:<\/strong><\/p>\n<blockquote>\n<pre class=\"lang:default decode:true \">2018-09-05T18:43:32.714956+08:00 58 Connect archive_wr@192.168.100.184 on destdb using TCP\/IP\r\n\r\n2018-09-05T18:43:32.715127+08:00 58 Query SET SQL_SAFE_UPDATES = 1\r\n\r\n2018-09-05T18:43:32.715929+08:00 58 Query set autocommit=0\r\n\r\n2018-09-05T18:43:32.716946+08:00 58 Query SHOW VARIABLES LIKE 'wait\\_timeout'\r\n\r\n2018-09-05T18:43:32.718650+08:00 58 Query SET SESSION wait_timeout=10000\r\n\r\n2018-09-05T18:43:32.720291+08:00 58 Query SELECT @@SQL_MODE\r\n\r\n2018-09-05T18:43:32.721198+08:00 58 Query SET @@SQL_QUOTE_SHOW_CREATE = 1\/*!40101, @@SQL_MODE='NO_AUTO_VALUE_ON_ZERO'*\/\r\n\r\n2018-09-05T18:43:32.722882+08:00 58 Query SELECT version()\r\n\r\n2018-09-05T18:43:32.727548+08:00 58 Query SHOW VARIABLES LIKE 'version%'\r\n\r\n2018-09-05T18:43:32.731768+08:00 58 Query SHOW ENGINES\r\n\r\n2018-09-05T18:43:32.735711+08:00 58 Query SHOW VARIABLES LIKE 'innodb_version'\r\n\r\n2018-09-05T18:43:32.738308+08:00 58 Query show variables like 'innodb_rollback_on_timeout'\r\n\r\n2018-09-05T18:43:32.740513+08:00 58 Query \/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, @@SQL_MODE := '', @OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, @@SQL_QUOTE_SHOW_CREATE := 1 *\/\r\n\r\n2018-09-05T18:43:32.743294+08:00 58 Query USE `destdb`\r\n\r\n2018-09-05T18:43:32.744080+08:00 58 Query SHOW CREATE TABLE `destdb`.`targettb`\r\n\r\n2018-09-05T18:43:32.745378+08:00 58 Query \/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, @@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE *\/\r\n\r\n2018-09-05T18:43:32.759996+08:00 58 Query SELECT CONCAT(@@hostname, @@port)\r\n\r\n2018-09-05T18:43:32.762450+08:00 58 Query INSERT INTO `destdb`.`targettb`(`id`,`name`) VALUES ('1','aaa')\r\n\r\n2018-09-05T18:43:32.763767+08:00 58 Query commit\r\n\r\n2018-09-05T18:43:32.769621+08:00 58 Query INSERT INTO `destdb`.`targettb`(`id`,`name`) VALUES ('2','bbb')\r\n\r\n2018-09-05T18:43:32.781708+08:00 58 Query commit\r\n\r\n2018-09-05T18:43:32.789535+08:00 58 Query commit\r\n\r\n2018-09-05T18:43:32.790562+08:00 58 Quit<\/pre>\n<p>&nbsp;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><strong>Pt-archive performs a lot of checks when it is executed, and it also allows you turn these checks off.<\/strong><\/p>\n<p>If you want to delete the data, then you can remove the &#8220;&#8211;no-delete&#8221; option, and we can get &#8220;delete&#8221; from the general log:<\/p>\n<blockquote>\n<pre class=\"lang:default decode:true \">2018-09-05T18:45:45.187173+08:00 56 Query SELECT \/*!40001 SQL_NO_CACHE *\/ `id`,`name` FROM `testarchive`.`sourcetb` FORCE INDEX(`PRIMARY`) WHERE (id &lt; 3) ORDER BY `id` LIMIT 1\r\n\r\n2018-09-05T18:45:45.191838+08:00 56 Query DELETE FROM `testarchive`.`sourcetb` WHERE (`id` = '1')\r\n\r\n2018-09-05T18:45:45.197355+08:00 56 Query commit\r\n\r\n2018-09-05T18:45:45.256209+08:00 56 Query SELECT \/*!40001 SQL_NO_CACHE *\/ `id`,`name` FROM `testarchive`.`sourcetb` FORCE INDEX(`PRIMARY`) WHERE (id &lt; 3) AND ((`id` &gt;= '1')) ORDER BY `id` LIMIT 1\r\n\r\n2018-09-05T18:45:45.258457+08:00 56 Query DELETE FROM `testarchive`.`sourcetb` WHERE (`id` = '2')\r\n\r\n2018-09-05T18:45:45.265718+08:00 56 Query commit\r\n\r\n2018-09-05T18:45:45.272541+08:00 56 Query SELECT \/*!40001 SQL_NO_CACHE *\/ `id`,`name` FROM `testarchive`.`sourcetb` FORCE INDEX(`PRIMARY`) WHERE (id &lt; 3) AND ((`id` &gt;= '2')) ORDER BY `id` LIMIT 1\r\n\r\n2018-09-05T18:45:45.274470+08:00 56 Query commit<\/pre>\n<p>&nbsp;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<h2>Other options of the pt-archive<\/h2>\n<p>You can use <code>pt-archiver --help<\/code>\u00a0 to get whole help information<\/p>\n<p>Here i list some commonly used options:<\/p>\n<p>&#8211;source: DSN specifying the table to archive from (required)<\/p>\n<p>&#8211;dest: DSN specifying the table to archive to<\/p>\n<p>&#8211;where: limit which rows to archive<\/p>\n<p>&#8211;no-delete: Do not delete archived rows<\/p>\n<p>&#8211;limit: Number of rows to fetch and archive per statement (default 1)<\/p>\n<p>&#8211;why-quit: Print reason for exiting unless rows exhausted<\/p>\n<p>&#8211;replace: Causes INSERTs into &#8211;dest to be written as REPLACE<\/p>\n<p>&#8211;bulk-delete: Delete each chunk with a single statement (implies &#8211;commit-each)<\/p>\n<p>&#8211;statistics: Collect and print timing statistics<\/p>\n<p>&#8211;max-lag=m:\u00a0 Pause archiving if the slave given by &#8211;check-slave-lag lags (default 1s). Optional suffix s=seconds, m=minutes, h=hours, d=days; if no suffix, s is used.<\/p>\n<p>&#8211;sleep=i:\u00a0Sleep time between fetches<\/p>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_2643\" class=\"pvc_stats all  \" data-element-id=\"2643\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; The Percona Toolkit contains many tools for MySQL. Usually, we use the pt-archive to archive our data. Pt-archive can archive the table data to a table or file, also can be used to purge data. First of all, how to install the Percona-Toolkit? 1. Download a suitable package at https:\/\/www.percona.com\/downloads\/percona-toolkit\/LATEST\/ , for example, i &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_2643\" class=\"pvc_stats all  \" data-element-id=\"2643\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":50,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[7],"tags":[1473],"class_list":["post-2643","post","type-post","status-publish","format-standard","","category-mysql","tag-pt-archive"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Archive data using pt-archiver - Database Tutorials<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Archive data using pt-archiver - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"&nbsp; The Percona Toolkit contains many tools for MySQL. Usually, we use the pt-archive to archive our data. Pt-archive can archive the table data to a table or file, also can be used to purge data. First of all, how to install the Percona-Toolkit? 1. Download a suitable package at https:\/\/www.percona.com\/downloads\/percona-toolkit\/LATEST\/ , for example, i &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-06T06:20:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-11-24T17:14:03+00:00\" \/>\n<meta name=\"author\" content=\"Shuo Wang\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shuo Wang\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/\"},\"author\":{\"name\":\"Shuo Wang\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/83d7028b846c78bfd03244ec6cd04289\"},\"headline\":\"Archive data using pt-archiver\",\"datePublished\":\"2018-09-06T06:20:42+00:00\",\"dateModified\":\"2018-11-24T17:14:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/\"},\"wordCount\":540,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"keywords\":[\"pt-archive\"],\"articleSection\":[\"MySQL-MariaDB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/\",\"name\":\"Archive data using pt-archiver - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"datePublished\":\"2018-09-06T06:20:42+00:00\",\"dateModified\":\"2018-11-24T17:14:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Archive data using pt-archiver\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/83d7028b846c78bfd03244ec6cd04289\",\"name\":\"Shuo Wang\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/da30aa3d0157ae5f1f853927f56b868cfb1d801888eb954768c471e5d41cdd87?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/da30aa3d0157ae5f1f853927f56b868cfb1d801888eb954768c471e5d41cdd87?s=96&d=mm&r=g\",\"caption\":\"Shuo Wang\"},\"url\":\"https:\/\/dbtut.com\/index.php\/author\/shuowang\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Archive data using pt-archiver - Database Tutorials","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/","og_locale":"en_US","og_type":"article","og_title":"Archive data using pt-archiver - Database Tutorials","og_description":"&nbsp; The Percona Toolkit contains many tools for MySQL. Usually, we use the pt-archive to archive our data. Pt-archive can archive the table data to a table or file, also can be used to purge data. First of all, how to install the Percona-Toolkit? 1. Download a suitable package at https:\/\/www.percona.com\/downloads\/percona-toolkit\/LATEST\/ , for example, i &hellip;","og_url":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/","og_site_name":"Database Tutorials","article_published_time":"2018-09-06T06:20:42+00:00","article_modified_time":"2018-11-24T17:14:03+00:00","author":"Shuo Wang","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Shuo Wang","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/"},"author":{"name":"Shuo Wang","@id":"https:\/\/dbtut.com\/#\/schema\/person\/83d7028b846c78bfd03244ec6cd04289"},"headline":"Archive data using pt-archiver","datePublished":"2018-09-06T06:20:42+00:00","dateModified":"2018-11-24T17:14:03+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/"},"wordCount":540,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"keywords":["pt-archive"],"articleSection":["MySQL-MariaDB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/","url":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/","name":"Archive data using pt-archiver - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"datePublished":"2018-09-06T06:20:42+00:00","dateModified":"2018-11-24T17:14:03+00:00","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2018\/09\/06\/archive-data-using-pt-archiver\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"Archive data using pt-archiver"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/83d7028b846c78bfd03244ec6cd04289","name":"Shuo Wang","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/da30aa3d0157ae5f1f853927f56b868cfb1d801888eb954768c471e5d41cdd87?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/da30aa3d0157ae5f1f853927f56b868cfb1d801888eb954768c471e5d41cdd87?s=96&d=mm&r=g","caption":"Shuo Wang"},"url":"https:\/\/dbtut.com\/index.php\/author\/shuowang\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/2643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/50"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=2643"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/2643\/revisions"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=2643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=2643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=2643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}