Quick add from library for MySQL and add from library for library

Source: Internet
Author: User

In reality, MySQL is more common is a master multi-slave, and in the main library The problem is that it needs to be raised from the library to the main library, but in fact this operation is very cumbersome, basically to all from the library operation.

In that case, you might want to make MySQL the structure of ABC, a master library, B is a from the library, C is a b from the library

In this case, the problem with a is that you can direct B-liter to the main library, and the rest of the subordinates will not need any action from the library.

Here is a record of this kind of operation, I here is the case, already exists a and b,a is the main, B is from

The requirement is to add a from library C, and then add a C from the library d.


Quickly add MySQL from the library (provided the same version of MySQL is already installed)

First, the master-slave stop from library B is dropped

mysql> stop slave; Query ok, 0 rows affected (0.06 sec)  mysql> show slave status\g ;*************************** 1. row ***************************                Slave_IO_State:                   master_host: 10.10.1.171                    master_user: mysqlab                   Master_Port: 3306                 Connect_Retry: 60               Master_Log_File: mysql-bin.000096          Read_Master_Log_Pos: 585421644                Relay_Log_File: mysql-relay-bin.000279                 Relay_Log_Pos: 2043143         Relay_Master_Log_File: mysql-bin.000096              Slave_IO_Running: No             slave_sql_running: no


then, from the library B The data files are packaged and copied to the new slave library separately . C and the C from the library D (sock and PID files are not packaged)

Synctar-czf mysqldata3326.tar.gz mysqldata3326/scp mysqldata3326.tar.gz 10.10.1.173:/home/scp mysqldata3326.tar.gz 10.10.1.174:/home/


The decompression is placed in C and the D Data Directory (delete master-slave information file)

Cd/hometar ZXF Mysqldata3326.tar.gzmv/home/mysqldata3326/datadir/master.info/home/mysqldata3326/datadir/master.info.bak


modify c and d Span style= "FONT-SIZE:10.5PT;" > config file Server-id c 11,    D 21, (I have a port difference here, this is based on the reality)

Vim/home/mysqldata3326/my.cnf


Start separately C and the D

/usr/local/mysql/bin/mysqld_safe--defaults-file=/home/mysqldata3326/my.cnf--user=mysql &


Configuration C and the D master and slave (be sure to configure the master and slave of C and D first)

C : View the master information for C

mysql> show master status;+------------------+--------- -+--------------+---------------------------------------------+| file              | position | binlog_do_db | binlog_ignore_ db                             |+------------------+----------+--------------+--- ------------------------------------------+| mysql-bin.000092 |  1953402 |               | mysql,test,information_ schema,sphinx_search |+------------------+----------+--------------+------------------------------------- --------+

D : Configure master/slave information for D

mysql> slave stop;mysql> reset slave;mysql> change master to  Master_host= ' 10.10.1.173 ', master_user= ' Mysqlab ', master_password= ' xxxxx ', master_log_file= ' mysql-bin.000092 ', master_log_pos=1953402;mysql> slave start;mysql> show slave status\g;**********  1. row ***************************                Slave_IO_State:                   Master_Host: 10.10.1.173                   master_user:  mysqlab                   Master_Port: 3326                 conneCt_retry: 60              master_ Log_file: mysql-bin.000092          read_master_log_pos :  1953490               relay_ log_file: mysql-relay-bin.000279                 relay_log_pos: 214513        relay_master _log_file: mysql-bin.000092              Slave_io_running: yes            slave_sql_ Running: yes


Modify C The main library synchronization information ( where the master and slave information is consistent with stop B information from the library)

mysql> slave stop;mysql> Reset slave;mysql> change master to master_host= ' 10.10.1.171 ', master_user= ' Mysqlab ', Master_password= ' xxxxxx ', master_log_file= ' mysql-bin.000096 ',master_log_pos=585421644;mysql> slave start;


Finally start B's master and slave! Complete


Verify:

Through show slave status\g; view master and slave messages, whether SQL and IO threads are Yes

The simplest validation is to create a library in a and show if D is in sync.

This article is from the "Tuesday" blog, make sure to keep this source http://cuimk.blog.51cto.com/6649029/1590205

Quick add from library for MySQL and add from library for library

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.