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

Tips for deleting DROP from large tables

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

In daily work, we often encounter the migration of large historical tables from the main database to the backup machine to free up the main database space. If you directly drop table, it may cause database jitter, increase in the number of connections and other problems, thus affecting the business.

Then with a little trick, you can easily and smoothly delete the history table from the main library.

1. Create a hard link, and the "spoof" MySQL has been deleted when the drop table table is in progress.

Ln test.ibd test.ibd.hdlk

2. Do not rm test.ibd.hdlk directly at this time, which will cause the disk IO speed to rise and the MySQL performance jitter.

Here we write a script that cycles 1G at a time and hibernates for 2 seconds until it is deleted.

1) move test.ibd.hdlk to the / data/bak/ directory first

Mv test.ibd.hdlk / data/bak/

2) execute the following script:

#! / bin/bashTRUNCATE=/usr/bin/truncatefor I in `Get100-10` # decrease 1G at a time starting from 100g, and finally make the file 0do sleep 2 echo "$TRUNCATE-s ${I} G / data/bak/test.ibd.hdlk" $TRUNCATE-s ${I} G / data/bak/test.ibd.hdlkdone

Note: first ll-h test.ibd.hdlk to see how many gigabytes are in the file, and then enter seq, the above example is 100g.

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