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

Solution to the MySQL error "Every derived table must have its own alias"

MySQL reports an error when executing multi-table...

10 Best Practices for Building and Maintaining Large-Scale Vue.js Projects

Table of contents 1. Use slots to make components...

Vue uses monaco to achieve code highlighting

Using the Vue language and element components, we...

Running PostgreSQL in Docker and recommending several connection tools

1 Introduction PostgreSQL is a free software obje...

Example code for implementing raindrop animation effect with CSS

Glass Windows What we are going to achieve today ...

Detailed explanation of views in MySQL

view: Views in MySQL have many similarities with ...

JavaScript Advanced Custom Exception

Table of contents 1. Concept 1.1 What are errors ...

How to add configuration options to Discuz! Forum

Discuz! Forum has many configuration options in th...

React implements import and export of Excel files

Table of contents Presentation Layer Business Lay...

Detailed explanation of CSS text decoration text-decoration &amp; text-emphasis

In CSS, text is one of the most common things we ...

Docker adds a bridge and sets the IP address range

I don't know if it's because the binary d...

Examples of using provide and inject in Vue2.0/3.0

Table of contents 1. What is the use of provide/i...