Steps to build MySQL master-slave cluster

Source: Internet
Author: User


The prerequisite is that you need to install 4 MySQL databases on Linux, all of which need to be configured to complete the corresponding information.                 Need to build: MySQL 01: master database Master MySQL 02: from database slave01 mysql 03: From Database Slave02 MySQL 04: From the Database slave03The first step:Edit the binary file format on MY.CNF on the primary server: Log-bin=mysql-bin; Binary format: binlog-format=mixed The second step: on the slave server: There are several slave servers that need to be configured: Binary log: Each configuration binary day from server in MY.CNF LOG: Relay-log=mysql-relay gaze: In each my.cnf from the database need to configure the third step: Configure the Server-id on the primary server this Server-id is unique and cannot be repeated. Usually the number of IP addresses behind each host Master: server-id=166 from: server-id=167, server-id=168, server-id=169, fourth step: Assuming a connection has occurred The problem with the database: the ability to use the following command:/usr/libexec/mysqlld--skip-grant-tables log in to the MySQL database separately.

 

         ./mysql  -h  192.168.1.166  -uroot-p  -P 3306 (port number)   Fifth step: &NB Sp         access to the main database interface:   for authorization. Create an account and connect to it from the database.           in main database interface: mysql> grant replication client,repliaction slave on * * to   ' xxxx ' @ ' 19 2.168.%.% '   identified by ' xxxxx '           Analysis of this authorized account:   First authorize the application to the database, set up an account to connect from the database, You need to set Username,password. Also ip          Authorization to view the status of the primary database on the primary database:         mysql>  show Master  status;  Sixth step:          set up an account to connect to the main database from the database:          & nbsp; Enter each from the database interface:           mysql>  change master to       &nbs P                master_host = ' 192.xxxx.xxx.xxx ',                       master_port = '3306 ',                       master_user = ' xxxxx ',  &nbs P                    master_password = ' xxxxxxx ',      &NBS P                master_log_file = ' msyql-bin.000001 ',        &N Bsp              master_log_pos = 975;                          master_log_file   and  master_log_pos need to be changed based on the status viewed on the primary database.
After executing the above command, then perform a view of the status from the data: mysql> show slave status \g; Can see the specific information of the connection: if not, can mysql> reset slave;                mysql> Stop SLAVW; Then continue with the link information that you just made.

Seventh step: Detect the Cluster master-slave database that was just built can, in the desktop of the client to test, set up a test database on the main database, inserted in the test database. Look at the test-bed set up from the database to see if it appears on the main database. Assuming that there is a smooth completion of the master-slave database cluster.

Steps to build MySQL master-slave cluster

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.