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

MySQL uses pt-archiver to archive historical data

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Pt-archiver can archive tables to a history database according to specified conditions, and also supports file export, which is very convenient for archiving and cleaning up online historical data.

If you want to archive the data of a table to a table in a historical database, you need to create a table structure in the historical database in advance.

(1) Archive the historical data in the table into the historical data according to the conditions, and generate the archive file locally

# create an archive table in the historical database (192.168.56.102)

Mysql > CREATE TABLE `emp` (

-> `id` int (11) NOT NULL

-> `name` varchar (15) DEFAULT NULL

-> PRIMARY KEY (`id`)

->) ENGINE=InnoDB DEFAULT CHARSET=utf8

Query OK, 0 rows affected (0.60 sec)

# View the source table

Mysql > select * from emp

+-+ +

| | id | name |

+-+ +

| | 10 | Neo |

| | 10036 | test |

| | 10037 | test |

| | 10038 | test |

| | 10039 | test |

| | 10040 | MySQL01 |

| | 10041 | MySQL01 |

| | 10042 | MySQL01 |

| | 100100 | test |

| | 100101 | test |

| | 100103 | test |

| | 100104 | test |

| | 100105 | test |

| | 100106 | test |

| | 100107 | test |

| | 100108 | test |

+-+ +

# Archive data with id less than 200000 to history database and local files

# pt-archiver-- source hobby 192.168.56.101Pendure 3307 id where id-- dest hype 192.168.56.102

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