Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a method, an apparatus, a device, and a readable medium for placing group owners in a binding pool in a distributed storage, by using the technical solution of the present invention, owners of corresponding PGs in two binding storage pools can be located on the same physical node as much as possible, thereby reducing the pressure of a network, improving the performance of a storage cluster, and improving the competitiveness of products.
Based on the above objects, an aspect of the embodiments of the present invention provides a method for placing a group owner in a binding pool in a distributed storage, including the steps of:
Acquiring PG in the reference pool, acquiring corresponding PG in the binding pool according to the corresponding relation of PG, and putting the PG in the acquired reference pool and the corresponding PG in the binding pool into a variable structure;
Traversing the members of the PG in the reference pool, acquiring the IP of the node where the members are located, taking the acquired IP as a keyword, and taking the IDs of the members and the PG as a group of values to be stored in a data structure;
traversing the members of the PG corresponding to the binding pool, and judging whether the node IP where the members are located can be inquired in the data structure;
Responding to the node IP where the member is located and inquiring in a data structure, and adding the IDs of the member and PG as a group of values into the data structure of the value of the IP key word;
and obtaining the number of the values in each IP, and selecting the member in the structure with the largest number of the IP median values as the master of each PG.
According to one embodiment of the present invention, further comprising:
Responsive to the number of values obtained in each IP being the same, adding the number of times that the member of the data structure of each IP is selected as the master;
And selecting the member with the least addition times as the master of each PG.
According to one embodiment of the present invention, further comprising:
Calculating the sum of the times of mastering each OSD on the node where each member is located in response to the fact that the added values of the times of selecting the member as the master in the data structure of each IP are the same;
the sum of the number of times of mastering is selected as the master of the respective PG.
According to one embodiment of the present invention, further comprising:
Deleting the PG from the variable structure in response to setting the selected member as the master of the respective PG;
Judging whether the variable structure is empty or not;
In response to the variable structure not being empty, traversing members of the remaining PGs in the variable structure and adding the number of times the members are selected as primary;
And selecting the member with the least addition times as the master of each PG.
In another aspect of the embodiment of the present invention, there is also provided an apparatus for binding pool placement group owner in distributed storage, the apparatus including:
The acquisition module is configured to acquire the PG in the reference pool, acquire the corresponding PG in the binding pool according to the corresponding relation of the PG, and put the PG in the acquired reference pool and the corresponding PG in the binding pool into a variable structure;
The storage module is configured to traverse the members of the PG in the reference pool, acquire the IP of the node where the members are located, take the acquired IP as a key word, and store the IDs of the members and the PG as a group of values in the data structure;
the judging module is configured to traverse the members of the PG corresponding to the binding pool and judge whether the node IP where the members are located can be inquired in the data structure;
The adding module is configured to respond to the fact that the node IP where the member is located can be queried in the data structure, and add the IDs of the member and the PG as a group of values to the data structure of the value of the IP key word;
And the selection module is configured to acquire the number of values in each IP, and select the member in the structure with the largest number of the values in the IP as the master of each PG.
According to one embodiment of the invention, the selection module is further configured to:
Responsive to the number of values obtained in each IP being the same, adding the number of times that the member of the data structure of each IP is selected as the master;
And selecting the member with the least addition times as the master of each PG.
According to one embodiment of the invention, the selection module is further configured to:
Calculating the sum of the times of mastering each OSD on the node where each member is located in response to the fact that the added values of the times of selecting the member as the master in the data structure of each IP are the same;
the sum of the number of times of mastering is selected as the master of the respective PG.
According to one embodiment of the invention, the method further comprises a deletion module configured to:
Deleting the PG from the variable structure in response to setting the selected member as the master of the respective PG;
Judging whether the variable structure is empty or not;
In response to the variable structure not being empty, traversing members of the remaining PGs in the variable structure and adding the number of times the members are selected as primary;
And selecting the member with the least addition times as the master of each PG.
In another aspect of the embodiments of the present invention, there is also provided a computer apparatus including:
at least one processor; and
And a memory storing computer instructions executable on the processor, the instructions when executed by the processor performing the steps of any of the methods described above.
In another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of any of the methods described above.
The invention has the following beneficial technical effects: according to the method for placing and selecting the binding pool in the distributed storage, PG in the reference pool is obtained, corresponding PG in the binding pool is obtained according to the corresponding relation of PG, and the obtained PG in the reference pool and the corresponding PG in the binding pool are placed into a variable structure; traversing the members of the PG in the reference pool, acquiring the IP of the node where the members are located, taking the acquired IP as a keyword, and taking the IDs of the members and the PG as a group of values to be stored in a data structure; traversing the members of the PG corresponding to the binding pool, and judging whether the node IP where the members are located can be inquired in the data structure; responding to the node IP where the member is located and inquiring in a data structure, and adding the IDs of the member and PG as a group of values into the data structure of the value of the IP key word; the method comprises the steps of obtaining the number of values in each IP, selecting members in the structure with the largest number of the IP median values as the main technical scheme of respective PG, enabling the main of the corresponding PG of the two binding storage pools to be on the same physical node as much as possible, reducing the pressure of a network, improving the performance of a storage cluster and improving the competitiveness of products.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention will be described in further detail with reference to the accompanying drawings.
With the above object in view, in a first aspect, an embodiment of a method for binding pool placement group election in a distributed storage is provided. Fig. 1 shows a schematic flow chart of the method.
As shown in fig. 1, the method may include the steps of:
S1, acquiring PG in the reference pool, acquiring corresponding PG in the binding pool according to the corresponding relation of PG, and putting the PG in the acquired reference pool and the corresponding PG in the binding pool into a variable structure.
The other storage pool is called a binding pool of the reference pool, and the number of the storage pools PG is always an integer power of 2, so that even if the number of the two storage pools PG is different, the relationship is an integer multiple of 2. From this, the following PG correspondence is always established: and taking the pool1 with the fewer PG number as a reference, segmenting the PGs in the storage pools with the more PG numbers according to the PG number of the pool1, wherein the PG number in each segmented part is equal to the PG number of the pool1, and carrying out one-to-one correspondence on each part and the PG of the pool1 to obtain the corresponding relation of the PGs. The first PG in the reference pool and the corresponding PG in the binding pool are acquired, and in the PG antitheft variable structures, as shown in fig. 2, the corresponding PG (group_pgs): 1.0,2.0,2.1024 denotes that PG No. 0 in the reference pool1 corresponds to PG No. 0 in the binding pool 2 and PG No. 1024 in the binding pool 2.
S2, traversing the members of the PG in the reference pool, acquiring the IP of the node where the members are located, taking the acquired IP as a keyword, and taking the IDs of the members and the PG as a group of values to be stored in a data structure.
Each PG has a plurality of OSD members, each member has a node IP where it is located, the node IPs among the members and the corresponding OSD members are counted, then the IDs of the OSD members and the PG are stored in a data structure as a set of values by taking the node IPs as keywords, as shown in fig. 3, the value in IP127.0.0.1 represents the number 0 PG corresponding to the number 0 OSD, IP127.0.0.2 in the reference pool 1 represents the number 6 OSD corresponding to the number 0 PG in the reference pool 1, and so on.
S3, traversing the members of the PG corresponding to the binding pool, and judging whether the node IP where the members are located can be inquired in the data structure.
S4, responding to the fact that the node IP where the member is located can be queried in the data structure, and adding the IDs of the member and the PG as a group of values to the data structure of the value of the IP key.
Then traversing members of PG of the binding pool corresponding to PG No. 0 in the reference pool 1, checking whether the node IP of the member can be queried in the data structure, and as shown in FIG. 4, increasing the value in IP127.0.0.1 to be OSD No.1 corresponding to PG No. 0 in the binding pool 2, OSD No. 2 corresponding to PG No. 1024 in the binding pool 2, and so on.
S5, obtaining the number of values in each IP, and selecting the member in the structure with the largest number of the IP median values as the master of each PG.
As shown in fig. 4, IP127.0.0.1 have 3 values, and if the number is the largest, the OSD corresponding to the 3 values is selected as the main of each PG. After the above steps are completed, the above steps are restarted from the second PG in the reference pool until all the main settings of all the PGs are completed.
By the technical scheme of the invention, the masters of the corresponding PGs of the two binding storage pools can be located on the same physical node as much as possible, the pressure of the network is reduced, the performance of the storage cluster is improved, and the product competitiveness is improved.
In a preferred embodiment of the present invention, further comprising:
Responsive to the number of values obtained in each IP being the same, adding the number of times that the member of the data structure of each IP is selected as the master;
And selecting the member with the least addition times as the master of each PG. If the number of data in each IP in the data structure is the same, counting the times of each member as the main, and selecting the member with the least times as the main of the PG.
In a preferred embodiment of the present invention, further comprising:
Calculating the sum of the times of mastering each OSD on the node where each member is located in response to the fact that the added values of the times of selecting the member as the master in the data structure of each IP are the same;
the sum of the number of times of mastering is selected as the master of the respective PG. If the number of times that the member takes the main is the same, counting the sum of the number of times that the member takes the main on the node, and selecting the member with the smallest sum of the number of times that the member takes the main on the node as the main of the PG.
In a preferred embodiment of the present invention, further comprising:
Deleting the PG from the variable structure in response to setting the selected member as the master of the respective PG;
Judging whether the variable structure is empty or not;
In response to the variable structure not being empty, traversing members of the remaining PGs in the variable structure and adding the number of times the members are selected as primary;
and selecting the member with the least addition times as the master of each PG. And after the selected main modification is completed, updating the OSD main count and the node main count, deleting the PGs from the group_pgs, if the group_pgs is not empty, indicating that the members with the PGs are not selected, traversing the members of the PGs, selecting the member with the least OSD main count as the main, if the members with the least OSD main count are the same, comparing the main counts of the nodes where the OSD is located, and updating the OSD main count and the node main count.
It should be noted that, it will be understood by those skilled in the art that all or part of the procedures in implementing the methods of the above embodiments may be implemented by a computer program to instruct related hardware, and the above program may be stored in a computer readable storage medium, and the program may include the procedures of the embodiments of the above methods when executed. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like. The computer program embodiments described above may achieve the same or similar effects as any of the method embodiments described above.
Furthermore, the method disclosed according to the embodiment of the present invention may also be implemented as a computer program executed by a CPU, which may be stored in a computer-readable storage medium. When executed by a CPU, performs the functions defined above in the methods disclosed in the embodiments of the present invention.
In view of the above object, a second aspect of the embodiments of the present invention proposes an apparatus for placing a group owner in a binding pool in a distributed storage, as shown in fig. 2, an apparatus 200 includes:
The acquisition module is configured to acquire the PG in the reference pool, acquire the corresponding PG in the binding pool according to the corresponding relation of the PG, and put the PG in the acquired reference pool and the corresponding PG in the binding pool into a variable structure;
The storage module is configured to traverse the members of the PG in the reference pool, acquire the IP of the node where the members are located, take the acquired IP as a key word, and store the IDs of the members and the PG as a group of values in the data structure;
the judging module is configured to traverse the members of the PG corresponding to the binding pool and judge whether the node IP where the members are located can be inquired in the data structure;
The adding module is configured to respond to the fact that the node IP where the member is located can be queried in the data structure, and add the IDs of the member and the PG as a group of values to the data structure of the value of the IP key word;
And the selection module is configured to acquire the number of values in each IP, and select the member in the structure with the largest number of the values in the IP as the master of each PG.
In a preferred embodiment of the invention, the selection module is further configured to:
Responsive to the number of values obtained in each IP being the same, adding the number of times that the member of the data structure of each IP is selected as the master;
And selecting the member with the least addition times as the master of each PG.
In a preferred embodiment of the invention, the selection module is further configured to:
Calculating the sum of the times of mastering each OSD on the node where each member is located in response to the fact that the added values of the times of selecting the member as the master in the data structure of each IP are the same;
the sum of the number of times of mastering is selected as the master of the respective PG.
In a preferred embodiment of the present invention, the method further comprises a deletion module configured to:
Deleting the PG from the variable structure in response to setting the selected member as the master of the respective PG;
Judging whether the variable structure is empty or not;
In response to the variable structure not being empty, traversing members of the remaining PGs in the variable structure and adding the number of times the members are selected as primary;
And selecting the member with the least addition times as the master of each PG.
Based on the above object, a third aspect of the embodiments of the present invention proposes a computer device. Fig. 3 is a schematic diagram of an embodiment of a computer device provided by the present invention. As shown in fig. 3, an embodiment of the present invention includes the following means: at least one processor 21; and a memory 22, the memory 22 storing computer instructions 23 executable on the processor, the instructions when executed by the processor performing the method of:
Acquiring PG in the reference pool, acquiring corresponding PG in the binding pool according to the corresponding relation of PG, and putting the PG in the acquired reference pool and the corresponding PG in the binding pool into a variable structure;
Traversing the members of the PG in the reference pool, acquiring the IP of the node where the members are located, taking the acquired IP as a keyword, and taking the IDs of the members and the PG as a group of values to be stored in a data structure;
traversing the members of the PG corresponding to the binding pool, and judging whether the node IP where the members are located can be inquired in the data structure;
Responding to the node IP where the member is located and inquiring in a data structure, and adding the IDs of the member and PG as a group of values into the data structure of the value of the IP key word;
and obtaining the number of the values in each IP, and selecting the member in the structure with the largest number of the IP median values as the master of each PG.
In a preferred embodiment of the present invention, further comprising:
Responsive to the number of values obtained in each IP being the same, adding the number of times that the member of the data structure of each IP is selected as the master;
And selecting the member with the least addition times as the master of each PG.
In a preferred embodiment of the present invention, further comprising:
Calculating the sum of the times of mastering each OSD on the node where each member is located in response to the fact that the added values of the times of selecting the member as the master in the data structure of each IP are the same;
the sum of the number of times of mastering is selected as the master of the respective PG.
In a preferred embodiment of the present invention, further comprising:
Deleting the PG from the variable structure in response to setting the selected member as the master of the respective PG;
Judging whether the variable structure is empty or not;
In response to the variable structure not being empty, traversing members of the remaining PGs in the variable structure and adding the number of times the members are selected as primary;
And selecting the member with the least addition times as the master of each PG.
Based on the above object, a fourth aspect of the embodiments of the present invention proposes a computer-readable storage medium. Fig. 4 is a schematic diagram of an embodiment of a computer-readable storage medium provided by the present invention. As shown in fig. 4, the computer-readable storage medium S31 stores a computer program S32 that, when executed by a processor, performs the following method:
Acquiring PG in the reference pool, acquiring corresponding PG in the binding pool according to the corresponding relation of PG, and putting the PG in the acquired reference pool and the corresponding PG in the binding pool into a variable structure;
Traversing the members of the PG in the reference pool, acquiring the IP of the node where the members are located, taking the acquired IP as a keyword, and taking the IDs of the members and the PG as a group of values to be stored in a data structure;
traversing the members of the PG corresponding to the binding pool, and judging whether the node IP where the members are located can be inquired in the data structure;
Responding to the node IP where the member is located and inquiring in a data structure, and adding the IDs of the member and PG as a group of values into the data structure of the value of the IP key word;
and obtaining the number of the values in each IP, and selecting the member in the structure with the largest number of the IP median values as the master of each PG.
In a preferred embodiment of the present invention, further comprising:
Responsive to the number of values obtained in each IP being the same, adding the number of times that the member of the data structure of each IP is selected as the master;
And selecting the member with the least addition times as the master of each PG.
In a preferred embodiment of the present invention, further comprising:
Calculating the sum of the times of mastering each OSD on the node where each member is located in response to the fact that the added values of the times of selecting the member as the master in the data structure of each IP are the same;
the sum of the number of times of mastering is selected as the master of the respective PG.
In a preferred embodiment of the present invention, further comprising:
Deleting the PG from the variable structure in response to setting the selected member as the master of the respective PG;
Judging whether the variable structure is empty or not;
In response to the variable structure not being empty, traversing members of the remaining PGs in the variable structure and adding the number of times the members are selected as primary;
And selecting the member with the least addition times as the master of each PG.
Furthermore, the method disclosed according to the embodiment of the present invention may also be implemented as a computer program executed by a processor, which may be stored in a computer-readable storage medium. The above-described functions defined in the methods disclosed in the embodiments of the present invention are performed when the computer program is executed by a processor.
Furthermore, the above-described method steps and system units may also be implemented using a controller and a computer-readable storage medium storing a computer program for causing the controller to implement the above-described steps or unit functions.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general purpose or special purpose computer or general purpose or special purpose processor. Further, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that as used herein, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The foregoing embodiment of the present invention has been disclosed with reference to the number of embodiments for the purpose of description only, and does not represent the advantages or disadvantages of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, and the program may be stored in a computer readable storage medium, where the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will appreciate that: the above discussion of any embodiment is merely exemplary and is not intended to imply that the scope of the disclosure of embodiments of the invention, including the claims, is limited to such examples; combinations of features of the above embodiments or in different embodiments are also possible within the idea of an embodiment of the invention, and many other variations of the different aspects of the embodiments of the invention as described above exist, which are not provided in detail for the sake of brevity. Therefore, any omission, modification, equivalent replacement, improvement, etc. of the embodiments should be included in the protection scope of the embodiments of the present invention.