Mysql Master Slave Config, mysqlslave

Source: Internet
Author: User

Mysql Master Slave Config, mysqlslave

Install two or more MySQL services on the same machine:

Download the mysql installation package. After the installation is complete, copy multiple copies of the installation folder on the disk. Enter my. ini modify port (port cannot conflict), server_id, basedir (optional), datadir (data file path) and other parameters;

# Path to the database root
Datadir = "D:/MySQL Server 5.7/data /"

# General and Slow logging.
Log-output = FILE
General-log = 1
General_log_file = "VIPSH-20140721I.log"
Slow-query-log = 1
Slow_query_log_file = "VIPSH-20140721I-slow.log"
Long_query_time = 2

# Binary Logging.
# Log-bin
Server_id = 54
Log_bin = D:/MySQL Server 5.7/data/EricSun-mysql-bin.log
Log_bin_index = D:/MySQL Server 5.7/data/EricSun-mysql-bin.index
Max_binlog_size = 256 M
Expire_logs_days = 30

#===== Slave server needs to be configured ====
Relay_log = EricSun-mysql-relay-bin
Log_slave_updates = 1
Read_only = 1


# Error Logging.
Log-error = "VIPSH-20140721I.err"

Note: You must delete auto when copying and installing folders. cnf. Otherwise, The following error occurs when starting slave: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UIDs must be different for replication to work.

After the preceding steps, run the cmd command to install the windows service: mysqld -- install MySQLXY -- defaults-file = "C: \ Program Files \ MySQL Server X.Y \ my. ini"

After the installation is successful, start different mysql services;

Log on to different mysql instances, enter show master status \ G, view master server status, enter show slave status \ G, and view slave server status;

Then, from the server CMD window, set: change master to master_host = 'localhost', master_user = 'root', master_password = 'root', master_log_file = 'mysql-bin.000001 ', master_log_pos = '0 ';

Then enter show slave status \ G again; To View

Slave_IO_Running: Yes
Slave_ SQL _Running: Yes

The background thread runs YES.

CRUD is performed on the master database, and the slave database is updated.


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.