当前位置:网站首页>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
边栏推荐
- seata 1.3.0 四種模式解决分布式事務(AT、TCC、SAGA、XA)
- Bookmarking - common website navigation for programmers
- [untitled]
- Mysql的json格式查询
- 关于在云服务器上(这里用腾讯云)安装mysql8.0并使本地可以远程连接的方法
- 通过 Play Integrity API 的 nonce 字段提高应用安全性
- PR Lecture Notes
- 科普达人丨一文弄懂什么是云计算?
- 对比学习之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
- IDEA快捷键大全
猜你喜欢
随机推荐
Template initial level template
Unity determines whether the mouse clicks on the UI
自动化测试框架
From pornographic live broadcast to live broadcast E-commerce
Kitex 重试机制
Go redis Middleware
高考作文,高频提及科技那些事儿……
mif 文件格式记录
2021-04-23
网络协议 概念
Vscode 尝试在目标目录创建文件时发生一个错误:拒绝访问【已解决】
Array object sorting
[untitled]
MIF file format record
Deeply understand the characteristics of database transaction isolation
從色情直播到直播電商
Rolling puddle Uni_ App (VIII)
Eth trunk link switching delay is too high
Unity websocket server
Vuthink proper installation process