Welcome Guest, Not a member yet? Register   Sign In
High Availability with Master / Master Mysql Setup
#1

[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

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


Messages In This Thread
High Availability with Master / Master Mysql Setup - by El Forum - 07-19-2011, 01:21 PM
High Availability with Master / Master Mysql Setup - by El Forum - 07-21-2011, 01:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB