Home Database Mysql Tutorial 清理8组nodes中表的历史数据,平均每个node中的表有1.5亿条记录_MySQL

清理8组nodes中表的历史数据,平均每个node中的表有1.5亿条记录_MySQL

Jun 01, 2016 pm 01:30 PM
history clean up space Record

bitsCN.com

清理8组nodes中表的历史数据,平均每个node中的表有1.5亿条记录

 

清理8组nodes中表的历史数据,平均每个node中的表有1.5亿条记录,需要根据date_created字段清理8000W数据记录,这个字段没有索引。

 

环境介绍 

线上磁盘空间不足,truncate了许多能动的表,磁盘空间还是占据了87%,我们的nagios报警阀值是80%。所以不断的还会收到email以及短信报警。需要根据时间字段date_created清理,但是在设计之初由于当初的开发人员考虑不足所以date_created字段没有建立索引。另外这些数据可以不用备份,直接删除掉。

 

问题来了,这么大记录量的表,根据date_created字段删除记录,而且还没有索引,难度肯定非常大。enl.ibd文件大小29G大小,磁盘剩余空间32G,两者差距比较小。

[mysql@xxxx-xxx ide]$ ll -h enl.ibd-rw-rw---- 1 mysql mysql 29G Aug 30 07:21 enl.ibd
Copy after login

方案策划中,大概准备采用shell命令。

虽然date_created 没有索引,但是我们做过实验

mysql> select * from enl where date_created < "2013-01-01 00:00:00" limit 1000;......1000 rows in set (0.00 sec)
Copy after login

看来执行效果还不错,那再试下delete效果

mysql> delete from enl where date_created < "2013-01-01 00:00:00" limit 1000;Query OK, 1000 row affected (2.00 sec)
Copy after login

看起来可以每次删除1000条,写脚本delete吧

for ((i=0;i<1000000;i++));do mysql -uroot -e &#39;use iden;delete  from enl where date_created < "2013-01-01 00:00:00" limit 1000;&#39;;done
Copy after login

 

 

等delete操作完成之后,找业务低峰期执行 alter table enl  engine=innodb;来释放磁盘空间。
 

bitsCN.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Introduction to the location of 5 lighthouses in the history of the sinking of Mingtide Introduction to the location of 5 lighthouses in the history of the sinking of Mingtide Mar 07, 2024 pm 03:58 PM

Are you looking for the five lighthouses in the History of the Sinking Tide quest? This guide will give you a detailed explanation of where these lighthouses are waiting to be discovered. We hope this will help you find the lighthouse you need quickly and complete your mission successfully! The history of the sinking of the Mingtide Five lighthouse locations are introduced and the specific locations are listed: 1. The first lighthouse: Please go to the barren stone highland, located directly above Beiluoye. 2. The second lighthouse: Next, please go to the Zhongqu Platform, which can be found around the teleportation point on the northeast side. 3. The third lighthouse: Please go to the southeast of Hukou Mountains and find it along Wuming Bay. 4. The fourth lighthouse: Please go to the teleportation point at the southeastern end of the Angry Birds Zee, near the cliff. 5. The fifth lighthouse: Please go to the first silent zone of the Lightless Forest, and you will find it on the edge of the cliff.

Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Mar 12, 2024 pm 07:20 PM

Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

How to check call history in iPhone and export it? How to check call history in iPhone and export it? Jul 05, 2023 pm 12:54 PM

Call recording in iPhone is often underestimated and is one of the most critical features of iPhone. With its simplicity, this feature is of vital importance and can provide important insights about the calls made or received on the device. Whether for work purposes or legal proceedings, the ability to access call records can prove invaluable. In simple terms, call history refers to the entries created on your iPhone whenever you make or receive a call. These logs contain key information, including the contact's name (or number if not saved as a contact), timestamp, duration, and call status (dialed, missed, or not answered). They are a concise record of your communication history. Call history includes call history strips stored on your iPhone

How to view and manage Linux command history How to view and manage Linux command history Aug 01, 2023 pm 09:17 PM

How to View Command History in Linux In Linux, we use the history command to view the list of all previously executed commands. It has a very simple syntax: history Some options for pairing with the history command include: Option description -c clears the command history for the current session -w writes the command history to a file -r reloads the command history from the history file -n Limit the number of output of recent commands Simply run the history command to see a list of all previously executed commands in a Linux terminal: In addition to viewing command history, you can also manage command history and perform modifications to previously executed commands , reverse search command history or even delete history completely

How to add swap space on Ubuntu 22.04 LTS How to add swap space on Ubuntu 22.04 LTS Feb 20, 2024 am 11:12 AM

Swap space plays an important role in Linux systems, especially when the system is low on memory. It acts as a backup memory storage space that helps the system run smoothly and maintain stability even under high load. This article provides you with a detailed guide to adding swap space on Ubuntu 22.04LTS to ensure that your system performance is optimized and can handle various workloads. Understanding Swap Space Swap space provides virtual memory that is used to supplement the system's physical RAM. When the system is low on RAM, the kernel swaps data to disk to prevent out-of-memory and system crashes. Linux systems commonly use swap space to handle this situation. Run multiple memory-intensive applications simultaneously to process very large files or data

How to effectively clean junk and cache in win7 system How to effectively clean junk and cache in win7 system Dec 27, 2023 pm 07:53 PM

When we use Win7 computers on a daily basis, a bunch of system cache garbage often accumulates over time, which requires us to clean it manually. So how to clean the garbage and cache of each system disk? Let’s take a look. How to clean up junk and cache in Windows 7 1. Find the disk you want to clean, right-click and select Properties. 2. The computer will pop up the detailed properties of the hard disk. Here we continue to click "Disk Cleanup" 3. After clicking, we select the option you want to clean here and click Clean.

Where to check win11 disk cleanup Where to check win11 disk cleanup Jun 29, 2023 pm 09:25 PM

Where can I check disk cleanup in win11? As the system is used for a long time, there will often be more than ten gigabytes or more useless junk files in the c drive or other computer disks. At this time, using the disk cleanup function that comes with win11 can help us quickly clean up these useless files. However, many users do not know where the disk cleanup function of win11 is and how to operate it. Today, the editor will bring you the steps to check the junk cleaning function that comes with Win 11, and let me explain it to you. Steps to check win11’s built-in junk cleaning function 1. First, press the [Win] key on the keyboard, or click [Start Menu] on the taskbar, and then select [Settings] under pinned applications; 2. The current path is: System >storage,

Are administrator rights required: win10 required to clean C drive Are administrator rights required: win10 required to clean C drive Jan 12, 2024 pm 03:45 PM

Many users have recently encountered the problem that when cleaning files in the C drive, a pop-up window will appear, indicating that permissions need to be granted to delete them. Click to grant permissions, but they still cannot be deleted. We only need to make a slight modification in the group policy. It can be solved. Does cleaning up the C drive in Win10 require administrator rights? Answer: Cleaning up the C drive in Win10 requires administrator rights. 1. Enter the command using the win+r shortcut key in the pop-up window, and press the Enter key. 2. Click to open----. 3. Then, on this page, change it to. 4. Similarly, set the options. 5. Finally, save the settings, close all pages, restart the computer, and then clean the C drive directly.

See all articles