Mysql Master/Slave Database Configuration

Source: Internet
Author: User

First, set the MySQL master server:

Create a user for the slave server on the master server:

1. grant replication slave on *. * to 192.168.0.1 identified by '2013 ';

# Use this file later than 4.1.

# Grant file on *. * to 192.168.0.1 identified by '123 ';

# Later, I added the super and client save permissions. You can skip this operation and try again.

Configuration File:/etc/my. cnf

2. on the master server

Server-id = 1

Log-bin

Binlog-do-db = Name of the database to be backed up. If multiple databases are backed up, set this option again.

Binlog-ignore-db = databases that do not need to be backed up suffer. If multiple databases are backed up, set this option again.

3. slave server

Log-bin

Server-id = 2

Master-host = host

Master-user = user Name

Master-password = password

Master-port = port

Replicate-do-db = Name of the database to be backed up. If multiple databases are backed up, set this option again.

++ ++ ++

It's just as simple as the above configuration.

Commands on the master server:

Show master status
Show slave hosts
Show logs
Show binlog events
Purge logs to 'Log _ name'
Purge logs before 'date'
Reset master (earlier version of flush master)
Set SQL _log_bin =

Commands on the slave server:

Slave start
Slave stop
Slave stop IO_THREAD // This thread writes logs of the master segment to the local
SLAVE start IO_THREAD
Slave stop SQL _THREAD // This thread applies logs written locally 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)
Change master to MASTER_HOST =, MASTER_PORT =, MASTER_USER =, MASTER_PASSWORD = // dynamically CHANGE master information
Purge master [before 'date'] deletes logs that have been synchronized from the master.
  
#

After that:

During the experiment, we backed up a database that has been running for a long time and has two problems.

1. The configuration files of the two databases are different.

The font is still different.

2. Inconsistency of database files, which was generated in subsequent operations. Therefore, no matter how important the master server is, when the slave server is to be a slave server, make sure that the master server

Stop. copy the file to the slave server.

It is helpful to take a look at the mysql Log Files.

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.