Method and system for automatically optimizing mirror image storage according to course progress in network target range
By introducing business modules, mirror storage modules and virtualization modules into the network shooting range system, the characteristics of mechanical hard disks and solid-state hard disks are used to automatically optimize mirror storage, solving the problem of both storage cost and startup speed, and achieving efficient and low-cost Mirror storage and boot.
Patent Information
- Application Number
- CN202411348489.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-02-18
AI Technical Summary
When storing virtual machine images, existing network shooting range systems need to use high-cost solid-state drives to ensure startup speed, or use low-performance mechanical hard drives to reduce costs, but it is difficult to take into account both.
By introducing business modules, mirror storage modules and virtualization modules into the network shooting range system, the mechanical hard disk stores a full amount of mirror files, and the image files associated with the recently completed and to be completed courses are stored to the solid-state hard disk to optimize the mirror startup speed .
It realizes the realization of reducing system storage costs while ensuring the startup speed of virtual machines, and automatically optimizes mirror storage by rationally utilizing the performance characteristics of mechanical hard disks and solid-state hard disks.
Smart Images

Figure CN119473491A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method and a system capable of automatically optimizing the startup speed of a virtual machine according to the progress of a course in a network range providing course learning, and belongs to the technical field of network security. Background Art
[0002] The network range system can be used in many scenarios, one of which is commonly used in school computer or network-related courses. The range system provides many preset courses, and different courses contain different simulation environments for teachers' classroom teaching or students' after-class exercises.
[0003] The simulation environment of the network target range requires storing many virtual machine images in the system environment. The process of building the simulation environment is to instantiate these virtual machine images into virtual machines on the cloud platform and then network them as needed.
[0004] The disk space occupied by the virtual machine images in the network target range is generally measured in G. The type and quantity of images required for each course may be different, which results in a large amount of disk space occupied by image resources.
[0005] In order to ensure the startup speed of the virtual machine, expensive and high-performance solid-state drives are often used to store images, which leads to high disk costs. If mechanical hard drives are used to store images, the cost can be greatly reduced, but the startup speed of the virtual machine will be seriously affected. Summary of the invention
[0006] Purpose of the invention: In view of the problems existing in the above-mentioned prior art, the purpose of the present invention is to provide a method and system for automatically optimizing image storage according to the course progress in a network shooting range, taking into account both high performance and low cost.
[0007] Technical solution: To achieve the above-mentioned invention object, the present invention adopts the following technical solution:
[0008] A method for automatically optimizing image storage according to course progress in a network range includes the following steps:
[0009] The business module stores course progress information and the image information required for each course;
[0010] The image storage module uses a mechanical hard disk to store the full amount of image files, queries all images associated with a set number of courses that have been recently completed and are about to be completed, and stores all the queried image files in the solid-state hard disk of the virtualization module;
[0011] When the business module notifies the virtualization module to start the image, the virtualization module uses the image file stored in the solid state drive to increase the speed of image startup.
[0012] Furthermore, the step of the image storage module storing the image file in the solid state disk of the virtualization module includes:
[0013] The image storage module calls the image file upload interface of the virtualization module, and the input parameters include file content and image identifier;
[0014] The virtualization module receives the file stream, writes the file to the disk, and uses the loading command of the virtualization platform to load the image file under the written file path;
[0015] After loading is completed, delete the corresponding image file on the disk.
[0016] Furthermore, when the business module notifies the virtualization module to start the image with the specified image identifier, the virtualization module searches for the specified image identifier through the interface of the virtualization platform. If it exists, a virtual machine is started using the specified image. Otherwise, the image storage module is notified to upload the image with the corresponding image identifier to the virtualization platform.
[0017] Furthermore, the image storage module periodically updates the image files in the virtualization platform, including:
[0018] The image storage module calls the business module interface to query all images associated with a set number of courses that have been recently completed and are to be completed, and obtain a first image list;
[0019] The image storage module calls the virtualization module interface to query all current images in the virtualization platform to obtain a second image list;
[0020] The image storage module calls the virtualization module interface to delete the image in the second image list but not in the first image list;
[0021] The image storage module calls the virtualization module interface to upload the image file in the first image list but not in the second image list to the solid state hard disk of the virtualization module.
[0022] Furthermore, the number of courses that have been recently completed and are to be completed is adjusted as the course progresses, and the value is increased as the course progresses faster.
[0023] A system for automatically optimizing image storage according to course progress in a network range, including a business module, an image storage module and a virtualization module;
[0024] The business module is used to store course progress information and image information required for each course;
[0025] The image storage module uses a mechanical hard disk to store a full amount of image files, queries all images associated with a set number of courses that have been recently completed and are to be completed, and stores all the queried image files in the solid-state hard disk of the virtualization module;
[0026] The virtualization module, when receiving a notification from the business module to start the image, uses the image file stored in the solid state drive to increase the speed of image startup.
[0027] Furthermore, the image storage module calls the image file upload interface of the virtualization module, and the input parameters include file content and image identification, and stores the image file to the solid-state hard disk of the virtualization module; the virtualization module receives the file stream, writes the file to the disk, and uses the loading command of the virtualization platform to load the image file under the written file path; after the loading is completed, the corresponding image file on the disk is deleted.
[0028] Furthermore, when the business module notifies the virtualization module to start the image with the specified image identifier, the virtualization module searches for the specified image identifier through the interface of the virtualization platform. If it exists, it uses the specified image to start a virtual machine. Otherwise, it notifies the image storage module to upload the image with the corresponding image identifier to the virtualization platform.
[0029] Furthermore, the image storage module periodically updates the image files in the virtualization platform. Each time an update is performed, the image storage module calls the business module interface to query all images associated with a set number of courses that have been recently completed and are to be completed, to obtain a first image list, calls the virtualization module interface to query all current images in the virtualization platform, to obtain a second image list; calls the virtualization module interface to delete images in the second image list but not in the first image list; calls the virtualization module interface to upload the images in the first image list but not in the second image list to the solid-state hard disk of the virtualization module.
[0030] Furthermore, the number of courses that have been recently completed and are to be completed is adjusted as the course progresses, and the value is increased as the course progresses faster.
[0031] Beneficial effects: The present invention predicts some images that are likely to be started according to the characteristics of the time progress of the class in the course shooting range, and uses a high-performance and high-cost solid-state hard disk to store these image files, so that the startup speed of the virtual machine is not affected to the greatest extent; other images of courses that have been taken for a long time or will not be used for a long time can be placed on low-cost and low-performance mechanical hard disks. And the storage of the image can be automatically adjusted by checking the progress of the course. Compared with the prior art, the present invention can greatly reduce the cost of system storage while ensuring the startup speed of the virtual machine to a large extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a module structure diagram of an embodiment of the present invention.
[0033] Figure 2 The following is a flowchart of image file uploading in an embodiment of the present invention.
[0034] Figure 3 This is a flowchart of mirror startup in an embodiment of the present invention.
[0035] Figure 4 The flowchart of regularly updating the image in the embodiment of the present invention. DETAILED DESCRIPTION
[0036] The technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings and specific embodiments.
[0037] The embodiment of the present invention discloses a method for automatically optimizing image storage according to course progress in a network range, which is mainly implemented by three modules: a business module, a virtualization module, and an image storage module. The main relationship between the three modules is as follows: Figure 1 The business module is responsible for providing specific business functions such as interface rendering, user login, permission control, and course addition, deletion, modification, and query. During the teaching of the cyber range course, both teachers and students interact with the business module. The virtualization module is responsible for building the simulation environment, in which images that are currently being used or may be used are stored. This module uses high-performance solid-state storage to increase the speed of image startup. The image storage module is responsible for storing all images that need to be used. This module uses low-cost mechanical hard disks to reduce the overall storage cost of the system.
[0038] The method for automatically optimizing image storage according to course progress in a network range according to an embodiment of the present invention mainly comprises the following steps:
[0039] The business module stores course progress information and the image information required for each course;
[0040] The image storage module uses a mechanical hard disk to store the full amount of image files, queries all images associated with a set number of courses that have been recently completed and are about to be completed, and stores all the queried image files in the solid-state hard disk of the virtualization module;
[0041] When the business module notifies the virtualization module to start the image, the virtualization module uses the image file stored in the solid state drive to increase the speed of image startup.
[0042] The present invention combines the use of a solid state drive and a mechanical hard disk, and according to the characteristics of the course moving over time, can both largely ensure the startup speed of the virtual machine and greatly reduce the hard disk cost.
[0043] In addition to providing various business functions, the business module needs to provide additional course progress and future image usage to facilitate the image storage module to schedule the image. In order to achieve this function, in this embodiment, the business module uses two tables, the course progress table and the course image composition table, to store image usage and course information, and provides a course progress interface to the outside world.
[0044] The course progress table stores the information of completed and unfinished courses, and its structure is shown in Table 1.
[0045] Table 1: Course Schedule
[0046] Course Logo Course sequence Completion course001 1 Completed course002 2 Completed course003 3 Unfinished courseN N Unfinished
[0047] The course image composition table stores the virtual machine image identifiers required for each course, and its structure is shown in Table 2.
[0048] Table 2: Course image composition table
[0049]
[0050] The course progress interface is used to query all images associated with the n courses that have been completed recently and the n courses that are about to be completed recently (n is the preset number). The input and output parameters are shown in Table 3.
[0051] Table 3: Course progress interface
[0052]
[0053] The main logic of the course progress interface:
[0054] used_images, a list of images of completed courses. The query logic is:
[0055] First, check the most recently completed course ID. Assuming the result is ${course_list}, the query statement is:
[0056] select course ID from course schedule where completion status = completed order by course sequence desclimit n.
[0057] Query the relevant image ID from the course image composition table. The query statement is:
[0058] select image_id from course_image_composition_table where course_id in ${course_list}.
[0059] soon_images, a list of images for courses that are about to start. The query logic is:
[0060] First, check the course IDs that will start soon. Assuming the result is ${course_list}, the query statement is:
[0061] select course identifier from course schedule where completion status = unfinished order by course sequence asclimit n.
[0062] Query the relevant image ID from the course image composition table. The query statement is:
[0063] Select image ID from course image composition table where course ID in ${course_list}.
[0064] In this embodiment, the virtualization module uses high-performance storage to store virtual machine images. The module can use dedicated virtualization platforms such as OpenStack. The module needs to store only images that are currently in use or may be used as much as possible to reduce the consumption of high-performance disk space. The module provides image query commands, image deletion commands, image addition commands, and image startup commands to the outside world, and provides an interface that can upload image files to the virtualization module storage. Taking OpenStack as an example, the commands it can provide are as follows:
[0065] Image query command:
[0066] openstack image list / / Query all image lists
[0067] openstack image show${image_name} / / Query based on image name
[0068] Image deletion command:
[0069] openstack image delete${image_name}
[0070] New commands added to the image:
[0071]
[0072] Mirror startup command:
[0073]
[0074] Table 4: Image file upload interface
[0075]
[0076] The image file upload process is as follows Figure 2 , the main steps are as follows:
[0077] N1: The file stream input from the interface is ready to be encapsulated into a file. The image identifier of the final generation is set as ${image_name}, and then proceed to step N2;
[0078] N2: Write the file content to disk, set the written file address to ${image_file_path}, and go to step N3;
[0079] N3: Use the command to load the image file in the ${image_file_path} path and load it into the virtualization platform. Taking OpenStack as an example, the command is as follows, and then proceed to step N4.
[0080]
[0081] N4: After loading, delete the file corresponding to ${image_file_path} to save storage space. The process ends.
[0082] In some embodiments, the virtualization module also provides a certain mechanism to deal with the situation where teachers or students suddenly specify to start some images that are not loaded in the image virtualization platform. Figure 3 , the main steps are as follows:
[0083] N1: Enter the image ID to be started, assuming its value is ${image_name}, and go to step N2;
[0084] N2: Search for the image in the virtualization module. Taking OpenStack as an example, the command used is as follows, and then proceed to judgment S1.
[0085] openstack image show${image_name}
[0086] S1: Determine whether the image exists. If so, proceed to step N3; otherwise, proceed to step N4;
[0087] N3: Use the image to start a virtual machine. The process ends after the startup is successful.
[0088] N4: Notify the image storage module to upload the image corresponding to ${image_name} to the virtualization platform, and then proceed to step N3.
[0089] The image storage module uses low-cost storage to store the full amount of image data, which requires the image storage module to store basic information of each image. In this embodiment, a basic image information table is provided, and the structure is shown in Table 5.
[0090] Table 5: Image basic information table
[0091] Mirror ID Image size Storage location in the image module image001 10G / images / dev1 / image001 image002 20G / images / dev1 / image002
[0092] As the course progresses, the images used will continue to change. At this time, the image storage module needs to upload the new image to the virtualization module, and then remove some images in the virtualization module. This requires the image storage module to have an automatic image update function, which can automatically delete the old image on the virtualization platform and upload the new image when no one is in class in the early morning.
[0093] The process of regularly updating the image is as follows Figure 4 , the main steps are as follows:
[0094] N1: Call the course progress interface of the business module to get the latest image. Assume that the image list is ${used_soon_image_list}. When calling the interface, you can adjust the size of the input parameter n according to the progress of the current course. If the course is progressing very fast, you can increase the value of n. Otherwise, you can use a smaller value of n. Go to step N2;
[0095] N2: Query the current list of all images in the virtualization platform, assuming that
[0096] ${current_image_list}, taking the openstack virtualization platform as an example, the command used is as follows: openstack image list. Go to step N3;
[0097] N3: Make the difference between ${current_image_list} and ${used_soon_image_list}, that is
[0098] ${current_image_list}-${used_soon_image_list}, and then use the image deletion command to delete the images in the difference set one by one to release storage space.
[0099] N4: Make a difference between ${used_soon_image_list} and ${current_image_list}, that is
[0100] ${used_soon_image_list}-${current_image_list}, so that you can get a set of images that do not exist in the virtualization platform.
[0101] Assuming that the image identifier is ${used_soon_image}, the storage location of the image file can be obtained from the image information table of the image module. The query condition used is select the storage location in the image module from the image basic information table where the image identifier = ${used_soon_image}.
[0102] Assuming the image storage location is ${image_path}, calling the file upload interface will
[0103] The content corresponding to ${image_path} is uploaded, and the image identification parameter value entered is ${used_soon_image}.
[0104] All images have been uploaded and the process is complete.
[0105] For example, if 500 courses are stored with 10G image resources for each course, 500*10G, or 5T of space, is required if all are stored in high-performance storage. After using the solution of the present invention, only the completed N courses and the unfinished N courses need to be stored. Assuming N=3, there are 6 courses in total. Then the required high-performance storage is 60G, which greatly reduces the use of high-cost storage.
[0106] The embodiment of the present invention discloses a system for automatically optimizing image storage according to course progress in a network range, comprising a business module, an image storage module and a virtualization module; wherein the business module is used to store course progress information and image information required for each course; the image storage module uses a mechanical hard disk to store a full amount of image files, queries all images associated with a set number of courses that have been recently completed and are to be completed, and stores all the queried image files in a solid-state hard disk of the virtualization module; when the virtualization module receives a notification from the business module to start the image, the image file stored in the solid-state hard disk is used to improve the speed of image startup.
[0107] The image storage module calls the image file upload interface of the virtualization module, and the input parameters include file content and image identification, and stores the image file to the solid-state hard disk of the virtualization module; the virtualization module receives the file stream, writes the file to the disk, and uses the loading command of the virtualization platform to load the image file under the written file path; after the loading is completed, the corresponding image file on the disk is deleted.
[0108] When the business module notifies the virtualization module to start the image with the specified image identifier, the virtualization module searches for the specified image identifier through the interface of the virtualization platform. If it exists, it uses the specified image to start a virtual machine. Otherwise, it notifies the image storage module to upload the image with the corresponding image identifier to the virtualization platform.
[0109] The image storage module periodically updates the image files in the virtualization platform. Each time an update is performed, the image storage module calls the business module interface to query all images associated with a set number of courses that have been recently completed and are to be completed, to obtain a first image list, calls the virtualization module interface to query all current images in the virtualization platform, to obtain a second image list; calls the virtualization module interface to delete images that are in the second image list but not in the first image list; calls the virtualization module interface to upload the images that are in the first image list but not in the second image list to the solid-state hard disk of the virtualization module.
[0110] The number of courses that have been recently completed and are to be completed is set. The number is adjusted as the course progresses. If the course progresses faster, the value is increased.
Claims
1. A method for automatically optimizing image storage according to course progress in a network range, characterized in that: The steps include: The business module stores course progress information and the image information required for each course; The image storage module uses a mechanical hard disk to store the full amount of image files, queries all images associated with a set number of courses that have been recently completed and are about to be completed, and stores all the queried image files in the solid-state hard disk of the virtualization module; When the business module notifies the virtualization module to start the image, the virtualization module uses the image file stored in the solid state drive to increase the speed of image startup.
2. The method for automatically optimizing image storage according to course progress in a network range according to claim 1, characterized in that: The steps of the image storage module storing the image file to the solid state disk of the virtualization module include: The image storage module calls the image file upload interface of the virtualization module, and the input parameters include file content and image identifier; The virtualization module receives the file stream, writes the file to the disk, and uses the loading command of the virtualization platform to load the image file under the written file path; After loading is completed, delete the corresponding image file on the disk.
3. The method for automatically optimizing image storage according to course progress in a network range according to claim 1, characterized in that: When the business module notifies the virtualization module to start the image with the specified image identifier, the virtualization module searches for the specified image identifier through the interface of the virtualization platform. If it exists, a virtual machine is started using the specified image. Otherwise, the image storage module is notified to upload the image with the corresponding image identifier to the virtualization platform.
4. The method for automatically optimizing image storage according to course progress in a network range according to claim 1, characterized in that: The image storage module periodically updates the image files in the virtualization platform, including: The image storage module calls the business module interface to query all images associated with a set number of courses that have been recently completed and are to be completed, and obtain a first image list; The image storage module calls the virtualization module interface to query all current images in the virtualization platform to obtain a second image list; The image storage module calls the virtualization module interface to delete the image in the second image list but not in the first image list; The image storage module calls the virtualization module interface to upload the image file in the first image list but not in the second image list to the solid state hard disk of the virtualization module.
5. The method for automatically optimizing image storage according to course progress in a network range according to claim 1, characterized in that: The number of courses that have been recently completed and are to be completed is set. The number is adjusted as the course progresses. If the course progresses faster, the value is increased.
6. A system for automatically optimizing image storage according to course progress in a network range, characterized in that: Includes business module, image storage module and virtualization module; The business module is used to store course progress information and image information required for each course; The image storage module uses a mechanical hard disk to store a full amount of image files, queries all images associated with a set number of courses that have been recently completed and are to be completed, and stores all the queried image files in the solid-state hard disk of the virtualization module; The virtualization module, when receiving a notification from the business module to start the image, uses the image file stored in the solid state drive to increase the speed of image startup.
7. The system for automatically optimizing image storage according to course progress in a network range according to claim 6, characterized in that: The image storage module calls the image file upload interface of the virtualization module, and the input parameters include file content and image identification, and stores the image file to the solid-state hard disk of the virtualization module; the virtualization module receives the file stream, writes the file to the disk, and uses the loading command of the virtualization platform to load the image file under the written file path; after the loading is completed, the corresponding image file on the disk is deleted.
8. The system for automatically optimizing image storage according to course progress in a network range according to claim 6, characterized in that: When the business module notifies the virtualization module to start the image with the specified image identifier, the virtualization module searches for the specified image identifier through the interface of the virtualization platform. If it exists, it uses the specified image to start a virtual machine. Otherwise, it notifies the image storage module to upload the image with the corresponding image identifier to the virtualization platform.
9. The system for automatically optimizing image storage according to course progress in a network range according to claim 6, characterized in that: The image storage module periodically updates the image files in the virtualization platform. Each time the image storage module is updated, the image storage module calls the business module interface to query all images associated with a set number of courses that have been recently completed and are to be completed, obtains a first image list, and calls the virtualization module interface to query all current images in the virtualization platform to obtain a second image list; Call the virtualization module interface to delete the image in the second image list but not in the first image list; call the virtualization module interface to upload the image file in the first image list but not in the second image list to the solid state drive of the virtualization module.
10. The system for automatically optimizing image storage according to course progress in a network range according to claim 6, characterized in that: The number of courses that have been recently completed and are to be completed is set. The number is adjusted as the course progresses. If the course progresses faster, the value is increased.