CN109995842B - Grouping method and device for distributed server cluster - Google Patents

Grouping method and device for distributed server cluster Download PDF

Info

Publication number
CN109995842B
CN109995842B CN201810002956.3A CN201810002956A CN109995842B CN 109995842 B CN109995842 B CN 109995842B CN 201810002956 A CN201810002956 A CN 201810002956A CN 109995842 B CN109995842 B CN 109995842B
Authority
CN
China
Prior art keywords
server
group
distributed
grouping
registered
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810002956.3A
Other languages
Chinese (zh)
Other versions
CN109995842A (en
Inventor
陶涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201810002956.3A priority Critical patent/CN109995842B/en
Publication of CN109995842A publication Critical patent/CN109995842A/en
Application granted granted Critical
Publication of CN109995842B publication Critical patent/CN109995842B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Abstract

The invention provides a grouping method and a grouping device for a distributed server cluster, wherein the distributed server cluster comprises a plurality of server groups, and the method comprises the following steps: acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored under a node corresponding to the distributed server cluster; acquiring a distributed lock of the distributed server cluster; if the distributed lock is obtained, determining a server group to be added according to a grouping strategy, and registering the server group to the corresponding server group; when the cluster needs to be grouped, the server to be registered acquires a grouping strategy from the node, and when the server self acquires the distributed lock, the server group to be added can be determined according to the grouping strategy, and the server self is registered into the corresponding server group, so that the distributed server cluster can be divided into a plurality of server groups, each server group provides different business services, and the efficiency of the distributed server cluster is improved.

Description

Grouping method and device for distributed server cluster
Technical Field
The present invention relates to the field of network technologies, and in particular, to a grouping method and apparatus for a distributed server cluster.
Background
With the development of the internet, the scale of website applications is continuously enlarged, a conventional vertical application architecture cannot cope with the scale, and a distributed service architecture is imperative.
When establishing a distributed service, this is typically done by establishing a ZooKeeper cluster. In the prior art, because the distributed server clusters cannot be grouped, one distributed server cluster can only provide one service, and the distributed server clusters cannot achieve the expected efficiency.
Disclosure of Invention
In view of the foregoing problems, the present invention is provided to provide a grouping method and apparatus for distributed server clusters, so as to solve the technical problem that a distributed server cluster cannot be grouped, so that one distributed server cluster can only provide one service function, and thus the distributed server cluster cannot achieve the expected efficiency.
In a first aspect of the present invention, a grouping method for a distributed server cluster, the distributed server cluster comprising a plurality of server groups, the method comprising:
acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored under a node corresponding to the distributed server cluster;
requesting to acquire a distributed lock of the distributed server cluster;
and if the distributed lock is acquired, determining a server group to be added according to the grouping strategy, and registering the server group to the corresponding server group.
Optionally, the grouping policy includes: average grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group is registered in the server group with the least total number of the currently registered servers according to the average grouping rule;
acquiring the total number of registered servers contained in each server group in the M server groups, and comparing to determine the server group with the minimum total number of the registered servers;
registering the server group with the minimum number of the current registered servers.
Optionally, the grouping policy includes: the method comprises the following steps of (1) weight grouping rules, information of dividing the distributed server cluster into M server groups and a weight value of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to a corresponding server group includes:
determining that the server group is registered in a server group of which the total number of the current registered servers does not reach the preset number according to the weight grouping rule, wherein the preset number is determined according to the weight value of the server group and the total number of target servers of the distributed server cluster;
acquiring the total number of registered servers contained in each server group in the M current server groups, and comparing the total number with the corresponding preset number to determine the server groups of which the total number of the registered servers does not reach the preset number;
and registering the self to the server group of which the total number of the determined current registered servers does not reach the preset number.
Optionally, the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group with the highest operation load is registered to according to the load grouping rule;
acquiring the operation load of each server group in the M server groups, and determining the server group with the highest current operation load through comparison;
and registering the server group with the highest determined current operation load.
Optionally, the grouping policy includes: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server self is registered in a server group corresponding to the designated group identification according to the designated grouping rule;
acquiring a designated group identifier and a group identifier of each server group in the M current server groups, and determining the server group corresponding to the designated group identifier by comparison;
and registering the self to the server group corresponding to the determined appointed group identification.
Optionally, each server group in the distributed server cluster is configured to provide different business services.
In a second aspect of the present invention, there is provided a grouping apparatus for a distributed server cluster, the distributed server cluster comprising a plurality of server groups, the apparatus comprising:
a policy obtaining unit, configured to obtain a grouping policy of the distributed server cluster, where the grouping policy is pre-stored in a node corresponding to the distributed server cluster;
a distributed lock acquisition unit, configured to request to acquire a distributed lock of the distributed server cluster;
and the registering unit is used for determining a server group to be added according to the grouping strategy and registering the server group to the corresponding server group when the distributed lock acquiring unit acquires the distributed lock.
Optionally, the grouping policy includes: average grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit is registered in a server group with the least total number of currently registered servers according to the average grouping rule;
the second determining subunit is configured to acquire the total number of the registered servers included in each of the M current server groups, and determine, through comparison, a server group with the fewest current total number of the registered servers;
and the registration subunit is used for registering the registered server group to the server group with the minimum total number of the determined currently registered servers.
Optionally, the grouping policy includes: the method comprises the following steps of (1) weight grouping rules, information of dividing the distributed server cluster into M server groups and a weight value of each server group; the registration unit includes:
the first determining subunit is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach a preset number of the group, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit is configured to obtain the total number of the registered servers included in each of the M server groups, and determine, by comparing the total number of the registered servers with a corresponding preset number, a server group for which the total number of the registered servers has not reached the preset number;
and the registration subunit is used for registering the registered server group to the server group of which the total number of the current registered servers does not reach the preset number.
Optionally, the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the highest operation load is registered to the server group according to the load grouping rule;
the second determining subunit is configured to obtain the operating load of each server group in the M server groups, and determine, through comparison, a server group with the highest current operating load;
and the registration subunit is used for registering the registration subunit to the server group with the highest determined current operation load.
Optionally, the grouping policy includes: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit should register the first determining subunit in the server group corresponding to the designated group identifier according to the designated grouping rule;
the second determining subunit is configured to acquire the designated group identifier and the group identifier of each of the M current server groups, and determine, by comparison, the server group corresponding to the designated group identifier;
and the registration subunit is used for registering the server group corresponding to the determined specified group identifier.
Optionally, each server group in the distributed server cluster is configured to provide different business services.
In a third aspect of the present invention, a grouping method for a distributed server cluster, the distributed server cluster comprising a plurality of server groups, the method comprising:
receiving an acquisition request sent by a server to be registered;
and sending a preset grouping strategy to the server to be registered according to the acquisition request, so that when the server to be registered acquires the distributed lock, the server group to be joined can be determined according to the grouping strategy, and the server group is registered into the corresponding server group.
In a fourth aspect of the present invention, a distributed server cluster is provided, which includes a plurality of server groups, servers to be registered, and a node; wherein the node is configured to store a grouping policy of the distributed server cluster, and the node corresponds to the distributed server cluster; the server to be registered includes:
a policy obtaining unit, configured to obtain, from the node, a grouping policy of the distributed server cluster;
a distributed lock acquisition unit, configured to request to acquire a distributed lock of the distributed server cluster;
and the registering unit is used for determining a server group to be added according to the grouping strategy and registering the server group to the corresponding server group when the distributed lock acquisition unit is determined to acquire the distributed lock.
Optionally, the grouping policy includes: average grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the minimum total number of the currently registered servers is registered according to the average grouping rule;
the second determining subunit is configured to obtain the total number of registered servers included in each of the M server groups, and determine, through comparison, a server group with the fewest total number of currently registered servers;
and the registration subunit is used for registering the registered server group to the server group with the minimum total number of the determined currently registered servers.
Optionally, the grouping policy includes: a weight grouping rule, information that the distributed server cluster is divided into M server groups, and a weight value of each server group; the registration unit includes:
the first determining subunit is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach a preset number of the group, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit is configured to obtain the total number of the registered servers included in each of the M server groups, and determine, by comparing the total number of the registered servers with a corresponding preset number, a server group for which the total number of the registered servers has not reached the preset number;
and the registration subunit is used for registering the registered server group to the server group of which the total number of the current registered servers does not reach the preset number.
Optionally, the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the highest operation load is registered to the server group according to the load grouping rule;
the second determining subunit is configured to obtain the operating load of each server group in the M server groups, and determine, through comparison, a server group with the highest current operating load;
and the registration subunit is used for registering the registration subunit to the server group with the highest determined current operation load.
Optionally, the grouping policy includes: appointing a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit should register the first determining subunit in the server group corresponding to the designated group identifier according to the designated grouping rule;
the second determining subunit is configured to acquire a specified group identifier and a group identifier of each of the current M server groups, and determine, by comparison, a server group corresponding to the specified group identifier;
and the registration subunit is used for registering the server group corresponding to the determined specified group identifier.
Optionally, each server group in the distributed server cluster is configured to provide different business services.
In a fifth aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, which program, when being executed by a processor, is capable of performing the method according to any one of the implementations of the first aspect.
In a sixth aspect of the invention, there is provided a computer apparatus for a distributed server cluster, comprising:
at least one processor; and
at least one memory communicatively coupled to the processor, wherein,
the memory stores program instructions executable by the processor, the processor invoking the program instructions to be capable of performing a method as any one of the implementations of the first aspect.
The technical scheme provided in the embodiment of the application has at least the following technical effects or advantages:
the invention provides a grouping method and a grouping device for a distributed server cluster, wherein the distributed server cluster comprises a plurality of server groups, and the method comprises the following steps: acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored in a node corresponding to the distributed server cluster; requesting to acquire a distributed lock of the distributed server cluster; if the distributed lock is acquired, determining a server group to be added according to the grouping strategy, and registering the server group to the corresponding server group; therefore, the preset grouping strategy is stored under the nodes, when the clusters need to be grouped, the server to be registered acquires the grouping strategy from the nodes, under the condition that the server acquires the distributed locks, the server group to be added can be determined according to the grouping strategy, and the server group is registered into the corresponding server group, so that the distributed server cluster can be divided into a plurality of server groups, and each server group can be configured to provide different business services, and the efficiency of the distributed server cluster is improved.
The above description is only an overview of the technical solutions of the present invention, and the present invention can be implemented in accordance with the content of the description so as to make the technical means of the present invention more clearly understood, and the above and other objects, features, and advantages of the present invention will be more clearly understood.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a schematic flowchart illustrating a grouping method for a distributed server cluster according to an embodiment of the present invention;
FIG. 2 is a schematic diagram illustrating that a distributed lock is stored in a node corresponding to a distributed server cluster according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a distributed lock maintained at a node outside of a distributed server cluster according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a grouping device for a distributed server cluster according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of a registration unit provided in the second embodiment of the present invention;
fig. 6 is a schematic flowchart illustrating a grouping method for a distributed server cluster according to a third embodiment of the present invention;
fig. 7 is a schematic structural diagram of a distributed server cluster according to a fourth embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Example one
An embodiment of the present invention provides a grouping method for a distributed server cluster, where the method is written from the perspective of a server to be registered as an execution subject, and as shown in fig. 1, the method includes:
s110, obtaining a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored in a node corresponding to the distributed server cluster;
when the distributed server cluster needs to be automatically grouped, a grouping strategy of the distributed server cluster needs to be acquired and is pre-stored in a node corresponding to the distributed server cluster. The distributed server cluster comprises a plurality of server groups, and each server group is used for providing different business services; that is, the node includes a plurality of sub-nodes, each sub-node corresponds to a server group, and each sub-node includes a plurality of dynamic nodes, each dynamic node corresponds to a server that has been successfully registered (survived).
Specifically, when the distributed server cluster is started, the to-be-registered server sends first request information for requesting to acquire the grouping strategy to the node, and the node issues the grouping strategy to the to-be-registered server according to the request information.
S111, requesting to acquire a distributed lock of the distributed server cluster;
here, the grouping policy and the distributed lock may be stored in the same node, or may be stored in different nodes; that is, the distributed lock may be stored in the node corresponding to the distributed server cluster, or may be stored in a node outside the distributed server cluster.
Referring to fig. 2, for example, a server cluster corresponds to a node a, and two server groups, namely an average group 1 and an average group 2, are located below the node a; it can be seen that the distributed lock is in a flat-level relationship with the average packet 1 and the average packet 2, and therefore the distributed lock is stored under the node corresponding to the distributed server cluster.
Similarly, referring to fig. 3, for example, a server cluster corresponds to a node a, and there are two server groups, i.e. an average group 1 and an average group 2, below the node a; it can be seen that distributed lock lockA is in a hierarchical relationship with node a, and thus distributed lock lockA is maintained under a node outside the distributed server cluster.
When the distributed lock is stored in a node outside the distributed server cluster, acquiring the distributed lock of the distributed server cluster is to acquire the distributed lock corresponding to the distributed server cluster. The distributed lock may be a ZK-based distributed lock, or a redis database-based distributed lock.
It should be noted that the parent node may be a first-level node or a multi-level node, and certainly, the parent node may not be needed in the distributed server cluster, and the distributed server cluster in this embodiment has no parent node.
Taking the example of storing in the same node as an example, when the server to be registered requests to acquire the distributed lock of the distributed server cluster, the following is specifically performed:
after the server to be registered acquires the grouping strategy, second request information for requesting acquisition of the distributed lock can be continuously sent to the node. For example, the node adds a server to be registered to a first acquisition queue of the distributed lock according to the second request information, where the second request information includes priority information of the server to be registered.
After the server to be registered is added into the first acquisition queue, the server to be registered requests the node to acquire the priority of all servers except the server to be registered in the first acquisition queue; and judging whether the priority of the distributed lock is the highest priority in the first acquisition queue or not, and if the priority of the distributed lock is the highest priority in the first acquisition queue, defaulting to directly acquiring the distributed lock.
When determining that the priority of the first acquisition queue is not the highest priority in the first acquisition queue, the method further comprises: calling a monitoring mechanism to monitor a server corresponding to an adjacent priority higher than the self priority; and directly acquiring the distributed lock under the condition that the server corresponding to the adjacent priority releases the distributed lock.
As an optional embodiment, after the server to be registered is added to the first acquisition queue, the node acquires the priorities of all servers in the first acquisition queue, and when the node determines that the priority of the server to be registered is the server with the highest priority in the queue, the distributed lock is distributed to the server to be registered.
After the server to be registered acquires the distributed lock, the server to be registered sends information that the distributed lock is occupied to the waiting server in the first acquisition queue.
As an alternative embodiment, the method for requesting, by a server to be registered, to acquire a distributed lock of the distributed server cluster includes:
after the server to be registered acquires the grouping strategy, the server to be registered can continue to send third request information for requesting to acquire the distributed lock to the node, and the node adds the server to be registered into a second acquisition queue of the distributed lock according to the second request information.
After the server to be registered is added into the second acquisition queue, the server to be registered requests a node to acquire the serial numbers of all servers in the second acquisition queue except the server to be registered in the second acquisition queue; and judging whether the sequence number of the self is the minimum sequence number in the second acquisition queue, and if the sequence number is the minimum sequence number, directly acquiring the distributed lock.
Similarly, when determining that the sequence number of the self is not the smallest sequence number in the second acquisition queue, the method further includes: calling a monitoring mechanism to monitor the adjacent servers with the sequence numbers smaller than the sequence numbers of the adjacent servers; and under the condition that the adjacent server is determined to release the distributed lock, directly acquiring the distributed lock.
As an optional embodiment, after the server to be registered is added to the second acquisition queue, the node acquires the sequence numbers of all servers in the first acquisition queue, and when it is determined that the server to be registered is the server with the smallest sequence number in the second queue, the distributed lock is distributed to the server to be registered.
Similarly, after the server to be registered acquires the distributed lock, the server to be registered sends information that the distributed lock is occupied to the waiting server in the second acquisition queue.
It should be noted that: the sequence of the steps S110 and S111 may be interchanged, that is, the server to be registered may request to acquire the grouping policy first and then request to acquire the distributed lock; or request to acquire the distributed lock first and then request to acquire the grouping policy, which is not limited herein.
And S112, if the distributed lock is acquired, determining a server group to be joined according to the grouping strategy, and registering the server group to the corresponding server group.
In this step, if the distributed lock is acquired, the server group to be joined is determined according to the grouping policy, and the server group is registered in the corresponding server group.
Specifically, as an optional embodiment, the grouping policy includes: average grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group is registered in the server group with the least total number of the currently registered servers according to the average grouping rule;
acquiring the total number of registered servers contained in each server group in the M current server groups, and comparing to determine the server group with the minimum total number of the current registered servers;
and registering the self to the server group with the minimum total number of the determined currently registered servers.
For example, M is 2, that is, the distributed server cluster includes two groups of servers, and if it is known that the total number of currently registered servers in the first group of server groups is 3 and the total number of currently registered servers in the second group of server groups is 4, the servers to be registered are determined to be registered in the second group of server groups by comparison, and then register themselves in the first group of server groups.
As an alternative embodiment, the grouping policy may include: a weight grouping rule, information that the distributed server cluster is divided into M server groups, and a weight value of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group is registered in a server group of which the total number of the currently registered servers does not reach the preset number according to the weight grouping rule, wherein the preset number is determined according to the weight value of the server group and the total number of the target servers of the distributed server cluster;
acquiring the total number of registered servers contained in each server group in the current M server groups, and comparing the total number with the corresponding preset number to determine the server groups of which the total number of the current registered servers does not reach the preset number;
and registering the self to the server group of which the total number of the determined current registered servers does not reach the preset number.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, the weighted value of the first group of server groups is 1/3, the weighted value of the second group of server groups is 2/3, and the total number of the target servers of the distributed server cluster is 9, then the number of the servers preset in the first group of server groups is 3, and the number of the servers preset in the second group of server groups is 6. If the number of the servers registered in the first group of server groups is known to be 3, and the number of the servers registered in the second group of server groups is known to be 5, after the servers to be registered are compared, the number of the servers registered in the second group of server groups is determined not to reach the preset number of the second group of server groups, and then the servers are registered in the second group of server groups.
As an alternative embodiment, the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to a corresponding server group includes:
determining that the server group with the highest operation load is registered to according to the load grouping rule;
acquiring the operation load of each server group in the current M server groups, and determining the server group with the highest current operation load through comparison;
and registering the server group with the highest determined current operation load.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, and it is known that the operation load of the first group of server groups is 80% and the operation load of the second group of server groups is 80%, then the operation load of the first group of server groups is determined to be the highest through comparison, and the server to be registered is registered in the first group of server groups if it is determined that the server to be registered should be registered in the first group of server groups.
As an alternative embodiment, the grouping policy includes: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server self is registered in a server group corresponding to the designated group identification according to the designated grouping rule;
acquiring a designated group identifier and a group identifier of each server group in the current M server groups;
and determining a server group corresponding to the appointed group identification through comparison, and registering the server group to the server group corresponding to the determined appointed group identification.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, where a group identifier of the first group of server groups is a, and a group identifier of the second group of server groups is B, and if the designated group identifier is a, the server to be registered determines that the server group corresponding to the designated group identifier a should be the first group of server groups by comparison, registers itself in the first group of server groups.
Therefore, each server can automatically register itself to the corresponding server group according to the grouping strategy, and when servers are on line or off line in the server group, the requirement of automatic grouping can still be met; and because different server groups are used for providing different business services, the efficiency of the distributed server cluster is further improved.
Here, the determining, according to the grouping policy, a server group to be joined, and after registering itself in a corresponding server group, further includes:
acquiring a redundancy configuration file in the grouping strategy; performing redundancy configuration on the current server based on the redundancy configuration file; therefore, when the server to be registered is down, the redundant machine takes over the work of the server to be registered, and data loss can not be caused.
And acquiring a resource configuration file in the grouping strategy; reserving a corresponding resource pool for the target service data based on the resource configuration file; the target service data comprises: and the user adds new service or user secret service. Thus, the reserved resource pool can be used for providing service space for the newly added service and the confidential service of the user.
After the distributed cluster is established, a module needing certain cluster service can check the number of the server groups and specific server information in each server group by checking nodes corresponding to the distributed server cluster through a WATCH function.
Example two
Corresponding to the first embodiment, this embodiment provides a grouping apparatus for a distributed server cluster, and as shown in fig. 4, the apparatus includes: a policy obtaining unit 21, a distributed lock obtaining unit 22, and a registration unit 23; wherein, the first and the second end of the pipe are connected with each other,
the policy obtaining unit 21 is configured to obtain a grouping policy of the distributed server cluster, where the grouping policy is pre-stored in a node corresponding to the distributed server cluster, the distributed server cluster includes multiple server groups, and each server group provides a different service; that is, the node includes a plurality of sub-nodes, each sub-node corresponds to a server group, and each sub-node includes a plurality of dynamic nodes, each dynamic node corresponds to a server that has been successfully registered (survived).
Specifically, when the distributed server cluster is started, the policy obtaining unit 21 sends first request information for requesting to obtain the grouping policy to the node, and the node issues the grouping policy to the server to be registered according to the request information.
The distributed lock acquiring unit 22 is configured to request to acquire a distributed lock of the distributed server cluster; here, the grouping policy and the distributed lock may be stored in the same node, or in different nodes, that is, as described in the first embodiment, the distributed lock may be stored in a node corresponding to the distributed server cluster, or in a node outside the distributed server cluster.
Taking the example of storing the distributed locks in the same node as an example, when the distributed lock obtaining unit 22 requests to obtain the distributed lock of the distributed server cluster, the following steps are specifically performed:
after the policy obtaining unit 21 obtains the grouping policy, the distributed lock obtaining unit 22 may continue to send second request information requesting to obtain a distributed lock to the node. For example, the node adds a server to be registered to a first acquisition queue of the distributed lock according to the second request information, where the second request information includes priority information of the server to be registered.
After the server to be registered is added into the first acquisition queue, the distributed lock acquisition unit 22 requests the node to acquire the priorities of all servers in the first acquisition queue except the server itself; and judging whether the priority of the distributed lock is the highest priority in the first acquisition queue or not, and if the priority is the highest priority in the first acquisition queue, defaulting to directly acquire the distributed lock.
When determining that the priority of the distributed lock acquisition unit is not the highest priority in the first acquisition queue, the distributed lock acquisition unit 22 is further configured to: calling a monitoring mechanism to monitor a server corresponding to an adjacent priority higher than the self priority; and directly acquiring the distributed lock under the condition that the server corresponding to the adjacent priority releases the distributed lock.
As an optional embodiment, after the server to be registered is added to the first acquisition queue, the node acquires the priorities of all servers in the first acquisition queue, and when the node determines that the priority of the server to be registered is the server with the highest priority in the queue, the distributed lock is allocated to the server to be registered.
After the distributed lock is acquired, the distributed lock acquisition unit 22 sends information that the distributed lock is occupied to the waiting server in the first acquisition queue.
As an alternative embodiment, the distributed lock acquiring unit 22, when requesting to acquire a distributed lock of the distributed server cluster, includes:
after the policy obtaining unit 21 obtains the grouping policy, the distributed lock obtaining unit 22 may continue to send third request information for requesting to obtain the distributed lock to the node, and the node adds the server to be registered to the second obtaining queue of the distributed lock according to the second request information.
After the server to be registered is added into the second acquisition queue, the distributed lock acquisition unit 22 requests the node to acquire the serial numbers of all servers in the second acquisition queue except the server itself; and judging whether the sequence number of the self is the minimum sequence number in the second acquisition queue, and if the sequence number is the minimum sequence number, directly acquiring the distributed lock.
Similarly, when determining that the sequence number of the distributed lock acquisition unit 22 is not the smallest sequence number in the second acquisition queue, the distributed lock acquisition unit is further configured to: calling a monitoring mechanism to monitor the adjacent servers with the sequence numbers smaller than the sequence numbers of the adjacent servers; and under the condition that the adjacent server is determined to release the distributed lock, directly acquiring the distributed lock.
As an optional embodiment, after the server to be registered is added to the second acquisition queue, the node acquires the sequence numbers of all servers in the first acquisition queue, and when it is determined that the server to be registered is the server with the smallest sequence number in the second queue, the distributed lock is allocated to the server to be registered.
Similarly, after acquiring the distributed lock, the distributed lock acquisition unit 22 is configured to send information that the distributed lock is occupied to a server waiting in the second acquisition queue.
It should be noted that: the policy obtaining unit 21 may first request to obtain the grouping policy, and then the distributed lock obtaining unit 22 requests to obtain the distributed lock; the lock acquiring unit 22 may first request to acquire the distributed lock, and the policy acquiring unit 21 then requests to acquire the grouping policy, which is not limited herein.
The registering unit 23 is configured to determine, according to the grouping policy, a server group to be joined when it is determined that the distributed lock acquisition unit acquires the distributed lock, and register itself in the corresponding server group.
Specifically, referring to fig. 5, the registration unit 23 includes: a first determining subunit 31, a second determining subunit 32, and a registering subunit 33.
As an alternative embodiment, the grouping policy includes: average grouping rules and information that the distributed server cluster is divided into M server groups; the first determining subunit 31 is configured to determine, according to the average grouping rule, that the server group that has the fewest total number of currently registered servers should be registered with itself;
the second determining subunit 32 is configured to acquire the total number of registered servers included in each server group in the current M server groups, and determine, through comparison, a server group with the fewest total number of currently registered servers;
the registering subunit 33 is configured to register itself in the server group with the minimum number of currently registered servers.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, the second determining subunit 32 obtains that the total number of currently registered servers in the first group of server groups is 3, and the total number of currently registered servers in the second group of server groups is 4, and then determines that the distributed server cluster should be registered in the second group of server groups through comparison, and the registering subunit 33 registers itself in the first group of server groups.
As an alternative embodiment, the grouping policy may include: the method comprises the following steps of (1) weight grouping rules, information of dividing the distributed server cluster into M server groups and a weight value of each server group; the first determining subunit 31 is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach the preset number, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit 32 is configured to acquire the total number of the registered servers included in each server group of the current M server groups, and compare the total number of the registered servers with the corresponding preset number to determine a server group for which the total number of the current registered servers has not reached the preset number;
the registering subunit 33 is configured to register itself in the server group whose determined total number of currently registered servers has not reached the set preset number.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, the weighted value of the first group of server groups is 1/3, the weighted value of the second group of server groups is 2/3, and the total number of the target servers of the distributed server cluster is 9, then the number of the servers preset in the first group of server groups is 3, and the number of the servers preset in the second group of server groups is 6. If the second determining subunit 32 learns that the number of servers already registered in the first group of server groups is 3 and the number of servers already registered in the second group of server groups is 5, after the comparison, it is determined that the number of servers already registered in the second group of server groups has not reached the preset number of the second group of server groups, and the registering subunit 33 registers itself in the second group of server groups.
As an alternative embodiment, the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the first determining subunit 31 is configured to determine, according to the load grouping rule, that the server group with the highest current operating load should be registered;
the second determining subunit 32 obtains the operation load of each server group in the current M server groups, and determines the server group with the highest current operation load through comparison;
the registering subunit 33 is configured to register itself in the server group with the highest determined current operating load.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, and the second determining subunit 32 knows that the operating load of the first group of server groups is 80% and the operating load of the second group of server groups is 80%, and then determines that the operating load of the first group of server groups is the highest through comparison, and when it is determined that the distributed server cluster should be registered in the first group of server groups, the registering subunit 33 registers itself in the first group of server groups.
As an alternative embodiment, the grouping policy includes: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the first determining subunit 31 is configured to determine, according to the specified grouping rule, that the server group corresponding to the specified group identifier should be registered by itself;
the second determining subunit 32 is configured to acquire the group identifier of the designated group and the group identifier of each server group in the current M server groups, and determine, by comparison, the server group corresponding to the designated group identifier;
the registering subunit 33 is configured to register itself in the server group corresponding to the determined specified group identifier.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, where the group identifier of the first group of server groups is a, and the group identifier of the second group of server groups is B, and if the designated group identifier is a, the second determining subunit 32 determines, through comparison, that the server group corresponding to the designated group identifier a should be the first group of server groups, and the registering subunit 33 registers itself in the first group of server groups.
Therefore, each server can automatically register itself to the corresponding server group according to the grouping strategy, and when servers are on line or off line in the server group, the requirement of automatic grouping can still be met; and because different server groups are used for providing different business services, the efficiency of the distributed server cluster is further improved.
Here, the server to be registered further includes a configuration unit 24, and after the registration subunit 33 registers itself to the corresponding server group, the configuration unit 24 is configured to:
acquiring a redundancy configuration file in the grouping strategy; performing redundancy configuration on the current server based on the redundancy configuration file; therefore, when the server to be registered is down, the redundant machine takes over the work of the server to be registered, and data loss can not be caused.
And acquiring a resource configuration file in the grouping strategy; reserving a corresponding resource pool for the target service data based on the resource configuration file; the target service data comprises: and the user adds new service or user secret service. Thus, the reserved resource pool can be used for providing service space for the newly added service and the confidential service of the user.
After the distributed cluster is established, a module needing a certain cluster service can check the number of the server groups and specific server information in each server group by checking nodes corresponding to the distributed server cluster through a WATCH function.
EXAMPLE III
The embodiment provides a grouping method for a distributed server cluster, wherein the distributed server cluster comprises a plurality of server groups, and each server group is used for providing different business services. The difference between this embodiment and embodiment 1 is that the embodiment is described from the perspective of the server to be registered serving as the execution subject, and the third embodiment is written from the perspective of the management node (usually, a master node, and for keeping the same with the embodiment, this embodiment is referred to as a node) in the distributed server cluster serving as the execution subject.
As shown in fig. 6, the method includes:
s410, receiving an acquisition request sent by a server to be registered;
when the distributed server cluster needs to be automatically grouped, when the distributed server cluster is started, a node receives an acquisition request sent by a server to be registered, a grouping strategy is pre-stored in the node, and the node corresponds to the distributed server cluster.
S411, sending a preset grouping strategy to the server to be registered according to the acquisition request, so that when the server to be registered acquires the distributed lock, the server group to be joined can be determined according to the grouping strategy, and the server group is registered into the corresponding server group.
After receiving an acquisition request, sending a preset grouping strategy to the server to be registered according to the acquisition request, so that when the server to be registered acquires the distributed lock, the server group to be joined can be determined according to the grouping strategy, and the server group is registered in the corresponding server group.
Here, after acquiring the grouping policy, the server to be registered needs to send a distributed lock acquisition request to the node so as to acquire the distributed lock.
It should be noted that the grouping policy and the distributed lock may be stored in the same node, or may be stored in different nodes, that is, as described in the first embodiment, the distributed lock may be stored in a node corresponding to the distributed server cluster, or may be stored in a node outside the distributed server cluster. The server to be registered may send the request for acquiring the grouping policy first or may send the request for acquiring the distributed lock first, which is not limited herein.
Taking the example of storing the lock information in the same node as an example, when the server to be registered requests to acquire the distributed lock of the distributed server cluster, the specific steps are as follows:
after the server to be registered acquires the grouping policy, the server to be registered may continue to send a request for acquiring the distributed lock to the node, and there are various ways for specifically implementing the request for the distributed lock, for example, the node adds the server to be registered to a first acquisition queue of the distributed lock according to the request for acquiring the distributed lock, and the request for acquiring the distributed lock contains priority information of the server to be registered.
After the server to be registered is added into the first acquisition queue, the server to be registered requests the node to acquire the priority of all servers in the first acquisition queue except the server to be registered; and judging whether the priority of the distributed lock is the highest priority in the first acquisition queue or not, and if the priority of the distributed lock is the highest priority in the first acquisition queue, defaulting to directly acquiring the distributed lock.
When determining that the priority of the first acquisition queue is not the highest priority in the first acquisition queue, the method further comprises: calling a monitoring mechanism to monitor a server corresponding to an adjacent priority higher than the self priority; and directly acquiring the distributed lock under the condition that the server corresponding to the adjacent priority releases the distributed lock.
As an optional embodiment, after the server to be registered is added to the first acquisition queue, the node acquires the priorities of all servers in the first acquisition queue, and when the node determines that the priority of the server to be registered is the server with the highest priority in the queue, the distributed lock is distributed to the server to be registered.
After the server to be registered acquires the distributed lock, the server to be registered sends the information that the distributed lock is occupied to the server waiting in the first acquisition queue.
As an optional embodiment, the acquiring, by a server to be registered, a distributed lock of the distributed server cluster when requesting to acquire, includes:
after the server to be registered acquires the grouping strategy, the server to be registered can continuously send a request for acquiring the distributed lock to the node, and the node adds the server to be registered into a second acquisition queue of the distributed lock according to the request for acquiring the distributed lock.
After the server to be registered is added into the second acquisition queue, the server to be registered requests the node to acquire the serial numbers of all servers in the second acquisition queue except the server to be registered in the second acquisition queue; and judging whether the sequence number of the self is the minimum sequence number in the second acquisition queue, and if the sequence number is the minimum sequence number, directly acquiring the distributed lock.
Similarly, when determining that the sequence number of the self is not the smallest sequence number in the second acquisition queue, the method further includes: calling a monitoring mechanism to monitor the adjacent servers with the sequence numbers smaller than the sequence numbers of the adjacent servers; and under the condition that the adjacent server is determined to release the distributed lock, directly acquiring the distributed lock.
As an optional embodiment, after the server to be registered is added to the second acquisition queue, the node acquires the sequence numbers of all servers in the first acquisition queue, and when it is determined that the server to be registered is the server with the smallest sequence number in the second queue, the distributed lock is allocated to the server to be registered.
Similarly, after the server to be registered acquires the distributed lock, the server to be registered sends information that the distributed lock is occupied to the waiting server in the second acquisition queue.
And if the server to be registered acquires the distributed lock, determining a server group to be joined according to the grouping strategy, and registering the server group to the corresponding server group.
Specifically, as an optional embodiment, the grouping policy includes: average grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to a corresponding server group includes:
determining that the server group is registered in the server group with the least total number of the currently registered servers according to the average grouping rule;
acquiring the total number of registered servers contained in each server group in the M current server groups, and determining the server group with the minimum total number of the registered servers through comparison;
and registering the self to the server group with the minimum total number of the determined currently registered servers.
For example, M is 2, that is, the distributed server cluster includes two groups of servers, and if it is known that the total number of currently registered servers in the first group of server groups is 3 and the total number of currently registered servers in the second group of server groups is 4, the servers to be registered are determined to be registered in the second group of server groups by comparison, and then register themselves in the first group of server groups.
As an alternative embodiment, the grouping policy may include: a weight grouping rule, information that the distributed server cluster is divided into M server groups, and a weight value of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to a corresponding server group includes:
determining that the server group is registered in a server group of which the total number of the current registered servers does not reach the preset number according to the weight grouping rule, wherein the preset number is determined according to the weight value of the server group and the total number of target servers of the distributed server cluster;
acquiring the total quantity of registered servers contained in each server group in the M current server groups, and comparing the total quantity of the registered servers with the corresponding preset quantity to determine the server groups of which the total quantity of the registered servers does not reach the preset quantity;
and registering the self to the server group of which the determined total number of the currently registered servers does not reach the preset number.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, the weighted value of the first group of server groups is 1/3, the weighted value of the second group of server groups is 2/3, and the total number of the target servers of the distributed server cluster is 9, then the number of the servers preset in the first group of server groups is 3, and the number of the servers preset in the second group of server groups is 6. If the number of the servers registered in the first group of server groups is known to be 3, and the number of the servers registered in the second group of server groups is known to be 5, after the servers to be registered are compared, the number of the servers registered in the second group of server groups is determined not to reach the preset number of the second group of server groups, and then the servers are registered in the second group of server groups.
As an alternative embodiment, the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to a corresponding server group includes:
determining that the server group with the highest operation load is registered to according to the load grouping rule;
acquiring the operation load of each server group in the current M server groups, and determining the server group with the highest current operation load through comparison;
and registering the server group with the highest determined current operation load.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, and it is known that the operation load of the first group of server groups is 80% and the operation load of the second group of server groups is 80%, then the operation load of the first group of server groups is determined to be the highest through comparison, and the server to be registered is registered in the first group of server groups if it is determined that the server to be registered should be registered in the first group of server groups.
As an alternative embodiment, the grouping policy includes: appointing a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server self is registered in a server group corresponding to the designated group identification according to the designated grouping rule;
acquiring a designated group identifier and a group identifier of each server group in the current M server groups;
and determining a server group corresponding to the appointed group identification through comparison, and registering the server group to the server group corresponding to the determined appointed group identification.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, where the group identifier of the first group of server groups is a, the group identifier of the second group of server groups is B, and if the designated group identifier is a, the server to be registered determines that the server group corresponding to the designated group identifier a should be the first group of server group by comparison, and registers itself in the first group of server group.
Therefore, each server can automatically register itself to the corresponding server group according to the grouping strategy, and when servers are on line or off line in the server group, the requirement of automatic grouping can still be met; and because different server groups are used for providing different service services, the efficiency of the distributed server cluster is further improved.
Here, after registering itself in the corresponding server group, the method further includes:
acquiring a redundancy configuration file in the grouping strategy; performing redundancy configuration on the current server based on the redundancy configuration file; therefore, when the server to be registered is down, the redundant machine takes over the work of the server to be registered, and data loss can not be caused.
And acquiring a resource configuration file in the grouping strategy; reserving a corresponding resource pool for the target service data based on the resource configuration file; the target service data comprises: and the user adds new service or user confidential service. Thus, the reserved resource pool can be used for providing service space for the newly added service and the confidential service of the user.
After the distributed cluster is established, a module needing certain cluster service can check the number of the server groups and specific server information in each server group by checking nodes corresponding to the distributed server cluster through a WATCH function.
Example four
This embodiment also provides a distributed server cluster, which is written in the present embodiment with the whole cluster as an angle, see fig. 7, where the distributed server cluster includes a plurality of server groups, for example, M groups (1 to M); a server 51 to be registered and a node 52; the node 52 is configured to store a grouping policy of the distributed server cluster, where the node 52 corresponds to the distributed server cluster; with continued reference to fig. 2, the server to be registered 51 includes: a policy obtaining unit 21, a distributed lock obtaining unit 22, and a registration unit 23; wherein, the first and the second end of the pipe are connected with each other,
the policy obtaining unit 21 is configured to obtain a grouping policy of the distributed server cluster, where the grouping policy is pre-stored in the node 52 corresponding to the distributed server cluster.
Specifically, when the distributed server cluster is started, the policy obtaining unit 21 sends first request information for requesting to obtain the grouping policy to the node, and the node issues the grouping policy to the server to be registered according to the request information.
The distributed lock acquiring unit 22 is configured to request to acquire a distributed lock of the distributed server cluster; here, the grouping policy and the distributed lock may be stored in the same node, or in different nodes, that is, as described in the first embodiment, the distributed lock may be stored in a node corresponding to the distributed server cluster, or in a node outside the distributed server cluster.
Taking the example of storing the distributed locks in the same node as an example, when the distributed lock acquiring unit 22 requests to acquire the distributed lock of the distributed server cluster, the following steps are specifically performed:
after the policy obtaining unit 21 obtains the grouping policy, the distributed lock obtaining unit 22 may continue to send second request information requesting to obtain a distributed lock to the node. For example, the node adds a server to be registered to a first acquisition queue of the distributed lock according to the second request information, where the second request information includes priority information of the server to be registered.
After the server to be registered is added to the first acquisition queue, the distributed lock acquisition unit 22 requests the node to acquire the priorities of all servers in the first acquisition queue except the server itself; and judging whether the priority of the distributed lock is the highest priority in the first acquisition queue or not, and if the priority is the highest priority in the first acquisition queue, defaulting to directly acquire the distributed lock.
When determining that the priority of the distributed lock acquisition unit is not the highest priority in the first acquisition queue, the distributed lock acquisition unit 22 is further configured to: calling a monitoring mechanism to monitor a server corresponding to an adjacent priority higher than the self priority; and directly acquiring the distributed lock under the condition that the server corresponding to the adjacent priority releases the distributed lock.
As an optional embodiment, after the server to be registered is added to the first acquisition queue, the node acquires the priorities of all servers in the first acquisition queue, and when the node determines that the priority of the server to be registered is the server with the highest priority in the queue, the distributed lock is allocated to the server to be registered.
After the distributed lock is acquired, the distributed lock acquisition unit 22 sends information that the distributed lock is occupied to the waiting server in the first acquisition queue.
As an alternative embodiment, the distributed lock acquiring unit 22, when requesting to acquire a distributed lock of the distributed server cluster, includes:
after the policy obtaining unit 21 obtains the grouping policy, the distributed lock obtaining unit 22 may continue to send third request information for requesting to obtain the distributed lock to the node, and the node adds the server to be registered to the second obtaining queue of the distributed lock according to the second request information.
After the server to be registered is added into the second acquisition queue, the distributed lock acquisition unit 22 requests the node to acquire the serial numbers of all servers in the second acquisition queue except the server itself; and judging whether the sequence number of the self is the minimum sequence number in the second acquisition queue, and if the sequence number is the minimum sequence number, directly acquiring the distributed lock.
Likewise, when determining that the sequence number of the distributed lock acquiring unit is not the smallest sequence number in the second acquiring queue, the distributed lock acquiring unit 22 is further configured to: calling a monitoring mechanism to monitor the adjacent servers with the sequence numbers smaller than the sequence numbers of the adjacent servers; and under the condition that the adjacent server is determined to release the distributed lock, directly acquiring the distributed lock.
As an optional embodiment, after the server to be registered is added to the second acquisition queue, the node acquires the sequence numbers of all servers in the first acquisition queue, and when it is determined that the server to be registered is the server with the smallest sequence number in the second queue, the distributed lock is distributed to the server to be registered.
Similarly, after acquiring the distributed lock, the distributed lock acquisition unit 22 is configured to send information that the distributed lock is occupied to a server waiting in the second acquisition queue.
It should be noted that: the policy obtaining unit 21 may first request to obtain the grouping policy, and then the distributed lock obtaining unit 22 requests to obtain the distributed lock; the lock acquiring unit 22 may first request to acquire the distributed lock, and the policy acquiring unit 21 then requests to acquire the grouping policy, which is not limited herein.
The registering unit 23 is configured to determine, according to the grouping policy, a server group to be joined when it is determined that the distributed lock acquisition unit acquires the distributed lock, and register itself in the corresponding server group.
Specifically, referring to fig. 3, the registration unit 23 includes: a first determining subunit 31, a second determining subunit 32 and a registering subunit.
As an alternative embodiment, the grouping policy includes: average grouping rules and information that the distributed server cluster is divided into M server groups; the first determining subunit 31 is configured to determine, according to the average grouping rule, that the server group that has the fewest total number of currently registered servers should be registered with itself;
the second determining subunit 32 is configured to learn the total number of registered servers included in each server group of the current M server groups, and determine, through comparison, a server group with the fewest current total number of registered servers;
the registering subunit 33 is configured to register itself in the server group with the minimum number of currently registered servers.
For example, M is 2, that is, the distributed server cluster includes two groups of servers, the second determining subunit 32 knows that the total number of currently registered servers in the first group of servers is 3, and the total number of currently registered servers in the second group of servers is 4, and then determines that the distributed server cluster should be registered in the second group of servers by comparison, and the registering subunit 33 registers itself in the first group of servers.
As an alternative embodiment, the grouping policy may include: the method comprises the following steps of (1) weight grouping rules, information of dividing the distributed server cluster into M server groups and a weight value of each server group; the first determining subunit 31 is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach the preset number, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit 32 is configured to acquire the total number of registered servers included in each server group of the current M server groups, and determine, by comparing the total number of the registered servers with the corresponding preset number, a server group for which the total number of the registered servers has not reached the preset number;
the registering subunit 33 is configured to register itself in the server group whose determined total number of currently registered servers has not reached the set preset number.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, the weighted value of the first group of server groups is 1/3, the weighted value of the second group of server groups is 2/3, and the total number of the target servers of the distributed server cluster is 9, then the number of the servers preset in the first group of server groups is 3, and the number of the servers preset in the second group of server groups is 6. If the second determining subunit 32 learns that the number of servers already registered in the first group of server groups is 3 and the number of servers already registered in the second group of server groups is 5, after the comparison, it is determined that the number of servers already registered in the second group of server groups has not reached the preset number of the second group of server groups, and the registering subunit 33 registers itself in the second group of server groups.
As an alternative embodiment, the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the first determining subunit 31 is configured to determine, according to the load grouping rule, that the server group with the highest current operating load should be registered;
the second determining subunit 32 obtains the operation load of each server group in the current M server groups, and determines the server group with the highest current operation load through comparison;
the registering subunit 33 is configured to register itself in the server group with the highest determined current operating load.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, the second determining subunit 32 knows that the operating load of the first group of server groups is 80% and the operating load of the second group of server groups is 80%, then by comparison, it determines that the operating load of the first group of server groups is the highest, and when it is determined that the distributed server cluster should be registered in the first group of server groups, the registering subunit 33 registers itself in the first group of server groups.
As an alternative embodiment, the grouping policy includes: appointing a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the first determining subunit 31 is configured to determine, according to the specified grouping rule, that the server group corresponding to the specified group identifier should be registered by itself;
the second determining subunit 32 is configured to obtain the designated group identifier and the group identifier of each of the current M server groups, and determine, by comparison, the server group corresponding to the designated group identifier;
the registering subunit 33 is configured to register itself in the server group corresponding to the determined specified group identifier.
For example, M is 2, that is, the distributed server cluster includes two groups of server groups, where the group identifier of the first group of server groups is a, the group identifier of the second group of server groups is B, if the designated group identifier is a, the second determining subunit 32 determines, through comparison, that the server group corresponding to the designated group identifier a should be the first group of server groups, and the registering subunit 33 registers itself in the first group of server groups.
Each server can automatically register itself to the corresponding server group according to the grouping strategy, and when servers are on line or off line in the server group, the requirement of automatic grouping can still be met; and because different server groups are used for providing different service services, the efficiency of the distributed server cluster is further improved.
Here, the server to be registered further includes a configuration unit 24, and after the registration subunit 33 registers itself to the corresponding server group, the configuration unit 24 is configured to:
acquiring a redundancy configuration file in the grouping strategy; performing redundancy configuration on the current server based on the redundancy configuration file; therefore, when the server to be registered is down, the redundant machine takes over the work of the server to be registered, and data loss can not be caused.
And acquiring a resource configuration file in the grouping strategy; reserving a corresponding resource pool for the target service data based on the resource configuration file; the target service data comprises: and the user adds new service or user confidential service. Thus, the reserved resource pool can be used for providing service space for the newly added service and the confidential service of the user.
After the distributed cluster is established, a module needing a certain cluster service can check the number of the server groups and specific server information in each server group by checking nodes corresponding to the distributed server cluster through a WATCH function.
The embodiment of the invention also discloses a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program is used for realizing the steps of the method embodiment when being executed by a processor.
The embodiment of the invention also discloses computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the steps of the method embodiment are realized when the processor executes the program.
The technical scheme provided in the embodiment of the application at least has the following technical effects or advantages:
the invention provides a grouping method and a grouping device for a distributed server cluster, wherein the distributed server cluster comprises a plurality of server groups, and the method comprises the following steps: acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored under a node corresponding to the distributed server cluster; requesting to acquire a distributed lock of the distributed server cluster; if the distributed lock is acquired, determining a server group to be joined according to the grouping strategy, and registering the server group to the corresponding server group; therefore, the preset grouping strategy is stored under the node, when the cluster needs to be automatically grouped, the server to be registered acquires the grouping strategy from the node, under the condition that the server acquires the distributed lock, the server group to be added can be determined according to the grouping strategy, and the server group is registered into the corresponding server group, so that the distributed server cluster can be divided into a plurality of server groups, and each server group can be configured to provide different business services, so that the efficiency of the distributed server cluster is improved; and when the servers in the server group are online or offline, the automatic grouping requirement can still be met through the grouping strategy, so that the operation efficiency of the distributed server cluster is ensured.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system is apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed to reflect the intent: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components of a gateway, proxy server, system according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
The invention discloses, A1, a grouping method for a distributed server cluster, the distributed server cluster comprises a plurality of server groups, the method comprises:
acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored in a node corresponding to the distributed server cluster;
requesting to acquire a distributed lock of the distributed server cluster;
and if the distributed lock is acquired, determining a server group to be added according to the grouping strategy, and registering the server group to the corresponding server group.
A2, the method as in A1, the grouping policy comprising: average grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group with the minimum total number of the current registered servers is registered according to the average grouping rule;
acquiring the total number of registered servers contained in each server group in the M current server groups, and determining the server group with the minimum total number of the registered servers through comparison;
registering the server group with the minimum number of the current registered servers.
A3, the method as in A1, the grouping policy comprising: a weight grouping rule, information that the distributed server cluster is divided into M server groups, and a weight value of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group is registered in a server group of which the total number of the current registered servers does not reach the preset number according to the weight grouping rule, wherein the preset number is determined according to the weight value of the server group and the total number of target servers of the distributed server cluster;
acquiring the total number of registered servers contained in each server group in the current M server groups, and comparing the total number with the corresponding preset number to determine the server groups of which the total number of the current registered servers does not reach the preset number;
and registering the self to the server group of which the determined total number of the currently registered servers does not reach the preset number.
A4, the method as in A1, the grouping policy including: load grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group with the highest operation load is registered to according to the load grouping rule;
acquiring the operation load of each server group in the current M server groups, and determining the server group with the highest current operation load through comparison;
and registering the server group with the highest determined current operation load.
A5, the method as in A1, the grouping policy comprising: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to a corresponding server group includes:
determining that the server self is registered in a server group corresponding to the designated group identification according to the designated grouping rule;
acquiring an appointed group identifier and a group identifier of each server group in M current server groups, and determining a server group corresponding to the appointed group identifier through comparison;
and registering the self to the server group corresponding to the determined appointed group identification.
A6, the method as claimed in any one of A1 to A5, each server group in the distributed server cluster being for providing different business services.
B7, a grouping apparatus for a distributed server cluster, the distributed server cluster comprising a plurality of server groups, the apparatus comprising:
a policy obtaining unit, configured to obtain a grouping policy of the distributed server cluster, where the grouping policy is pre-stored in a node corresponding to the distributed server cluster;
a distributed lock acquisition unit, configured to request to acquire a distributed lock of the distributed server cluster;
and the registering unit is used for determining a server group to be added according to the grouping strategy and registering the server group to the corresponding server group when the distributed lock acquisition unit is determined to acquire the distributed lock.
B8, the apparatus as in B7, the grouping policy comprising: average grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the minimum total number of the currently registered servers is registered according to the average grouping rule;
the second determining subunit is configured to acquire the total number of registered servers included in each of the current M server groups, and determine, through comparison, a server group with the fewest total number of currently registered servers;
and the registration subunit is used for registering the registered server group to the server group with the minimum total number of the determined currently registered servers.
The apparatus according to B9 and B7, wherein the grouping policy includes: the method comprises the following steps of (1) weight grouping rules, information of dividing the distributed server cluster into M server groups and a weight value of each server group; the registration unit includes:
the first determining subunit is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach a preset number of the group, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit is configured to acquire the total number of the registered servers included in each of the current M server groups, and compare the acquired total number with the corresponding preset number to determine a server group for which the total number of the current registered servers has not reached the preset number;
and the registration subunit is used for registering the registered server group to the server group of which the total number of the current registered servers does not reach the preset number.
The apparatus according to B10, B7, wherein the grouping policy includes: load grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit is registered in a server group with the highest current operation load according to the load grouping rule;
the second determining subunit is used for acquiring the operation load of each server group in the current M server groups and determining the server group with the highest current operation load through comparison;
and the registration subunit is used for registering the registration subunit to the server group with the highest determined current operation load.
B11, the apparatus as in B7, the grouping policy comprising: appointing a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit should register the first determining subunit in the server group corresponding to the designated group identifier according to the designated grouping rule;
the second determining subunit is used for acquiring the designated group identifier and the group identifier of each server group in the current M server groups, and determining the server group corresponding to the designated group identifier through comparison;
and the registration subunit is used for registering the server group corresponding to the determined specified group identifier.
B12, the apparatus according to any of B7 to B11, wherein each server group in the distributed server cluster is used for providing different business services.
C13, a grouping method for a distributed server cluster, the distributed server cluster comprising a plurality of server groups, the method comprising:
receiving an acquisition request sent by a server to be registered;
and sending a preset grouping strategy to the server to be registered according to the acquisition request, so that when the server to be registered acquires the distributed lock, the server group to be joined can be determined according to the grouping strategy, and the server group is registered into the corresponding server group.
D14, a distributed server cluster which comprises a plurality of server groups, servers to be registered and a node; wherein the node is configured to store a grouping policy of the distributed server cluster, and the node corresponds to the distributed server cluster; the server to be registered comprises:
a policy obtaining unit, configured to obtain, from the node, a grouping policy of the distributed server cluster;
a distributed lock acquisition unit, configured to request to acquire a distributed lock of the distributed server cluster;
and the registering unit is used for determining a server group to be added according to the grouping strategy and registering the server group to the corresponding server group when the distributed lock acquisition unit is determined to acquire the distributed lock.
D15, the cluster according to D14, the grouping policy comprising: average grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit is registered in a server group with the least total number of currently registered servers according to the average grouping rule;
the second determining subunit is configured to acquire the total number of registered servers included in each of the current M server groups, and determine, through comparison, a server group with the fewest current total number of registered servers;
and the registration subunit is used for registering the registration subunit to the server group with the minimum total number of the determined currently registered servers.
D16, the cluster according to D14, the grouping policy comprising: the method comprises the following steps of (1) weight grouping rules, information of dividing the distributed server cluster into M server groups and a weight value of each server group; the registration unit includes:
the first determining subunit is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach a preset number of the group, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit is configured to acquire the total number of the registered servers included in each of the current M server groups, and compare the acquired total number with the corresponding preset number to determine a server group for which the total number of the current registered servers has not reached the preset number;
and the registration subunit is used for registering the registered server group to the server group of which the total number of the current registered servers does not reach the preset number.
D17, the cluster as set forth in D14, the grouping policy comprising: load grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit is registered in a server group with the highest current operation load according to the load grouping rule;
the second determining subunit is used for acquiring the operation load of each server group in the current M server groups and determining the server group with the highest current operation load through comparison;
and the registration subunit is used for registering the registration subunit to the server group with the highest determined current operation load.
D18, the cluster according to D14, the grouping policy comprising: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit should register the first determining subunit in the server group corresponding to the designated group identifier according to the designated grouping rule;
the second determining subunit is used for acquiring the designated group identifier and the group identifier of each server group in the current M server groups, and determining the server group corresponding to the designated group identifier through comparison;
and the registration subunit is used for registering the server group corresponding to the determined specified group identifier.
D19, the cluster according to any one of D14 to D18, each server group in the distributed server cluster being for providing a different business service.
E20, a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored under a node corresponding to the distributed server cluster; the distributed server cluster comprises a plurality of server groups;
requesting to acquire a distributed lock of the distributed server cluster;
and if the distributed lock is acquired, determining a server group to be added according to the grouping strategy, and registering the server group to the corresponding server group.
F21, a computer device for a distributed server cluster, comprising:
at least one processor; and
at least one memory communicatively coupled to the processor, wherein,
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform a method as described in any of A1-A6 or C13.

Claims (21)

1. A grouping method for a distributed server cluster, the distributed server cluster comprising a plurality of server groups, the method comprising:
acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored in a node of the distributed server cluster, and the node corresponds to a server in the distributed server cluster;
requesting to acquire a distributed lock of the distributed server cluster;
and if the distributed lock is acquired, determining a server group to be added according to the grouping strategy, and registering the server group to the corresponding server group.
2. The method of claim 1, wherein the grouping policy comprises: average grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to a corresponding server group includes:
determining that the server group is registered in the server group with the least total number of the currently registered servers according to the average grouping rule;
acquiring the total number of registered servers contained in each server group in the M server groups, and comparing to determine the server group with the minimum total number of the registered servers;
registering the server group with the minimum number of the current registered servers.
3. The method of claim 1, wherein the grouping policy comprises: a weight grouping rule, information that the distributed server cluster is divided into M server groups, and a weight value of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group is registered in a server group of which the total number of the current registered servers does not reach the preset number according to the weight grouping rule, wherein the preset number is determined according to the weight value of the server group and the total number of target servers of the distributed server cluster;
acquiring the total quantity of the registered servers contained in each server group in the M current server groups, and comparing the total quantity with the corresponding preset quantity to determine the server groups of which the total quantity of the registered servers does not reach the preset quantity;
and registering the self to the server group of which the determined total number of the currently registered servers does not reach the preset number.
4. The method of claim 1, wherein the grouping policy comprises: load grouping rules and information that the distributed server cluster is divided into M server groups; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server group with the highest operation load is registered to according to the load grouping rule;
acquiring the operation load of each server group in the M server groups, and determining the server group with the highest current operation load through comparison;
and registering the server group with the highest determined current operation load.
5. The method of claim 1, wherein the grouping policy comprises: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the determining a server group to be joined according to the grouping policy and registering the server group to the corresponding server group includes:
determining that the server self is registered in a server group corresponding to the designated group identification according to the designated grouping rule;
acquiring an appointed group identifier and a group identifier of each server group in the M server groups, and determining the server group corresponding to the appointed group identifier through comparison;
and registering the self to the server group corresponding to the determined appointed group identification.
6. The method of any of claims 1 to 5, wherein each server group in the distributed server cluster is for providing a different business service.
7. A grouping apparatus for a distributed server cluster, the distributed server cluster comprising a plurality of server groups, the apparatus comprising:
a policy obtaining unit, configured to obtain a grouping policy of the distributed server cluster, where the grouping policy is pre-stored in a node of the distributed server cluster, and the node corresponds to a server in the distributed server cluster;
the distributed lock acquisition unit is used for requesting to acquire the distributed lock of the distributed server cluster;
and the registering unit is used for determining a server group to be added according to the grouping strategy and registering the server group to the corresponding server group when the distributed lock acquisition unit is determined to acquire the distributed lock.
8. The apparatus of claim 7, wherein the grouping policy comprises: average grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the minimum total number of the currently registered servers is registered according to the average grouping rule;
the second determining subunit is configured to obtain the total number of registered servers included in each of the M server groups, and determine, through comparison, a server group with the fewest total number of currently registered servers;
and the registration subunit is used for registering the registered server group to the server group with the minimum total number of the determined currently registered servers.
9. The apparatus of claim 7, wherein the grouping policy comprises: a weight grouping rule, information that the distributed server cluster is divided into M server groups, and a weight value of each server group; the registration unit includes:
the first determining subunit is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach a preset number of the group, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit is configured to obtain the total number of the registered servers included in each of the M server groups, and determine, by comparing the total number of the registered servers with a corresponding preset number, a server group for which the total number of the registered servers has not reached the preset number;
and the registration subunit is used for registering the registered server group to the server group of which the total number of the current registered servers does not reach the preset number.
10. The apparatus of claim 7, wherein the grouping policy comprises: load grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the highest operation load is registered to the server group according to the load grouping rule;
the second determining subunit is configured to obtain the operating load of each server group in the M server groups, and determine, through comparison, a server group with the highest current operating load;
and the registration subunit is used for registering the registration subunit to the server group with the highest determined current operation load.
11. The apparatus of claim 7, wherein the grouping policy comprises: specifying a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit should register the first determining subunit in the server group corresponding to the designated group identifier according to the designated grouping rule;
the second determining subunit is configured to acquire the designated group identifier and the group identifier of each of the M current server groups, and determine, by comparison, the server group corresponding to the designated group identifier;
and the registration subunit is used for registering the server group corresponding to the determined specified group identifier.
12. The apparatus of any of claims 7 to 11, wherein each server group in the distributed server cluster is to provide a different business service.
13. A grouping method for a distributed server cluster, wherein the distributed server cluster comprises a plurality of server groups, the method comprising:
receiving an acquisition request sent by a server to be registered;
and sending a preset grouping strategy to the server to be registered according to the acquisition request, so that when the server to be registered acquires the distributed lock, the server group to be joined can be determined according to the grouping strategy, and the server group is registered into the corresponding server group.
14. A distributed server cluster is characterized by comprising a plurality of server groups, servers to be registered and a node; wherein the node is configured to store a grouping policy for the distributed server cluster, and the node corresponds to a server in the distributed server cluster; the server to be registered includes:
a policy obtaining unit, configured to obtain, from the node, a grouping policy of the distributed server cluster;
a distributed lock acquisition unit, configured to request to acquire a distributed lock of the distributed server cluster;
and the registering unit is used for determining a server group to be added according to the grouping strategy and registering the server group to the corresponding server group when the distributed lock acquisition unit is determined to acquire the distributed lock.
15. The cluster of claim 14, wherein the grouping policy comprises: average grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the minimum total number of the currently registered servers is registered according to the average grouping rule;
the second determining subunit is configured to acquire the total number of the registered servers included in each of the M current server groups, and determine, through comparison, a server group with the fewest current total number of the registered servers;
and the registration subunit is used for registering the registered server group to the server group with the minimum total number of the determined currently registered servers.
16. The cluster of claim 14, wherein the grouping policy comprises: a weight grouping rule, information that the distributed server cluster is divided into M server groups, and a weight value of each server group; the registration unit includes:
the first determining subunit is configured to determine, according to the weight grouping rule, that the first determining subunit should register the first determining subunit into a server group whose total number of currently registered servers does not reach a preset number of the group, where the preset number is determined according to a weight value of the server group and a total number of target servers of the distributed server cluster;
the second determining subunit is configured to obtain the total number of the registered servers included in each of the M server groups, and determine, by comparing the total number of the registered servers with a corresponding preset number, a server group for which the total number of the registered servers has not reached the preset number;
and the registration subunit is used for registering the registered server group to the server group of which the total number of the current registered servers does not reach the preset number.
17. The cluster of claim 14, wherein the grouping policy comprises: load grouping rules and information that the distributed server cluster is divided into M server groups; the registration unit includes:
the first determining subunit is used for determining that the server group with the highest operation load is registered to the server group according to the load grouping rule;
the second determining subunit is configured to obtain the operating load of each server group in the M server groups, and determine, through comparison, a server group with the highest current operating load;
and the registration subunit is used for registering the registration subunit to the server group with the highest determined current operation load.
18. The cluster of claim 14, wherein the grouping policy comprises: appointing a grouping rule, information of dividing the distributed server cluster into M server groups and a group identifier of each server group; the registration unit includes:
the first determining subunit is used for determining that the first determining subunit is registered in a server group corresponding to the designated group identifier according to the designated grouping rule;
the second determining subunit is configured to acquire the designated group identifier and the group identifier of each of the M current server groups, and determine, by comparison, the server group corresponding to the designated group identifier;
and the registration subunit is used for registering the server group corresponding to the determined specified group identifier.
19. The cluster of any of claims 14 to 18, wherein each server group in the distributed server cluster is to provide a different business service.
20. A computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, performing the steps of:
acquiring a grouping strategy of the distributed server cluster, wherein the grouping strategy is pre-stored in a node of the distributed server cluster, and the node corresponds to a server in the distributed server cluster; the distributed server cluster comprises a plurality of server groups;
requesting to acquire a distributed lock of the distributed server cluster;
and if the distributed lock is acquired, determining a server group to be added according to the grouping strategy, and registering the server group to the corresponding server group.
21. A computer device for a distributed server cluster, comprising:
at least one processor; and
at least one memory communicatively coupled to the processor, wherein,
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of claims 1 to 6 or 13.
CN201810002956.3A 2018-01-02 2018-01-02 Grouping method and device for distributed server cluster Active CN109995842B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810002956.3A CN109995842B (en) 2018-01-02 2018-01-02 Grouping method and device for distributed server cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810002956.3A CN109995842B (en) 2018-01-02 2018-01-02 Grouping method and device for distributed server cluster

Publications (2)

Publication Number Publication Date
CN109995842A CN109995842A (en) 2019-07-09
CN109995842B true CN109995842B (en) 2022-12-02

Family

ID=67128831

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810002956.3A Active CN109995842B (en) 2018-01-02 2018-01-02 Grouping method and device for distributed server cluster

Country Status (1)

Country Link
CN (1) CN109995842B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110233767A (en) * 2019-07-26 2019-09-13 苏州浪潮智能科技有限公司 Service configuration method, system, device and the readable storage medium storing program for executing of distributed type assemblies
CN110519348A (en) * 2019-08-15 2019-11-29 苏州浪潮智能科技有限公司 A kind of mostly service distributed type assemblies deployment system and method
CN111901422B (en) * 2020-07-28 2022-11-11 浪潮电子信息产业股份有限公司 Method, system and device for managing nodes in cluster
CN112751926B (en) * 2020-12-29 2023-05-26 北京浪潮数据技术有限公司 Management method, system and related device for working nodes in cluster
CN113127172A (en) * 2021-04-21 2021-07-16 上海销氪信息科技有限公司 Task execution method and device, electronic equipment and storage medium
CN114879942B (en) * 2022-05-20 2023-02-03 北京宇信科技集团股份有限公司 Distributed time wheel group registration verification method, device, medium and equipment
CN115412510B (en) * 2022-10-31 2023-01-17 成都中科合迅科技有限公司 Flexible configuration method based on distributed framework service

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004049656A1 (en) * 2002-11-27 2004-06-10 Netseal Mobility Technologies - Nmt Oy Scalable and secure packet server-cluster
CN107241445A (en) * 2017-07-31 2017-10-10 郑州云海信息技术有限公司 A kind of distributed server cluster dispositions method and system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6801937B1 (en) * 2000-05-31 2004-10-05 International Business Machines Corporation Method, system and program products for defining nodes to a cluster
US8582470B2 (en) * 2007-03-12 2013-11-12 Telefonaktiebolaget L M Ericsson (Publ) Arrangement and method relating to network management
CN106027634B (en) * 2016-05-16 2019-06-04 白杨 Message port Exchange Service system
CN106993019B (en) * 2016-11-29 2019-11-19 深圳壹账通智能科技有限公司 Distributed task dispatching method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004049656A1 (en) * 2002-11-27 2004-06-10 Netseal Mobility Technologies - Nmt Oy Scalable and secure packet server-cluster
CN107241445A (en) * 2017-07-31 2017-10-10 郑州云海信息技术有限公司 A kind of distributed server cluster dispositions method and system

Also Published As

Publication number Publication date
CN109995842A (en) 2019-07-09

Similar Documents

Publication Publication Date Title
CN109995842B (en) Grouping method and device for distributed server cluster
CN109428922B (en) Subscription and publishing method and server
US9002997B2 (en) Instance host configuration
US8185905B2 (en) Resource allocation in computing systems according to permissible flexibilities in the recommended resource requirements
US7984147B2 (en) Apparatus and method for identifying a requested level of service for a transaction
CN106790692A (en) A kind of load-balancing method and device of many clusters
CN108881512B (en) CTDB virtual IP balance distribution method, device, equipment and medium
CN103607424B (en) Server connection method and server system
US8966025B2 (en) Instance configuration on remote platforms
CN114025021B (en) Communication method, system, medium and electronic equipment crossing Kubernetes cluster
CN107105013B (en) File processing method, server, terminal and system
CN110633175B (en) Multi-computer-room data processing method based on micro-service, electronic equipment and storage medium
WO2017185251A1 (en) Vnfm determining method and network function virtualization orchestrator
CN110311837B (en) Online service availability detection method and device and computer equipment
CN109873714B (en) Cloud computing node configuration updating method and terminal equipment
WO2017118318A1 (en) Data storage and service processing method and device
CN106713353A (en) Intelligent seamless aggregation method and system for geographic information service
US8504682B2 (en) Localization of peer to peer traffic
CN111352726A (en) Streaming data processing method and device based on containerized micro-service
CN111628878A (en) Fault positioning method, device and system based on multi-stage network nodes
US9819732B2 (en) Methods for centralized management API service across disparate storage platforms and devices thereof
CN114979286A (en) Access control method, device and equipment for container service and computer storage medium
US11323368B1 (en) System and method for web service atomic transaction (WS-AT) affinity routing
CN112988405B (en) Automatic degradation method and device for micro-service and computing equipment
CN111221847B (en) Monitoring data storage method, device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant