Simple implementation of MySQL master-slave replication technology

Source: Internet
Author: User
Tags mysql version

Configure the Environment:

The master-Slave server operating system is ubuntu15.10

MySQL version of master-slave server is MySQL5.6.31

Primary server ip:192.168.0.178

From server ip:192.168.0.145

The master-slave server is able to ping each other.

Note: The master-slave server and the database version can be different, but the current database in the master-slave server is best consistent, or there may be some errors later due to database inconsistency.

Primary server configuration:

1, enable the binary log, set the server unique ID;

2, modify/etc/mysql/my.cnf "bind-address = 0.0.0.0;" allows MySQL to allow remote connection;

3, enter the terminal, for the user backend give REPLICATION SLAVE permissions, and then execute "flush privileges;" Refresh permissions; (I already have this user here, no one should create a user first and give REPLICATION SLAVE permissions) The user is used to connect to the master server database from the server.

4. Restart mysql and enter MySQL terminal to perform "show Master status;" View mater status;

5. Record the value of file and position because it is used when configuring from the server. Do not move the main database at this time, so as not to affect the value of position.

From the server configuration:

1, like the main service to configure the Enable binary log, set the server unique ID; (master server server-id=1, server-id=2 from the server)

2. Restart mysql and enter MySQL terminal;

3. Execute the following statement and start slave from the library:

Note: The master_host here is to set the primary server Ip,master_user is the user to set up the connection to the master server database, Master_password is the user's password, master_log_file and Master_log_ The files and values that are recorded when the POS sets the master server;

4, perform "show slave status;\g" View slave from the library status:

If both slave_io_running and slave_sql_running are yes, then the master-slave configuration is successful.

5, to the main database to create a database "create databases Test_master_slave;"

6, to execute from the server "show databases;" The discovery also created the database test_master_slave;

Simple implementation of MySQL master-slave replication technology

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.