MySQL5 master slave installation and configuration log is simple

Source: Internet
Author: User

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

 
 
  1. 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

 
 
  1. server-id = 2 
  2. master-host = 192.168.100.231  
  3. master-user = test 
  4. 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.

 
 
  1. 070307 16:30:27 [ERROR] Slave: Error 'table' passport.
  2. Loginuser 'doesn' t exist 'on query. Default database: 'passport '.
  3. Query: 'delete from loginuser where tokenRefreshTime <= '2017-07-03 07:00:00 '', Error_code: 2006
  4. 070307 16:30:27 [ERROR] Error running query,
  5. Slave SQL thread aborted. Fix the problem,
  6. And restart the slave SQL thread with "SLAVE START ".
  7. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.