Flying saucer shooting athlete training data isolation method based on multi-tenant architecture
By using ShardingSphere sub-repository sub-table components and strict access control in the UFO shooting athlete training data management system, the shortcomings of traditional data isolation technology in a multi-tenant environment are solved, the precise isolation and security of data are achieved, and the system performance is improved and scalability, simplifying development and maintenance.
Patent Information
- Application Number
- CN202411237170.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-12-27
AI Technical Summary
The traditional data isolation component of the database sub-table data is difficult to maintain data consistency in the field of UFO shooting training data management, and it is difficult to cope with the problems of uneven data distribution, low resource utilization, and insufficient dynamic scaling capabilities, which cannot meet UFO shooting in a multi-tenant environment. Safety and performance requirements for athlete training data.
Using ShardingSphere library and table component, the distribution of training data is monitored in real time, reasonable sharding strategies and dynamic adjustment of sharding rules are designed, combined with strict access control mechanisms, to ensure data isolation and security, and to improve the system through dynamic scaling strategies. Performance and scalability.
It realizes accurate sharding and routing of training data for UFO shooting athletes, ensures data security and privacy, alleviates data tilt problems, improves system performance and scalability, simplifies development and maintenance work, and has flexibility and cost. benefit.
Smart Images

Figure CN119203178A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of computers, multi-tenant architectures and data isolation, and provides a method for isolating skeet shooting athlete training data based on a multi-tenant architecture. Background Art
[0002] With the rapid development of computer technology, multi-tenant architecture has been widely used in many industries. In the training data management system for skeet shooting athletes, it is crucial to ensure the security and privacy of each athlete's training data. However, with the expansion of the training system scale and the increase in the number of athletes participating in the training, the traditional data isolation method can no longer meet the growing demand, and it is urgent to improve the level of data isolation to ensure the security of athletes' training data.
[0003] At present, although there are some data isolation technologies, such as virtualization, access control, identity authentication, data encryption, distributed databases, and sub-databases and sub-tables, in the field of skeet shooting training data management, traditional sub-database and sub-table data isolation components still have shortcomings: data consistency maintenance is difficult, it is difficult to deal with uneven data distribution, resource utilization is low, and dynamic scaling capabilities are insufficient. Therefore, we need a more flexible and intelligent data isolation method.
[0004] To address the above issues, we proposed a multi-tenant architecture data isolation method suitable for the field of skeet shooting athlete training data. Based on the traditional sharding components, this method monitors the distribution of training data in real time and dynamically adjusts the sharding strategy to deal with data skew. The number of database tables can be flexibly adjusted according to system load and performance requirements. We designed a method that can effectively isolate athlete training data and ensure data security. By dynamically adjusting the sharding and database table strategies, this method can better adapt to the performance requirements of skeet shooting athlete training data management in a multi-tenant environment. Summary of the invention
[0005] The purpose of the present invention is to solve the deficiency of traditional data isolation technology in effectively isolating the training data of skeet shooting athletes in a multi-tenant environment. The method integrates ShardingSphere sub-library and sub-table components, designs a reasonable sharding strategy, realizes accurate sharding and routing of athlete training data, and ensures data isolation and security. At the same time, a strict access control mechanism is introduced to prevent unauthorized data access, improve the performance and scalability of the training data management system, simplify the development and maintenance of the system, and have flexibility and cost-effectiveness. To achieve the above purpose, the present invention adopts the following technical means:
[0006] The present invention provides a method for isolating training data of skeet shooting athletes based on a multi-tenant architecture, comprising the following steps:
[0007] Step 1: Design the database architecture, determine the sharding key, and design the sharding strategy.
[0008] Step 2: Select the shardingSphere component of the sharding framework and configure it, introduce the dependencies of ShardingSphere, configure the data source, and configure the sharding rules of ShardingSphere according to the sharding strategy designed in step 1;
[0009] Step 3: Initialize the sharded database and table. According to the sharding rules, create multiple databases, create the same table structure in each database, and create corresponding sharded tables in each database according to the sharding rules.
[0010] Step 4: By monitoring the data in the database table created after sharding, dynamically adjust the sharding strategy to reduce the occurrence of data skew, and adopt a dynamic scaling strategy to adjust the distribution of system resources;
[0011] Step 5: Tenant data routing and access control. Calculate the shard key value based on the tenant ID, determine which database table the data is routed to, and implement access control so that only authorized tenants can access their data.
[0012] In the above technical solution, step 1 includes the following steps:
[0013] Step 1.1: Select tenant ID as the shard key to distinguish data of different tenants. Tenant ID is the unique identifier of each tenant.
[0014] Step 1.2: Design a sharding strategy to determine how to distribute data to different database tables based on how and how often tenants access data. For example, data can be distributed to different database tables based on values within a certain range. Data with tenant IDs between 1 and 1000 is stored in one database table, data with tenant IDs between 1001 and 2000 is stored in another database table, and so on.
[0015] Step 1.3: Select the sharding algorithm provided by ShardingSphere based on the sharding strategy, and shard the data according to the tenant ID. The sharding algorithm will determine which database shard the data should be assigned to based on the value of the sharding key. The sharding algorithm includes the hash modulus algorithm, range sharding algorithm or consistent hashing algorithm.
[0016] In the above technical solution, step 2 includes the following steps:
[0017] Step 2.1: Introduce the relevant dependencies of ShardingSphere into the multi-tenant architecture project, including the dependencies of the sharding database and sharding table modules;
[0018] Step 2.2: Configure the data source information in the configuration file. You need to modify the data source's host address, port number, database name, user name, and password to adapt to the database environment.
[0019] Step 2.3: Configure specific sharding rules according to the sharding strategy designed in step 1. The sharding rule is the specific implementation of the sharding strategy. It defines how to map data to specific database shards based on the sharding key to achieve the data distribution method in the sharding strategy.
[0020] Step 2.4: Specify the shard key. Based on the selection in step 1.1, use the tenant ID as the shard key to ensure that each tenant's data can be uniquely identified and routed.
[0021] Step 2.5: Select or customize the sharding algorithm. Configure the sharding algorithm according to step 1.3, such as the standard sharding algorithm or the custom sharding algorithm, to implement the data distribution logic defined in the sharding strategy;
[0022] Step 2.6: Configure shard mapping. According to the sharding strategy in step 1.2, configure the mapping relationship between the sharding key value and the actual database shard. For example, if the strategy is to shard by tenant ID range, you need to configure which database shard the tenant ID in each range is mapped to.
[0023] Step 2.7: Adjust the configuration file information according to business needs and sharding rules. You need to replace the actual table name, sharding key name, sharding algorithm class name, and data node to meet the needs of data sharding.
[0024] In the above technical solution, step 3 includes the following steps:
[0025] Step 3.1: Determine the number of databases to be created based on the sharding rules and data volume. Specifically, determine the number of databases based on business needs and expected data growth rate.
[0026] Step 3.2: Create multiple databases on the database server to store sharded data. Create a corresponding number of databases on the database server one by one according to the number of databases determined in step 3.1;
[0027] Step 3.3: Design the table structure of the shard table, including field names and data types:
[0028] Design the table structure based on business requirements and data characteristics, determine the fields that each shard table needs to include, as well as the field data type, length, and constraints.
[0029] Step 3.4: Create corresponding shard tables in each database according to the sharding rules. Determine the database to which each shard table belongs according to the sharding rules, and then create shard tables in the corresponding databases. Use database management tools or SQL scripts to execute DDL statements for creating tables, create corresponding shard tables in each database, and ensure that the table structure is consistent with the design in step 3.3.
[0030] Step 3.5: Use the DDL function provided by ShardingSphere to execute the SQL statement to create the sharding table. ShardingSphere will automatically create the table in the corresponding database and perform data sharding according to the configured sharding rules. Use the database management tool or the monitoring function of ShardingSphere to verify the creation of the sharding table and the effect of data sharding.
[0031] In the above technical solution, step 4 includes the following steps:
[0032] Step 4.1: Monitor the load of data shards in the database in real time, including the data volume and access frequency indicators of each shard, analyze the monitoring data, evaluate the data skew degree of each shard, and determine which shards have data skew problems and the degree of skew;
[0033] Step 4.2: For shards with serious data skew, dynamically increase the number of data shards through the Java API provided by ShardingSphere, re-evaluate the sharding rules according to the data distribution, and dynamically adjust the sharding range so that the data can be more evenly distributed in each shard;
[0034] Step 4.3: Monitor the data volume changes of each shard table in the database in real time, count the data volume of each shard table, or monitor data insertion and deletion operations in real time to obtain the latest data volume information;
[0035] Step 4.4: According to business needs and system performance, set the data volume threshold for dynamically creating shard tables and the data volume threshold for deleting shard tables. When the data volume of a shard table reaches the creation threshold, the mechanism for automatically creating a new table is triggered; when the data volume of a shard table is lower than the deletion threshold, the mechanism for automatically deleting the shard table is triggered;
[0036] Step 4.5: When the data volume of a shard table reaches the creation threshold, execute the SQL statement to create a new table through the DDL function provided by ShardingSphere. Create a new shard table in the same database according to the predefined naming rules and ensure that the table structure is consistent with the existing shard table;
[0037] Step 4.6: When the new table is created successfully and the data migration is completed, execute the SQL statement to delete the old table through the DDL function provided by ShardingSphere;
[0038] Step 4.7: When the data volume of a shard table is lower than the deletion threshold and no new data has been inserted into the shard table for a long time, migrate the data of the shard table to a shard table in the same database whose data volume does not reach the creation threshold, and execute the SQL statement to delete the old table.
[0039] In the above technical solution, step 5 includes the following steps:
[0040] Step 5.1: Because the tenant ID is used as the shard key value, the shard key value is calculated according to the sharding rules and sharding algorithm to determine which database table the tenant data is routed to.
[0041] Step 5.2: Implement identity authentication and authorization functions to ensure that only authorized tenants can access their data.
[0042] Step 5.3: Use the access control function provided by ShardingSphere to configure access rights and role permissions. In the configuration file, modify spring.sharding.authentication.users to define user access rights. This includes specifying which users can access the database and the operations they can perform. Modify spring.sharding.authentication.roles to define role permissions, assign a set of permissions to specific roles, and then assign roles to users. With the above configuration, you can achieve flexible control of user access rights and role permissions, ensure that only authorized users can access their data, and perform permission management and authorization operations according to actual needs.
[0043] The above technical solution also includes step 6: monitoring and maintenance, monitoring the performance and load of the sharded database, timely discovering and handling performance bottlenecks or failures, and using automated tools and scripts to achieve automated deployment, expansion and reduction of the sharded database, as well as data migration and backup.
[0044] In the above technical solution, step 6 specifically includes the following steps:
[0045] Step 6.1: Configure the monitoring system to monitor the performance indicators of the sharded database, including CPU utilization and memory usage;
[0046] Step 6.2: Periodically collect and analyze monitoring data to identify and handle performance bottlenecks or failures;
[0047] Step 6.3: Write automation scripts to realize automatic deployment, expansion and reduction of shard databases;
[0048] Step 6.4: Configure scheduled tasks to perform data migration and backup regularly to ensure stable operation of the system.
[0049] Because the present invention adopts the above technical solution, it has the following beneficial effects:
[0050] 1. Effective data isolation:
[0051] Initializing the sharded database and table ensures that the training data of different athletes are correctly sharded and stored in isolation. By calculating the athlete's ID as the sharding key value, the data will be routed to different database tables, ensuring that each athlete's training data is stored independently and maintaining data security and privacy. The initialization process of the sharded database and table also takes into account the high availability and fault tolerance of the database, ensuring that the system can recover quickly in the face of failures and ensuring the continuity of training data. Initialization is achieved through automated tools and scripts, which improves the efficiency and accuracy of data initialization and reduces the burden of database table management and maintenance.
[0052] 2. Alleviate data skew and dynamic scaling:
[0053] Real-time monitoring of database tables and dynamic adjustment of sharding strategies effectively alleviate the data skew problem and improve the performance and stability of the system. Dynamic adjustment of the number of database tables based on the growth of athlete training data and system load enables the system to flexibly adapt to resource requirements and enhances the scalability and elasticity of the system.
[0054] 3. Flexible access control:
[0055] A refined access control mechanism is implemented to ensure that only authorized athletes and coaches can access specific training data, preventing the risk of data leakage and unauthorized access. By configuring access control, access rights can be flexibly managed and controlled according to different business scenarios and security requirements.
[0056] 4. Accuracy and ease of management:
[0057] Choosing the athlete ID as the sharding key ensures that each athlete's data is accurately sharded and isolated, avoiding data confusion or conflict and ensuring data integrity and consistency. The uniqueness of the athlete ID simplifies data routing and access control, and improves the maintainability and manageability of the system.
[0058] 5. Flexibility and scalability:
[0059] By using the sharding strategy provided by ShardingSphere, sharding rules can be flexibly designed according to the characteristics and access patterns of athlete training data, and flexible sharding and routing of data can be achieved. A properly designed sharding strategy helps to achieve parallel processing and load balancing of data, improve the concurrent processing capability and performance of the system, and ensure the stable operation of the system when facing large-scale data.
[0060] 6. Simplify development and reliability:
[0061] Integrating ShardingSphere's database and table sharding components simplifies the development process, provides rich functions and automated tools, quickly implements data isolation, and saves development costs and time. The maturity and wide application of ShardingSphere ensure its excellent performance in performance, stability and reliability, and meets the high standards for data isolation in multi-tenant architecture.
[0062] 7. Dynamic adjustment and configuration:
[0063] By configuring data sources and sharding rules, you can flexibly specify data source connection information and sharding strategies to meet the specific needs of different athletes' training data. This configuration method improves the manageability and maintainability of the system, simplifies database management, and reduces labor costs. At the same time, it supports dynamic adjustment of sharding strategies based on business needs and system load to ensure continuous stability and efficient operation of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 The figure is a flow chart of a possible embodiment of the present invention. DETAILED DESCRIPTION
[0065] The following is a detailed description of the embodiments of the present invention. Although the present invention will be described and illustrated in conjunction with some specific embodiments, it should be noted that the present invention is not limited to these embodiments. On the contrary, modifications or equivalent substitutions made to the present invention should all be included in the scope of the claims of the present invention.
[0066] In addition, in order to better illustrate the present invention, numerous specific details are given in the following specific embodiments. It will be understood by those skilled in the art that the present invention can also be implemented without these specific details.
[0067] A method for isolating training data of skeet shooting athletes based on a multi-tenant architecture comprises the following steps:
[0068] Step 1: Design the database architecture, determine the sharding key, and design the sharding strategy. By selecting the tenant ID as the sharding key, the data of different tenants can be stored in different database tables to achieve data isolation. Designing a sharding strategy and selecting a sharding algorithm can ensure that data is evenly distributed in the database and improve data access efficiency.
[0069] Step 1.1: Select a suitable shard key to distinguish the data of different tenants. In this method, the tenant ID is selected as the shard key because the tenant ID can uniquely identify each tenant.
[0070] Step 1.2: Design a sharding strategy to determine how to distribute data to different database tables based on business requirements and data access patterns. For example, data can be distributed to different database tables based on values within a certain range. Data with tenant IDs between 1 and 1000 is stored in one database table, data with tenant IDs between 1001 and 2000 is stored in another database table, and so on.
[0071] Step 1.3: Select an appropriate sharding algorithm, such as the hash modulus algorithm, range sharding algorithm, or consistent hashing algorithm, to shard the data based on the tenant ID.
[0072] Step 2: Select the shardingSphere framework component and configure it, introduce the dependency of ShardingSphere, and configure the data source and sharding rules. By introducing the ShardingSphere framework, the implementation process of sharding can be simplified, and the sharding function can be realized with simple configuration. Configuring the data source and sharding rules can ensure that the data can be stored and accessed as expected.
[0073] Step 2.1: Introduce the relevant dependencies of ShardingSphere into the multi-tenant architecture project, including the dependencies of the sharding database and table modules.
[0074] Step 2.2: Configure the data source information in the configuration file. You need to modify the data source's host address, port number, database name, user name, and password to suit the database environment. At the same time, you can adjust the connection pool configuration parameters as needed.
[0075] Step 2.3: Configure sharding rules, specify sharding keys and sharding algorithms. Adjust the configuration file information according to business requirements and sharding rules. You need to replace the actual table name, sharding key name, sharding algorithm class name, and data node to meet the needs of data sharding.
[0076] Step 3: Initialize the shard database and table, and create multiple databases according to the sharding rules. Create the same table structure in each database. Create corresponding shard tables in each database according to the sharding rules. By creating multiple databases and tables, data can be stored in different shard tables according to the sharding rules to achieve distributed storage of data. Creating the same table structure in each database can simplify data management and maintenance.
[0077] Step 3.1: Determine the number of databases to be created based on the sharding rules and the expected data volume. According to the sharding rules, each database will store a portion of the sharded data, so the number of databases needs to be determined based on the data volume and the database's carrying capacity. The number of databases can be determined based on business needs and the expected data growth rate.
[0078] Step 3.2: Create multiple databases on the database server to store the sharded data. Create the corresponding number of databases on the database server one by one according to the number of databases determined in step 3.1. Ensure that each database has sufficient storage space and performance to meet the storage and query requirements of the sharded data.
[0079] Step 3.3: Design the table structure of the shard table, including field names and data types. Design a suitable table structure based on business requirements and data characteristics to ensure that shard data can be stored and queried. Determine the fields that each shard table needs to contain, as well as the field data type, length, and constraints.
[0080] Step 3.4: Create corresponding shard tables in each database according to the sharding rules. Determine the database to which each shard table belongs according to the sharding rules, and then create the shard tables in the corresponding databases. Use database management tools or SQL scripts to execute the DDL statements for creating tables, create corresponding shard tables in each database, and ensure that the table structure is consistent with the design in step 3.3.
[0081] Step 3.5: Use the DDL function provided by ShardingSphere to execute the SQL statement for creating the sharding table. After executing the SQL statement for creating the sharding table, you can view the execution result. ShardingSphere will automatically create the table in the corresponding database and perform data sharding according to the configured sharding rules. You can verify the creation of the sharding table and the effect of data sharding through the database management tool or the monitoring function of ShardingSphere.
[0082] Step 4: By monitoring the data in the database table created after sharding, dynamically adjust the sharding strategy to reduce the occurrence of data skew, and adopt a dynamic scaling strategy to adjust the distribution of system resources. By real-time monitoring of the data distribution and load in the database, data skew problems can be discovered in a timely manner, and by dynamically adjusting the sharding strategy and system resource allocation, uniform data distribution and optimal utilization of system resources can be achieved.
[0083] Step 4.1: Monitor the load of data shards in the database in real time, including the data volume and access frequency indicators of each shard. Analyze the monitoring data, evaluate the data skew degree of each shard, and determine which shards have data skew problems and the degree of skew.
[0084] Step 4.2: For shards with serious data skew, dynamically increase the number of data shards through the Java API provided by ShardingSphere. Re-evaluate the sharding rules according to the data distribution, and dynamically adjust the sharding range so that the data can be more evenly distributed in each shard.
[0085] Step 4.3: Monitor the data volume changes of each shard table in the database in real time. Count the data volume of each shard table, or monitor data insertion and deletion operations in real time to obtain the latest data volume information.
[0086] Step 4.4: According to business needs and system performance, set the data volume threshold for dynamically creating shard tables and the data volume threshold for deleting shard tables. When the data volume of a shard table reaches the creation threshold, the mechanism for automatically creating a new table is triggered; when the data volume of a shard table is lower than the deletion threshold, the mechanism for automatically deleting the shard table is triggered.
[0087] Step 4.5: When the data volume of a shard table reaches the creation threshold, execute the SQL statement to create a new table through the DDL function provided by ShardingSphere. Create a new shard table in the same database according to the predefined naming rules and ensure that the table structure is consistent with the existing shard table.
[0088] Step 4.6: When the new table is created successfully and the data migration is completed, execute the SQL statement to delete the old table through the DDL function provided by ShardingSphere.
[0089] Step 4.7: When the data volume of a shard table is lower than the deletion threshold and no new data has been inserted into the shard table for a long time, migrate the data of the shard table to a shard table in the same database whose data volume does not reach the creation threshold, and execute the SQL statement to delete the old table.
[0090] Step 5: Tenant data routing and access control, calculate the shard key value based on the tenant ID, and determine which database table the data is routed to. Implement access control to ensure that only authorized tenants can access their data. By calculating the shard key value based on the tenant ID, data from different tenants can be routed to different database tables to achieve data isolation. Implementing access control can ensure that only authorized tenants can access their data, improving data security.
[0091] Step 5.1: Because the tenant ID is used as the shard key value, the shard key value is calculated according to the sharding rules and sharding algorithm to determine which database table the tenant data is routed to.
[0092] Step 5.2: Implement identity authentication and authorization functions to ensure that only authorized tenants can access their data.
[0093] Step 5.3: Use the access control function provided by ShardingSphere to configure access rights and role permissions. In the configuration file, modify spring.sharding.authentication.users to define user access rights. This includes specifying which users can access the database and the operations they can perform. Modify spring.sharding.authentication.roles to define role permissions, assign a set of permissions to specific roles, and then assign roles to users. With the above configuration, you can achieve flexible control of user access rights and role permissions, ensure that only authorized users can access their data, and perform permission management and authorization operations according to actual needs.
[0094] Step 6: Monitoring and maintenance. Monitor the performance and load of the sharded database to promptly identify and handle performance bottlenecks or faults. Use automated tools and scripts to automate the deployment, expansion and reduction of the sharded database, as well as data migration and backup. By monitoring the performance and load of the sharded database, you can promptly identify and handle performance bottlenecks or faults to ensure the stable operation of the database. Using automated tools and scripts, you can automate the deployment, expansion and reduction of the sharded database, as well as data migration and backup, to improve database management efficiency.
[0095] Step 6.1: Configure the monitoring system to monitor the performance indicators of the sharded database, such as CPU utilization and memory usage.
[0096] Step 6.2: Regularly collect and analyze monitoring data to promptly identify and handle performance bottlenecks or failures.
[0097] Step 6.3: Write automated scripts to automate the deployment, expansion, and reduction of sharded databases.
[0098] Step 6.4: Configure scheduled tasks to perform data migration and backup regularly to ensure stable operation of the system.
[0099] In summary, the present invention has the following characteristics:
[0100] Effectiveness of data isolation: By integrating ShardingSphere sharding components, a method that can effectively isolate tenant data is designed. This method realizes parallel processing and load balancing of data through reasonable design of sharding strategy and use of distributed database technology, improves the concurrent processing capability and performance of the system, and thus better meets the performance requirements in a multi-tenant environment.
[0101] Flexible access control mechanism: A strict access control mechanism is implemented to ensure that only authorized tenants can access their data, preventing the risk of unauthorized access and data leakage. By configuring the access control function, the access rights of tenants can be flexibly managed and controlled to meet different business scenarios and security requirements.
[0102] Flexibility and accuracy of sharding strategy: Selecting tenant ID as the sharding key can ensure that each tenant's data can be accurately sharded and isolated, thereby achieving accurate data isolation. At the same time, the tenant ID is usually a unique identifier, which can ensure that data between different tenants will not be confused or conflicted, ensuring data integrity and consistency.
[0103] System flexibility and scalability: By using the sharding strategy provided by ShardingSphere, you can flexibly design sharding rules according to business needs and data access patterns, and achieve flexible sharding and routing of data, so as to better adapt to different business scenarios and needs. By reasonably designing sharding strategies, you can achieve parallel processing and load balancing of data, and improve the concurrent processing capability and performance of the system.
[0104] Simplification of the development process and system reliability: Integrating ShardingSphere sharding components can simplify the development process. It provides a wealth of sharding functions and automation tools, which can quickly achieve data isolation and save development costs and time. At the same time, ShardingSphere is a mature open source project with excellent performance, stability and reliability.
[0105] Dynamic adjustment of configuration and manageability of the system: By configuring data sources and sharding rules, you can flexibly specify the connection information and sharding strategies of the data source, and implement flexible sharding and routing of data to better meet the needs of different tenants. It can also improve the manageability and maintainability of the system, better manage and maintain the database, and reduce the complexity of management work and labor costs.
Claims
1. A method for isolating training data of skeet shooting athletes based on a multi-tenant architecture, characterized in that: The following steps are involved: Step 1: Design the database architecture, determine the sharding key, and design the sharding strategy. Step 2: Select the shardingSphere component of the sharding framework and configure it, introduce the dependencies of ShardingSphere, configure the data source, and configure the sharding rules of ShardingSphere according to the sharding strategy designed in step 1; Step 3: Initialize the sharded database and table. According to the sharding rules, create multiple databases, create the same table structure in each database, and create corresponding sharded tables in each database according to the sharding rules. Step 4: By monitoring the data in the database table created after sharding, dynamically adjust the sharding strategy to reduce the occurrence of data skew, and adopt a dynamic scaling strategy to adjust the distribution of system resources; Step 5: Tenant data routing and access control. Calculate the shard key value based on the tenant ID, determine which database table the data is routed to, and implement access control so that only authorized tenants can access their data.
2. A method for isolating skeet shooting athlete training data based on a multi-tenant architecture according to claim 1, characterized in that: Step 1 includes the following steps: Step 1.1: Select tenant ID as the shard key to distinguish data from different tenants. Tenant ID is the unique identifier of each tenant. Step 1.2: Design a sharding strategy to determine how to distribute data into different database tables based on how and how often tenants access data. Step 1.3: Select the sharding algorithm provided by ShardingSphere based on the sharding strategy, and shard the data according to the tenant ID. The sharding algorithm will determine which database shard the data should be assigned to based on the value of the sharding key. The sharding algorithm includes the hash modulus algorithm, range sharding algorithm or consistent hashing algorithm.
3. A method for isolating skeet shooting athlete training data based on a multi-tenant architecture according to claim 1, characterized in that: Step 2 includes the following steps: Step 2.1: Introduce the relevant dependencies of ShardingSphere into the multi-tenant architecture project, including the dependencies of the sharding database and sharding table modules; Step 2.2: Configure the data source information in the configuration file. You need to modify the data source's host address, port number, database name, user name, and password to adapt to the database environment. Step 2.3: Configure specific sharding rules according to the sharding strategy designed in step 1. The sharding rule is the specific implementation of the sharding strategy. It defines how to map data to specific database shards based on the sharding key to achieve the data distribution method in the sharding strategy. Step 2.4: Specify the shard key. Based on the selection in step 1.1, use the tenant ID as the shard key to ensure that each tenant's data can be uniquely identified and routed. Step 2.5: Select or customize the sharding algorithm. Configure the sharding algorithm according to step 1.3, such as the standard sharding algorithm or the custom sharding algorithm, to implement the data distribution logic defined in the sharding strategy; Step 2.6: Configure shard mapping. According to the sharding strategy in step 1.2, configure the mapping relationship between the sharding key value and the actual database shard. For example, if the strategy is to shard by tenant ID range, you need to configure which database shard each tenant ID in the range is mapped to. Step 2.7: Adjust the configuration file information according to business needs and sharding rules. You need to replace the actual table name, sharding key name, sharding algorithm class name, and data node to meet the needs of data sharding.
4. A method for isolating skeet shooting athlete training data based on a multi-tenant architecture according to claim 1, characterized in that: Step 3 includes the following steps: Step 3.1: Determine the number of databases to be created based on the sharding rules and data volume. Specifically, determine the number of databases based on business needs and expected data growth rate. Step 3.2: Create multiple databases on the database server to store sharded data. Create a corresponding number of databases on the database server one by one according to the number of databases determined in step 3.1; Step 3.3: Design the table structure of the shard table, including field names and data types: Design the table structure based on business requirements and data characteristics, determine the fields that each shard table needs to include, as well as the data type, length, and constraints of the fields; Step 3.4: Create corresponding shard tables in each database according to the sharding rules. Determine the database to which each shard table belongs according to the sharding rules, and then create shard tables in the corresponding databases. Use database management tools or SQL scripts to execute DDL statements for creating tables, create corresponding shard tables in each database, and ensure that the table structure is consistent with the design in step 3.
3. Step 3.5: Use the DDL function provided by ShardingSphere to execute the SQL statement to create the sharding table. ShardingSphere will automatically create the table in the corresponding database and perform data sharding according to the configured sharding rules. Use the database management tool or the monitoring function of ShardingSphere to verify the creation of the sharding table and the effect of data sharding.
5. The method for isolating training data of skeet shooting athletes based on a multi-tenant architecture according to claim 1, characterized in that: Step 4 includes the following steps: Step 4.1: Monitor the load of data shards in the database in real time, including the data volume and access frequency indicators of each shard, analyze the monitoring data, evaluate the data skew degree of each shard, and determine which shards have data skew problems and the degree of skew; Step 4.2: For shards with serious data skew, dynamically increase the number of data shards through the Java API provided by ShardingSphere, re-evaluate the sharding rules according to the data distribution, and dynamically adjust the sharding range so that the data can be more evenly distributed in each shard; Step 4.3: Monitor the data volume changes of each shard table in the database in real time, count the data volume of each shard table, or monitor data insertion and deletion operations in real time to obtain the latest data volume information; Step 4.4: According to business needs and system performance, set the data volume threshold for dynamically creating shard tables and the data volume threshold for deleting shard tables. When the data volume of a shard table reaches the creation threshold, the mechanism for automatically creating a new table is triggered; when the data volume of a shard table is lower than the deletion threshold, the mechanism for automatically deleting the shard table is triggered; Step 4.5: When the data volume of a shard table reaches the creation threshold, execute the SQL statement to create a new table through the DDL function provided by ShardingSphere. Create a new shard table in the same database according to the predefined naming rules and ensure that the table structure is consistent with the existing shard table; Step 4.6: When the new table is created successfully and the data migration is completed, execute the SQL statement to delete the old table through the DDL function provided by ShardingSphere; Step 4.7: When the data volume of a shard table is lower than the deletion threshold and no new data has been inserted into the shard table for a long time, migrate the data of the shard table to a shard table in the same database whose data volume does not reach the creation threshold, and execute the SQL statement to delete the old table.
6. A method for isolating skeet shooting athlete training data based on a multi-tenant architecture according to claim 1, characterized in that: Step 5 includes the following steps: Step 5.1: Because the tenant ID is used as the sharding key value, the sharding key value is calculated according to the sharding rules and sharding algorithm to determine which database table the tenant data is routed to; Step 5.2: Implement identity authentication and authorization functions to ensure that only authorized tenants can access their data. Step 5.3: Use the access control function provided by ShardingSphere to configure access rights and role rights. In the configuration file, modify spring.sharding.authentication.users to define user access rights, which includes specifying which users can access the database and the operations they can perform. Modify spring.sharding.authentication.roles to define role rights, assign a set of rights to specific roles, and then assign roles to users. Through the above configuration, flexible control of user access rights and role rights can be achieved, ensuring that only authorized users can access their data, and can perform permission management and authorization operations according to actual needs.
7. A method for isolating skeet shooting athlete training data based on a multi-tenant architecture according to claim 1, characterized in that: It also includes step 6: monitoring and maintenance, monitoring the performance and load of the sharded database, promptly discovering and handling performance bottlenecks or failures, and using automated tools and scripts to achieve automated deployment, expansion and reduction of the sharded database, as well as data migration and backup.
8. A method for isolating skeet shooting athlete training data based on a multi-tenant architecture according to claim 7, characterized in that: Including step 6 specifically including the following steps: Step 6.1: Configure the monitoring system to monitor the performance indicators of the sharded database, including CPU utilization and memory usage; Step 6.2: Periodically collect and analyze monitoring data to identify and handle performance bottlenecks or failures; Step 6.3: Write automation scripts to realize automatic deployment, expansion and reduction of shard databases; Step 6.4: Configure scheduled tasks to perform data migration and backup regularly to ensure stable operation of the system.
Citation Information
Cited By
Data space multi-tenant isolation method and system based on zero-trust architecture
CN120185913A
A Data Space Multi-Tenant Isolation Method and System Based on Zero-Trust Architecture
CN120185913B
Self-adaptive performance optimization method, device and equipment for distributed database
CN120523799A
An adaptive performance optimization method, device and equipment for a distributed database
CN120523799B
