Disclosure of Invention
In view of the above, the present invention has been made to provide a file storage method, apparatus, computing device and computer storage that overcome or at least partially address the above-mentioned problems.
According to an aspect of the present invention, there is provided a file storage method including:
monitoring the performance index of the backup server in real time, and calculating the health score of the backup server according to the performance index; wherein the performance indicators comprise one or more of the following indicators: CPU utilization rate, memory utilization rate, network utilization rate and disk utilization rate;
determining the number of backup threads needing to be started according to the health score of the backup server;
and starting the corresponding number of backup threads according to the number of the backup threads needing to be started, acquiring the backup file data from the network memory, and backing up the backup file data to the backup server.
Optionally, the file storage method further includes: and mounting the network storage to the backup server in a read-only mode by adopting the optimized mounting parameters.
Optionally, the monitoring the performance index of the backup server in real time further includes: and reading the kernel file of the backup server through the acquisition thread to obtain the performance index of the backup server.
Optionally, the backing up the backup file data to the backup server further comprises: grouping the backup file data to obtain a plurality of backup file data groups; and any backup thread compresses and packs the backup file data groups one by one into a single file to be backed up in the backup server.
Optionally, grouping the backup file data, and obtaining a plurality of backup file data groups further includes: and creating a data index table and a tag table, scanning the current file system, cutting the data index table into a plurality of sub-data index tables, and obtaining a plurality of backup file data groups.
Optionally, the step of compressing and packaging the backup file data groups one by any backup thread into a single file backup, where the step of compressing and packaging the single file backup into the backup server further includes: and checking the tag table, calculating a backup file data group to be backed up, compressing and packaging the backup file data group to be backed up one by one into a single file to be backed up to a backup server based on the subdata index table of the backup file data group to be backed up.
Optionally, the backup file data is small file data, and the network storage is NAS storage.
According to another aspect of the present invention, there is provided a file storage apparatus including:
the monitoring module is suitable for monitoring the performance index of the backup server in real time and calculating the health score of the backup server according to the performance index; wherein the performance indicators comprise one or more of the following indicators: CPU utilization rate, memory utilization rate, network utilization rate and disk utilization rate;
the determining module is suitable for determining the number of backup threads needing to be started according to the health score of the backup server; and
and the starting module is suitable for starting the corresponding number of backup threads according to the number of the backup threads needing to be started, acquiring the backup file data from the network memory and backing up the backup file data to the backup server.
Optionally, the monitoring module is further adapted to: and mounting the network storage to the backup server in a read-only mode by adopting the optimized mounting parameters.
Optionally, the monitoring module is further adapted to: and reading the kernel file of the backup server through the acquisition thread to obtain the performance index of the backup server.
Optionally, the opening module is further adapted to: grouping the backup file data to obtain a plurality of backup file data groups; and any backup thread compresses and packs the backup file data groups one by one into a single file to be backed up in the backup server.
Optionally, the opening module is further adapted to: and creating a data index table and a tag table, scanning the current file system, cutting the data index table into a plurality of sub-data index tables, and obtaining a plurality of backup file data groups.
Optionally, the opening module is further adapted to: and checking the tag table, calculating a backup file data group to be backed up, compressing and packaging the backup file data group to be backed up one by one into a single file to be backed up to a backup server based on the subdata index table of the backup file data group to be backed up. Optionally, the backup file data is small file data, and the network storage is NAS storage.
According to yet another aspect of the present invention, there is provided a computing device comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction enables the processor to execute the operation corresponding to the file storage method.
According to still another aspect of the present invention, a computer storage medium is provided, in which at least one executable instruction is stored, and the executable instruction causes a processor to execute operations corresponding to the file storage method.
According to the file storage method, the file storage device, the computing equipment and the storage medium, performance indexes of the backup server are monitored in real time, and health scores of the backup server are obtained through calculation according to the performance indexes; wherein the performance indicators comprise one or more of the following indicators: CPU utilization rate, memory utilization rate, network utilization rate and disk utilization rate; determining the number of backup threads needing to be started according to the health score of the backup server; and starting the corresponding number of backup threads according to the number of the backup threads needing to be started, acquiring the backup file data from the network memory, and backing up the backup file data to the backup server. The file storage method remarkably reduces the pressure of the metadata database of the backup server, and greatly improves the backup efficiency.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can 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 invention to those skilled in the art.
Example one
Fig. 1 is a flowchart illustrating a file storage method according to an embodiment of the present invention.
As shown in fig. 1, the method includes:
step S110, monitoring the performance index of the backup server in real time, and calculating the health score of the backup server according to the performance index; wherein the performance indicators comprise one or more of the following indicators: CPU utilization, memory utilization, network utilization, and disk utilization.
The invention adopts a backup scheduling algorithm which is self-researched by an inventor to monitor the performance index of the backup server in real time, and calculates the health score of the backup server according to the performance index, wherein the health score of the backup server is calculated based on one or more performance indexes of the CPU utilization rate, the memory utilization rate, the network utilization rate and the disk utilization rate of the backup server.
When the backup operation is initiated, the dynamic scheduler respectively acquires the CPU utilization rate, the memory utilization rate, the network utilization rate and the disk utilization rate through the acquisition thread.
Wherein the CPU utilization may be obtained in particular by: reading a CPU kernel file of a chip performance index file (/ proc/cpuinfo) under a backup server, and calculating the CPU utilization rate of the current backup server through a calculation formula 100 (threadCpuTime 2-threadCpuTime 1)/(totalcCpuTime 2-totalcuTime 1); wherein, the readCpuTime 2-the readCpuTime1 represents the CPU time difference occupied by the process running, and the totalCpuTime 2-the totalCpuTime1 represents the total CPU time difference.
The memory usage rate may be obtained specifically by the following method: reading a memory kernel file of a memory performance index file (/ proc/meminfo) under the backup server, and calculating the memory utilization rate of the current backup server through a calculation formula 100 (MemTotal-MemFree)/MemTotal, wherein MemTotal represents the total memory capacity, and MemFree represents the vacant memory capacity.
The network usage rate may be obtained by: reading a network kernel file of a network card performance index file (/ proc/net/DEV) under a backup server, and acquiring the network utilization rate through a network card performance index acquisition instruction (sar-n DEV 1);
the disk usage rate may be obtained specifically by the following method: reading an input/output (IO) kernel file of a disk performance index file (/ proc/disks) under a backup server, and acquiring the utilization rate of a disk through a disk performance index acquisition instruction (iostat-x 1).
Step S120, determining the number of backup threads needing to be started according to the health score of the backup server.
After the dynamic scheduler obtains the 4 performance indexes, the health score of the backup server is calculated based on the backup server scoring algorithm.
Specifically, the scoring algorithm for the health score of the backup server is as follows:
S=100-(Σcpu+Σmem+Σnet+Σdisk)*100/4
the device comprises a backup server, a sigma CPU, a sigma mem, a sigma net and a sigma disk, wherein the sigma CPU represents the utilization rate of a CPU (central processing unit) of the backup server, the sigma mem represents the utilization rate of a memory of the backup server, the sigma net represents the network utilization rate of the backup server, and the sigma disk represents the disk utilization rate of the backup server.
Specifically, fig. 2 shows a scheduling flowchart of the dynamic scheduler of the file storage method according to the embodiment, and as shown in fig. 2, a logical judgment is performed on the health score of the backup server to determine the number of backup threads to be started. Specifically, when the health score of the backup server is lower than 70 minutes, the dynamic scheduler does not initiate any backup thread and enters a waiting state, preferably, the health score is obtained every 5 minutes, and the specific time interval is not limited; when the health score of the backup server is between 70 and 80 points, the dynamic scheduler initiates 1 backup thread, and the single thread performs backup; when the health score of the backup server is between 80 and 90 points, the dynamic scheduler initiates 2 backup threads and starts the 2 backup threads for backup; when the health score of the backup server is between 90 and 100, the dynamic scheduler initiates 4 backup threads and starts the 4 backup threads for backup. And after the backup thread finishes the corresponding backup task, informing the dynamic scheduler of finishing the backup task and automatically releasing the resources. Specifically, the corresponding relationship between the health score of the backup server and the number of the initiated backup threads may be specifically set by a person skilled in the art according to a specific situation, and is not limited herein.
Step S130, according to the number of backup threads to be started, starting a corresponding number of backup threads, acquiring backup file data from the network memory, and backing up the backup file data to the backup server.
FIG. 3 shows a flowchart of a dynamically packaged backup of a file storage method according to an embodiment of the invention. As shown in fig. 3, according to the number of backup threads to be started, starting a corresponding number of backup threads, and after the backup threads are started, first creating a data index table and a tag table in a local database, where the database may be embedded, and is not particularly limited. The data index table is used for storing file metadata, and the data in the data table can have an index function, preferably, the file name and the md5 value in the data table have the index function; the tag table is used for recording information of the file data group which has been backed up.
Secondly, the backup thread starts a scanning thread, scans the current file system, acquires the file name and md5 value of each file in the data index table, and stores the acquired file name and md5 value of each file into the index data table correspondingly. Next, the backup thread starts a cutting thread, cuts the data index table into a plurality of sub data index tables, and obtains a plurality of backup file data sets, and optionally cuts the database index table into a plurality of sub data index tables with 200 ten thousand files as a unit, specifically, the number of files in each sub data index table may be set by a person skilled in the art according to specific situations. Alternatively, different sub data index tables may have different numbers of files.
After a plurality of backup file data groups are obtained, the backup file data groups are compared with information of the file data groups which are recorded in the tag table and have completed backup, the backup file data groups which need to be backed up are calculated based on the information of the backup file data groups and the recording information in the tag table, the backup file data groups which need to be backed up in the groups are compressed and packaged one by one based on the sub-data index table of the backup file data groups which need to be backed up, a single tar.
Optionally, the backup file data is small file data, and the network storage is an NAS storage.
The small file data is relative to the large file data, the small file data is generally less than or equal to 64M (or smaller than 64M), and the general small file data can include a JPG file, a txt file, a general doc file, an html file and the like.
Note that 64M is a relative value, and a file larger than 64M is a large file and a file not larger than 64M is a small file with a certain data size as a boundary according to a predetermined file boundary, but a file larger than 32M may be defined as a large file and a file not larger than 32M may be defined as a small file. The file is defined according to the service scene, and the file is determined to be smaller than or equal to a certain defined value, namely the small file, or the large file. Typically, the size of a small file is defined to be 64M or less.
Therefore, according to the file storage method of the embodiment, the single-thread backup is optimized into the multi-thread parallel backup; by means of dynamic compression, packaging and backup, tens of millions or even hundreds of millions of files are compressed into a plurality of files for backup, pressure of a metadata base of a backup server is remarkably relieved, and backup efficiency is greatly improved.
Example two
Fig. 4 is a flowchart illustrating a file storage method according to a second embodiment of the present invention.
As shown in fig. 4, the method includes:
step S410: and mounting the network storage to a backup server in a read-only mode by adopting the optimized mounting parameters.
The file storage method of the embodiment adopts an agentless mode for backup, a production server does not need to install a backup client, and all operations and interactions are completely performed and realized at a backup server side in the whole backup process.
When a file system needs to be backed up, the backup server directly mounts the file system to the backup server in a read-only mode by adopting the optimized and optimized mounting parameters. Specifically, the mounting parameter may be mount-tnfs-ers ═ 3, soft, timeo ═ 300, retry ═ 3, nordirplus, intr, noacl, noct, notome, nondiramate 192.168.1.1:/fs01/bookstore/fs01, where vers denotes the use of NFS V3 version; the timeo and retry respectively represent the overtime time and the overtime retry times of the nfs client and the server, and 300 milliseconds and 3 times are the best practices; norpirplus represents a readadirplus request not using NFS3, noratime represents an inode access time not updating a file, and nondiramate represents an inode access time not updating a directory, and norpirplus, notatime, and nondiramate all increase the speed of NFS reading; soft means mounting the system by using a soft mounting mode, intr means allowing NFS to interrupt file operation and return a value to a program calling the NFS, and soft and intr are used for guaranteeing the accuracy of reading the file.
Step 420, step 430, and step 440 are similar to step 110, step 120, and step 130, respectively, and are not described herein again.
Therefore, in the file storage method of the embodiment, only the backup server interacts with the file system, the production server does not participate, the network interaction times in the backup process are reduced from the original two times to one time, and the backup threads are reduced from the original four times to two times. Due to the fact that the times of network interaction and backup threads are shortened, the backup efficiency is remarkably improved.
EXAMPLE III
Fig. 5 is a schematic functional structure diagram of a file storage device according to a third embodiment of the present invention. As shown in fig. 5, the apparatus includes: a monitoring module 51, a determination module 52 and an opening module 53.
The monitoring module 51 is suitable for monitoring the performance index of the backup server in real time and calculating the health score of the backup server according to the performance index; wherein the performance indicators comprise one or more of the following indicators: CPU utilization rate, memory utilization rate, network utilization rate and disk utilization rate;
the determining module 52 is adapted to determine the number of backup threads to be started according to the health score of the backup server; and
the starting module 53 is adapted to start a corresponding number of backup threads according to the number of backup threads to be started, acquire backup file data from the network memory, and backup the backup file data to the backup server.
Optionally, the monitoring module 51 is further adapted to: and mounting the network storage to the backup server in a read-only mode by adopting the optimized mounting parameters.
Optionally, the monitoring module 51 is further adapted to: and reading the kernel file of the backup server through the acquisition thread to obtain the performance index of the backup server.
Optionally, the opening module 53 is further adapted to: grouping the backup file data to obtain a plurality of backup file data groups; and any backup thread compresses and packs the backup file data groups one by one into a single file to be backed up in the backup server.
Optionally, the opening module 53 is further adapted to: and creating a data index table and a tag table, scanning the current file system, cutting the data index table into a plurality of sub-data index tables, and obtaining a plurality of backup file data groups.
Optionally, the opening module 53 is further adapted to: and checking the tag table, calculating a backup file data group to be backed up, compressing and packaging the backup file data group to be backed up one by one into a single file to be backed up to a backup server based on the subdata index table of the backup file data group to be backed up.
Optionally, the backup file data is small file data, and the network storage is NAS storage.
Therefore, according to the file storage device of the embodiment, the single-thread backup is optimized into the multi-thread parallel backup; by means of dynamic compression, packaging and backup, tens of millions or even hundreds of millions of files are compressed into a plurality of files for backup, pressure of a metadata database of a backup server is obviously relieved, and backup efficiency is greatly improved.
Example four
According to a fourth embodiment of the present invention, a non-volatile computer storage medium is provided, where the computer storage medium stores at least one executable instruction, and the computer executable instruction can execute the method in any of the above-mentioned method embodiments.
The executable instructions may be specifically configured to cause the processor to: monitoring the performance index of the backup server in real time, and calculating the health score of the backup server according to the performance index; wherein the performance indicators comprise one or more of the following indicators: CPU utilization rate, memory utilization rate, network utilization rate and disk utilization rate; determining the number of backup threads needing to be started according to the health score of the backup server; and starting the corresponding number of backup threads according to the number of the backup threads needing to be started, acquiring the backup file data from the network memory, and backing up the backup file data to the backup server.
In an alternative embodiment, the executable instructions may be specifically configured to cause the processor to: and mounting the network storage to the backup server in a read-only mode by adopting the optimized mounting parameters.
In an alternative embodiment, the executable instructions may be specifically configured to cause the processor to: and reading the kernel file of the backup server through the acquisition thread to obtain the performance index of the backup server.
In an alternative embodiment, the executable instructions may be specifically configured to cause the processor to: grouping the backup file data to obtain a plurality of backup file data groups; and any backup thread compresses and packs the backup file data groups one by one into a single file to be backed up in the backup server.
In an alternative embodiment, the executable instructions may be specifically configured to cause the processor to: and creating a data index table and a tag table, scanning the current file system, cutting the data index table into a plurality of sub-data index tables, and obtaining a plurality of backup file data groups.
In an alternative embodiment, the executable instructions may be specifically configured to cause the processor to: and checking the tag table, calculating a backup file data group to be backed up, compressing and packaging the backup file data group to be backed up one by one into a single file to be backed up to a backup server based on the subdata index table of the backup file data group to be backed up.
In an alternative embodiment, the backup file data is small file data, and the network storage is NAS storage.
Therefore, according to the file storage method of the embodiment, multithreading parallel backup can be realized, and single-thread backup is optimized into multithreading parallel backup; by means of dynamic compression, packaging and backup, tens of millions or even hundreds of millions of files are compressed into a plurality of files for backup, pressure of a metadata database of a backup server is obviously relieved, and backup efficiency is greatly improved.
EXAMPLE five
Fig. 6 is a schematic structural diagram of a computing device according to a fifth embodiment of the present invention, and the specific embodiment of the present invention does not limit the specific implementation of the computing device.
As shown in fig. 6, the computing device may include: a processor (processor)602, a communication Interface 604, a memory 606, and a communication bus 608.
Wherein: the processor 602, communication interface 604, and memory 606 communicate with one another via a communication bus 608. A communication interface 604 for communicating with network elements of other devices, such as clients or other servers. The processor 602 is configured to execute the program 610, and may specifically perform relevant steps in the foregoing method embodiments.
In particular, program 610 may include program code comprising computer operating instructions.
The processor 602 may be a central processing unit CPU or an application Specific Integrated circuit asic or one or more Integrated circuits configured to implement embodiments of the present invention. The computing device includes one or more processors, which may be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
And a memory 606 for storing a program 610. Memory 606 may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 610 may specifically be configured to cause the processor 602 to perform the following operations:
monitoring the performance index of the backup server in real time, and calculating the health score of the backup server according to the performance index; wherein the performance indicators comprise one or more of the following indicators: CPU utilization rate, memory utilization rate, network utilization rate and disk utilization rate;
determining the number of backup threads needing to be started according to the health score of the backup server;
and starting the corresponding number of backup threads according to the number of the backup threads needing to be started, acquiring the backup file data from the network memory, and backing up the backup file data to the backup server.
In an alternative embodiment, the program 610 may be specifically configured to cause the processor 602 to perform the following operations:
and mounting the network storage to the backup server in a read-only mode by adopting the optimized mounting parameters.
In an alternative embodiment, the program 610 may be specifically configured to cause the processor 602 to perform the following operations:
in an alternative embodiment, the program 610 may be specifically configured to cause the processor 602 to perform the following operations:
and reading the kernel file of the backup server through the acquisition thread to obtain the performance index of the backup server.
In an alternative embodiment, the program 610 may be specifically configured to cause the processor 602 to perform the following operations:
grouping the backup file data to obtain a plurality of backup file data groups; and any backup thread compresses and packs the backup file data groups one by one into a single file to be backed up in the backup server.
In an alternative embodiment, the program 610 may be specifically configured to cause the processor 602 to perform the following operations:
and creating a data index table and a tag table, scanning the current file system, cutting the data index table into a plurality of sub-data index tables, and obtaining a plurality of backup file data groups.
In an alternative embodiment, the program 610 may be specifically configured to cause the processor 602 to perform the following operations:
and checking the tag table, calculating a backup file data group to be backed up, compressing and packaging the backup file data group to be backed up one by one into a single file to be backed up to a backup server based on the subdata index table of the backup file data group to be backed up.
In an alternative embodiment, the backup file data is small file data, and the network storage is NAS storage.
Therefore, according to the file storage method of the embodiment, the single-thread backup is optimized into the multi-thread parallel backup; by means of dynamic compression, packaging and backup, tens of millions or even hundreds of millions of files are compressed into a plurality of files for backup, pressure of a metadata database of a backup server is obviously relieved, and backup efficiency is greatly improved.
The algorithms or displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. In addition, embodiments of the present invention are 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. It is understood, however, 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 embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the invention and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: 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 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 steps in the above embodiments should not be construed as limiting the order of execution unless specified otherwise.