Last active
April 8, 2018 07:30
-
-
Save zdev0x/0cc95b459e4a8df7873434b6ab5c6af3 to your computer and use it in GitHub Desktop.
[Yii2 Database Master Slaves Config] #yii2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # filename: common/main-local.php | |
| components => [ | |
| /** | |
| * Master | |
| */ | |
| 'db' => [ | |
| 'class' => 'yii\db\Connection', | |
| 'charset' => 'utf8', | |
| 'dsn' => 'mysql:host=master.db.dev;dbname=yii2db', | |
| 'username' => 'yii2db', | |
| 'password' => 'yii2db', | |
| 'slaveConfig' => [ | |
| 'username' => "yii2db_slave", | |
| "password" => "yii2db_slave_pwd", | |
| "attributes" => [ | |
| PDO::ATTR_TIMEOUT => 10, | |
| ] | |
| ], | |
| /** | |
| * Slaves | |
| */ | |
| 'slaves' => [ | |
| ['dsn' => 'mysql:host=slave1.db.dev;dbname=yii2db'], | |
| ['dsn' => 'mysql:host=slave2.db.dev;dbname=yii2db'], | |
| ['dsn' => 'mysql:host=slave3.db.dev;dbname=yii2db'], | |
| ], | |
| ], | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment