Steps to build MySQL master-slave cluster

Source: Internet
Author: User


The prerequisite is that 4 MySQL databases need to be installed on Linux and the corresponding information needs to be configured.                 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:            MY.CNF on the master server edit               binary file format: Lo g-bin=mysql-bin;            binary format: binlog-format=mixed second step:        & nbsp On the slave server: There are several servers that need to be configured:          binary logs: each from the server configured in  MY.CNF           Binary log:  relay-log=mysql-relay          Comment: Configuration   on each my.cnf from the database:    the third step nbsp     Configure Server-id on the primary server this is unique for each server-id and cannot be duplicated. Typically the number of IP addresses behind each host           main: server-id=166           from: server-id= 167  ,server-id=168,server-id=169,   Fourth step:          If there is a problem connecting to the database:          You can use the following commands:           /USR/LIBEXEC/MYSQLLD  --skip-grant-ta bles          Log in to the MySQL database separately.           ./mySQL  -h  192.168.1.166  -uroot-p  -P 3306 (port number)   Fifth step:          Enter the main database interface:   Authorize, set up an account to connect from the database to use,          in the main database interface: Mysql> Grant replication Client,repliaction Slave on * * to   ' xxxx ' @ ' 192.168.%.% '   identified by ' xxxxx '           for analysis of this authorized account:   First First authorize the application to the database, set up an account to connect from the database, you need to set the user name, password, and ip          authorization, you need to view the primary database status on the primary database:         mysql>  show Master  status;  Sixth step:          to connect to the primary database from the database Established accounts:            Enter each from the database interface:           mysql>  change Master to                        master_host = ' 192.xxxx . xxx.xxx ',                       master_port = ' 3306 ',  & nbsp         &NBSP          master_user = ' xxxxx ',                  &NB Sp    master_password = ' xxxxxxx ',                      &NBS P;master_log_file = ' msyql-bin.000001 ',                        Master_log_pos = 975;                           Master_log_file   and  master_log_pos need to be changed based on the state that is viewed on the primary database.
After you run the above command, then perform a view of the status from the data: mysql> show slave status \g; You can see the connection details: If not, you can mysql> reset slave;                mysql> Stop SLAVW;   Then continue to run the link information just now. The seventh step: detection of the cluster master-slave database just set up, in the desktop of the client to test, on the main database to establish a test database, insert test database inside, look at the building from the database is displayed on the main database of the test library. If there is, the successful completion of the master-slave database cluster.

Steps to build MySQL master-slave cluster

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.