Redis instance deployment method and related device
By obtaining physical host resource data and Redis deployment rules, and automatically selecting and deploying Redis instances, the problem of long deployment cycles caused by manually specifying nodes in the existing technology is solved, and the automated deployment of Redis instances is realized, improving efficiency and system robustness.
Patent Information
- Application Number
- CN202411234795.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-10
AI Technical Summary
The existing Redis instance deployment method requires manual specification of physical nodes, resulting in a long delivery cycle and cannot meet the fast response needs of the business layer.
By obtaining the host resource data in the physical host resource pool and the deployment rules of the Redis instance, automatically selecting the target physical host for deployment, realizing the automated deployment of the Redis instance.
It improves deployment efficiency, shortens delivery time, meets the business layer's rapid response needs, and ensures load balancing of physical host resources and system robustness.
Smart Images

Figure CN119105771A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a Redis instance deployment method and related devices. Background Art
[0002] As a non-relational database (Not Only SQL, NoSQL) basic team, we provide Redis services for the business layer. Specifically, we can deploy Redis instances to enable the business layer to write, store, and read data.
[0003] In actual applications, although there are some automated scripts for the deployment of Redis instances, key steps such as the selection of physical nodes still require manual intervention during the implementation of the deployment, that is, physical nodes need to be manually specified. Among them, the physical node is used to indicate the physical host, and the deployment of the Redis instance is to deploy the Redis instance on a specific physical host. Under this deployment method, the delivery cycle of the Redis instance is long, and the response to the business layer requirements is not timely, which makes it difficult to meet the needs of the business layer. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a Redis instance deployment method and related devices, which are conducive to improving deployment efficiency.
[0005] The embodiments of the present application disclose the following technical solutions:
[0006] On the one hand, an embodiment of the present application provides a Redis instance deployment method, the method comprising:
[0007] In response to a service instance deployment request, obtaining a Redis instance indicated by the service instance deployment request, and obtaining host resource data corresponding to a plurality of physical hosts in a physical host resource pool, wherein the host resource data is used to indicate a resource load condition of the physical host;
[0008] Determine a target physical host corresponding to the Redis instance based on the host resource data corresponding to the multiple physical hosts and the deployment rules corresponding to the Redis instance;
[0009] The Redis instance is deployed through the target physical host.
[0010] On the other hand, an embodiment of the present application provides a Redis instance deployment device, the device comprising an acquisition unit, a determination unit and a deployment unit:
[0011] The acquisition unit is used to respond to the service instance deployment request, acquire the Redis instance indicated by the service instance deployment request, and acquire host resource data corresponding to multiple physical hosts in the physical host resource pool, wherein the host resource data is used to indicate the resource load of the physical host;
[0012] The determining unit is used to determine the target physical host corresponding to the Redis instance based on the host resource data corresponding to the multiple physical hosts respectively and the deployment rules corresponding to the Redis instance;
[0013] The deployment unit is used to deploy the Redis instance through the target physical host.
[0014] In another aspect, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:
[0015] The memory is used to store program code and transmit the program code to the processor;
[0016] The processor is used to execute the Redis instance deployment method described in the above aspects according to the instructions in the program code.
[0017] It can be seen from the above technical solution that in response to the service instance deployment request, the Redis instance indicated by the service instance deployment request is first obtained, and the host resource data corresponding to the multiple physical hosts in the physical host resource pool are obtained. Among them, the Redis instance can refer to the service instance to be deployed, and the host resource data is used to indicate the resource load of the physical host. Then, based on the host resource data corresponding to the multiple physical hosts and the deployment rules corresponding to the Redis instance, the target physical host corresponding to the Redis instance is determined. Due to the differences in the working modes of different Redis instances, the relevant requirements in the deployment stage are also different. In this regard, by setting the deployment rules of the Redis instance, the differences between different Redis instances are compatible, so as to achieve the purpose of automatic deployment of Redis instances and improve the deployment efficiency. It can be seen that for the Redis instance, the deployment rules at the Redis instance level and the resource load at the physical host level are comprehensively considered to realize the automatic selection of physical nodes. Because of the combination of these two aspects, the differences between different Redis instances can be compatible, and it is conducive to ensuring the resource load balancing of the physical host, so as to improve the robustness of the system in subsequent work. Finally, after determining the target physical host, the Redis instance can be deployed through the target physical host. Based on this, the automatic deployment of Redis instances is completed, especially the selection of physical nodes, which no longer requires manual specification, thus helping to improve deployment efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 A flowchart of a Redis instance deployment method provided in an embodiment of the present application;
[0020] Figure 2 A structural diagram of a Redis instance deployment device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0022] The Redis instance deployment method provided in the embodiment of the present application can be implemented by a computer device, which can be a terminal device or a server, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, etc. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this.
[0023] The specific examples are as follows:
[0024] Figure 1 A flowchart of a Redis instance deployment method provided in an embodiment of the present application is provided, and a server is used as the aforementioned computer device as an example for explanation. The method includes S101-S103:
[0025] S101: In response to a service instance deployment request, obtain a Redis instance indicated by the service instance deployment request, and obtain host resource data corresponding to a plurality of physical hosts in a physical host resource pool.
[0026] When a service instance needs to be deployed, automated deployment can be triggered based on a service instance deployment request. First, in response to the service instance deployment request, the Redis instance to be deployed and the host resource data corresponding to each physical host in the physical host resource pool can be obtained, wherein the host resource data is used to indicate the resource load of the physical host.
[0027] It should be noted that this application does not impose any limitation on the specific settings of the host resource data.
[0028] For ease of understanding, the present application provides the following examples as examples:
[0029] In one possible implementation, the host resource data may include the memory (total memory, currently available memory, occupied memory, etc.), central processing unit (CPU), load and other indicator data of the physical host. Based on this, the resource load of the physical host can be analyzed more comprehensively to determine whether there are sufficient resources to deploy the aforementioned Redis instance.
[0030] In actual applications, Redis instances are used to implement the writing and reading of business data, which involves the transmission of business data. Therefore, in another possible implementation method, the host resource data may also include the Transmission Control Protocol (TCP) of the physical host. Based on this, it is possible to more comprehensively analyze whether the data transmission and other conditions of the physical host are compatible with the Redis instance to be deployed, thereby determining whether it is suitable for deploying the aforementioned Redis instance.
[0031] In addition, the host resource data may also include the disk and system log of the physical host, so as to reflect the current operation status of the physical host, so as to more comprehensively analyze whether it is suitable for deploying the aforementioned Redis instance.
[0032] It should also be noted that the present application does not impose any limitation on how to obtain the host resource data. For ease of understanding, the present application embodiment also provides the following method as an example:
[0033] In a possible implementation, host resource data corresponding to a plurality of physical hosts in a physical host resource pool may be obtained from a storage component, wherein the storage component is used to receive the host resource data corresponding to the physical host returned by the physical host.
[0034] Based on this, the host resource data is stored using storage components, so that it can be obtained more quickly when needed, which is conducive to improving efficiency.
[0035] The present application does not impose any limitation on the construction method of the storage component and the method of the physical host returning the host resource data. For ease of understanding, the present application provides the following methods as examples:
[0036] Tools based on distributed service discovery and configuration (such as Consul) have a key-value storage function, also known as a KV storage function. Therefore, in one possible implementation, Consul can be used as the aforementioned storage component. In addition, Consul also has functions such as service discovery, multi-data center, health check, and service grid. Its service discovery and health check (in order to subsequently detect the status of the physical host) and KV storage functions are used in this application.
[0037] In addition, a Machine-Agent can be run on the physical host. This program runs on each physical host and is responsible for synchronizing the host resource data of the physical host to the aforementioned Consul in real time. For example, the synchronization of host resource data can be achieved by encapsulating the http interface. In addition, the Machine-Agent can also be used to be responsible for executing operations and other requests on the physical host (such as creating an instance, destroying an instance, etc.).
[0038] That is to say, in addition to obtaining the host resource data in response to the service instance deployment request in the aforementioned S101, the host resource data can also be synchronized to the storage component in real time through the Machine-Agent to facilitate subsequent detection of the physical host. For ease of understanding, the embodiment of the present application also provides the following example description:
[0039] In a possible implementation, the monitoring component can obtain host resource data corresponding to the physical host from the storage component, and then the monitoring component can detect the operating status of the physical host based on the obtained host resource data. Based on this, the operating status of the physical host can be detected in real time, so that relevant problems (such as excessive resource load, etc.) can be discovered in time.
[0040] In addition to detecting the status of the physical host, in another possible implementation, the status of the Redis instance deployed on the physical host can also be detected. In specific implementation, the physical host can also provide an instance indicator interface. Then, the instance indicator interface provided by the physical host can be called by the monitoring component to obtain the instance indicator data corresponding to the Redis instance deployed in the physical host. Then, the monitoring component can detect the status of the Redis instance deployed in the physical host based on the acquired instance indicator data. Based on this, the instance indicator data of the Redis instance deployed in the physical host is synchronized to the monitoring component through the instance indicator interface, and the status of the Redis instance is detected so that relevant problems (such as abnormal data synchronization between the master node and the slave node, etc.) can be discovered in a timely manner.
[0041] In actual applications, Stat can be run on the physical host. This program runs on each physical host and is responsible for collecting instance indicator data of the Redis instance on the physical host. Usually, the aforementioned instance indicator interface also corresponds to Stat.
[0042] It should also be noted that this application does not impose any limitation on the setting of instance indicator data. For ease of understanding, the following examples are provided in the embodiments of this application:
[0043] In a possible implementation, the instance indicator data of the Redis instance may include memory (such as the memory of the master node and the memory of the slave node), number of connections, inlet and outlet traffic, hit rate, command request, slow query, etc. Based on this, a comprehensive detection of the state of the Redis instance can be achieved.
[0044] In actual applications, on the basis of realizing detection, in order to be able to respond to abnormal problems in a timely manner, etc., an alarm strategy can also be configured. In specific implementation, the aforementioned monitoring components can be built based on the tool components of Prometheus+Alertmanager. Among them, Prometheus can be used to regularly capture indicator data (such as the aforementioned host resource data and instance indicator data), store it in the local database, and provide a powerful query language (PromQL) for data analysis and query to achieve the aforementioned detection. Alertmanager is a supporting component of Prometheus, which is used to process and send alarm notifications. Specifically, Alertmanager provides flexible alarm rules and notification configurations, which can trigger alarms according to changes in indicator data and predefined rules. Once an alarm is triggered, Alertmanager can make an alarm notification according to the configured notification method (such as email, etc.) to inform relevant personnel in a timely manner. In addition, Alertmanager also provides functions such as troubleshooting and silent alarms to ensure the accuracy and reliability of alarm notifications.
[0045] In the embodiment of the present application, the monitoring component built based on Prometheus+Alertmanager may include a control plane and a data plane, wherein the control plane is responsible for the detection and alarm of the physical host, and the data plane is responsible for the detection and alarm of the Redis instance (such as Redis master-slave switching, basic data, performance indicators, and the monitoring and alarm of the Redis process itself). Based on this, the physical host and the Redis instance are distinguished, the interference of the detection and alarm of the two is reduced, and the accuracy and reliability of the detection and alarm are improved.
[0046] S102: Determine a target physical host corresponding to the Redis instance based on host resource data corresponding to the multiple physical hosts and deployment rules corresponding to the Redis instance.
[0047] In actual applications, different Redis instances have different working modes, etc., which leads to different requirements in the deployment phase. This difference is also one of the reasons why manual intervention is required to select physical nodes in related technologies. In this regard, in this application, by setting the deployment rules of Redis instances, the differences between different Redis instances can be accommodated, so that the automated deployment method provided by this application can be used for different Redis instances, thereby improving deployment efficiency. Specifically:
[0048] The deployment rules at the Redis instance level and the resource load at the physical host level can be comprehensively considered to achieve automatic selection of physical nodes for Redis instances. That is, the aforementioned target physical host is the physical node selected for the Redis instance. It is precisely because of the combination of these two aspects that it is compatible with the differences between different Redis instances and is conducive to ensuring the resource load balancing of the physical host, which is conducive to improving the robustness of the system in subsequent work.
[0049] It should be noted that the application embodiment does not impose any limitation on how to select the target physical host in combination with the above two aspects. In practical applications, while satisfying the deployment rules, the physical host with the most idle resources can be preferentially selected as the target physical host, thereby protecting the resource load balance between the various physical nodes, and being more conducive to improving the overall robustness of the physical host resource pool.
[0050] It should also be noted that this application does not make any restrictions on the deployment rules corresponding to the Redis instance. In practical applications, it can be flexibly set according to actual needs. In practical applications, common Redis instances can include two types: Redis master-slave instances and Redis cluster instances. For ease of understanding, the embodiments of this application provide the following methods as examples for these two types of instances:
[0051] A Redis master-slave instance refers to a Redis with a master node (Master) corresponding to N (N>=1) slave nodes (Replication) architecture. Usually, the Master is responsible for writing data and the Replication is responsible for reading data, thereby achieving read-write separation in business.
[0052] In order to ensure business continuity and instance robustness, in a possible implementation, if the Redis instance is a Redis master-slave instance, the Redis master-slave instance includes a master node and at least one slave node, then the aforementioned deployment rule is used to indicate that the master node and the slave node in the Redis master-slave instance are deployed on different physical hosts, the master node is used to process data write requests, the slave node is used to replicate data stored in the master node, and the slave node is used to process data read requests.
[0053] Based on this, for the Redis master-slave instance, when automatically selecting physical nodes, the master node and the slave node are restricted to be deployed on different physical hosts based on the deployment rules, thereby improving compatibility with fault conditions. For example, if the physical host where the master node is deployed fails and causes the master node to be unavailable, the slave nodes deployed on other physical hosts will not be affected. Correspondingly, for fault compatibility, the embodiments of the present application provide the following methods:
[0054] If there are multiple slave nodes in the Redis master-slave instance, since the slave nodes copy data from the master node, that is, the slave nodes store a certain amount of data from the master node, therefore, when the master node in the Redis master-slave instance fails, in response to the failure of the master node, the data offsets corresponding to the multiple slave nodes can be obtained respectively, and the data offsets are used to indicate the difference between the data stored in the slave node and the data stored in the master node, and then the slave node with the smallest data offset can be determined as the new master node.
[0055] Based on this, when the Master fails, Replication can be promoted to the new Master to ensure business continuity and instance robustness. In actual applications, the status of the Redis instance can be detected and alarmed based on the aforementioned monitoring components to determine whether the master node has failed.
[0056] And, Redis cluster instance, also known as Redis Cluster instance or distributed Redis Cluster, is a distributed data storage solution for open source Redis. A Redis cluster instance usually contains multiple groups of shards, each group of shards is responsible for reading and writing part of the data, and each group of shards has a master node (Master) and at least one slave node (Replication).
[0057] Correspondingly, in a possible implementation, if the Redis instance is a Redis cluster instance, the Redis cluster instance includes multiple groups of shards, each group of shards includes a master node and at least one slave node, then the aforementioned deployment rule is used to indicate that the ratio between the number of deployments and the total number of master nodes included in the Redis cluster instance is less than a preset threshold, the number of deployments is the number of master nodes of the Redis cluster instance deployed on a physical host, and the master nodes and slave nodes in each group of shards are deployed on different physical hosts, the master node in each group of shards is used to process data write requests and data read requests, and the slave nodes in each group of shards are used to copy the data stored in the master node of each group of shards. It can be seen that in the Redis cluster instance, the master node is responsible for data reading and writing, and the slave node is responsible for copying data from the master node, playing the role of data backup. Based on this, when the master node fails, etc., the slave node can be pulled up as a new master node to ensure data security, etc.
[0058] Based on this, by limiting the number of master nodes deployed on the same physical host, we can avoid the situation where all master nodes deployed on a physical host are unavailable due to a physical host failure. In addition, for each group of shards, the master node and the slave node are also deployed on different physical hosts to better accommodate failures and ensure data security.
[0059] In actual applications, a condition for a Redis cluster instance to provide services is that most of the master nodes in the Redis cluster instance are available. Therefore, the aforementioned preset threshold can be set to 0.5, so that more than half of the master nodes are not deployed on the same physical host, so as to reduce the situation where most of the master nodes are unavailable at the same time.
[0060] It is understandable that, similar to the Redis master-slave instance, after a master node in a Redis cluster instance fails, a slave node can be promoted from other slave nodes in the shard to which the master node belongs as a new master node to ensure the consistency of business data. For details, please refer to the description of the above embodiment, which will not be repeated here.
[0061] S103: Deploy a Redis instance through a target physical host.
[0062] Finally, the Redis instance can be deployed through the target physical host. Based on this, the automatic deployment of the Redis instance can be completed, especially the selection of physical nodes, which no longer requires manual specification, thereby improving deployment efficiency, shortening instance delivery time, etc., and better meeting business needs.
[0063] It can be seen from the above technical solution that in response to the service instance deployment request, the Redis instance indicated by the service instance deployment request is first obtained, and the host resource data corresponding to the multiple physical hosts in the physical host resource pool are obtained. Among them, the Redis instance can refer to the service instance to be deployed, and the host resource data is used to indicate the resource load of the physical host. Then, based on the host resource data corresponding to the multiple physical hosts and the deployment rules corresponding to the Redis instance, the target physical host corresponding to the Redis instance is determined. Due to the differences in the working modes of different Redis instances, the relevant requirements in the deployment stage are also different. In this regard, by setting the deployment rules of the Redis instance, the differences between different Redis instances are compatible, so as to achieve the purpose of automatic deployment of Redis instances and improve the deployment efficiency. It can be seen that for the Redis instance, the deployment rules at the Redis instance level and the resource load at the physical host level are comprehensively considered to realize the automatic selection of physical nodes. Because of the combination of these two aspects, the differences between different Redis instances can be compatible, and it is conducive to ensuring the resource load balancing of the physical host, so as to improve the robustness of the system in subsequent work. Finally, after determining the target physical host, the Redis instance can be deployed through the target physical host. Based on this, the automatic deployment of Redis instances is completed, especially the selection of physical nodes, which no longer requires manual specification, thus helping to improve deployment efficiency.
[0064] In addition, the embodiment of the present application also provides a hybrid deployment method, specifically:
[0065] The Redis instance deployment provided in the embodiment of the present application can be applied to a Redis instance hybrid deployment system, where the number of the aforementioned Redis instances is multiple, and the multiple Redis instances include multiple Redis master-slave instances and multiple Redis cluster instances. In the hybrid deployment, in order to ensure the correctness of the business use, in response to the successful deployment of multiple Redis instances, multiple first service interfaces and multiple second service interfaces can also be provided. Among them, a first service interface corresponds to a Redis master-slave instance, and different Redis master-slave instances correspond to different first service interfaces, and a second service interface corresponds to a Redis cluster instance, and different Redis cluster instances correspond to different second service interfaces.
[0066] It can be seen that hybrid deployment refers to hybrid deployment of two types of Redis instances, and the number of each type of Redis instances is multiple, specifically, all Redis instances share a physical host resource pool, so that fewer machines (physical hosts) can be used to implement the scheduling and orchestration of multiple instances. On this basis, after successful deployment, an instance corresponds to a service interface of its own, so that during the business use phase, the data to be written or the data to be read can be transmitted through the service interface, thereby avoiding conflicts between data of different instances and ensuring the correctness of business use.
[0067] In a hybrid deployment mode, in order to facilitate better deployment and management of multiple different types of Redis instances, in a possible implementation mode, a Redis master-slave control plane is configured for Redis master-slave instances, and a Redis cluster control plane is configured for Redis cluster instances. In a hybrid deployment mode, the Redis instances deployed on the same physical host may include these two types of instances, so a master-slave agent (Redis-Agent) and a cluster agent (Cluster-Agent) are configured on the physical host.
[0068] Specific:
[0069] The Redis master-slave control plane is responsible for the creation of Redis master-slave instances, health monitoring and fault handling, and instance life cycle management (runtime configuration updates, vertical expansion, instance recycling, etc.).
[0070] The Redis cluster control plane is responsible for creating Redis cluster instances, checking cluster status, instance health monitoring and fault handling, vertical / horizontal expansion, and instance lifecycle management.
[0071] The master-slave agent (Redis-Agent) runs on each physical host and is responsible for handling the creation and recovery of Redis master-slave instances from the master-slave control plane, as well as the backoff mechanism when the Machine-Agent on this physical host is unavailable.
[0072] Cluster-Agent, this program runs on each physical host and is responsible for processing requests from the cluster control plane to create and destroy Redis-Server and update the Redis-Server view of this physical host. For creation requests, first request Machine-Agent to check whether the resources of this physical host meet the requirements. If they meet the requirements, directly create Redis-Server on this physical host and return the results to the cluster control plane. And, for the shutdown request of Redis-Server, directly destroy the corresponding instance to release resources. In addition, the Redis-Server instance on this physical host can be updated to Consul at regular intervals.
[0073] Based on this, in the hybrid deployment mode, by distinguishing the two types of instances and configuring their corresponding control planes and agents, it is conducive to better instance deployment and management.
[0074] In addition, in order to better meet business needs, Redis instances can also support elastic expansion. Specifically, the Redis master-slave expansion capability is supported by the Redis master-slave control plane, and the entire expansion process is completed automatically, mainly including expanding the number of slave nodes in the master-slave instance. The Redis cluster expansion capability is jointly completed by the Redis cluster control plane and the data migration service Reshard. The cluster control plane is responsible for generating data migration rules, and Reshard is responsible for the migration of specific data. There is a degradation protection mechanism during the data migration process to protect the integrity of the data during the entire migration process. Based on this, the business-unaware cluster horizontal expansion can be achieved during runtime to improve the system's throughput and scalability.
[0075] In addition, the related technologies rely on manual intervention to implement instance deployment. From the perspective of actual operation and maintenance, this approach is complex, labor-intensive and error-prone, and failures are not handled in a timely manner. In this regard, the present application implements automated deployment on the one hand, and can detect related problems in a timely manner based on indicator data detection and alarms on the other hand.
[0076] And the entire life cycle of the instance can be completed automatically. For example, for Redis master-slave instances, the high availability of the instance itself is completed by the master-slave control plane, and there is no need to introduce Redis Sentinel, which can only do failover. The master-slave control plane can handle instance configuration changes, vertical scaling, and life cycle management, which helps reduce maintenance costs. Among them, Redis Sentinel exists independently of the Redis instance and can manage the Master-Replication instance group. When the Master fails, it can complete the automatic transfer work to ensure the continuity and availability of the system.
[0077] In addition, for Redis cluster instances, the cluster control plane completes the high availability, horizontal expansion, configuration changes, and lifecycle management of the cluster instance itself. For example, horizontal expansion, calculation of the number of new shards required, node selection, recalculation of cluster topology, and data migration are all automatically completed by the cluster control plane without human intervention. Based on this, it can effectively reduce human involvement and save maintenance costs.
[0078] It can be understood that it basically corresponds to the method embodiment, so the relevant parts can refer to the partial description of the method embodiment.
[0079] Figure 2 A structural diagram of a Redis instance deployment device provided in an embodiment of the present application, wherein the device includes an acquisition unit 201, a determination unit 202, and a deployment unit 203:
[0080] The acquisition unit 201 is used to respond to the service instance deployment request, acquire the Redis instance indicated by the service instance deployment request, and acquire host resource data corresponding to multiple physical hosts in the physical host resource pool, wherein the host resource data is used to indicate the resource load of the physical host;
[0081] The determining unit 202 is used to determine the target physical host corresponding to the Redis instance based on the host resource data corresponding to the multiple physical hosts and the deployment rules corresponding to the Redis instance;
[0082] The deployment unit 203 is used to deploy the Redis instance through the target physical host.
[0083] In a possible implementation manner, the acquiring unit is further configured to:
[0084] The host resource data respectively corresponding to the multiple physical hosts in the physical host resource pool are obtained from a storage component, and the storage component is used to receive the host resource data corresponding to the physical host returned by the physical host.
[0085] In a possible implementation manner, the acquiring unit is further configured to:
[0086] Acquire host resource data corresponding to the physical host from the storage component through the monitoring component;
[0087] The monitoring component detects the operating status of the physical host based on the acquired host resource data.
[0088] In a possible implementation manner, the physical host provides an instance indicator interface, and the acquisition unit is further used to:
[0089] Calling the instance indicator interface provided by the physical host through the monitoring component to obtain instance indicator data corresponding to the Redis instance deployed in the physical host;
[0090] The monitoring component detects the status of the Redis instance deployed in the physical host based on the acquired instance indicator data.
[0091] In one possible implementation, if the Redis instance is a Redis master-slave instance, the Redis master-slave instance includes a master node and at least one slave node, the deployment rule is used to indicate that the master node and the slave node in the Redis master-slave instance are deployed on different physical hosts, the master node is used to process data write requests, the slave node is used to copy data stored in the master node, and the slave node is used to process data read requests.
[0092] In a possible implementation manner, if the number of the slave nodes is multiple, the determining unit is further configured to:
[0093] In response to a failure of the master node, obtaining data offsets respectively corresponding to the plurality of slave nodes, the data offsets being used to indicate a difference between data stored in the slave node and data stored in the master node;
[0094] The slave node with the smallest data offset is determined as the new master node.
[0095] In a possible implementation, if the Redis instance is a Redis cluster instance, the Redis cluster instance includes multiple groups of shards, each group of shards includes a master node and at least one slave node, the deployment rule is used to indicate that the ratio between the deployment quantity and the total number of master nodes included in the Redis cluster instance is less than a preset threshold, the deployment quantity is the number of master nodes of the Redis cluster instance deployed on a physical host, and the master nodes and slave nodes in each group of shards are deployed on different physical hosts, the master node in each group of shards is used to process data write requests and data read requests, and the slave nodes in each group of shards are used to replicate the data stored in the master node of each group of shards.
[0096] In a possible implementation, the method is applied to a Redis instance hybrid deployment system, the number of the Redis instances is multiple, the multiple Redis instances include multiple Redis master-slave instances and multiple Redis cluster instances, and the determination unit is further used to:
[0097] In response to the successful deployment of multiple Redis instances, multiple first service interfaces and multiple second service interfaces are provided, one first service interface corresponds to one Redis master-slave instance, and different Redis master-slave instances correspond to different first service interfaces, one second service interface corresponds to one Redis cluster instance, and different Redis cluster instances correspond to different second service interfaces.
[0098] It can be seen from the above technical solution that in response to the service instance deployment request, the Redis instance indicated by the service instance deployment request is first obtained, and the host resource data corresponding to the multiple physical hosts in the physical host resource pool are obtained. Among them, the Redis instance can refer to the service instance to be deployed, and the host resource data is used to indicate the resource load of the physical host. Then, based on the host resource data corresponding to the multiple physical hosts and the deployment rules corresponding to the Redis instance, the target physical host corresponding to the Redis instance is determined. Due to the differences in the working modes of different Redis instances, the relevant requirements in the deployment stage are also different. In this regard, by setting the deployment rules of the Redis instance, the differences between different Redis instances are compatible, so as to achieve the purpose of automatic deployment of Redis instances and improve the deployment efficiency. It can be seen that for the Redis instance, the deployment rules at the Redis instance level and the resource load at the physical host level are comprehensively considered to realize the automatic selection of physical nodes. Because of the combination of these two aspects, the differences between different Redis instances can be compatible, and it is conducive to ensuring the resource load balancing of the physical host, so as to improve the robustness of the system in subsequent work. Finally, after determining the target physical host, the Redis instance can be deployed through the target physical host. Based on this, the automatic deployment of Redis instances is completed, especially the selection of physical nodes, which no longer requires manual specification, thus helping to improve deployment efficiency.
[0099] In another aspect, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:
[0100] The memory is used to store program code and transmit the program code to the processor;
[0101] The processor is used to execute the Redis instance deployment method provided in the above embodiment according to the instructions in the program code.
[0102] The computer device may include a terminal device or a server, and the aforementioned Redis instance deployment apparatus may be configured in the computer device.
[0103] On the other hand, an embodiment of the present application further provides a storage medium, wherein the storage medium is used to store a computer program, and the computer program is used to execute the Redis instance deployment method provided in the above embodiment.
[0104] In addition, an embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the Redis instance deployment method provided in the above embodiment.
[0105] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, the above program can be stored in a computer-readable storage medium, and when the program is executed, it executes the steps of the above method embodiment; and the above storage medium can be at least one of the following media: read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc., various media that can store program codes.
[0106] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0107] It should be noted that, in this article, relational terms such as "first" and "second", etc. (if any) are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0108] The above is a detailed introduction to a Redis instance deployment method and related devices provided by the embodiment of the present application. The principle and implementation method of the present application are described in detail using specific examples herein. The description of the above embodiments is only used to help understand the method of the present application. At the same time, for those skilled in the art, according to the method of the present application, there will be changes in the specific implementation method and application scope.
[0109] In summary, the content of this specification should not be understood as limiting the present application, and any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in this application should be included in the protection scope of this application. Moreover, based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations.
Claims
1. A Redis instance deployment method, It is characterized in that The method comprises: In response to a service instance deployment request, obtaining a Redis instance indicated by the service instance deployment request, and obtaining host resource data corresponding to a plurality of physical hosts in a physical host resource pool, wherein the host resource data is used to indicate a resource load condition of the physical host; Determine a target physical host corresponding to the Redis instance based on the host resource data corresponding to the multiple physical hosts and the deployment rules corresponding to the Redis instance; The Redis instance is deployed through the target physical host.
2. The method according to claim 1, It is characterized in that The obtaining of host resource data respectively corresponding to a plurality of physical hosts in the physical host resource pool includes: The host resource data respectively corresponding to the multiple physical hosts in the physical host resource pool are obtained from a storage component, and the storage component is used to receive the host resource data corresponding to the physical host returned by the physical host.
3. The method according to claim 2, It is characterized in that The method further comprises: Acquire host resource data corresponding to the physical host from the storage component through the monitoring component; The monitoring component detects the operating status of the physical host based on the acquired host resource data.
4. The method according to claim 3, It is characterized in that The physical host provides an instance indicator interface, and the method further includes: Calling the instance indicator interface provided by the physical host through the monitoring component to obtain instance indicator data corresponding to the Redis instance deployed in the physical host; The monitoring component detects the status of the Redis instance deployed in the physical host based on the acquired instance indicator data.
5. The method according to claim 1, It is characterized in that If the Redis instance is a Redis master-slave instance, the Redis master-slave instance includes a master node and at least one slave node, the deployment rule is used to indicate that the master node and the slave node in the Redis master-slave instance are deployed on different physical hosts, the master node is used to process data write requests, the slave node is used to copy data stored in the master node, and the slave node is used to process data read requests.
6. The method according to claim 5, It is characterized in that If the number of the slave nodes is multiple, the method further includes: In response to a failure of the master node, obtaining data offsets respectively corresponding to the plurality of slave nodes, the data offsets being used to indicate a difference between data stored in the slave node and data stored in the master node; The slave node with the smallest data offset is determined as the new master node.
7. The method according to claim 1, It is characterized in that If the Redis instance is a Redis cluster instance, the Redis cluster instance includes multiple groups of shards, each group of shards includes a master node and at least one slave node, the deployment rule is used to indicate that the ratio between the deployment quantity and the total number of master nodes included in the Redis cluster instance is less than a preset threshold, the deployment quantity is the number of master nodes of the Redis cluster instance deployed on a physical host, and the master nodes and slave nodes in each group of shards are deployed on different physical hosts, the master node in each group of shards is used to process data write requests and data read requests, and the slave nodes in each group of shards are used to replicate data stored in the master node of each group of shards.
8. The method according to claim 1, It is characterized in that The method is applied to a Redis instance hybrid deployment system, where the number of the Redis instances is multiple, and the multiple Redis instances include multiple Redis master-slave instances and multiple Redis cluster instances. The method further includes: In response to the successful deployment of multiple Redis instances, multiple first service interfaces and multiple second service interfaces are provided, one first service interface corresponds to one Redis master-slave instance, and different Redis master-slave instances correspond to different first service interfaces, one second service interface corresponds to one Redis cluster instance, and different Redis cluster instances correspond to different second service interfaces.
9. A Redis instance deployment device, It is characterized in that The device comprises an acquisition unit, a determination unit and a deployment unit: The acquisition unit is used to respond to the service instance deployment request, acquire the Redis instance indicated by the service instance deployment request, and acquire host resource data corresponding to multiple physical hosts in the physical host resource pool, wherein the host resource data is used to indicate the resource load of the physical host; The determining unit is used to determine the target physical host corresponding to the Redis instance based on the host resource data corresponding to the multiple physical hosts respectively and the deployment rules corresponding to the Redis instance; The deployment unit is used to deploy the Redis instance through the target physical host.
10. A computer device, It is characterized in that The computer device comprises a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the method according to any one of claims 1 to 8 according to the instructions in the program code.
