discuz 配置讀寫分離(主寫從讀)

爛筆頭.發表於2019-04-22

修改配置檔案: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_';


 

相關文章