MySQLRebuildAndOptimiseIndexCron

MySQL command mysqlcheck

this can be run whilst mysql is running, unlike myasmchk which ideally shouldn’t be run on a live mySQL server

 

  • mysql – rebuild indexes by database in crontab

 

	* 00 11 * * * /usr/local/mysql/bin/mysqlcheck -u<user> -p<password>  
  --repair --quick --databases <db name(s)> --silent

 

  • mysql – rebuild indexes by table(s) in crontab

 

	* 00 11 * * * /usr/local/mysql/bin/mysqlcheck -u<user> -p<password>  
  --repair --quick <database> <table name(s)(,comma separated)> --silent

 

MySQL command myisamchk

 

    myisamchk --force --fast --update-state -O key_buffer=128M -O sort_buffer=128M -O  
    read_buffer=1M -O write_buffer=2M /usr/local/mysql/data/s_mon/*.MYI 2>&1 > myisamchk.log

 

  myisamchk: warning: Table is marked as crashed and last repair failed 
  myisamchk: warning: 1 clients is using or hasn't closed the table properly 
  myisamchk: warning: Size of indexfile is: 12240194560 Should be: 4986249216 
  myisamchk: warning: Size of datafile is: 7019888251 Should be: 6931236906

output in log is:

 

  [email protected]# cat myisamchk.log 
  Checking MyISAM? file: /usr/local/mysql/data/s_mon/component_data.MYI 
  Data records: 407719818 Deleted blocks: 0

Sii il primo a lasciare un commento. Non essere timido!

Partecipa alla Discussione

Puoi usare i seguenti HTML tag e attributi: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>