Thursday, March 19, 2009

Using Perl Script for memory calculation of NDB Cluster in Fedora 9

Step 1: Check that you have perl

get the perl DBI module installed by using,

yum install perl-DBD-MySQL

step 2: cd into $MYSQL_HOME(or mysql base directory usually /usr/local/mysql and try

./bin/ndb_size.pl --database=myDb --user=myUser --socket=/tmp/mysql.sock --password=password

If this fails with the error like Can't use string ("9/16") as a HASH ref while "strict refs" ..... then you need to get fix the bug by replacing the following peice of code,

current code, in release ..it starts from line number 920


foreach my $i(@show_indexes)
{
$indexes{${%$i}{Key_name}}= {
type=>${%$i}{Index_type},
unique=>!${%$i}{Non_unique},
comment=>${%$i}{Comment},
} if !defined($indexes{${%$i}{Key_name}});
$indexes{${%$i}{Key_name}}{columns}[${%$i}{Seq_in_index}-1]=
${%$i}{Column_name};
}


need to be replaced as follows,

foreach my $i(@show_indexes)
{
$indexes{$i->{Key_name}}= {
type=>$i->{Index_type},
unique=>$i->{Non_unique},
comment=>$i->{Comment},
} if !defined($indexes{$i->{Key_name}});

$indexes{$i->{Key_name}}{columns}[$i->{Seq_in_index}-1]=
$i->{Column_name};
}


then executing,

./bin/ndb_size.pl --database=myDb --user=myUser --socket=/tmp/mysql.sock --password=password

should get the output for you.