<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<title>Re: [hobbit] MySQL Replicaiton Script</title>
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Lucida Grande";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Much apperciated :)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Nicolas
[mailto:nico@crysto.org] <br>
<b>Sent:</b> Wednesday, May 26, 2010 10:43 AM<br>
<b>To:</b> hobbit@hswn.dk<br>
<b>Subject:</b> Re: [hobbit] MySQL Replicaiton Script<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Lucida Grande","serif"'><br>
Hi,<br>
<br>
We use this one:<br>
<br>
<br>
<br>
------------<br>
<br>
#!/bin/bash <br>
<br>
<br>
############################################################################################<br>
test -e /usr/local/mysql/bin/mysql && PROG=/usr/local/mysql/bin/mysql<br>
test -e /usr/bin/mysql && PROG=/usr/bin/mysql<br>
MAXDRIFT=5<br>
############################################################################################<br>
<br>
MYSQLCOLOR=""<br>
MYSQLLINE=""<br>
HOSTIP=127.0.0.1<br>
IPADDR=127.0.0.1<br>
MACHINE=`uname -n`<br>
<br>
MAXSEC=60<br>
<br>
MYSQLUSER=root<br>
MYSQLPORT=3306<br>
LINE=`echo "show slave status \G" | ${PROG} -h ${HOSTIP} -u ${MYSQLUSER}
-P ${MYSQLPORT} 2>&1`<br>
MASTERPOS=`echo $LINE | grep Read_Master_Log_Pos | awk -F 'Read_Master_Log_Pos:
' '{print $2}' | awk '{print $1}'`<br>
SLAVEPOS=`echo $LINE | grep -i Exec_Master_Log_Pos | awk -F
'Exec_Master_Log_Pos: ' '{print $2}' | awk '{print $1}'`<br>
SLAVEUP=`echo $LINE | grep Running | wc -l`<br>
SLAVE_SECOND_BEHIND_MASTER=`echo $LINE | grep 'Seconds_Behind_Master:'  |
awk -F 'Seconds_Behind_Master: ' '{print $2}'  | awk '{print $1}'` <br>
test $SLAVEUP -eq "1"  &&  DRIFT=$((${MASTERPOS} -
${SLAVEPOS}))<br>
echo "${LINE}" | ${GREP} "Running: No" >/dev/null<br>
if test "$?" -eq "0"<br>
then<br>
    MYSQLCOLOR="red"<br>
    MYSQLLINE="`${DATE}` MYSQL Slave in error<br>
${LINE}"<br>
elif test ${SLAVEUP} -ne "1"<br>
then<br>
    MYSQLCOLOR="green"<br>
    MYSQLLINE="`${DATE}` MYSQL Slave is Stopped<br>
${LINE}"<br>
elif test ${SLAVE_SECOND_BEHIND_MASTER} -ge ${MAXSEC} <br>
then<br>
    MYSQLCOLOR="yellow"<br>
    MYSQLLINE="`${DATE}` MYSQL Slave is ${DRIFT}
statements behind!<br>
${LINE}"<br>
else<br>
    MYSQLCOLOR="green"<br>
    MYSQLLINE="`${DATE}` MYSQL Slave is ${DRIFT}
statements behind!<br>
${LINE}"<br>
fi<br>
<br>
#echo "${BB} ${BBDISP} status ${MACHINE}.mysqlslave ${MYSQLCOLOR}
${MYSQLLINE}"<br>
${BB} ${BBDISP} "status ${MACHINE}.mysqlslave ${MYSQLCOLOR}
${MYSQLLINE}"<br>
<br>
-----------------<br>
<br>
To make it working, you need to create the file : ~hobbit/.my.cnf  <br>
<br>
[mysql]<br>
<br>
password=XXXXXXXX<br>
<br>
[mysqlclient]<br>
<br>
password= XXXXXXXX<br>
<br>
[mysqladmin]<br>
<br>
password= XXXXXXXX<br>
<br>
[mysqlshow]<br>
<br>
password= XXXXXXXX<br>
<br>
[mysqldump]<br>
<br>
password= XXXXXXXX<br>
<br>
<br>
chown hobbit: ~hobbit/.my.cnf<br>
chmod 600 ~hobbit/.my.cnf<br>
<br>
<br>
Add the section in clientlaunch.cfg<br>
<br>
[mysqlslave]<br>
        ENVFILE
$HOBBITCLIENTHOME/etc/hobbitclient.cfg<br>
        CMD
$HOBBITCLIENTHOME/ext/mysqlslave.sh<br>
        LOGFILE
$HOBBITCLIENTHOME/logs/mysqlslave.log<br>
        INTERVAL 5m<br>
<br>
<br>
Restart hobbit-client.<br>
<br>
Cheers,<br>
Nico<br>
<br>
<br>
On 26/05/10 19:12, "Domnick Eger" <deger@cobercafe.net> wrote:</span><o:p></o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Lucida Grande","serif"'>Just wanted to see if anyone had a working
copy of the MySQL replication script that they would be willing to share ?</span><o:p></o:p></p>

</div>

</body>

</html>