discuz 配置读写分离(主写从读)

修改配置文件:config/config_global.php

$_config = array();

// ----------------------------  CONFIG DB  ----------------------------- //
//主库的连接信息
$_config['db']['1']['dbhost'] = 'localhost';
$_config['db']['1']['dbuser'] = 'root';
$_config['db']['1']['dbpw'] = 'password';
$_config['db']['1']['dbcharset'] = 'utf8';
$_config['db']['1']['pconnect'] = '0';
$_config['db']['1']['dbname'] = 'bbs';
$_config['db']['1']['tablepre'] = 'bbs_';
//$_config['db']['slave'] = '';
//$_config['db']['common']['slave_except_table'] = '';


$_config['db']['slave'] = true; //开启从服务器
$_config['db']['1']['slave'] = array();
$_config['db']['1']['slave']['1']['dbhost'] = '192.168.1.25';  //mysql 从库的host
$_config['db']['1']['slave']['1']['dbuser'] = 'root';   //mysql 从库的数据库用户名
$_config['db']['1']['slave']['1']['dbpw'] = 'password';    //mysql 从库的数据库密码
$_config['db']['1']['slave']['1']['dbcharset'] = 'utf8';
$_config['db']['1']['slave']['1']['pconnect'] = '0';
$_config['db']['1']['slave']['1']['dbname'] = 'bbs'; //mysql从库的数据库名
$_config['db']['1']['slave']['1']['tablepre'] = 'bbs_';


 

你可能感兴趣的:(PHP)