当前位置:网站首页>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
边栏推荐
- Eth trunk link switching delay is too high
- The database synchronization tool dbsync adds support for mongodb and es
- 基于DE2 115开发板驱动HC_SR04超声波测距模块【附源码】
- 软件设计之——“高内聚低耦合”
- Project ERROR: Unknown module(s) in QT: core gui
- 2021 summary and 2022 outlook
- Static semantic check of clang tidy in cicd
- CentOS系统下Redis安装和自启动配置的步骤
- Get pictures through opencv, change channels and save them
- VIM命令模式与输入模式切换
猜你喜欢
[untitled]
MPX plug-in
The post-90s resigned and started a business, saying they would kill cloud database
JSON format query of MySQL
Drive HC based on de2115 development board_ SR04 ultrasonic ranging module [source code attached]
IDEA快捷键大全
[untitled]
Seata 1.3.0 four modes to solve distributed transactions (at, TCC, Saga, XA)
Idea shortcut keys
关于SIoU《SIoU Loss: More Powerful Learning for Bounding Box Regression Zhora Gevorgyan 》的一些看法及代码实现
随机推荐
自律,提升自制力原来也有方法
[pyqt] the cellwidget in tablewidget uses signal and slot mechanism
Wallhaven wallpaper desktop version
Which securities company is the best and safest to open an account for the subscription of new shares
什么是高内聚、低耦合?
A case of compiling QT file qmake compiling script
Verilog 实现数码管显视驱动【附源码】
测试优惠券要怎么写测试用例?
The opacity value becomes 1%
测试开发基础,教你做一个完整功能的Web平台之环境准备
Verilog design responder [with source code]
[untitled]
Compile QT project script with qmake
Qt 实现容器的DELETE的方式
Unity websocket client
Array object sorting
Arduino board description
Add a self incrementing sequence number to the antd table component
Kitex 重试机制
Force buckle 1002 Find common characters