当前位置:网站首页>MySQL master-slave replication solves read-write separation
MySQL master-slave replication solves read-write separation
2022-06-10 22:37:00 【Lingbeichen】
MySQL Master slave copy
The concept of separation of reading and writing
All the pressure of reading and writing is borne by one database , The data will be lost if the database service disk is damaged due to high pressure , A single point of failure

mysql Master-slave replication of can solve this problem
Introduce
MySQL Master-slave replication is an asynchronous replication process , The bottom layer is based on Mysql Binary log function of database . Just one or more Mysql database (slave, From the library ) From the other Mysql database (master, The main library ) Copy the log, then parse the log and apply it to itself , Finally, the data of the slave database is consistent with that of the master database .Mysql Principal and subordinate malfeasance is MySql The database has its own functions , No third party tools required .
mysql The replication process is divided into three steps
master Log changes to binary log (binary log)
slave take master Of binary log Copy to his relay log (relay log)
slave Redo relay log events , Apply the changes to your own database

To configure - precondition
Prepare two servers in advance , Install separately mysql And start the service successfully
Main library master
First step : modify Mysql Profile of the database /etc/my.cnf
[mysqld]
log-bin=mysql-bin #[ must ] Enable binary logging
server-id=100 #[ must ] The server is unique ID
The second step : restart mysql service
systemctl restart mysqld
The third step : Sign in Mysql database , Do the following SQL
GRANT REPLICATION SLAVE ON *.* to 'xiaoming'@'%' identified by '[email protected]';
notes : above SQL The role of is to create a xiaoming, The password for [email protected], And give xiaoming User grants REPLICATION SLAVE jurisdiction . It is often used to establish the user permissions required for replication , That is to say slave Must be master Authorize the user with this permission , Can be copied by this user .
Step four : Sign in mysql data , Do the following SQL, Record the results File and Position Value
show master status;
notes : above SQL View when Master The state of , After that SQL Do not perform any more operations
Slave Library slave
First step : modify mysql Profile of the database /etc/my.cnf
[mysqld]
server-id=100 #[ must ] The server is unique ID
The second step : restart mysql service
systemctl restart mysqld
The third step : Sign in Mysql database , Do the following SQL
change master to master_host='192.168.138.100',master_user='xiaoming',master_password='[email protected]',master_log_file='mysql-bin.000001',master_log_pos=439;
start slave;
Step four : Sign in Mysql database , Do the following SQL, View the status of the slave database
show slave status;
The cause of the error
1. The Internet is not working 2. The password is wrong 3.pos incorrect 4. The firewall is not off 5.server-id Conflict
If you use clone virtual machines , Must be modified mysql Of uuid, Otherwise it will show Slave_IO_Running: No
terms of settlement :
1. First of all mysql Installation address of
show variables like 'datadir';
# adopt MySQL Generate a uuid Recording, etc. will be used to modify
select uuid
2. Then enter datadir Catalog
cd /var/lib/mysql/
vi auto.cnf
Take what you have just prepared uuid Value substitution
3. restart mysql
systemctl start mysqld
边栏推荐
猜你喜欢
![[tcapulusdb knowledge base] tcapulusdb daily inspection introduction](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[tcapulusdb knowledge base] tcapulusdb daily inspection introduction
![[applet] vant sliding cell adds the function of clicking other positions to close automatically](/img/ef/3d954323a981026e2b917428cbc92b.png)
[applet] vant sliding cell adds the function of clicking other positions to close automatically
![[tcapulusdb knowledge base] Introduction to tcapulusdb patrol inspection statistics](/img/67/e0112903cb3992a64bab02060dd59a.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb patrol inspection statistics

C语言内功修炼【整型在内存中的存储】

GMPNN:Drug-drug interaction prediction with learnable size-adaptive molecular substructures.

【TcaplusDB知识库】TcaplusDB机器初始化和上架介绍

鯨會務智慧景區管理解决方案
![[tcapulusdb knowledge base] tcapulusdb machine initialization and launch introduction](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[tcapulusdb knowledge base] tcapulusdb machine initialization and launch introduction

Array union set

存储引擎分析
随机推荐
Differences between disk serial number, disk ID and volume serial number
Use of C language qsort() function (detailed explanation)
What about the popular state management library mobx?
Record (III)
【phpstorm】 No data sources are configured to run this SQL and provide advanced c
Pytorch installation is super simple
【TcaplusDB知识库】TcaplusDB TcapDB扩缩容介绍
Shell基础概念
[py] the failure of interface signature verification may be due to ensure_ ASCII problems
Different ways to create four indexes in MySQL
[tcapulusdb knowledge base] Introduction to tcapulusdb push configuration
【TcaplusDB知识库】TcaplusDB事务管理介绍
Shell basic concepts
【TcaplusDB知识库】TcaplusDB机器初始化和上架介绍
Ability to deliver packages within D days [abstract class dichotomy -- Abstract judgment method]
Tcapulusdb Jun · industry news collection (VI)
【TcaplusDB知识库】TcaplusDB日常巡检介绍
mathtype7.x的基本使用
[tcapulusdb knowledge base] Introduction to tcapulusdb patrol inspection statistics
GMPNN:Drug-drug interaction prediction with learnable size-adaptive molecular substructures.