Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Perform MySQL 5.6+ restart with buffer pool save and reload
  4.  
  5. # MySQL credentials
  6. user=
  7. pass=
  8.  
  9. # Exit on any command failure
  10. set -e
  11.  
  12. # Show me my pool stats
  13. mysql -u $user -p$pass -e "SHOW STATUS LIKE '%buff%';"
  14.  
  15. # Dump the buffer pool
  16. mysql -u $user -p$pass -e 'SET GLOBAL innodb_buffer_pool_dump_now=ON;'
  17.  
  18. # Wait for buffer dump to complete
  19. echo "Waiting for dump to complete"
  20.  
  21. while ! mysql -u $user -p$pass -e "SHOW STATUS LIKE 'Innodb_buffer_pool_dump_status';" | grep 'dump completed' | cut -d ' ' -f3- ; do
  22. sleep 2
  23. done
  24.  
  25. # Restart MySQL
  26. service mysql restart
  27.  
  28. # Load the saved buffer pool
  29. mysql -u $user -p$pass -e 'SET GLOBAL innodb_buffer_pool_load_now=ON;'
  30.  
  31. echo "Waiting for load to complete"
  32.  
  33. # Wait for buffer pool load to complete
  34. while mysql -u $user -p$pass -e "SHOW STATUS LIKE 'Innodb_buffer_pool_load_status';" | grep '/'; do
  35. sleep 2
  36. done
  37.  
  38. echo "Load succeeded"
  39.  
  40. # Show me my pool stats again
  41. mysql -u $user -p$pass -e "SHOW STATUS LIKE '%buff%';"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement