当前位置:网站首页>MySQL master-slave replication
MySQL master-slave replication
2022-06-26 00:07:00 【ZgaoYi】
1. 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 AySQL 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 Master slave replication 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 its trunk log ( relay log)
- slave Redo events in relay log , Apply the changes to your own database

2. To configure
There is only one master database , Can be multiple from , This time, it is implemented on the virtual machine , Create two virtual machines , Equivalent to two servers , And install MySQL, Versions, . The implementation is as follows .
2.1 Main library Master
First step : modify Mysq1 Profile of the database /etc/my.cnf
vim /etc/my.cnf
add to :
log-bin=mysql-bin #[ must ] Enable binary logging
server-id=100 #[ must ] The server is unique ID
notes : there id Is the server IP The last number of , Such as my IP yes 192.168.125.100, here id Just fill in 100
The second step , Restart the database systemctl restart mysqld
The third step : Sign in Mysql database , Do the following SQL
GRANT REPLICATION SLAVE ON *.* to 'xiaoming'@'%' identified by 'Root@123456';
notes : above SQL The function of is to create a user 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 , Check the status , The next configuration circled here needs to be used when configuring from the database .
2.2 To configure - Slave Library Slave
First step : modify Mysql Profile of the database /etc/my.cnf
vim /etc/my.cnf
server-id=101 ##[ must ] The server is unique ID
The second step , Restart the database systemctl restart mysqld
The third step : Sign in Mysql database , Do the following SQL
change master to master_host =‘192.168.126.100’,master_user=‘xiaoming’,master_password=‘[email protected]’,master_log_file= ‘mysql-bin.000001’,master_log_pos=441;
If an error is reported slave Started , execute stop slave;
Then execute again
change master to master_host =‘192.168.126.100’,master_user=‘xiaoming’,master_password=‘[email protected]’,master_log_file= ‘mysql-bin.000001’,master_log_pos=441;
Restart after execution slave
start slave

3. Go to the database to test
In the main MySQL Add database to test1 , And then from MySQL Auto update add to test1
Configuration complete .
边栏推荐
- Network protocol: detailed explanation of redis protocol
- Record a simple question with ideas at the moment of brushing leetcode - Sword finger offer 09 Implementing queues with two stacks
- Raspberry pie sends hotspot for remote login
- Find the minimum value of flipped array [Abstract bisection]
- 文獻調研(三):數據驅動的建築能耗預測模型綜述
- smt贴片加工行业pcba常见测试方法优劣分析比较
- 懒人教你用猕猴桃一月饱减16斤_过路老熊_新浪博客
- Virtual and pure virtual destructors and their implementation in c++
- Common methods of object class
- 给定参数n,从1到n会有n个整数1,2,3,...,n,这n个数组共有n!种排列,按照大小顺序升序排列出所有列的情况,并一一标记,给定n和k,返回第k个值
猜你喜欢

STEP7主站与远程I/O组网_过路老熊_新浪博客

Studio5k v28安装及破解_过路老熊_新浪博客

Efficacy of kiwi fruit enzyme_ Old bear passing by_ Sina blog

如何配置SQL Server 2008管理器_过路老熊_新浪博客

POSTMAN测试出现SSL无响应

keil编译运行错误,缺少error:#5:#includecore_cm3.h_过路老熊_新浪博客

文献调研(四):基于case-based reasoning、ANN、PCA的建筑小时用电量预测

Summary of c++ references and pointers

Linking MySQL database with visual studio2015 under win10

Redis之跳跃表
随机推荐
Search rotation array ii[Abstract dichotomy exercise]
Studio5k V28 installation and cracking_ Old bear passing by_ Sina blog
别再吃各种维生素C片了,这6种维生素C含量最高的水果
postman如何测试需要登录的接口
ssh的复习
redis之详解
ValueError: color kwarg must have one color per data set. 9 data sets and 1 colors were provided
[reprint]rslogix 5000 instance tutorial
About the solution to prompt modulenotfounderror: no module named'pymongo 'when running the scratch project
10.4.1 data console
WINCC与STEP7的仿真连接_过路老熊_新浪博客
Rocket之消息存储
Raspberry pie sends hotspot for remote login
10.4.1、数据中台
用ES5的方式实现const
使用npm创建并发布包时遇到的常见问题
剑指 Offer 48. 最长不含重复字符的子字符串
Recherche documentaire (3): examen des modèles de prévision de la consommation d'énergie des bâtiments fondés sur les données
P3052 [USACO12MAR]Cows in a Skyscraper G
Studio5k v28安装及破解_过路老熊_新浪博客