Service component deployment method and device, equipment, storage medium and program product
By using the affinity information and resource usage information of service components in hybrid deployment scenarios, the most suitable physical machine is automatically selected for deployment, which solves the problems of long deployment time and low efficiency in the prior art and achieves efficient service component deployment.
Patent Information
- Application Number
- CN202411698630.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-05-06
AI Technical Summary
In hybrid deployment scenarios, the existing technology fails to effectively consider the insufficient physical machine resources, resulting in a long deployment time for service components and low deployment efficiency.
By determining the physical machine grouping that meets the deployment requirements based on the affinity information and resource usage information of the service components, and generating resource usage scores and residual resource scores, the most suitable physical machine is automatically selected for deployment.
It realizes automatic scheduling and deployment of service components, simplifies operational processes, reduces manual intervention, reduces operation and maintenance costs, and improves deployment efficiency.
Smart Images

Figure CN119938298A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cluster technology, and in particular to a deployment method, device, equipment, storage medium and program product of a service component. Background Art
[0002] For large-scale clusters, service components need to be deployed on physical machines in the cluster so that the cluster has the corresponding functions of the service components. In order to ensure the availability of service components, most service components will adopt a high-availability deployment form. High-availability deployment means that through a series of technologies and architectural designs, service components can continue to run for as long as possible.
[0003] In the process of service component deployment, there are two scenarios: the first is the scenario where the service component occupies the physical machine exclusively. In this scenario, there is no need to pay attention to the resource information of the physical machine, and the deployment can be carried out directly according to the deployment plan; the second is the scenario of mixed deployment, that is, multiple service components are deployed on one physical machine, and different service components often have different resource requirements for the physical machine. In the related art, in the mixed deployment scenario, the deployment method of the service component is to deploy it manually, or to deploy service components with similar resource requirements on the same physical machine; this method does not take into account the situation where the physical machine resources are insufficient. When the physical machine resources are insufficient, the service component is deployed on the physical machine, resulting in the squeezing of the use of resources of the existing service components on the physical machine. When the physical machine resources are insufficient, the service component needs to be deployed on other physical machines, which makes the deployment time longer and reduces the deployment efficiency. Summary of the invention
[0004] In view of this, the present invention provides a method, apparatus, device, storage medium and program product for deploying a service component to solve the problem of long deployment time and reduced deployment efficiency.
[0005] In a first aspect, the present invention provides a method for deploying a service component, comprising: determining at least one physical machine grouping that meets the deployment requirements of the service component based on affinity information of the service component; generating a resource usage score based on resource usage information of the service component; the resource usage information is used to characterize the usage of physical resources of the physical machine on which the service component is to be deployed by the service component; obtaining remaining resource information of multiple physical machines in at least one physical machine grouping, and generating multiple remaining resource scores corresponding to the multiple physical machines respectively based on the remaining resource information to obtain a remaining resource score set; the remaining resource information is used to characterize the remaining resource situation of the physical machine; judging whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, and if there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, deploying the service component to the physical machine corresponding to the target remaining resource score.
[0006] The present invention first determines at least one physical machine group that meets the deployment requirements of the service component based on the affinity information of the service component, preliminarily selects the physical machine group that meets the deployment requirements of the service component, and selects a physical machine from the physical machine group that meets the deployment requirements of the service component for deployment. There is no need to select from all physical machines later, which simplifies the operation and improves the deployment efficiency. The present invention generates a resource usage score based on the resource usage information of the service component, generates multiple remaining resource scores corresponding to the multiple physical machines respectively based on the remaining resource information of the multiple physical machines in at least one physical machine group, obtains a remaining resource score set, compares the multiple remaining resource scores in the remaining resource score set with the resource usage score, obtains the target remaining resource score of the physical resources that meet the deployment requirements of the service component, and deploys the service component to the physical machine corresponding to the target remaining resource score, thereby realizing automatic scheduling and deployment of the service component. Compared with related technologies, the present invention automatically deploys service components, simplifies operating steps, reduces manual intervention, and reduces operation and maintenance costs. The present invention analyzes the physical resources required by the service components and the remaining physical resources of the physical machine to prevent the situation where the service components are deployed on a physical machine with insufficient physical resources, thereby reducing the deployment time of the service components and improving the deployment efficiency of the service components.
[0007] In an optional embodiment, the affinity information includes an affinity tag and / or an anti-affinity tag, and at least one physical machine grouping that meets the service component deployment requirements is determined based on the affinity information of the service component, including: if the affinity information includes an affinity tag and an anti-affinity tag, based on the affinity tag, selecting a first physical machine grouping corresponding to the affinity tag; based on the anti-affinity tag, selecting a second physical machine grouping other than the physical machine grouping corresponding to the anti-affinity tag; and the first physical machine grouping and the second physical machine grouping form at least one physical machine grouping that meets the service component deployment requirements.
[0008] The present invention quickly determines at least one physical machine grouping that meets the service component deployment requirements by setting affinity tags and anti-affinity tags, optimizes physical resource allocation, and preliminarily selects the physical machine grouping that meets the service component deployment requirements. Physical machines can be selected from the physical machine grouping that meets the service component deployment requirements for deployment, and there is no need to select from all physical machines subsequently, thereby simplifying operations and improving deployment efficiency.
[0009] In an optional embodiment, the resource usage information includes multiple physical resource quantities and multiple first priority parameters. A resource usage score is generated based on the resource usage information of the service component, including: multiplying the multiple physical resource quantities by the multiple first priority parameters corresponding to the multiple physical resource quantities to obtain multiple first multiplication results; and summing the multiple first multiplication results to generate a resource usage score.
[0010] The present invention determines the product of multiple physical resource quantities and multiple first priority parameters corresponding to the multiple physical resource quantities and then sums them to obtain a resource usage score, taking into account the multiple physical resources required for service component deployment and improving the accuracy of physical machine selection.
[0011] In an optional implementation, the remaining resource information includes multiple remaining resource quantities and multiple second priority parameters; based on the remaining resource information, multiple remaining resource scores corresponding to the multiple physical machines are generated to obtain a remaining resource score set, including: multiplying the multiple remaining resource quantities corresponding to each physical machine by the multiple second priority parameters corresponding to the multiple remaining resource quantities to obtain multiple second multiplication results; summing the multiple second multiplication results corresponding to each physical machine to generate multiple remaining resource scores, and the multiple remaining resource scores constitute a remaining resource score set.
[0012] In an optional implementation, deploying the service component on a physical machine corresponding to the target remaining resource score includes: if there are multiple target remaining resource scores, deploying the service component on a first target physical machine corresponding to the largest first target remaining resource score.
[0013] In the present invention, if there are multiple target remaining resource scores, the service component is deployed to the first target physical machine corresponding to the largest first target remaining resource score, ensuring that the selected physical machine is the most suitable physical machine for deploying the service component.
[0014] In an optional implementation, after the service component is deployed to the physical machine corresponding to the target remaining resource score, the method also includes: if the first target physical machine fails, determining whether the service component is a stateful service component; a stateful service component indicates a service component that stores data information in a local directory; if the service component is a stateful service component, executing a recovery command to back up the data information to a database, and deploying the service component to a second target physical machine; the second target physical machine is a physical machine corresponding to other target remaining resource scores except the first target remaining resource score among multiple target remaining resource scores; if the service component is a stateless service component, deploying the service component to the second target physical machine; a stateless service component is a service component that stores data information in a database or has no data information.
[0015] In the present invention, when a physical machine fails, it is determined whether the service component is a stateful service component that stores data information in a local directory. If so, a recovery command is executed to back up the data information to a database, and the service component is deployed to a second target physical machine that meets the deployment conditions other than the first target physical machine to achieve redeployment of the service component. If not, the service component can be directly deployed to the second target physical machine. In the related art, an alarm is sent after the service component is detected to be abnormal. The recovery of the service component requires manual selection of a physical machine for redeployment. If the physical machine is not selected properly, the use of the physical resources of the existing service component will be squeezed. The present invention adopts the form of automatic deployment to quickly find a physical machine that meets the physical resource requirements of the service component, and redeploy the service component on the new physical machine to restore the operation of the service component, greatly reducing the cost of manual operation and maintenance. The present invention is provided with different processing strategies for stateful service components and stateless service components, which can cope with different demand scenarios, meet the demand for automatic recovery of service components in different business scenarios, and improve the reliability and availability of service components.
[0016] In a second aspect, the present invention provides a deployment device for a service component, comprising: a physical machine grouping module, used to determine at least one physical machine grouping that meets the deployment requirements of the service component based on the affinity information of the service component; a resource usage score generation module, used to generate a resource usage score based on the resource usage information of the service component; the resource usage information is used to characterize the usage of the physical resources of the physical machine on which the service component is to be deployed by the service component; a remaining resource score set determination module, used to obtain the remaining resource information of multiple physical machines in at least one physical machine group, and generate multiple remaining resource scores corresponding to the multiple physical machines respectively based on the remaining resource information to obtain a remaining resource score set; the remaining resource information is used to characterize the remaining resource situation of the physical machine; a service component configuration module, used to determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, and according to the presence of a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, deploy the service component to the physical machine corresponding to the target remaining resource score.
[0017] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method for deploying service components of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0018] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for deploying a service component of the first aspect or any corresponding embodiment thereof.
[0019] In a fifth aspect, the present invention provides a computer program product, including computer instructions, which are used to enable a computer to execute the method for deploying service components of the above-mentioned first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 is a flow chart of a method for deploying a service component according to an embodiment of the present invention;
[0022] Figure 2 is a schematic diagram of a physical machine grouping structure according to an embodiment of the present invention;
[0023] Figure 3 is a flow chart of a deployment method of another service component according to an embodiment of the present invention;
[0024] Figure 4 is a flow chart of another method for deploying a service component according to an embodiment of the present invention;
[0025] Figure 5 is a flow chart of a method for deploying another service component according to an embodiment of the present invention;
[0026] Figure 6 is a structural block diagram of a deployment device for a service component according to an embodiment of the present invention;
[0027] Figure 7 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0029] For large-scale clusters, in order to ensure the availability of service components, all service components will be deployed in a highly available manner. High availability (HA) deployment means that a series of technologies and architectural designs are used to enable the system or service components to continue to run for as long as possible. For scenarios where service components exclusively occupy physical machines, there is no need to pay attention to the physical resource information of the physical machine. After planning the service components, they can be deployed directly. However, for mixed deployment scenarios, for example, multiple service components are deployed on a physical machine, and each service component has different resource requirements for the physical machine, deployment planning needs to be done in advance before deployment. In related technologies, in mixed deployment scenarios, there are two ways to deploy service components. The first is to manually deploy service components. This method is complex to operate, has high manual operation and maintenance costs, is inefficient, and is prone to errors. The second method is to deploy service components with similar resource requirements on the same physical machine. This method does not take into account the situation where the physical machine resources are insufficient. When the physical machine resources are insufficient, the service components are deployed on the physical machine, which causes the use of resources of the existing service components on the physical machine to be squeezed. When the physical machine resources are insufficient, the service components need to be deployed on other physical machines, which takes a long time to deploy and reduces the deployment efficiency.
[0030] Even if all service components can be reasonably allocated to appropriate physical machines in the cluster during the deployment phase, as the usage of physical resources of the physical machines increases, when a physical machine fails, the service components need to be migrated to other physical machines. If the physical machines are not selected appropriately using the service component deployment method in related technologies, the physical resources of existing service components will be squeezed, resulting in a longer deployment time and low deployment efficiency.
[0031] An embodiment of the present invention provides a method for deploying a service component, which selects a physical machine group that meets the service component deployment requirements and deploys the service component based on a judgment of a remaining resource score and a resource usage score, so as to achieve the effect of improving deployment efficiency.
[0032] According to an embodiment of the present invention, a deployment method embodiment of a service component is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0033] In this embodiment, a method for deploying a service component is provided, which can be used in a computer device. Figure 1 is a flow chart of a method for deploying a service component according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0034] Step S101: determining at least one physical machine group that meets the deployment requirements of the service component according to the affinity information of the service component.
[0035] The affinity information includes affinity tags and / or anti-affinity tags. Both affinity tags and anti-affinity tags have corresponding physical groups. The physical group corresponding to the affinity tag indicates that the service component will be deployed on the physical machine in the physical group. The physical group corresponding to the anti-affinity tag indicates that the service component will be deployed on the physical machine in other physical groups except the physical group. Meeting the service component deployment requirements in this embodiment means that there is affinity between the physical machines in the determined physical machine group and the current service component (or service).
[0036] In some optional embodiments, the affinity information of different service components is different. For example, the service components in this embodiment may include but are not limited to a first service component, a second service component and a third service component. The affinity information of the first service component only includes an affinity tag, the affinity information of the second service component only includes an anti-affinity tag, and the affinity information of the third service component includes an affinity tag and an anti-affinity tag.
[0037] In some optional embodiments, a service component may include multiple services. For example, the service component may be a cloud database management system (PostgreSQL). When deploying the cloud database PostgreSQL, the services that need to be deployed include the PostgreSQL database service, the backup and recovery component (Backrest) service, and the proxy service used by users to connect to the database.
[0038] In the embodiment of the present invention, before deploying the service components, it is necessary to register and group the physical machines, such as Figure 2As shown in the figure, it is a schematic diagram of the physical machine grouping structure. First, the control module needs to be deployed on a server outside the cluster, and ensure that the control module can connect to all physical machines in the cluster through the encryption protocol (Secure Shell, SSH) interface without secrets. Register all physical machines in the cluster, and send the physical machine identifier, encryption protocol port, and grouping information to the control module so that the control module can manage the physical machines.
[0039] Among them, all physical machines in the cluster are grouped. Physical machines can be grouped according to their functions, such as Figure 2 As shown, the physical machine grouping includes: control-panel, storage panel (store-panel) and value-added panel (value-added-panel). In addition, more groups can be set according to needs, such as compute panel (compute-panel), etc. Each physical machine group includes multiple physical machines.
[0040] Exemplarily, when deploying the cloud database PostgreSQL, affinity information is set for the PostgreSQL database service, the backup and recovery component service, and the proxy service. For the PostgreSQL database service: an affinity label is set, and the corresponding physical machine group is the storage panel; for the backup and recovery component service: an affinity label is set, and the corresponding physical machine group is the value-added panel; for the proxy service: an anti-affinity label is set, and the corresponding physical machine group is the value-added panel. Then, the PostgreSQL database service will be deployed on the physical machine corresponding to the storage panel, the backup and recovery component service will be deployed on the physical machine corresponding to the value-added panel, and the proxy service will be deployed on the physical machine corresponding to the physical machine group other than the value-added panel, that is, the proxy service will be deployed on the physical machine corresponding to the storage panel and the control panel. Therefore, when deploying the cloud database PostgreSQL, it will be deployed on the physical machines corresponding to the storage panel, the control panel, and the value-added panel.
[0041] Step S102, generating a resource usage score according to the resource usage information of the service component; the resource usage information is used to characterize the usage of the physical resources of the physical machine on which the service component is to be deployed by the service component.
[0042] Among them, resource usage information refers to the occupation of physical resources by service components. For example, the resource usage information is the usage of physical resources required for service component deployment set in advance by the user and the priority parameters corresponding to the physical resources. Therefore, the resource usage score may include multiple physical resource quantities and multiple first priority parameters. The larger the physical resources required for service component deployment, the larger the value of the first priority parameter can be set.
[0043] For example, for the service component of the cloud database PostgreSQL of 4C8G500G (4 cores, 8GB memory, 500G disk), the physical resources required include the central processing unit (CPU), memory (MEM), and disk, etc. The first priority parameter is set to 25 for the central processing unit, 50 for the memory, and 25 for the disk.
[0044] In some optional implementations, a resource usage score is generated based on the resource usage information of the service component, including: multiplying the quantities of multiple physical resources by multiple first priority parameters corresponding to the quantities of the multiple physical resources to obtain multiple first multiplication results; and summing the multiple first multiplication results to generate a resource usage score.
[0045] For example, for the service component of the PostgreSQL cloud database of 4C8G500G, the formula for calculating the resource usage score is:
[0046] S1=CPU_cnt*CPU_priority+MEM_cnt*MEM_priority+Disk_capacity
[0047] *Disk_priorigy;
[0048] Among them, S1 is the resource usage score, CPU_cnt is the number of central processors, CPU_priority is the central processor priority parameter, MEM_cnt is the number of memories, MEM_priority is the memory priority parameter, Disk_capacity is the number of disks, and Disk_priorigy is the disk priority parameter.
[0049] Step S103, obtaining the remaining resource information of multiple physical machines in at least one physical machine group, generating multiple remaining resource scores corresponding to the multiple physical machines respectively according to the remaining resource information, and obtaining a remaining resource score set; the remaining resource information is used to characterize the remaining resource situation of the physical machine.
[0050] Among them, the remaining resource information includes multiple remaining resource quantities and multiple second priority parameters. The remaining resource information is stored and managed by the management and control module. The larger the remaining amount of the remaining resource, the larger the second priority parameter; the remaining resource score set can be composed of multiple generated remaining resource scores.
[0051] In this embodiment, the multiple physical machines in at least one physical machine group may be all the physical machines respectively included in each determined physical machine group. The remaining resource score and the remaining resource information may be positively correlated. For example, the larger the remaining amount of resources on the physical machine corresponding to the remaining resource information, the higher the remaining resource score tends to be, and the smaller the remaining amount of resources on the physical machine corresponding to the remaining resource information, the lower the remaining resource score tends to be.
[0052] In some optional embodiments, based on the remaining resource information, multiple remaining resource scores corresponding to the multiple physical machines are generated to obtain a remaining resource score set, including: multiplying the multiple remaining resource quantities corresponding to each physical machine by the multiple second priority parameters corresponding to the multiple remaining resource quantities to obtain multiple second product results; summing the multiple second product results corresponding to each physical machine to generate multiple remaining resource scores, and the multiple remaining resource scores constitute a remaining resource score set.
[0053] For example, during the deployment of the service component of the 4C8G500G cloud database PostgreSQL, the formula for calculating the remaining resource score of each physical machine is:
[0054] S2=Avail_CPU_cnt*Avail_CPU_priority+Avail_MEM_cnt
[0055] *Avail_MEM_priority+Avail_Disk_capacity
[0056] *Avail_Disk_priorigy;
[0057] Among them, S2 is the remaining resource score, Avail_CPU_cnt is the remaining number of CPUs, Avail_CPU_priority is the remaining CPU priority parameter, Avail_MEN_cnt is the remaining memory amount, Avail_MEM_priority is the remaining memory priority parameter, Avail_Disk_capacity is the remaining disk amount, and Avail_Disk_priorigy is the remaining disk priority parameter.
[0058] Step S104, determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set. If there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, deploy the service component to the physical machine corresponding to the target remaining resource score.
[0059] In some optional implementations, if there is a remaining resource score greater than or equal to the resource usage score in the remaining resource score set, a remaining resource score greater than or equal to the resource usage score is selected from the multiple remaining resource scores in the remaining resource score set as the target remaining resource score.
[0060] In some optional implementations, if there is no target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, a first prompt message is generated, wherein the first prompt message is used to prompt that the remaining resources are insufficient and the service component cannot be deployed.
[0061] For example, for the service component of the 4C8G500G cloud database PostgreSQL, the resource usage score is calculated as: S1=25*4+8*50+500*25=13000, then the remaining resource score greater than or equal to 13000 is selected as the target remaining resource score in the remaining resource score set.
[0062] In an embodiment of the present invention, the target remaining resource score greater than or equal to the resource usage score in the remaining resource score set may be one or more. If the target remaining resource score is one, the service component is deployed on the physical machine corresponding to the target remaining resource score. If the target remaining resource score is multiple, the service component is deployed on the first target physical machine corresponding to the largest first target remaining resource score.
[0063] The deployment method of the service component provided by the embodiment of the present invention first determines at least one physical machine group that meets the deployment requirements of the service component based on the affinity information of the service component, preliminarily selects the physical machine group that meets the deployment requirements of the service component, and selects a physical machine from the physical machine group that meets the deployment requirements of the service component for deployment. There is no need to select from all physical machines later, which simplifies the operation and improves the deployment efficiency. The embodiment of the present invention generates a resource usage score based on the resource usage information of the service component, generates multiple remaining resource scores corresponding to the multiple physical machines respectively based on the remaining resource information of the multiple physical machines in the at least one physical machine group, obtains a remaining resource score set, compares the multiple remaining resource scores in the remaining resource score set with the resource usage score, obtains the target remaining resource score of the physical resources that meet the deployment requirements of the service component, and deploys the service component to the physical machine corresponding to the target remaining resource score, thereby realizing automatic scheduling and deployment of the service component. Compared with related technologies, the embodiments of the present invention automatically deploy service components, simplify operating steps, reduce manual intervention, and reduce operation and maintenance costs. The present invention analyzes the physical resources required by the service components and the remaining physical resources of the physical machine to prevent the situation where the service components are deployed on a physical machine with insufficient physical resources, thereby reducing the deployment time of the service components and improving the deployment efficiency of the service components.
[0064] In this embodiment, a method for deploying a service component is provided, which can be used in a computer device. Figure 3 is a flow chart of a deployment method of another service component according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0065] Step S301: Determine at least one physical machine group that meets the deployment requirements of the service component according to the affinity information of the service component.
[0066] In some optional embodiments, the affinity information includes an affinity tag and / or an anti-affinity tag.
[0067] Specifically, the above step S301 includes:
[0068] Step S3011: If the affinity information includes an affinity tag and an anti-affinity tag, a first physical machine group corresponding to the affinity tag is selected according to the affinity tag.
[0069] Step S3012: According to the anti-affinity label, select a second physical machine group other than the physical machine group corresponding to the anti-affinity label.
[0070] Step S3013: The first physical machine group and the second physical machine group are used to form at least one physical machine group that meets the service component deployment requirement.
[0071] In some optional implementations, if the affinity information includes an affinity tag, a first physical machine group corresponding to the affinity tag is selected according to the affinity tag, and the first physical machine group is at least one physical machine group that meets the service component deployment requirements.
[0072] Among them, if the affinity label corresponds to one physical machine group, the first physical machine group is the physical machine group that meets the service component deployment requirements; if the affinity label corresponds to multiple physical machine groups, the first physical machine group is multiple physical machine groups that meet the service component deployment requirements.
[0073] In some optional embodiments, if the affinity information includes an anti-affinity tag, a second physical machine grouping other than the physical machine grouping corresponding to the anti-affinity tag is selected based on the anti-affinity tag, and the second physical machine grouping is at least one physical machine grouping that meets the service component deployment requirements.
[0074] The second physical machine group may be one or more.
[0075] Step S302: Generate a resource usage score based on the resource usage information of the service component; the resource usage information is used to represent the usage of the physical resources of the physical machine on which the service component is to be deployed by the service component.
[0076] In some optional implementations, the resource usage information includes multiple physical resource quantities and multiple first priority parameters.
[0077] Specifically, the above step S302 includes:
[0078] Step S3021: multiply the quantities of multiple physical resources by the multiple first priority parameters respectively corresponding to the quantities of multiple physical resources to obtain multiple first product results.
[0079] Step S3022: sum up multiple first product results to generate a resource usage score.
[0080] Step S303, obtaining the remaining resource information of multiple physical machines in at least one physical machine group, generating multiple remaining resource scores corresponding to the multiple physical machines respectively according to the remaining resource information, and obtaining a remaining resource score set; the remaining resource information is used to characterize the remaining resource situation of the physical machine.
[0081] In some optional implementations, the remaining resource information includes multiple remaining resource quantities and multiple second priority parameters.
[0082] Specifically, the above step S303 includes:
[0083] Step S3031: multiply the multiple remaining resource quantities corresponding to each physical machine by the multiple second priority parameters corresponding to the multiple remaining resource quantities to obtain multiple second multiplication results.
[0084] Step S3032: sum the multiple second product results corresponding to each physical machine to generate multiple remaining resource scores, and the multiple remaining resource scores form a remaining resource score set.
[0085] Step S304: Determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set. If there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, deploy the service component to the physical machine corresponding to the target remaining resource score. Figure 1 Step S104 of the illustrated embodiment will not be described in detail here.
[0086] The deployment method of the service component provided by the embodiment of the present invention quickly determines at least one physical machine group that meets the deployment requirements of the service component by setting affinity tags and anti-affinity tags, optimizes physical resource allocation, preliminarily selects the physical machine group that meets the deployment requirements of the service component, and selects a physical machine for deployment from the physical machine group that meets the deployment requirements of the service component. There is no need to select from all physical machines later, which simplifies the operation and improves the deployment efficiency. The deployment method of the service component provided by the embodiment of the present invention determines the product of multiple physical resource quantities and multiple first priority parameters corresponding to the multiple physical resource quantities and then sums them to obtain a resource usage score, taking into account the multiple physical resources required for the deployment of the service component, and improving the accuracy of the selection of physical machines.
[0087] In this embodiment, a method for deploying a service component is provided, which can be used in a computer device. Figure 4 is a flow chart of another method for deploying a service component according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0088] Step S401: Determine at least one physical machine group that meets the deployment requirements of the service component based on the affinity information of the service component. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0089] Step S402: Generate a resource usage score based on the resource usage information of the service component; the resource usage information is used to represent the usage of the physical resources of the physical machine on which the service component is to be deployed by the service component. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0090] Step S403, obtaining the remaining resource information of multiple physical machines in at least one physical machine group, generating multiple remaining resource scores corresponding to the multiple physical machines according to the remaining resource information, and obtaining a remaining resource score set; the remaining resource information is used to characterize the remaining resource status of the physical machine. For details, please refer to Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0091] Step S404, determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set. If there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, deploy the service component to the physical machine corresponding to the target remaining resource score.
[0092] Specifically, the above step S404 includes:
[0093] Step S4041, determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set. If there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, and if there are multiple target remaining resource scores, deploy the service component to the first target physical machine corresponding to the largest first target remaining resource score.
[0094] In the embodiment of the present invention, if there are multiple target remaining resource scores, the service component is deployed to the first target physical machine corresponding to the largest first target remaining resource score, ensuring that the selected physical machine is the most suitable physical machine for deploying the service component.
[0095] Step S405: If the first target physical machine fails, determine whether the service component is a stateful service component.
[0096] Among them, the stateful service component refers to a service component that stores data information in a local directory.
[0097] Step S406: If the service component is a stateful service component, a recovery command is executed to back up the data information to the database, and the service component is deployed to the second target physical machine.
[0098] The second target physical machine is a physical machine corresponding to other target remaining resource scores except the first target remaining resource score among the multiple target remaining resource scores.
[0099] The restore command may be restore_command.
[0100] Step S407: if the service component is a stateless service component, deploy the service component to the second target physical machine; a stateless service component is a service component whose data information is stored in a database or has no data information.
[0101] In an embodiment of the present invention, the difference between a stateful service component and a stateless service component lies in whether the service component can be freely migrated between different physical machines within a cluster without affecting the operation of the service component. A stateful service usually includes a series of data information. For example, a PostgreSQL service deployed in a highly available PostgresSQL database, its data, write-ahead log (WAL) and some configuration information are all stored in a local directory. For the data information stored in the local directory, it is necessary to back up the data information to other physical nodes or object buckets or databases in real time to prevent the loss of data information after a physical machine failure. A stateless service component usually refers to a service component that does not store the data information of the task itself. The data information is usually stored in a database or no data information is needed at all.
[0102] The deployment method of the service component provided by the embodiment of the present invention determines whether the service component is a stateful service component that stores data information in a local directory when a physical machine fails. If so, a recovery command is executed to back up the data information to a database, and the service component is deployed to a second target physical machine that meets the deployment conditions other than the first target physical machine to realize the redeployment of the service component. If not, the service component can be directly deployed to the second target physical machine. In the related art, an alarm is sent after the abnormality of the service component is detected. The recovery of the service component requires manual selection of a physical machine for re-deployment. If the physical machine is not selected properly, the use of the physical resources of the existing service component will be squeezed. The embodiment of the present invention adopts the form of automatic deployment to quickly find a physical machine that meets the physical resource requirements of the service component, and redeploy the service component on the new physical machine to restore the operation of the service component, which greatly reduces the cost of manual operation and maintenance. The embodiment of the present invention is provided with different processing strategies for stateful service components and stateless service components, which can cope with different demand scenarios, meet the demand for automatic recovery of service components in different business scenarios, and improve the reliability and availability of service components.
[0103] In this embodiment, a method for deploying a service component is provided, which can be used in a computer device. Figure 5 FIG. 1 is a flow chart of a method for deploying another service component according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:
[0104] Step S501: grouping of physical nodes.
[0105] The control module is deployed on a server outside the cluster, and it is ensured that the control module can be connected to all physical machines in the cluster through the secure shell (SSH) interface without secrets. All physical machines in the cluster are registered, and the identifiers, encryption protocol ports, and grouping information of the physical machines are sent to the control module so that the control module can manage the physical machines.
[0106] In some optional implementations, all physical machines in the cluster are grouped. The physical machines can be grouped according to their functions. For example, the physical machine grouping includes: a control panel, a storage panel, and a value-added panel. In addition, more groups can be set up according to needs, such as a compute panel, etc. Each physical machine group includes multiple physical machines.
[0107] Step S502: Automatic scheduling of service components in the deployment phase.
[0108] In some optional implementations, after all physical machines are registered and managed, the service components are deployed, the usage of physical resources required by the service components and the priority of the physical resources are defined in advance, and a resource usage score for priority scheduling is calculated based on the usage of the physical resources and the priority of the physical resources;
[0109] In some optional implementations, the remaining resources on each physical machine in a scenario that satisfies the physical machine grouping affinity of the service component are calculated to obtain a remaining resource score set.
[0110] In some optional implementations, when there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, the service component can be deployed to the physical machine corresponding to the target remaining resource score. Otherwise, the service component is considered unschedulable. Before deploying the service component, the user is prompted that insufficient physical resources are available and the service component cannot be deployed.
[0111] Step S503: automatic scheduling in a fault scenario.
[0112] In an embodiment of the present invention, when a physical machine fails, it is necessary to migrate the service component from the failed physical machine and redeploy it on a new physical machine. For the migration of stateless service components, it is only necessary to redeploy them on a new physical machine if the resource usage score is met. For stateful service components, configure the corresponding restore_command (recovery command), store the data information, and then redeploy the service component on the new physical machine to ensure that the service component can still operate normally after the physical machine is migrated.
[0113] In this embodiment, a deployment device for a service component is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0114] This embodiment provides a deployment device for a service component, such as Figure 6 As shown, including:
[0115] The physical machine grouping module 601 is used to determine at least one physical machine grouping that meets the deployment requirements of the service component according to the affinity information of the service component.
[0116] The resource usage score generating module 602 is used to generate a resource usage score according to the resource usage information of the service component; the resource usage information is used to represent the usage of the physical resources of the physical machine where the service component is to be deployed by the service component.
[0117] The remaining resource score set determination module 603 is used to obtain the remaining resource information of multiple physical machines in at least one physical machine group, and generate multiple remaining resource scores corresponding to the multiple physical machines according to the remaining resource information to obtain a remaining resource score set; the remaining resource information is used to characterize the remaining resource situation of the physical machine.
[0118] The service component configuration module 604 is used to determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, and deploy the service component to the physical machine corresponding to the target remaining resource score based on whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set.
[0119] In some optional implementations, the physical machine grouping module 601 includes:
[0120] The first physical machine group selection unit is configured to select a first physical machine group corresponding to the affinity tag according to the affinity information including the affinity tag and the anti-affinity tag.
[0121] The second physical machine group selecting unit is configured to select, according to the anti-affinity label, a second physical machine group other than the physical machine group corresponding to the anti-affinity label.
[0122] The physical machine grouping integration unit is used to form at least one physical machine grouping that meets the service component deployment requirements according to the first physical machine grouping and the second physical machine grouping.
[0123] In some optional implementations, the resource usage score generating module 602 includes:
[0124] The first multiplication unit is used to multiply the multiple physical resource quantities and the multiple first priority parameters corresponding to the multiple physical resource quantities to obtain multiple first product results.
[0125] The first summing unit is used to sum the multiple first product results to generate a resource usage score.
[0126] In some optional implementations, the remaining resource scoring set determination module 603 includes:
[0127] The second product unit is used to multiply the multiple remaining resource quantities corresponding to each physical machine by the multiple second priority parameters corresponding to the multiple remaining resource quantities to obtain multiple second product results.
[0128] The second summing unit is used to sum the multiple second product results corresponding to each physical machine to generate multiple remaining resource scores, and the multiple remaining resource scores form a remaining resource score set.
[0129] In some optional implementations, the service component configuration module 604 includes:
[0130] The service component deployment unit is used to deploy the service component to a first target physical machine corresponding to the largest first target remaining resource score according to the existence of multiple target remaining resource scores.
[0131] In some optional implementations, the deployment device of the service component further includes:
[0132] The service component type determination module is used to determine whether the service component is a stateful service component according to a failure of the first target physical machine; a stateful service component indicates a service component that stores data information in a local directory.
[0133] The backup and deployment module is used to execute the recovery command to back up the data information to the database and deploy the service component to the second target physical machine according to the service component being a stateful service component; the second target physical machine is the physical machine corresponding to the remaining resource scores of other targets except the remaining resource score of the first target among multiple remaining resource scores of the target.
[0134] The service component deployment module is used to deploy the service component to the second target physical machine according to the service component being a stateless service component; the stateless service component is a service component whose data information is stored in a database or has no data information.
[0135] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0136] The deployment device of the service component in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0137] The embodiment of the present invention also provides a computer device having the above Figure 6 A deployment device for the service components shown.
[0138] See also Figure 7 , Figure 7 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 7As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 7 A processor 10 is taken as an example.
[0139] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0140] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0141] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0142] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0143] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0144] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0145] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0146] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for deploying a service component, characterized in that: The method comprises: Determining, according to the affinity information of the service component, at least one physical machine group that meets the deployment requirements of the service component; Generate a resource usage score according to the resource usage information of the service component; the resource usage information is used to characterize the usage of the physical resources of the physical machine on which the service component is deployed by the service component; Obtaining the remaining resource information of the plurality of physical machines in the at least one physical machine group, and generating a plurality of remaining resource scores respectively corresponding to the plurality of physical machines according to the remaining resource information to obtain a remaining resource score set; the remaining resource information is used to characterize the remaining resource status of the physical machine; Determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set; if there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, deploy the service component to a physical machine corresponding to the target remaining resource score.
2. The method according to claim 1, characterized in that The affinity information includes an affinity tag and / or an anti-affinity tag, and determining at least one physical machine grouping that meets the deployment requirements of the service component according to the affinity information of the service component includes: If the affinity information includes an affinity tag and an anti-affinity tag, selecting a first physical machine group corresponding to the affinity tag according to the affinity tag; According to the anti-affinity label, selecting a second physical machine group other than the physical machine group corresponding to the anti-affinity label; At least one physical machine grouping that meets the service component deployment requirement is formed by the first physical machine grouping and the second physical machine grouping.
3. The method according to claim 1 or 2, characterized in that: The resource usage information includes multiple physical resource quantities and multiple first priority parameters, and generating a resource usage score according to the resource usage information of the service component includes: multiplying the plurality of physical resource quantities by the plurality of first priority parameters respectively corresponding to the plurality of physical resource quantities to obtain a plurality of first multiplication results; The plurality of first multiplication results are summed to generate the resource usage score.
4. The method according to claim 1 or 2, characterized in that: The remaining resource information includes multiple remaining resource quantities and multiple second priority parameters; and the generating, based on the remaining resource information, multiple remaining resource scores corresponding to the multiple physical machines respectively, to obtain a remaining resource score set includes: Multiplying the multiple remaining resource quantities corresponding to each physical machine by the multiple second priority parameters respectively corresponding to the multiple remaining resource quantities to obtain multiple second multiplication results; The multiple second multiplication results corresponding to each physical machine are summed to generate the multiple remaining resource scores, and the multiple remaining resource scores form the remaining resource score set.
5. The method according to claim 1 or 2, characterized in that: The deploying the service component to a physical machine corresponding to the target remaining resource score includes: If there are multiple target remaining resource scores, the service component is deployed on a first target physical machine corresponding to the largest first target remaining resource score.
6. The method according to claim 5, characterized in that After deploying the service component to the physical machine corresponding to the target remaining resource score, the method further includes: If the first target physical machine fails, determining whether the service component is a stateful service component; the stateful service component represents a service component that stores data information in a local directory; If the service component is a stateful service component, execute a recovery command to back up the data information to a database, and deploy the service component to a second target physical machine; the second target physical machine is a physical machine corresponding to the other target remaining resource scores except the first target remaining resource score among the multiple target remaining resource scores; If the service component is a stateless service component, the service component is deployed on the second target physical machine; the stateless service component is a service component in which the data information is stored in a database or has no data information.
7. A deployment device for a service component, characterized in that: The device comprises: A physical machine grouping module, configured to determine at least one physical machine grouping that meets the deployment requirements of the service component according to the affinity information of the service component; A resource usage score generating module, used to generate a resource usage score according to resource usage information of the service component; the resource usage information is used to characterize the usage of the physical resources of the physical machine on which the service component is to be deployed by the service component; A remaining resource score set determination module is used to obtain the remaining resource information of multiple physical machines in the at least one physical machine group, and generate multiple remaining resource scores corresponding to the multiple physical machines respectively according to the remaining resource information to obtain a remaining resource score set; the remaining resource information is used to characterize the remaining resource situation of the physical machine; The service component configuration module is used to determine whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set, and deploy the service component to the physical machine corresponding to the target remaining resource score based on whether there is a target remaining resource score greater than or equal to the resource usage score in the remaining resource score set.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for deploying the service component described in any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the service component deployment method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the service component deployment method according to any one of claims 1 to 6.