Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does mycat divide the database by month?

Shulou Source: shulou.com Published: 2022-06-01 08:39:22 10月01日 Update

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!

Tags: Data orders database information rules details monthly minutes content files more knowledge services configuration different practical successful learning next mainframe practices all goods Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Apple Huawei MySQL