• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
High Availability with Master / Master Mysql Setup

[eluser]Eric Brown[/eluser]
I'm trying to implement failover logic into my code. I'd like to get some opinions on how to best do this. Essentially all of my writes should go to "DB01" but if the connection is unavailable because the server crashed or it's under high load or there is a routing issue, I'd like the app to fail over to DB02. Here's what I have. Thanks for your comments and suggestions

//Load DB01 Master
            $this->db = $this->load->database('db01',TRUE);
                // verify DB01 master connected
                $this->db_connected == TRUE;
                // if not connected, fail over to second master
                // Load DB02 Master
                $this->db = $this->load->database('db02',TRUE);
                    $this->db_connected == TRUE;
                    // if not connected, no database connection available
                    $this->db_connected == FALSE;

Ironically, i looked through the forum before I posted my query, which is almost identical(!), and never saw your posting!

Looks a good idea ... and at first glance would work - your manually loading the database each time? Whats the thought for if the primary database fails after you've loaded but between queries?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.