Hi. I put this perl code in my application in order to switch automatically to the backup server if the primary server is down.
I found that the backup ip has been used many times even, if the primary was up and running
Can you evaluate this and let me know your ideas and/or experience in similar situations?
eval {
$db='DBI:mysql:database='.$db_name.';hostname='.$db_host;
my $dbh = DBI->connect($db,$db_user, $db_pass);
$dbh->disconnect;
};
if ($@) {
$db_host ="192.168.1.21";
...
I found that the backup ip has been used many times even, if the primary was up and running
Can you evaluate this and let me know your ideas and/or experience in similar situations?
Code:
eval {
$db='DBI:mysql:database='.$db_name.';hostname='.$db_host;
my $dbh = DBI->connect($db,$db_user, $db_pass);
$dbh->disconnect;
};
if ($@) {
$db_host ="192.168.1.21";
...