laravel多主多从配置示例
'mysql' => [ 'write' => [ [ 'host' => '192.168.1.180', 'username' => '', 'password' => '', ], ], 'read' => [ [ 'host' => '192.168.1.182', 'username' => '', 'password' => '', ], [ 'host' => '192.168.1.179', 'username' => '', 'password' => '', ], ], 'driver' => 'mysql', 'database' => 'database', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ]
验证
开启MySQL的general-log,通过tail -f的方式监控log变化来确定配置是否生效