MySQL cluster explanation (iv) One master more from the environment to build

Source: Internet
Author: User

MySQL cluster tutorial (iv)

A master more from the environment to build:

A: Environment configuration (#号后内容记得删除)

Configuring the master-slave MySQL profile my.cnf

Main (3307) join

Log-bin=mysql-bin #表示启用二进制日志

server-id=3307 #表示server编号, the number must be unique

Add from (3308)

server-id=3308 #表示server编号, the number must be unique

Add from (3309)

server-id=3309 #表示server编号, the number must be unique

Add from (3310)

server-id=3310 #表示server编号, the number must be unique

This is the 3307 database as the main

The file is as follows:

[Client]

Port = 3307

Socket =/usr/local/mysql-5.7.18/data/3307/mysql.sock

Default-character-set=utf8

[Mysqld]

Port = 3307

Socket =/usr/local/mysql-5.7.18/data/3307/mysql.sock

DataDir =/usr/local/mysql-5.7.18/data/3307

Log-error =/usr/local/mysql-5.7.18/data/3307/error.log

Pid-file =/usr/local/mysql-5.7.18/data/3307/mysql.pid

Character-set-server=utf8

Lower_case_table_names=1

Autocommit = 1

# # # Master Slave # # #

Log-bin=mysql-bin

server-id=3307

The remaining 3308 3309 3310 as from the configuration is similar to the following

[Client]

Port = 3308

Socket =/usr/local/mysql-5.7.18/data/3308/mysql.sock

Default-character-set=utf8

[Mysqld]

Port = 3308

Socket =/usr/local/mysql-5.7.18/data/3308/mysql.sock

DataDir =/usr/local/mysql-5.7.18/data/3308

Log-error =/usr/local/mysql-5.7.18/data/3308/error.log

Pid-file =/usr/local/mysql-5.7.18/data/3308/mysql.pid

Character-set-server=utf8

Lower_case_table_names=1

Autocommit = 1

server-id=3308

B: Service startup:

Go to the/usr/local/mysql-5.7.18/bin directory, restart the four MySQL service, and start with the specified configuration file:

./mysqld_safe--DEFAULTS-FILE=/USR/LOCAL/MYSQL-5.7.18/DATA/3307/MY.CNF &

./mysqld_safe--DEFAULTS-FILE=/USR/LOCAL/MYSQL-5.7.18/DATA/3308/MY.CNF &

./mysqld_safe--DEFAULTS-FILE=/USR/LOCAL/MYSQL-5.7.18/DATA/3309/MY.CNF &

./mysqld_safe--DEFAULTS-FILE=/USR/LOCAL/MYSQL-5.7.18/DATA/3310/MY.CNF &

C: Set the master-slave relationship:

1. Create an account with replication data on the primary server and authorize:

Grant Replication Slave on * * to ' copy ' @ ' percent ' identified by ' 123456 ';

2, it is recommended to reset the main service status, execute the command: RESET master;

3, execute the command on the primary server, get the primary server binary Binlog coordinates (binary file name and coordinate value will be used later):

Show master status;

To execute commands from the server, set the master from the server

4, (do not underestimate these two commands if the intermediate configuration error can be cleared with this command configuration)

Recommended configuration when executed:

Stop slave;

Reset slave;

5, (port number with their own: If the configuration error, perform 4 operations)

Change Master to master_host= ' 192.168.91.135 ', master_user= ' copy ',

Master_port=3307,master_password= ' 123456 ',

Master_log_file= ' mysql-bin.000001 ', master_log_pos=154;

6, start slave; Start action

D: Master-Slave verification:

Check the status of the replication feature from the server

Mysql> Show Slave status \g

Slave_io_running and slave_sql_running Yes, that's the normal state.

Create a database, table, data on the primary server, and then see if it has replicated on the server

The above operation procedure shows normal, the master-slave server configuration is complete;

MySQL cluster explanation (iv) One master more from the environment to build

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.