MYISAM table batch compression bitsCN.com
Batch compression of MYISAM tables
These two operations need to be used with caution. before compression, you need to confirm that mysqld is disabled or that the table to be compressed does not have any other SQL operations, and the compression process will occupy cpu resources, we recommend that you do this when the server is idle.
The following is the shell process used to compress the following table of a database (it is worth noting that if the data volume is large, we recommend that you perform the operation multiple times because it takes a lot of time ):
1 #! /Bin/bash 2 data_dir = "/data/mysql/my_dbname/" 3 filelist = 'ls $ data_dir '4 echo "myisampack begin. "5 for filename in $ filelist 6 do 7 idx = 'expr match" $ filename "". *. MYI "'8 if [[$ idx> 0] 9 then10/usr/bin/myisampack $ data_dir $ filename11 fi12 done13 14 echo" MYISAMPACK End. myisamchk begin. "15 16 for filename in $ filelist17 do18 idx = 'expr match" $ filename "". *. MYI "'19 if [[$ idx> 0] 20 then21/usr/bin/myisamchk-r-o-f -- sort-index -- analyze $ data_dir $ filename22 fi23 done24 echo "myisamchk end."
BitsCN.com