Read and write separation of MySQL database

Source: Internet
Author: User

A familiarity with MySQL read-write separation and MySQL storage engine differences.

  1. NDB cluster storage engine ,MyISAM,InnoDB

  2. Myisam is the default storage engine after installation of MySQL, does not support The functions of transaction, row-level and foreign key constraints;NDB is a mysql cluster storage engine with InnoDB supports things, row-level locks, and foreign key constraints. Use show engines; View the storage engine supported by MySQL.

  3. Read/write Separation:

I. Environment:

    1. Application Client

    2. Database Proxy

    3. Database Cluster (two + mysql machines)

Ii. Build Master and slave:

    1. install MySQL;

    2. Configure the my.cnf for master:

Log-bin=mysql-bin

Server-id=1

To add a user dedicated to synchronization:

GRAND REPLICATION SLAVE on * * [email protected] identifiefd by ' password ';

Restart MySQL to make the configuration effective;

last view mysql status:Show Master status;

Configure the slave my.cnf:

server-id=2

after the configuration takes effect, the configuration and Master The connection:

Mysql> Change MASTER to
Master_host= ' 10.20.147.110 ',
Master_user= ' Repl ',
-master_password= ' 111111 ',
Master_log_file= ' mysql-bin.000003 ',
master_log_pos=161261;

whichMaster_hostis aMasterMachine'sIP,Master_userand theMaster_passwordis that we were justMasteradded on the user,Master_log_fileand theMaster_log_posCorrespondence andMasterstatusthe information in

Last Launch slave :

Mysql>start slave;

4 ) Validation Master-slave Construction takes effect

by viewing slave Machine's Log ( /var/log/mysqld.log ):

10070310:51:42 [Note] Slave I/O thread:connected to master ' [email protected]:3306 ', replication started in log ' Mysql-bi N.000003 ' at position 161261

If you see the above information proves the success of the building, if there are problems can also be through this Log Find out why


Read and write separation of MySQL database

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.