We will introduce the actual installation and configuration of MySQL5 master slave to you today. In the following background, we will install and configure the MySQL5 master slave, the following is an introduction to the specific content of the article. I hope you will gain some benefits after browsing it.
Master: 192.168.100.231 MySQL (best combination with PHP) 5.0.19 linux
Slave: 192.168.100.234 MySQL (best combination with PHP) 5.0.18 linux
Step 1) configure the master
Add in/etc/init. d MySQL (the best combination with PHP) Section d
Database to be synchronized)
- binlog_do_db = test
And make sure that
- Server-id = 1
- Log-bin = MySQL (the best combination with PHP)-bin
- Step 2) authorize slave
- Grant replication slave on *. * TO test@192.168.100.234 identified by '2013 ';
Restart master
Step 3) Configure slave
Vi/etc/my. cnf
Set the following four lines
- server-id = 2
- master-host = 192.168.100.231
- master-user = test
- master-password = 123
Restart to find that the slave I/O thread works normally, but the SQL thread does not work
A strange error was reported.
070307 16:30:27 [ERROR] Slave: Error 'table' passport. loginuser 'doesn' t exist 'on query. default database: 'passport '. query: 'delete from loginuser where tokenRefreshTime <= '2017-07-03 07:00:00 '', Error_code: 2006
070307 16:30:27 [ERROR] Error running query, slave SQL thread aborted. fix the problem, and restart the slave SQL thread with "SLAVE START ". we stopped at log 'mysql (the best combination with PHP)-bin.000001 'position 98
Because there is a problem with the data in the relay log
Copy the data on the master machine to 244 and find that there is still a problem.
Therefore, add/etc/my. cnf
- replicate-do-db=test
In the MySQL5 master slave installation configuration log, restart slave,
Show slave status found that two threads are working normally
5) test
A record is added to the user table of the master test data.
Then, you can use show processlist on slave to check whether slave works normally,
Check the slave Error Log if the database data is not updated.
070307 16:45:16 [ERROR] Slave: Error 'can't create database 'test'; database exists 'on query. default database: 'test '. query: 'create database test', Error_code: 1007
070307 16:45:16 [ERROR] Error running query, slave SQL thread aborted. fix the problem, and restart the slave SQL thread with "SLAVE START ". we stopped at log 'mysql (the best combination with PHP)-bin.000040' position 70671
It turns out that I copied the data at the beginning, because the host logs started when I created the database, so I copied more data, so
I deleted the copied database. Everything is OK.
The above content is an introduction to the MySQL5 master slave installation configuration log. I hope you will get something.