Xarici bir yaxın dostlardan biri (server administrator işləyir həmin adam) bugün deyəndəki bəs serverdə mysql-dən full dumpları ala bilmirəm özümə də maraql gəldi niyə.
Serverə login olandan sonra gördümki mysql serverdə 250-dən çox database var.
VƏ mysqldump vasitəsilə full dump aldıqda bəzi myisam engine tipli table-larda crashlar gedib.
4-5 table-ı manual yolla repair elədim gördüm amma yox gərək bunları repair etmək üçün səhərə qədər işləyim)
İşin digər tərəfi isə mysisamchk vasitəsilə belə repair etmək olmurda table-ları.Buffer çatışmır deyirdi.
my.ini -də bufferin həcmin belə artıqdıq + restartladıq mysql serveri.Amma xeyri olmadı.Problem qalırdı.myisamchk öhdəsindən gələ bilmirdi bu işin.
Manual yolla həmin truncate və drop belə etmək olmurdu crashed table-ları.
Nəticədə taskı avtomatizə etmək üçün kiçik bir skript yazdım və bununla serverdə crashed table-ları repair edə və nəticədə hər şeyi qaydasına qoya bildik.
Kiməsə lazım olar bəlkə: http://pastebin.com/fkqpWtfx
Kod:
<?php
/***********************************
*CODED BY AKASTEP
*WWW.ANTI-armenia.ORG
*MASS MYISAM TABLES REPAIR TOOL.
*
**********************************/
error_reporting(E_ALL);
set_time_limit(0);
$host='localhost';// allowed host//
$user='root';//mysql user + root olmalidir//
$password='databasepassword';// mysql root usere pass burada//
$hhandle=mysql_connect($host,$user,$password) or die("Can't Connect!");
$doquery=mysql_query("SHOW DATABASES") or die("Can't execute!");
!isset($i) ? $i=NULL : '';
while($s['Database']=mysql_fetch_assoc($doquery))
{
$db=$s['Database']['Database'] .PHP_EOL;
$db=mysql_real_escape_string(trim( (string) $db));
$sql="SELECT TABLE_NAME AS table_name FROM `information_schema`.`tables` WHERE `table_schema`='$db'";
$yobani=mysql_query($sql) or die(htmlentities(mysql_error()));
while($rt['table_name']=mysql_fetch_assoc($yobani))
{
$i++;
$full='`' .$db . '`.'. '`' . $rt['table_name']['table_name'] . '`';
if ($db!='information_schema') {
echo '[ ' . $i .' ]' . ' TRY-ing to REPAIR TABLE : ' . htmlentities($full) .PHP_EOL;
$d=mysql_query("REPAIR TABLE {$full}") or trigger_error(htmlentities(mysql_error()));
while ($z=mysql_fetch_assoc($d))
{
echo 'Current Table: ' . htmlentities($z['Table']) . PHP_EOL .
'Current Operation: ' . htmlentities($z['Op']) . PHP_EOL .
'MESSAGE TYPE: '. htmlentities($z['Msg_type']) . PHP_EOL .
'WTF GOES? ' . htmlentities($z['Msg_text']) . PHP_EOL;
}}}}
die(' DONE! ');
?>
Daha qısa variant: http://pastebin.com/MfPy0ZcY
Kod:
<?php
/***********************************
*CODED BY AKASTEP
*WWW.ANTI-armenia.ORG
*MASS MYISAM TABLES REPAIR TOOL.
* VARIANT 2
**********************************/
error_reporting(E_ALL);
set_time_limit(0);
$host='localhost';// allowed host//
$user='root';//mysql user + root olmalidir//
$password='databasepassword';// mysql root usere pass burada//
$hhandle=mysql_connect($host,$user,$password) or die("Can't Connect!");
$doquery=mysql_query("SELECT concat(table_schema,'.',table_name) akastep FROM information_schema.tables where engine='myisam' and table_schema!='information_schema'") or die("Can't execute!");
while($s=mysql_fetch_assoc($doquery))
{
$execquery=mysql_query("REPAIR TABLE {$s['akastep']}") or trigger_error(htmlentities(mysql_error()));
while($z=mysql_fetch_assoc($execquery))
{
echo 'Current Table: ' . htmlentities($z['Table']) . PHP_EOL .
'Current Operation: ' . htmlentities($z['Op']) . PHP_EOL .
'MESSAGE TYPE: '. htmlentities($z['Msg_type']) . PHP_EOL .
'WTF GOES? ' . htmlentities($z['Msg_text']) . PHP_EOL;
}
}
echo ' DONE ';
?>