kirillsablin / doctrine-failover
There is no license information available for the latest version (dev-master) of this package.
Doctrine mysql master-master failover with automatic failback
dev-master
2014-09-30 15:51 UTC
Requires
- php: >=5.3.0
- doctrine/dbal: 2.3.3
Requires (Dev)
- behat/behat: 2.4.*@stable
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2025-08-25 19:14:37 UTC
README
Doctrine mysql master-master failover with automatic failback
Installation
At this moment only table based heartbeat strategy implemented (checking if replication is online)
-
Create heartbeat table at both masters Example SQL:
CREATE TABLE `heartbeat` ( `value` varchar(255) DEFAULT NULL, KEY `value` (`value`) )
-
If you use composer add to your composer.json
"require": { .... "kirillsablin/doctrine-failover": "dev-master" .... }
2a) If you don't use composer copy add contents of src folder to you project and setup autoload if necessary
- Add necessary configuration to to your Doctrine's config
Doctrine configuration example
$config = array( 'driver' => 'pdo_mysql', 'host' => '192.168.0.1', 'port' => '3306', // optional 'reserveHost' => '192.168.0.1', // mandatory 'reservePort' => '3308', // optional 'user' => 'username', // if you need different username or password for reserve host use reserveUser and reservePassword 'password' => "password", 'dbname' => "test", 'heartbeatTable' => 'heartbeat', // default value is 'heartbeat' 'heartbeatTableColumn' => 'value', // default value is 'value' 'dontRetryPeriod' => '600', // period between retries to failback to main host 'wrapperClass' => '\DoctrineExtensions\DBAL\Connections\MasterMasterFailoverConnection', // mandatory 'failoverStatusCacheImpl' => new \Doctrine\Common\Cache\ApcCache() // mandatory, should be instance of \Doctrine\Common\Cache );
Failover-specific events
Two new event's types were added 'onFailover', 'onFailback'.