Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the problems with the master-slave configuration of MySQL database

Shulou Source: shulou.com Published: 2022-05-31 12:39:58 09月29日 Update

This article mainly introduces what are the problems with the master-slave configuration of MySQL database. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

MySQL database is a kind of relational database management system whose function is not very powerful. although the function is not perfect, MySQL database has won the favor of the majority of users with the advantages of high speed, good adaptability and high reliability. depending on the performance of MySQL database, we should start from the configuration of MySQL database.

I.

Server-id can be set on its own, but try not to set it to 1 and cannot repeat it with the slave server.

Two hosts are required to act as the master server and the slave server.

Master server IP:192.168.1.1

IP:192.168.1.2 from the server

First, configure the mysql service on the two services.

On the primary server:

# vim/etc/my.cnf

Modify or add the following entries

Log-bin=master-bin

Log-bin-index=master-bin.index

Server-id=11

Note: server-id can be set by itself, but try not to set it to 1 and cannot repeat it with the slave server.

Restart the service

# servicemysqldrestart

Add REPLICATION (copy) account: repl

# mysql

> GRANTREPLICATIONSLAVE

> REPLICATIONCLIENTON*.*

> TOrepl@'192.168.1.%'

> IDENTIFIEDBY'redhat'

Note: *. * indicates any table in any database. '192.168.1%' means that only the master height of the 192.168.1.0 network segment is allowed to access the database

> FLUSHPRIVILEGES

>\ Q

II.

On the slave side:

# vim/etc/my.cnf

Modify or add the following entries:

Relay-log=relay-log-bin

Relay-log-index=slave-relay-bin.index

Server-id=22

Note: the server-id cannot be the same as the primary server

Restart the mysql service

# servicemysqldrestart

# mysql

> CHANGEMASTERTO

IP of the MASTER_HOST='192.168.1.1',## master server

> MASTER_PORT=3306,##3306 cannot be in quotation marks. This trip is optional.

> MASTER_USER='repl'

> MASTER_PASSWORD='redaht'

>

> STARTSLAVE

At this point, the master-slave mysql server configuration is complete!

Test:

Make changes to the database on the primary server, such as:

# mysql

> CREATDATABASEmydb

Before viewing from the server side:

# mysql

> SHOWDATABASES

There will also be an identical database called mydb!

These are all the contents of this article entitled "what are the problems with the master-slave configuration of MySQL database?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Service server data database configuration master-slave problem content function entry article powerful identical identical dispensable host value advantage interest functionality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei NVidia Apple vpn