1. Modify the MySQL configuration file for the master server
Vi/etc/my.cnf
[mysqld] Log // server-id=1//
Pagoda-installed MySQL By default this is the one you don't have to change.
Then create an accessible user to access from the server
GRANT all on * * to [email protected]'%'123456'
View current master server information MySQL
2. Start configuration from server
vim/etc/my.cnf[mysqld] Server-id=2
Then log in to MySQL
Mysql>change Master to master_host='114.215.186.197', master_user= ' User '
Master_password= ' 123456 ', master_log_file=' file ' of the master server, ----- This is mysql-bin.000005.
Master_log_pos= position of the primary server; -----me, this is 577.
Turn on Sync
View synchronization Status
Two are all yes is successful, if there is a connecting that is the wrong password, or password did not take
Plus the configuration of Yii read-write separation
'DB'= [ 'class'='yii\db\connection', //Configuring the primary server 'DSN'='Mysql:host=118.25.108.136;dbname=yii_book', 'username'='User', 'Password'='123456', 'CharSet'='UTF8', //Configure the slave server 'Slaveconfig'= [ 'username'='User', 'Password'='123456', 'attributes'= [ //Use a smaller connection timeoutPdo::attr_timeout =Ten, ], 'CharSet'='UTF8', ], //Configure the From server group 'Slaves'= [ ['DSN'='Mysql:host=116.196.83.132;dbname=yii_book'], ], ],
Mysql Master-Slave configuration