MySQL5 master slave installation and configuration process

Source: Internet
Author: User

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)

 
 
  1. binlog_do_db = test 

And make sure that

 
 
  1. Server-id = 1
  2. Log-bin = MySQL (the best combination with PHP)-bin
  3. Step 2) authorize slave
  4. 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

 
 
  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.

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

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

Related Article

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.