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

How does mycat divide the database by month?

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the knowledge of "how to divide the database by month". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

2.4. Slice by month

If you now have a very large amount of data in a year, or you have a very large amount of data every month, then the best thing to do at this time is to slice according to different months. Then you should prepare 12 databases to implement your operations, but don't forget that 12 databases need to be configured from the database.

1. [mycat-server-01] modify the sharding rule file: vim/usr/local/mycat/conf/rule.xml

Define a sharding rule:

Define the algorithm for the use of sharding:

2. [mycat-server-01] modify the configuration file of mycat: vim/usr/local/mycat/conf/schema.xml

Mysql-server-01:1~4

Mysql-server-02:5~8

Mysql-server-03:9~12

3. [mycat-server-01] start the mycat service: / usr/local/mycat/bin/mycatconsole

If 12 hosts are set up now, the observation must be very good.

2.5. ER model sharding (sub-table sharding)

Generally speaking, such a mechanism is often established when the shopping system is established: suppose that there is an order now, then the order must have the details of multiple orders in order to describe all the goods purchased by the user in detail. Well, the data storage of the details of this order, then the data of the details of the order must be based on the data information of an order, and this data should be stored in the same database as the order record.

1. [mysql-server-*] create a database script:

DROPDATABASEIFEXISTSmdb;CREATEDATABASEmdbCHARACTERSETUTF8;usemdb

2. [mycat-server-01] modify mycat rule: vim/usr/local/mycat/conf/schema.xml

3. [mycat-server-01] start the mycat service: / usr/local/mycat/bin/mycatconsole

4. [mysql-server-*] Connect mycat for testing

Additional order data:

INSERTINTOorders (oid,title,pubdate) VALUES (11) and INSERTINTOorders (oid,title,pubdate) VALUES

Additional order details:

INSERTINTOorders_details (odid,oid,gtitle,amount) VALUES (1001, 11, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 2, 5, 2, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6

At this point, orders_details as a child table is saved in the same database as the parent table.

This is the end of the content of "how to divide the mycat by month". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report