Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Scenarios of Shard-Jdbc database expansion and solutions to the problems

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "the scene of Shard-Jdbc database expansion and the solution to the problem". In the daily operation, I believe that many people have doubts about the scene of Shard-Jdbc database expansion and the solution to the problem. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "Shard-Jdbc database expansion scenario and problem solution". Next, please follow the editor to study!

1. Database expansion 1. Business scenarios

There are many business scenarios of "large amount of data, high business complexity and need for sub-database and sub-table" in Internet projects.

Such a hierarchical architecture

(1) the upper layer is the business layer biz, which implements business logic encapsulation.

(2) in the middle is the service layer service, which encapsulates data access.

(3) the lower layer is the data layer db, which stores business data.

2. Expansion scenarios and problems

When the data volume continues to increase, faced with this demand, two databases cannot be accommodated, and the database capacity needs to be expanded. Here, select the mode of 2-expanding to 3, as shown below:

The problem of expanding capacity like this

(1) the strategy of sub-database and sub-table leads to large data migration.

(2) affect the continuous service of the data.

(3) when the specified time is completed, the technical pressure is great, which can easily lead to unexpected errors.

How to migrate data smoothly without downtime and ensure the continuous service of the system is the problem to be discussed in this paper.

2. Expansion solution 1. Diagram of expansion plan

(1) the sub-library and sub-table is based on MySQL database and uses shard-jdbc middleware.

(2) the whole idea of this scheme is based on the SpringCloud micro-service architecture.

2. Solve the problem of capacity expansion

(1) in the case of capacity expansion, there is no need to suspend service

(2) the pressure of data migration is small, and the specified time is not required.

3. Data access layer logic

Scheme description

Based on two databases and tables, abbreviated as Service 2

Based on three databases sub-database sub-table, referred to as: service 3

(1) provide two sets of services, service 2 and service 3

(2) after the database is expanded, if the data is obtained directly from the access service 3, the process ends.

(3) if the access service 3 cannot obtain the data, the access service 2 obtains the data.

(4) during the beginning of the migration, the access pressure will still be on Service 2.

(5) in this way, the data access service will not be down.

(6) this access mode is easy to achieve based on SpringCloud.

4. Data migration layer logic

Scheme description

(1) disable the data storage process based on the two databases

(2) start the data storage process based on the three libraries, so that the new data can be directly accessed by the service three.

(3) develop data migration middleware to scan the data of the previous two libraries.

(4) the scanned data is judged whether it needs to be migrated according to the strategy of three databases.

(5) if the data needs to be migrated, call the data storage interface of Service 3.

(6) after the data migration is completed, delete the data of the original location.

(7) this migration model is easy to achieve based on SpringCloud.

5. Advantages of migration in this scheme.

(1) the whole process is the continuous provision of online services.

(2) the development complexity of data migration middleware is low.

(3) you can move slowly at a limited speed without time pressure.

Third, source code control GitHub address https://github.com/cicadasmile/spring-cloud-baseGitEE address https://gitee.com/cicadasmile/spring-cloud-base, on the "Shard-Jdbc database expansion scenarios and problem solutions" study is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report