kirillsablin / doctrine-failover
此包的最新版本(dev-master)没有可用的许可证信息。
Doctrine mysql 主主故障转移及自动恢复
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: 2024-09-23 14:38:59 UTC
README
Doctrine mysql 主主故障转移及自动恢复
安装
目前仅实现了基于表的 heartbeat 策略(检查复制是否在线)
-
在两个主节点上创建 heartbeat 表 示例 SQL
CREATE TABLE `heartbeat` ( `value` varchar(255) DEFAULT NULL, KEY `value` (`value`) )
-
如果你使用 composer,请将其添加到你的 composer.json 中
"require": { .... "kirillsablin/doctrine-failover": "dev-master" .... }
2a) 如果你没有使用 composer,请将 src 文件夹的内容复制到你的项目中,并在必要时设置自动加载
- 将必要的配置添加到你的 Doctrine 配置中
Doctrine 配置示例
$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 );
故障转移特定事件
增加了两种新事件类型:'onFailover','onFailback'。