Record the whole process of MySQL master-slave configuration based on Linux

Record the whole process of MySQL master-slave configuration based on Linux

mysql master-slave configuration

1. Preparation

Host: 192.168.244.128
Slave: 192.168.244.130

Configuring the Host

2. Authorize the slave server

GRANT REPLICATION SLAVE ON *.* to 'rep1'@'192.168.244.130' identified by 'root@bisnow';
FLUSH PRIVILEGES;

Here it means that the slave login username is configured as rep1, the password is 123, and it must be logged in from the address 192.168.248.139. After a successful login, you can operate any table in any database. If you do not need to restrict the login address, you can change the IP address to a %.

3. Modify the main library configuration file

vi /etc/my.cnf
[mysqld]
log-bin=/var/lib/mysql/binlog
server-id=130
binlog-do-db = cmdb
 
server-id: ID number of the master;
log-bin: Synchronized log path and file name. Be sure to note that this directory must be written by MySQL (I was lazy here and put it directly under the datadir below);
binlog-do-db: the name of the database to be synchronized 

4. Restart the MySQL service after configuration is complete

systemctl restart mysqld.service

5. Check the current binary log name and offset of the master server. The purpose of this operation is to recover data from this point after starting the slave database.

mysql> show master status;

Configuring the Slave

6. Add the following configuration in /etc/my.cnf

server-id=131

Note: If the slave is copied from the master, the uuids of the two mysqls are the same and need to be modified manually. The modification location is in the auto.cnf file in the data directory.
vi /var/lib/mysql/auto.cnf

7. Use commands to configure the slave:

change master to master_host='192.168.244.128',master_port=3306,master_user='rep1',master_password='root@bisnow',master_log_file='binlog.000002',master_log_pos=120;

8. Start the slave process

9. Check the slave status. If the following two values ​​are YES, the configuration is correct:

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

At this point, the configuration is complete. The host creates a library, adds data, and the slaves are automatically synchronized.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • MySQL master-slave configuration study notes
  • MySQL5.7 master-slave configuration example analysis
  • Docker mysql master-slave configuration details and examples
  • A brief note on the MySQL master-slave configuration solution
  • Sharing of the master-slave configuration method of MySQL database
  • Mysql implements master-slave configuration and multi-master-multi-slave configuration

<<:  WeChat applet learning notes: page configuration and routing

>>:  Linux CentOS 6.5 Uninstall, tar and install MySQL tutorial

Recommend

Detailed explanation of the background-position percentage principle

When I was helping someone adjust the code today,...

Simple usage example of MySQL 8.0 recursive query

Preface This article uses the new features of MyS...

Pure CSS custom multi-line ellipsis problem (from principle to implementation)

How to display text overflow? What are your needs...

MySQL 8.0.12 installation graphic tutorial

MySQL8.0.12 installation tutorial, share with eve...

Several ways to add timestamps in MySQL tables

Scenario: The data in a table needs to be synchro...

Determine the direction of mouse entry based on CSS

In a front-end technology group before, a group m...

HTTPS Principles Explained

As the cost of building HTTPS websites decreases,...

Details on using bimface in vue

Table of contents 1. Install Vue scaffolding 2. C...

Vue button permission control introduction

Table of contents 1. Steps 1. Define buttom permi...

The principle and application of MySQL connection query

Overview One of the most powerful features of MyS...

WeChat applet implements the snake game

This article shares the specific code of the WeCh...

Linux redis-Sentinel configuration details

download Download address: https://redis.io/downl...