Changeset 1203

Show
Ignore:
Timestamp:
02/26/10 06:03:00 (5 months ago)
Author:
Gary
Message:

unxsVZ boot-slave.sh debugged and alpha tested.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tools/mysql-server/boot-cluster/boot-slave.sh

    r1202 r1203  
    1212 
    1313#Configuration section 
    14 iTimeoutSecs="300"; 
     14#2 hours 
     15iTimeoutSecs="7200"; 
    1516cWarnEmail="supportgrp@unixservice.com"; 
    1617cSSHPort="22" 
     
    3031while [ $? != 0 ] && [ $iCounter -lt $iTimeoutSecs ];do 
    3132        let iCounter=iCounter+1; 
     33        #fLog "retrying ping $iCounter/$iTimeoutSecs"; 
    3234        ping -c 1 $2 > /dev/null 2>&1; 
    3335done 
    3436if [ $iCounter -eq "$iTimeoutSecs" ];then 
    35         fLog "ping master timeout $iCounter"; 
    36         exit 1; 
     37        fLog "ping master timeout"; 
     38        #exit 1; 
     39fi 
     40 
     41iCounter=0; 
     42/usr/bin/ssh -p $cSSHPort $2 exit > /dev/null 2>&1; 
     43while [ $? != 0 ] && [ $iCounter -lt $iTimeoutSecs ];do 
     44        let iCounter=iCounter+1; 
     45        sleep 1; 
     46        #fLog "retrying check for ssh $iCounter/$iTimeoutSecs"; 
     47        /usr/bin/ssh -p $cSSHPort $2 exit > /dev/null 2>&1; 
     48done 
     49if [ $iCounter -eq "$iTimeoutSecs" ];then 
     50        fLog "remote ssh timeout"; 
     51        #exit 2; 
    3752fi 
    3853 
     
    4156while [ $? != 0 ] && [ $iCounter -lt $iTimeoutSecs ];do 
    4257        let iCounter=iCounter+1; 
     58        sleep 1; 
     59        #fLog "retrying check for mysqld $iCounter/$iTimeoutSecs"; 
    4360        /usr/bin/ssh -p $cSSHPort $2 ps -ef | grep mysqld  > /dev/null 2>&1; 
    44         sleep 1; 
    4561done 
    4662if [ $iCounter -eq "$iTimeoutSecs" ];then 
    4763        fLog "remote mysqld timeout"; 
    48         exit 2; 
     64        #exit 2; 
    4965fi 
    5066 
    5167 
     68iCounter=0; 
     69cBinLog=""; 
     70cPosition=""; 
     71eval `/usr/bin/ssh -p $cSSHPort $2 "echo 'SHOW MASTER STATUS' | mysql -p$1 | grep mysql_binary_log" | awk '{printf"cBinLog=%s\ncPosition=%s\n",$1,$2}'`; 
     72while ( [ "$cBinLog" == "" ] || [ "$cPosition" == "" ] ) && [ $iCounter -lt $iTimeoutSecs ];do 
     73        let iCounter=iCounter+1; 
     74        cBinLog=""; 
     75        cPosition=""; 
     76        sleep 1; 
     77        #fLog "retrying get master data $iCounter/$iTimeoutSecs"; 
     78        eval `/usr/bin/ssh -p $cSSHPort $2 "echo 'SHOW MASTER STATUS' | mysql -p$1 | grep mysql_binary_log" | awk '{printf"cBinLog=%s\ncPosition=%s\n",$1,$2}'`; 
     79done 
     80if [ $iCounter -eq "$iTimeoutSecs" ];then 
     81        fLog "remote get master data timeout $iCounter/$iTimeoutSecs"; 
     82        #exit 2; 
     83fi 
     84 
     85#fLog "debug exit $iCounter/$iTimeoutSecs cBinLog=$cBinLog cPosition=$cPosition"; 
     86#exit 0; 
     87 
    5288#master is up, get master status and parse master status. 
     89cBinLog=""; 
     90cPosition=""; 
    5391eval `/usr/bin/ssh -p $cSSHPort $2 "echo 'SHOW MASTER STATUS' | mysql -p$1 | grep mysql_binary_log" | awk '{printf"cBinLog=%s\ncPosition=%s\n",$1,$2}'`; 
    5492if [ $? == 0 ]  && [ "$cBinLog" != "" ] && [ "$cPosition" != "" ];then 
     
    62100 
    63101        #SQL "change master to" parsed data on local slave MySQL server. 
    64         fLog "cBinLog=$cBinLog cPosition=$cPosition"; 
    65102        echo "CHANGE MASTER TO MASTER_LOG_FILE='$cBinLog',MASTER_LOG_POS=$cPosition" | mysql -p$1 > /dev/null 2>&1; 
    66103        if [ $? != 0 ];then 
     
    68105                exit 5; 
    69106        fi 
     107        fLog "change master ok cBinLog=$cBinLog cPosition=$cPosition"; 
    70108 
    71109        #start slave 
     
    87125                exit 7; 
    88126        fi 
    89         fLog "iSecondsBehindMaster=$iSecondsBehindMaster"; 
     127        #fLog "iSecondsBehindMaster=$iSecondsBehindMaster"; 
    90128        iCounter=0; 
    91129        while [ $iCounter -lt "$iTimeoutSecs" ] && [ $iSecondsBehindMaster -gt "0" ];do 
     
    100138                        exit 9; 
    101139                fi 
    102                 #double the timeout for long catch-up 
    103                 sleep 2; 
     140                sleep 1; 
    104141        done 
    105142        if [ $iCounter -eq "$iTimeoutSecs" ];then