MySQL from library cascade

Source: Internet
Author: User

MySQL from the library cascade this way is the MySQL from behind the library and then another from the library, this way can be used in the case of the main library can not be stopped, but also need more backup database, you can from the library after the next from the library. But the second system environment from the library needs to be exactly the same as the first one from the library's system environment.

Main Library master:10.10.10.139

from library salve1:10.10.10.133

from library salve2:10.10.10.136

actions configured on the Master Library Master

Vim/etc/my.cnf

Log-bin=mysql-bin

Server-id = 1

View database after starting MySQL service there are several libraries showdatabases

from the configuration on the library salve1

Vim/et c/my.cnf

Server-id = + (here the Server-id requirements are different from master )

Log-slave-updates=1 (This parameter must be added, log_slave_updates is to log updates received from the server from the primary server into the server's own binaries. )

from the configuration on the library salve2

Vim/etc/my.cnf

Log-bin=mysql-bin

Server-id = 200

The authorization action is then required to authorize REPLICATION permissions on Master , which allows slave1 to synchronize the data locally.

Grantreplication SLAVE on * * to ' SLAVE ' @ '% ' identified by ' 123456 '

% according to the actual work needs to add IP

You also need to authorize slave2 on the slave1.

Grantreplication SLAVE on * * to ' SLAVE ' @ '% ' identified by ' 123456 '

Configure slave1 connection to Master after authorization is complete

Show Master status on Master view The name of the Binglog file, the node is logged

On the slave1 .

Slave stop

Reset slave

Change Master to

Master_host= ' 10.10.10.139 ',

Master_user= ' slave ',

Master_password= ' 123456 ',

Master_log_file= ' mysql-bin.00000x ',

Master_log_pos=xxx

Slave start

Show Slavestatus to see If the status of the process is

Slave_io_running:yes

Slave_sql_running:yes

If you do not follow the error message to find the problem

when slave1 opens slave start show Master status view binglog file name, node record

login slave2 do and salve1 the same operation

Slave stop

Reset slave

Change Master to

master_host= ' 10.10.10.133 ', (Here's IP it needs to be written slave1 of)

Master_user= ' slave ',

Master_password= ' 123456 ',

Master_log_file= ' mysql-bin.00000x ',

Master_log_pos=xxx

Slave start

Test Whether the master-slave- slave mode is successful

Create a database, build a table in the library, and add data

CREATE DATABASE ' test2 '

CREATE TABLE ' t_table ' (

' Name ' char (DEFAULT NULL),

' Age ' int (one) DEFAULT NULL,

' Note ' varchar DEFAULT NULL

) Engine=myisamdefault Charset=latin1

Insert intot_table values (' Linda ', ' Beijing ');

Insert intot_table values (' Jerry ', ' Shanghai ');

log slave1, slave2 to see if the database is synchronized

If it is the actual production environment, it is best to lock the table first, in order to avoid data loss.


MySQL from library cascade

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.