Summary of the invention
The present invention provides the method, apparatus and system of a kind of volume distribution of host, can be improved disk resource utilization rate.
In order to achieve the above object, the present invention is achieved through the following technical solutions:
In a first aspect, the present invention provides a kind of methods of host volume distribution, comprising:
S1: being directed to each host, at least one disk in the host be divided into different volume groups, determines
The attribute information of each volume group, and create each described volume group of the host;
S2: at least one data volume information is determined;
S3: according to the attribute information, the corresponding target host machine of at least one described data volume information is filtered out;
S4: the request of the corresponding creation logical volume of at least one described data volume information is sent to the target host
Machine.
Further, the S1, comprising:
It for each host, is performed both by: determining the type and size of at least one disk in the host;
The disk with same type at least one described disk is divided into a roll of group, at least one volume is obtained
Group;
Based on the type and size of at least one disk described in determining, the attribute information of each volume group is determined,
And the attribute information include volumegroup name claim, roll up set type, volume group size, host IP address, in included disk extremely
Few one kind;
The request of the attribute information of each determining volume group and creation volume group is sent to the host;
The volume group creation information that the host returns is saved.
Further, the attribute information includes: volume set type and volume group size;
The S2, comprising: when creation container, determine its at least one data volume information carried, and the book is believed
Breath includes at least one of type, size and its catalogue in the container of book;Establish includes described at least one
The data volume list of a data volume information;
The S3, comprising:
A1: it according to the host list including each host pre-established, determines in the host list
First host;
A2: judging whether the data volume list is empty, if so, determine that first host is target host machine,
And terminate current process, otherwise, obtain first data volume information in the data volume list;
A3: according to the target type and target sizes for including in first data volume information, judge described first
It whether include the mesh rolled up set type and be not less than the target sizes for the target type and volume group size in the volume group of host
Volume group is marked, if so, first data volume information is removed from the data volume list, according to the target sizes to described
Target volume group carries out resource preemption, and executes A2, otherwise, first host is removed from the host list, and
Execute A1.
Further, this method further include: be ranked up according to the volume group size summation of the volume group of each host;Root
The host list is established according to descending ranking results.
Second aspect, the present invention provides a kind of hosts to roll up assigned unit, comprising:
At least one disk in the host is divided into difference for being directed to each host by creating unit
Volume group, determine the attribute information of each volume group, and create each described volume group of the host;
Determination unit, for determining at least one data volume information;
Screening unit, for according to the attribute information, filtering out at least one described corresponding target of data volume information
Host;
Transmission unit, it is described for the request of the corresponding creation logical volume of at least one described data volume information to be sent to
Target host machine.
Further, the creating unit is specifically used for being directed to each host, is performed both by: determining the host
In at least one disk type and size;The disk with same type at least one described disk is divided into together
A roll of group, obtain at least one volume group;Based on the type and size of at least one disk described in determining, determine described in each
The attribute information of volume group, and the attribute information includes that volumegroup name claims, rolls up set type, volume group size, host IP address, wrapped
At least one of disk included;The request of the attribute information of each determining volume group and creation volume group is sent to institute
State host;The volume group creation information that the host returns is saved.
Further, the attribute information includes: volume set type and volume group size;
The determination unit when being specifically used for creation container, determines its at least one data volume information carried, and described
Book information includes at least one of type, size and its catalogue in the container of book;Establishing includes institute
State the data volume list of at least one data volume information;
The screening unit comprises determining that subelement, the first processing subelement, second processing subelement;
The determining subelement, for determining institute according to the host list including each host pre-established
State first host in host list;
The first processing subelement, for judging whether the data volume list is empty, if so, determining described first
Host is target host machine, and terminates current process, otherwise, obtains first book letter in the data volume list
Breath;
The second processing subelement, for according to the target type and target for including in first data volume information
Size, judge in the volume group of first host whether include volume set type for the target type and volume group size it is not small
In the target volume group of the target sizes, if so, first data volume information is removed from the data volume list, according to
The target sizes carry out resource preemption to the target volume group, and trigger the first processing subelement, otherwise, from the place
First host is removed in Host List, and triggers the determining subelement.
Further, the creating unit is also used to be carried out according to the volume group size summation of the volume group of each host
Sequence;The host list is established according to descending ranking results.
The third aspect, the present invention provides a kind of systems of host volume distribution, comprising:
Any of the above-described the host volume assigned unit and at least one host, wherein
Each described host, the creation logical volume sent for receiving and executing the host volume assigned unit
Request, and it is described creation logical volume request correspond at least one data volume information.
Further, each described host is specifically used for according to data volume information described in each, in the data
Logical volume is created in the corresponding volume group of volume information;The logical volume of creation is formatted as ext4 file system;According to creation
The logical volume uuid, be mounted to the specified directory of the host, and be written to/etc/fatab file.
The present invention provides the method, apparatus and system of a kind of volume distribution of host, for each host, by host
At least one disk in machine is divided into different volume groups, determines the attribute information of each volume group, and creates the host
Each volume group;Determine at least one data volume information;According to determining attribute information, at least one data volume information is filtered out
Corresponding target host machine;The request of the corresponding creation logical volume of an at least data volume information is sent to the target host
Machine.The disk of host is divided into different volume groups, and according to the attribute information of volume group and the data volume information determined, with
Logical volume is created on host, so as to make full use of the disk resource of host.Therefore, the present invention can be improved disk money
Source utilization rate.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments, based on the embodiments of the present invention, those of ordinary skill in the art
Every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
As shown in Figure 1, may comprise steps of the embodiment of the invention provides a kind of method of host volume distribution:
Step 101: being directed to each host, at least one disk in the host is divided into different volumes
Group, determines the attribute information of each volume group, and creates each described volume group of the host.
Step 102: determining at least one data volume information.
Step 103: according to the attribute information, filtering out at least one described corresponding target host of data volume information
Machine.
Step 104: the request of the corresponding creation logical volume of at least one described data volume information is sent to the target
Host.
The embodiment of the invention provides a kind of methods of host volume distribution will be in host for each host
At least one disk be divided into different volume groups, determine the attribute information of each volume group, and create each of the host
A volume group;Determine at least one data volume information;According to determining attribute information, it is corresponding to filter out at least one data volume information
Target host machine;The request of the corresponding creation logical volume of an at least data volume information is sent to the target host machine.It will
The disk of host is divided into different volume groups, and according to the attribute information of volume group and the data volume information determined, in host
Logical volume is created on machine, so as to make full use of the disk resource of host.Therefore, the embodiment of the present invention can be improved disk
Resource utilization.
In one embodiment of the invention, in order to illustrate a kind of implementation for host creation volume group, so,
The step 101, comprising: be directed to each host, be performed both by: determining the type of at least one disk in the host
And size;The disk with same type at least one described disk is divided into a roll of group, at least one volume is obtained
Group;Based on the type and size of at least one disk described in determining, the attribute information of each volume group is determined, and described
Attribute information includes that volumegroup name at least one of claims, rolls up set type, volume group size, host IP address, included disk;
The request of the attribute information of each determining volume group and creation volume group is sent to the host;By the host
The volume group creation information of return is saved.
It, can be when needing to create container, according to the attribute of the volume group of creation by creating volume group to each host
Information, to determine suitable target host machine, so as to pass through the target host machine as container allocation logical volume, and carry
To host catalogue.
The realization side of target host machine is determined when in one embodiment of the invention, in order to illustrate a kind of creation container
Formula, so, the attribute information includes: volume set type and volume group size;
The step 102, comprising: when creation container, determine its at least one data volume information carried, and the data
Volume information includes at least one of type, size and its catalogue in the container of book;It establishes including described in extremely
The data volume list of a few data volume information;
The step 103, comprising:
Step 1031: according to the host list including each host pre-established, determining the host column
First host in table;
Step 1032: judging whether the data volume list is empty, if so, determining that first host is target place
Host, and terminate current process, otherwise, obtain first data volume information in the data volume list;
Step 1033: according to the target type and target sizes for including in first data volume information, described in judgement
Whether including rolling up, set type is the target type and volume group size is big not less than the target in the volume group of first host
Small target volume group, if so, first data volume information is removed from the data volume list, according to the target sizes
Resource preemption is carried out to the target volume group, and executes step 1032, otherwise, removes described first from the host list
A host, and execute step 1031.
By this implementation, successively each of host list host can be judged, until sieve
Target host machine corresponding with required creation container is selected, so as to be container allocation logical volume using the target host machine.
In one embodiment of the invention, in order to illustrate a kind of list sortord of host list, so, the place
The method of host volume distribution may further include: is ranked up according to the volume group size summation of the volume group of each host;
The host list is established according to descending ranking results.
Due to that can be ranked up according to the volume group size summation of host to establish host list, therefore can be quick
The target host machine determining target host machine, and determining be container allocation logical volume after, can usually have relatively large number of
Remaining space thereby may be ensured that target host machine still has superior performance.
As shown in Fig. 2, one embodiment of the invention provides the method for another host volume distribution, this method with
For Docker host rolls up allocation strategy, specifically includes the following steps:
Step 201: server-side is performed both by for each host: determining the type of at least one disk in host
And size, the disk with same type at least one disk is divided into a roll of group, to obtain at least one volume
Group.
In the embodiment of the present invention, executing host volume assigned unit can be a server-side, and can be in the service
End executes Docker host and rolls up allocation strategy.Wherein, Docker support uses host catalogue as book carry container.
In an embodiment of the invention, in order to realize that Docker host rolls up allocation strategy, to divide in a production environment
With host disk resource, therefore Docker service can be disposed on each host, dispose in server-side by staff
From the Docker cluster management software ground, and by the resource information of host, such as including disk, CPU, memory store to clothes
Business end.
It usually all include at least one disk, and type and size of each disk for each host
To have differences.Wherein, the type of disk may include SATA (Serial ATA, serial ports ATA), SSD (Solid State
Drives, solid state hard disk), SAS (Serial Attached SCSI, Serial Attached SCSI (SAS)), NLSAS etc..
For each host, the disk with same type of the host can be divided into a roll by server-side
Group, therefore at least one available different types of volume group, and each disk that the size of each volume group can be included for it
The sum of size.
Step 202: for each host, server-side based at least one determining disk type and size, really
The attribute information of each fixed volume group, and the request of the attribute information of each determining volume group and creation volume group is sent to place
Host.
In detail, since server-side can create at least one volume group of the host for each host, therefore
For each volume group, the attribute information of volume group may include: that volumegroup name claims, rolls up set type, volume group size, host IP
At least one of address, included disk.
In an embodiment of the invention, server-side can use LVM (Logical Volume Manager, logical volume
Management) disk is initialized, dispatched and is distributed.In detail, server-side can use LVM and carry out initially to host disk
Change, and the disk of the same type in same host is divided into the same volume group, and by the attribute information of each volume group
It is stored in database.
For each host, server-side can incite somebody to action after the attribute information of each volume group of the host has been determined
The request of determining attribute information and creation volume group is sent to the host, so as to so that the host is every according to what is received
One attribute information is to create corresponding volume group.
Step 203: each host is in the attribute information and creation volume for receiving each volume group that server-side is sent
When the request of group, each volume group is created, and volume group creation information is sent to server-side.
In an embodiment of the invention, server-side is through business processing, by the request for creating volume group be forwarded to host it
Afterwards, the agent of host deployment can complete the creation of volume group.
In detail, the attribute information for each volume group that host is sent according to server-side can use disk creation physical volume,
Each volume group is created, and the physical volume of creation is divided into corresponding volume group.Host complete volume group creation operation when,
Volume group can be created into information and be sent to server-side.
Step 204: server-side saves the volume group creation information that each host returns.
Step 205: server-side is ranked up according to the volume group size summation of the volume group of each host, and according to by big
Host list is established to small ranking results.
In detail, the volume group size summation of the volume group of each host can be each included by the host
The adduction of the volume group size of volume group.The volume group size summation is bigger, and the storage resource of corresponding host is more.
In order to which there are still more remaining spaces after target host machine is container allocation logical volume, to guarantee target
Host can have superior performance, therefore can be ranked up according to above-mentioned volume group size summation, and with descending sequence
As a result host list is established.Therefore, it when screening target host machine from host list to create container, can sieve first
It selects and both meets container creation requirement, while still with the target host machine of more remaining space.This implementation can add
The breakneck acceleration of fast target host machine.
Step 206: when creation container, server-side determines its at least one data volume information carried, establishes including this extremely
The data volume list of a few data volume information.
In detail, each data volume information may include: in the type of book, size and its catalogue in container
At least one.
Server-side can be successively according to each of data volume list data volume information, to each place in host list
Host is screened, to filter out the host for meeting each data volume information.
Step 207: server-side determines first host in the host list established.
In detail, server-side can according to the ranking results of host list, successively judge each host whether be
Target host machine, until determining target host machine.Therefore, first host in host list can be determined first.
For example, first host determined is host 1.
Step 208: server-side judges whether data volume list is empty, if so, determining that first host is target host
Machine, and step 210 is executed, otherwise, obtain first data volume information in data volume list.
For each of data volume list data volume information, if the host being currently judged meets book letter
Breath, it can be temporarily removed from data volume list, therefore when there is no data volume information, as sky in data volume list, it says
The bright host being currently judged can satisfy each data volume information, therefore the host that explanation is currently judged can be mesh
Mark host.
Therefore, server-side is determining first host: after host 1, whether may determine that data volume list first
For sky, due at present to judge for the first time, therefore data volume list is not empty, therefore first data in available data volume list
Volume information, for example, being data volume information 1.
Step 209: server-side judges first according to the target type and target sizes that include in first data volume information
It whether include the target volume group rolled up set type and be not less than target sizes for target type and volume group size in the volume group of a host,
If so, removing first data volume information from data volume list, resource preemption is carried out to target volume group according to target sizes, and
Step 208 is executed, otherwise, first host is removed from host list, and execute step 207.
According to first data volume information: the target type and target sizes of data volume information 1, according to first host
Machine: the attribute information of the volume group of host 1, it can be determined that go out host 1 in whether include volume set type be the target type and
Volume group size illustrates that host 1 meets data volume information 1, therefore can temporarily move not less than the volume group of the target sizes if including
Except data volume information 1, and step 208 is executed, to obtain first new data volume information: data volume information 2, and carried out again
Judgement.
Since the type of different data volume information can be identical, therefore when judging that host 1 meets data volume information 1,
Resource preemption can be carried out to the respective roll group in host 1 according to the data volume size of data volume information 1, i.e., by the volume group
Volume group size subtracts the data volume size of data volume information 1, subsequent sentence using remaining size as the volume group size of the volume group
It is disconnected.
Assuming that host 1 can be moved from host list when judging that host 1 is unsatisfactory for data volume information 2
It removes, then needing to judge next host.Therefore, each book that can will be temporarily removed from data volume list
Information is restored, successively to carry out the judgement of other hosts according to the data volume list.
Further, since host 1 is not target host machine, therefore the camp-on resource in host 1 can be restored.
Assuming that the execution repeatedly through step 208 and step 209, judges newly determine first host: such as host 1
Host 5 later meets each data volume information, thus again execute step 208 when, it can be determined that go out data volume list be
Sky, therefore can determine that the host 5 is target host machine.
In an embodiment of the invention, due to being stored with the resource information of each host, and the money in server-side
Source information may include CPU and memory, therefore according to different practical application needs, it is carried simultaneously when in server-side creation container
CPU, and/or, it, can be before judging data volume list, to the host for meeting the qualifications when qualifications of memory
It is screened, is not met the host of the qualifications to screen out part, and host list is established according to the selection result.
Certainly, according to the demand of different user, equally it can judge that target host machine is after judging data volume list
It is no to meet the qualifications, if satisfied, thening follow the steps 210, otherwise, the target host machine can be removed, and execute step again
Rapid 207 to obtain first new host and carry out subsequent judgement processing operation.
Step 210: the request of the corresponding creation logical volume of an at least data volume information is sent to target place by server-side
Host.
When determining target host machine is host 5, the request for creating logical volume can be sent to host by server-side
Machine 5, and the request corresponds at least one described data volume information, so that host 5 is according at least one data volume information
To create logical volume.
Step 211: target host machine: host 5 is to receive at least one data volume information that server-side sends corresponding
Creation logical volume request when, according to each data volume information, create logical volume in the corresponding volume group of data volume information,
And the logical volume of creation is formatted as ext4 file system, and the uuid of the logical volume according to creation, it is mounted to place
The specified directory of host, and it is written to/etc/fatab file.
In detail, the uuid of logical volume can be the corresponding equipment unique identification of logical volume.In addition, being patrolled by what will be created
It collects volume and is written to/etc/fatab file, be persisted to linux system.Container starting after, can by system command,
View book directory information.
In an embodiment of the invention, host, can when receiving the request for the creation logical volume that server-side is sent
The creation, formatting and carry of logical volume are completed to execute LVM order.
From the foregoing, it will be observed that when server-side creates container, the data volume information that can be carried according to container, and according to creation
Host volume group attribute information, to filter out suitable target host machine.It is patrolled by sending creation to target host machine
The request of volume is collected, target host machine can be the container allocation logical volume, and be mounted to host catalogue.This implementation can
Host disk management is effectively performed, and make full use of the disk resource of host.
As shown in figure 3, one embodiment of the invention provides a kind of host volume assigned unit 30, comprising:
At least one disk in the host is divided into not by creating unit 301 for being directed to each host
Same volume group, determines the attribute information of each volume group, and create each described volume group of the host;
Determination unit 302, for determining at least one data volume information;
Screening unit 303, for according to the attribute information, filtering out at least one described corresponding mesh of data volume information
Mark host;
Transmission unit 304, for the request of the corresponding creation logical volume of at least one described data volume information to be sent to
The target host machine.
In an embodiment of the invention, the creating unit 301 is specifically used for being directed to each host, be performed both by:
Determine the type and size of at least one disk in the host;To there is same type at least one described disk
Disk be divided into a roll of group, obtain at least one volume group;Based on the type and size of at least one disk described in determining,
Determine the attribute information of each volume group, and the attribute information includes that volumegroup name claims, rolls up set type, volume group size, place
At least one of host IP address, included disk;By the attribute information of each determining volume group and creation volume
The request of group is sent to the host;The volume group creation information that the host returns is saved.
In an embodiment of the invention, referring to FIG. 4, the attribute information includes: volume set type and volume group size;
The determination unit 302 when being specifically used for creation container, determines its at least one data volume information carried, and
The book information includes at least one of type, size and its catalogue in the container of book;Establish packet
Include the data volume list of at least one data volume information;
The screening unit 303 comprises determining that subelement 3031, first handles subelement 3032, second processing subelement
3033;
The determining subelement 3031, for the host list including each host that basis pre-establishes, really
First host in the fixed host list;
The first processing subelement 3032, for judging whether the data volume list is empty, if so, determining described the
One host is target host machine, and terminates current process, otherwise, obtains first book in the data volume list
Information;
The second processing subelement 3033, for according to the target type that includes in first data volume information and
Target sizes judge in the volume group of first host whether include volume set type for the target type and volume group size
Not less than the target volume group of the target sizes, if so, first data volume information is removed from the data volume list,
Resource preemption is carried out to the target volume group according to the target sizes, and triggers the first processing subelement 3032, otherwise,
First host is removed from the host list, and triggers the determining subelement 3031.
In an embodiment of the invention, the creating unit 301 is further used for the volume group according to each host
Volume group size summation be ranked up;The host list is established according to descending ranking results.
As shown in figure 5, the embodiment of the invention provides a kind of systems of host volume distribution, comprising: any of the above-described described
Host volume assigned unit 30 and at least one host 40, wherein
Each described host 40 is patrolled for receiving and executing the creation that the host volume assigned unit 30 is sent
The request of volume is collected, and the request of the creation logical volume corresponds at least one data volume information.
In an embodiment of the invention, each described host 40 is specifically used for according to book described in each
Information creates logical volume in the corresponding volume group of the data volume information;The logical volume of creation is formatted as ext4 text
Part system;According to the uuid of the logical volume of creation, it is mounted to the specified directory of the host 40, and be written to/
Etc/fatab file.
The contents such as the information exchange between each unit, implementation procedure in above-mentioned apparatus, due to implementing with the method for the present invention
Example is based on same design, and for details, please refer to the description in the embodiment of the method for the present invention, and details are not described herein again.
In conclusion each embodiment of the invention at least has the following beneficial effects:
1, in the embodiment of the present invention, for each host, at least one disk in host is divided into difference
Volume group, determine the attribute information of each volume group, and create each volume group of the host;Determine at least one book
Information;According to determining attribute information, the corresponding target host machine of at least one data volume information is filtered out;By an at least number
The target host machine is sent to according to the request of the corresponding creation logical volume of volume information.The disk of host is divided into different volumes
Group, and according to the attribute information of volume group and the data volume information determined, to create logical volume on host, so as to abundant
Utilize the disk resource of host.Therefore, the embodiment of the present invention can be improved disk resource utilization rate.
2, in the embodiment of the present invention, when server-side creates container, the data volume information that can be carried according to container, and
According to the attribute information of the volume group of the host of creation, to filter out suitable target host machine.By being sent out to target host machine
The request of creation logical volume is sent, target host machine can be the container allocation logical volume, and be mounted to host catalogue.This reality
Host disk management can be effectively performed in existing mode, and makes full use of the disk resource of host.
It should be noted that, in this document, such as first and second etc relational terms are used merely to an entity
Or operation is distinguished with another entity or operation, is existed without necessarily requiring or implying between these entities or operation
Any actual relationship or order.Moreover, the terms "include", "comprise" or its any other variant be intended to it is non-
It is exclusive to include, so that the process, method, article or equipment for including a series of elements not only includes those elements,
It but also including other elements that are not explicitly listed, or further include solid by this process, method, article or equipment
Some elements.In the absence of more restrictions, the element limited by sentence " including a 〃 ", is not arranged
Except there is also other identical factors in the process, method, article or apparatus that includes the element.
Those of ordinary skill in the art will appreciate that: realize that all or part of the steps of above method embodiment can pass through
The relevant hardware of program instruction is completed, and program above-mentioned can store in computer-readable storage medium, the program
When being executed, step including the steps of the foregoing method embodiments is executed;And storage medium above-mentioned includes: ROM, RAM, magnetic disk or light
In the various media that can store program code such as disk.
Finally, it should be noted that the foregoing is merely presently preferred embodiments of the present invention, it is merely to illustrate skill of the invention
Art scheme, is not intended to limit the scope of the present invention.Any modification for being made all within the spirits and principles of the present invention,
Equivalent replacement, improvement etc., are included within the scope of protection of the present invention.