微擎主從庫開啟,,在data/config.php設(shè)置的讀寫分離狀態(tài)主要代碼,,包含微擎開啟主從庫的設(shè)置,注意主從庫是2個(gè)數(shù)據(jù)庫,,不能同一個(gè)庫,。 $config['db']['master']['host'] = '127.0.0.1'; //主庫地址 $config['db']['master']['username'] = 'admin'; //用戶名 $config['db']['master']['password'] = '123456'; //密碼 $config['db']['master']['port'] = '3306'; //端口 $config['db']['master']['database'] = 'we7'; 數(shù)據(jù)庫名 $config['db']['master']['charset'] = 'utf8'; $config['db']['master']['pconnect'] = 0; $config['db']['master']['tablepre'] = 'ims_'; 從庫的開啟修改下面,地址需要從數(shù)據(jù)庫供應(yīng)商獲取,,不可把普通的數(shù)據(jù)庫用作從庫,,否則出現(xiàn)錯(cuò)誤。開啟微擎遠(yuǎn)程redis緩存 相關(guān)配置 $config['db']['slave_status'] = true; //從庫,,默認(rèn)false $config['db']['slave']['1']['host'] = '127.0.0.2'; //從庫地址 $config['db']['slave']['1']['username'] = 'admin'; //賬戶 $config['db']['slave']['1']['password'] = '234567'; //密碼 $config['db']['slave']['1']['port'] = '3307'; //端口 $config['db']['slave']['1']['database'] = 'we8'; //數(shù)據(jù)庫名 $config['db']['slave']['1']['charset'] = 'utf8'; $config['db']['slave']['1']['pconnect'] = 0; $config['db']['slave']['1']['tablepre'] = 'ims_'; $config['db']['slave']['1']['weight'] = 0; $config['db']['common']['slave_except_table'] = array('core_sessions'); 這樣就設(shè)置完成了,,注意2個(gè)地址一般是購買云庫使用,主庫寫入權(quán)限,,從庫讀取權(quán)限,。用戶緩解服務(wù)器的壓力,不可隨意搞個(gè)數(shù)據(jù)庫就開啟讀寫分離狀態(tài),,這樣是會(huì)出錯(cuò)的,。開啟微擎性能優(yōu)化redis 微擎memcache 本站內(nèi)容均為原創(chuàng),請(qǐng)注明出處:https:///dis/69.html |
|