Configure Mysql master-slave service implementation example

Configure Mysql master-slave service implementation example

Configure Mysql master-slave service implementation example

### Configure the main database my.cnf

server-id=1
log-bin=master-bin
log-bin-index=master-bin.index

### Create a synchronization account on the primary database

create user backup;
GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.%.%' IDENTIFIED BY 'mysql';

### Configure the slave database my.cnf

server-id=2
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin

### Restart mysql service

service mysqld restart

### Connect to the Master Service

change master to master_host='192.168.91.128',
master_port=3306,master_user='backup',master_password='mysql',
master_log_file='master-bin.000001',master_log_pos=0;

### Start the slave service

start slave;

### Check the Master service status

SHOW MASTER STATUS;

### Check the Slave service status

SHOW slave STATUS \G;

### Check if server_id is the same, it needs to be different

show variables like 'server_id';

Common Mistakes

Error: Fatal error : The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.

Solution: Check if server-uuid=******************** in auto.cnf in the data directory is the same, change it to different

Thank you for reading, I hope it can help you, thank you for your support of this site!

You may also be interested in:
  • Special issues with mysql master-slave server configuration
  • Simple configuration of mysql master-slave server
  • My experience of MySQL master-slave server synchronization

<<:  js to implement the snake game with comments

>>:  How to build a new image based on an existing image in Docker

Recommend

How to Rename Multiple Files at Once in Linux

Preface In our daily work, we often need to renam...

Detailed explanation of common commands in Docker repository

Log in docker login Complete the registration and...

In-depth interpretation of /etc/fstab file in Linux system

Preface [root@localhost ~]# cat /etc/fstab # # /e...

Introduction to CSS BEM Naming Standard (Recommended)

1 What is BEM Naming Standard Bem is the abbrevia...

HTML form application includes the use of check boxes and radio buttons

Including the use of check boxes and radio buttons...

Learn about TypeScript data types in one article

Table of contents Basic Types any type Arrays Tup...

How to install jupyter in docker on centos and open ports

Table of contents Install jupyter Docker port map...

The whole process of installing and configuring Harbor1.7 on CentOS7.5

1. Download the required packages wget -P /usr/lo...

The images in HTML are directly replaced by base64 encoded strings

Recently, I came across a webpage that had images ...

HTML table markup tutorial (16): title horizontal alignment attribute ALIGN

By default, the table title is horizontally cente...

Several common methods of CSS equal height layout

Equal height layout Refers to the layout of child...

JavaScript to achieve digital clock effect

This article example shares the specific code of ...

A brief introduction to MySQL database optimization techniques

A mature database architecture is not designed wi...

How to quickly delete all tables in MySQL without deleting the database

This article uses an example to describe how to q...