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

Rainbow button style made with CSS3

Result: Implementation code: html <div class=&...

Some functions of using tcpdump to capture packets in the Linux command line

tcpdump is a flexible and powerful packet capture...

Alibaba Cloud Server Linux System Builds Tomcat to Deploy Web Project

I divide the whole process into four steps: Downl...

How to run commands on a remote Linux system via SSH

Sometimes we may need to run some commands on a r...

CSS new feature contain controls page redrawing and rearrangement issues

Before introducing the new CSS property contain, ...

Summary of the benefits of deploying MySQL delayed slaves

Preface The master-slave replication relationship...

How to implement Docker Registry to build a private image warehouse

The image of the microservice will be uploaded to...

Vue uses echart to customize labels and colors

This article example shares the specific code of ...

25 advanced uses of JS array reduce that you must know

Preface Reduce is one of the new conventional arr...

XHTML Getting Started Tutorial: XHTML Tags

Introduction to XHTML tags <br />Perhaps you...

Solution to the problem that order by is not effective in MySQL subquery

By chance, I discovered that a SQL statement prod...

Vue uses ECharts to implement line charts and pie charts

When developing a backend management project, it ...