基于MyCat的数据库读写分离技术的研究与应用
2021-11-03张清涛

DOI:10.19850/j.cnki.2096-4706.2021.08.035
摘 要:为了解决大型应用系统中后台数据库读写性能瓶颈的问题,在MariaDB数据库构建的主从复制集群中引入MyCat中间件服务器,安装必要的软件包、修改MyCat配置文件,搭建可读写分离的数据库服务器集群,从而解决了对一个数据库同时进行写、读操作时性能会严重下降的问题,并提高了在高并发环境下数据库集群的整体处理性能。
关键词:MyCat;读写分离;中间件;MariaDB
中图分类号:TP311.1 文献标识码:A 文章编号:2096-4706(2021)08-0125-03
Research and Application of Database Read-Write Separation Technology Based on MyCat
ZHANG Qingtao
(Hebei Petroleum University of Technology,Chengde 067000,China)
Abstract:In order to solve the problem of the bottleneck of read and write performance of background database in large application system,MyCat middleware server is introduced into the master-slave replication cluster which is built in MariaDB database. The necessary software package is installed,the configuration file of MyCat is modified,and the database server cluster with read-write separation is built. Thus,the problem that the performance will be seriously degraded when carrying out writing and reading operation to a database at the same time is solved,and the overall processing performance of database cluster in high concurrent environment is improved.
Keywords:MyCat;read-write separation;middleware;MariaDB
0 引 言
每學期末,笔者单位都会出现大量学生集中在教务系统进行成绩查询、课程查询、选课等操作,致使后台数据库服务器不堪重负、出现性能下降甚至崩溃的情况。这一方面是因为大量的数据库并发操作超出了单台数据库服务器的最大处理能力;另一方面是因为在对数据库进行写操作时,读性能会严重下降。
单位系统前台和应用系统业务逻辑本身采用反向代理技术实现Web服务器负载均衡,可以解决高并发访问问题;但唯独系统的后台基石——数据库服务器在解决高并发访问难题上可用手段一直较少。在存储层面直接采用水平分割、垂直分割等分布式技术来增强数据库系统吞吐性能,可谓困难重重,后台数据库的性能瓶颈亟需解决。
MyCat中间件的使用就是解决上述问题的方法之一。
1 原理
MyCat是一个开源的数据库中间件产品,在高并发的企业应用中可以用于搭建大型数据库集群,和开源的MariaDB配合可以作为Oracle集群的一种免费替代方案。在集群中部分节点负责数据写入,部分节点负责数据读出,可以分担高并发环境对数据库服务器的访问压力。……
