This article mainly tells you how to install and configure the log of MySQL5 master slave. First, we will start from the background of the installation and configuration log of MySQL5 master slave, the following describes the main content of the article.
MySQL5 master slave installation configuration log Background:
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
# Databases 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 '123';
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
In the MySQL5 master slave installation configuration log, because the data in the relay log is faulty
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
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
The above content is an introduction to the MySQL5 master slave installation configuration log. I hope you will get something.