MySQL master-slave database configuration

Source: Internet
Author: User
Tags reset thread

First set up the MySQL master server:

To create a user from the server on the primary server:

1.grant replication Slave on *.* to 192.168.0.1 identified by ' 1234 ';

#4.1 with this, before you can use file.

#grant file on *.* to 192.168.0.1 identified by ' 1234 ';

#后来我又加了super和client Save permission, you can not add it first. and then try again.

Configuration file:/etc/my.cnf

2. On the primary server

Server-id = 1

Log-bin

binlog-do-db= the name of the database you want to back up, and if you back up multiple databases, repeat this option

binlog-ignore-db= database does not need to be backed up, if you back up multiple databases, repeat this option

3. From the server

Log-bin

server-id=2

Master-host= Host

master-user= User Name

master-password= Password

master-port= Port

replicate-do-db= the name of the database you want to back up, and if you back up multiple databases, repeat this option

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Just as simple as the above configuration is OK.

Related commands on the primary server:

Show Master Status
Show slave hosts
Show logs
Show Binlog Events
Purge logs to ' log_name '
Purge logs before ' date '
Reset Master (old version flush Master)
Set sql_log_bin=

Related commands from the server:

Slave start
Slave stop
SLAVE STOP io_thread//This thread writes the log of the master segment to the local
SLAVE Start Io_thread
SLAVE STOP sql_thread//This thread applies logs written to local to the database
SLAVE Start Sql_thread
Reset Slave
SET GLOBAL Sql_slave_skip_counter
Load data from Master
Show slave status (Super,replication CLIENT)
Changes master to master_host=, master_port=,master_user=, master_password=//dynamic Change master information
PURGE Master [before ' date '] Deletes a log that has been synchronized at the master end
  
#

Something:

To do the experiment is to a long running and very critical database backup, encountered two problems

1. The configuration files for two databases are different.

Even the font is not the same. No language ing

2. Database file inconsistency problem, which was generated later. So no matter how important the primary server is to do from the server when the master server must be

Stop, cuff the stuff to the server.

And then more to see the MySQL log file, very helpful

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.