当前位置:网站首页>Distributed database master-slave configuration (MySQL)
Distributed database master-slave configuration (MySQL)
2022-07-07 11:16:00 【Java_ Liziling】
Distributed database master-slave configuration (MySQL)
Be careful : It is installed by default mysql, See my other blog for the installation tutorial –springboot The project is deployed to Alibaba cloud server (centos7)_Java_ Li Ziling's blog -CSDN Blog _springboot Deploy to alicloud
My master database and slave database are placed on a cloud server respectively , If there is only one ECs, you can install one on your computer MySQL, It should be noted that
Windows The configuration file to be modified under the system is my.in
1. Master database configuration
modify my.cnf file
vim /etc/my.cnf
Add the following
server-id=1 # The server ID, Any integer log-bin=mysql-bin # Log on binlog-do-db=db_test # Only synchronize the configuration to this database , If you copy multiple databases , Repeat this option
As shown in the figure
restart MySQL
systemctl restart mysqld
Sign in MySQL, Test configuration success
Sign in MySQL
mysql -uroot -p
Create the corresponding database ( It is consistent with that in the configuration file :bindlog-do-db=db_test)
create database db_test
Check the master database status , As shown in the figure below , Then the configuration is successful
show master status
2. Configure from database
modify my.cnf file
vim /etc/my.cnf
Add the following
server-id=2 # The server ID, Any integer , It is different from the main library
As shown in the figure
restart MySQL
systemctl restart mysqld
Sign in MySQL, Test configuration success
Sign in MySQL
mysql -uroot -p
Create the corresponding database ( It is consistent with that in the master database configuration file :bindlog-do-db=db_test)
create database db_test
Execute the following commands in turn
stop slave
Be careful : The specific content needs to be filled in by yourself
change master to master_host=' Master database server IP', master_user=' Primary database user name ', master_password=' Master database password ', master_log_file='mysql-bin.000005', # And graph 2 File Consistent values master_log_pos=322; # And graph 2 Position Consistent values
start slave
show slave status
- If there are two Yes Then the configuration is successful ( As shown in the figure below )
detection result
In the main database db_test Create a database table randomly in the database , Add a few more test data , You will find that the corresponding database tables and data will be automatically created from the database
边栏推荐
- 2021 summary and 2022 outlook
- Deeply understand the characteristics of database transaction isolation
- Case study of Jinshan API translation function based on retrofit framework
- 【pyqt】tableWidget里的cellWidget使用信号与槽机制
- 解决VSCode只能开两个标签页的问题
- 面试被问到了解哪些开发模型?看这一篇就够了
- 2021 summary and 2022 outlook
- RationalDMIS2022阵列工件测量
- 软件设计之——“高内聚低耦合”
- vim 的各种用法,很实用哦,都是本人是在工作中学习和总结的
猜你喜欢
The concept, implementation and analysis of binary search tree (BST)
Mysql的json格式查询
如何在博客中添加Aplayer音乐播放器
科普达人丨一文弄懂什么是云计算?
JS add spaces to the string
【C#】WinForm运行缩放(变糊)的解决方法
Static semantic check of clang tidy in cicd
对比学习之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
在我有限的软件测试经历里,一段专职的自动化测试经验总结
shardingsphere分库分表示例(逻辑表,真实表,绑定表,广播表,单表)
随机推荐
基于Retrofit框架的金山API翻译功能案例
mif 文件格式记录
How to get hardware information in unity
Debezium同步之Debezium架构详解
Unity websocket client
What if copying is prohibited?
seata 1.3.0 四種模式解决分布式事務(AT、TCC、SAGA、XA)
From pornographic live broadcast to live broadcast E-commerce
The opacity value becomes 1%
Deeply understand the characteristics of database transaction isolation
POJ1821 Fence 题解报告
[untitled]
How to use cherry pick?
Bookmarking - common website navigation for programmers
90后,辞职创业,说要卷死云数据库
在我有限的软件测试经历里,一段专职的自动化测试经验总结
关于在云服务器上(这里用腾讯云)安装mysql8.0并使本地可以远程连接的方法
Input type= "password" how to solve the problem of password automatically brought in
How to play video on unityui
Activity lifecycle