我不需要故障转移连接方面的帮助,只是这个故障转移阵列可能有什么问题?我已经测试了备用数据库连接和工程伟大。问题是,当我关闭主设备时,故障转移并没有按它应该的方式连接。这是直接从代码点火器文档。有什么小技巧可以帮助你排除故障吗?
/*
* Mysql Driver
* /
$db['mysql']['hostname'] = getenv('DB_HOST');
$db['mysql']['username'] = getenv('DB_USERNAME');
$db['mysql']['password'] = getenv('DB_PASSWORD');
$db['mysql']['database'] = getenv('DB_DATABASE');
$db['mysql']['dbdriver'] = 'mysql';
$db['mysql']['dbprefix'] = '';
$db['mysql']['pconnect'] = FALSE;
$db['mysql']['db_debug'] = FALSE;
$db['mysql']['cache_on'] = FALSE;
$db['mysql']['cachedir'] = '';
$db['mysql']['char_set'] = 'utf8';
$db['mysql']['dbcollat'] = 'utf8_general_ci';
$db['mysql']['swap_pre'] = '';
$db['mysql']['autoinit'] = TRUE;
$db['mysql']['stricton'] = FALSE;
$db['mysql']['failover'] = array(
array(
'hostname' => getenv('DB_HOST2'),
'username' => getenv('DB_USERNAME2'),
'password' => getenv('DB_PASSWORD2'),
'database' => getenv('DB_DATABASE2'),
'dbdriver' => 'mysql',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE
)
);
1条答案
按热度按时间7gs2gvoe1#
必须设置默认连接,请尝试以下操作:
https://codeigniter.com/user_guide/database/configuration.html