当前位置:网站首页>MySQL read / write separation configuration
MySQL read / write separation configuration
2022-06-27 23:46:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
mysql Read write separation configuration
With the increase of website visits and requests , The connection to a single database server has been exhausted , The connection request is still waiting , Or the database server crashes , At this point, we consider how to reduce the database connection , You can optimize your code 、 Use the cache 、 Database read-write separation and other methods to solve this problem . What is separation of reading and writing : Read the database 、 Write operations work on different databases ( Different physical machines ) On . Applicable scenario : Read operations are far greater than write operations , Contains a large number of complex statistics 、 Offline computing and other tasks ( For example, statistics and analysis of data are performed regularly according to each dimension , Or settlement Commission, etc ) Studied for a while , Various problems occurred during the configuration process .. It has just been configured today windows System environment : This machine +VM virtual machine :MySql5.6, Install first. MySql find MySql5.6 Of my.ini The configuration file , stay C:\ProgramData\MySQL\MySQL Server 5.6 Directory ,ProgramData Folders are hidden by default Mysql The reality of master-slave synchronization : 1、Master The library records changes to binlog in 2、Slave take master Of binlog Copy to its relay log( relay logs ) in 3、slave Redo events in relay log Read / write separation can be realized through the middle price , Such as Ameba,Corba,mysql-Proxy( official )
practice
A: Main warehouse operation 1、 stay my.ini Of documents [mysqld] Section, add the following configuration items : server-id=1 log-bin=master-bin.log sync_binlog=1 binlog-do-db=d # To the database d Log , This parameter may not be configured , My is not configured
2、 Use root The user logs in to the main library mysql, Create a user for synchronization , The slave database synchronizes the master database data through the user 3、 User authorization to be synchronized :GRANT REPLICATION SLAVE ON . to ‘test’@’%’ identified by ‘test’; 4、 Restart the main library mysql service , And log in again to view the main database status :show master status;
Remember the following master-bin.000001 and 422 This is the file to be synchronized from the library and the location of the synchronization
B: Operation from the library 1、 Log in to the virtual machine , stay my.ini Of documents [mysqld] Section, add the following configuration items : server-id=2 log-bin=myslave-bin.log sync_binlog=1
2、 Use root User login from library mysql, Modify the... From the library master Information change master to master_host=’192.168.1.109’,master_user=’test’,master_password=’test’,master_log_file=’mysql-bin.,000001’,master_log_pos=422;– Note the log number
3、 Start from library :start slave; 4、 View the slave library status :show slave status; The two parameters in the red box below are Yes, The master-slave configuration is successful !, It was tragic ,Slave_IO_Running Has always been a No perhaps Connecting.
Now the configuration is complete ... The following tests whether the changes of the master library will be synchronized to the slave library ... Use the test The user logs in to the main library , open cmd command , Locate the mysql Of the installation directory bin Catalog ,cd C:\ProgramData\MySQL\MySQL Server 5.6
Log in from library , Check out the test Whether the library has added a table t And data
Re execution update Order to try
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/133165.html Link to the original text :https://javaforall.cn
边栏推荐
- webService
- 【蓝桥杯集训100题】scratch数字计算 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第16题
- 第 2 章 集成 MP
- 思源笔记订阅停止直接删云端数据嘛?
- c语言字符指针、字符串初始化问题
- 未能加载文件或程序集“CefSharp.Core.Runtime.dll”或它的某一个依赖项。 不是有效的 Win32 应用程序。 (异常来自 HRESULT:0x800700C1)
- One step forward is excellent, one step backward is ignorant
- First principles (optimal solution theory)
- NDSS 2022 接收的列表
- Are the registered accounts of the top ten securities companies safe and risky?
猜你喜欢

Zero foundation self-study SQL course | if function

MSP430F5529 单片机 读取 GY-906 红外温度传感器

如何设置企业微信群机器人定时发消息?
![[sword finger offer] 47 Maximum value of gifts](/img/bc/1aff1223b1672c4089151dc56c4d4e.png)
[sword finger offer] 47 Maximum value of gifts

Small chip chiplet Technology

EasyCVR平台路由日志功能的技术实现过程【附代码】

通过 MQTT 检测对象和传输图像

webserver流程图——搞懂webserver各模块间调用关系

捷码赋能案例:湖南天辰产研实力迅速提升!实战玩转智慧楼宇/工地等项目

Practice torch FX: pytorch based model optimization quantization artifact
随机推荐
c语言之字符串数组
Discuz small fish game wind shadow legend business gbk+utf8 version template /dz game website template
如何找到外文文献对应的中文文献?
【剑指Offer】48. 最长不含重复字符的子字符串
virtualbox扩展动态磁盘大小的坑
Download versions such as typora 1.2.5
使用cef3开发的浏览器不支持flash问题的解决
Classification of cifar-10 dataset with pytorch
pytorch实现kaggle猫狗识别
零基础自学SQL课程 | CASE函数
webService
[sword finger offer] 47 Maximum value of gifts
Structure de stockage des graphiques
Halcon's region: features of multiple regions (6)
Are the registered accounts of the top ten securities companies safe and risky?
UESTC (shenhengtao team) & JD AI (Mei Tao team) proposed a structured dual stream attention network for video Q & A, with performance SOTA! Better than the method based on dual video representation!
Zero foundation self-study SQL course | complete collection of date functions in SQL
发射,接收天线方向图
【PCL自学:PCLPlotter】PCLPlotter绘制数据分析图
小芯片chiplet技术杂谈