当我们数据量增大时,数据库需要进行扩张时,或者做高可用,那么我们就需要用到同时多台mysql服务器。 通过配置:可以实现,一台主mysql,负责记录数据的变化,多台从mysql,查询结果。 修改文件:/www/configs/mysql_config.php 使用前提:已经做好数据主从同步。数据已经同步完成! <?phpdefined(‘IN_WZ‘) or exit(‘No direct script access allowed‘);return array ( ‘default‘ => array ( ‘dbhost‘ => ‘svn.phpip.com‘, ‘dbname‘ => ‘dev_wuzhicms‘, ‘username‘ => ‘dev_uesrs‘, ‘password‘ => ‘1111‘, ‘tablepre‘ => ‘wz_‘, ‘dbcharset‘ => ‘utf8‘, ‘type‘ => ‘mysqli‘, ‘pconnect‘ => 0, ‘slave_server‘ => array(‘default‘=>20,‘slave1‘=>30) ), ‘slave1‘ => array ( ‘dbhost‘ => ‘wuzhicms.com‘, ‘dbname‘ => ‘dev_wuzhicms‘, ‘username‘ => ‘aa‘, ‘password‘ => ‘bb‘, ‘tablepre‘ => ‘wz_‘, ‘dbcharset‘ => ‘utf8‘, ‘type‘ => ‘mysqli‘, ‘pconnect‘ => 0, ),)?>
时间: 2024-10-12 15:19:35