Created
October 29, 2015 03:53
-
-
Save lichti/a21d79d34de60a2707f0 to your computer and use it in GitHub Desktop.
mysql_optimize_ng.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MYSQL_LOGIN='-uroot --password=neOfByon' | |
while read line | |
do | |
# SIZE | DATABASE | TABLE | FLAG | |
SIZE=$( echo "$line" | cut -d\| -f 1) | |
DATABASE=$( echo "$line" | cut -d\| -f 2) | |
TABLE=$( echo "$line" | cut -d\| -f 3) | |
FLAG=$( echo "$line" | cut -d\| -f 4) | |
if [ $FLAG -eq 1 ];then | |
echo -n " * Optimizing $DATABASE $TABLE ($SIZE) ... " | |
echo "USE $DATABASE; OPTIMIZE TABLE $TABLE" | mysql $MYSQL_LOGIN >/dev/null | |
fi | |
done < $1 | |
#Executar script | |
# timeout 140m ./bin/mysql_optimize_ng.sh /root/tables.txt | |
#Gerar lista | |
# cd /var/lib/mysql/; ls -lhS */*.ibd | tac | awk '{print $5,$9}' | tr '/' ' ' | sed s/\ /\ \|\ /g | sed s/\.ibd/\ \|\ 1/g > /tmp/tables.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment