Virtual machine unvarnished transmission disk replacement method and device, equipment, medium and program product

Through automatic monitoring and management tools, semi-automatic replacement of virtual machine transmissive disks is realized, solving the problem of insufficient complex and timely manual replacement after physical disks are damaged, and improving replacement efficiency and service recovery speed.

CN119847417APending Publication Date: 2025-04-18CHINA TELECOM CLOUD TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411629262.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In a small hyperconverged environment, after the physical disk is damaged, the existing technology requires manual replacement of the virtual machine's transmissive disk, resulting in complex and untimely processes, involving people in different fields, and the time interval between the bad disk and the replacement may be long.

Method used

It provides a method for replacing virtual machine transparent disks. By automatically monitoring the information of bad disks, identifying the physical disks that the host needs to be replaced, using the preset management tool to automatically unplug out the bad disks and inserting them into the new disks, and restoring the virtual machine service status through the qemu-guest-agent tool to achieve semi-automatic replacement.

Benefits of technology

It shortens the time to change disks, improves the timeliness of bad disk replacement, avoids manual operations to the greatest extent, and ensures rapid recovery of virtual machine services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847417A_ABST
    Figure CN119847417A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of virtualization, and discloses a virtual machine unvarnished transmission disk replacement method and device, equipment, a medium and a program product, and the method comprises the following steps: obtaining bad disk information of a virtual machine; determining physical disk information needing to be replaced by the host machine according to the bad disk information; when the bad physical disk is pulled out according to the physical disk information, detecting whether a new physical disk is inserted or not; and if the new physical disk is inserted, deleting the bad physical disk from the virtual machine based on a preset management tool, and transparently transmitting the new physical disk to the virtual machine. According to the method, the bad disk can be automatically monitored, automatic disk replacement and service recovery of the virtual machine are completed, semi-automatic replacement of the unvarnished transmission disk of the virtual machine in the whole process is achieved, manual operation is avoided to the maximum extent, the disk replacement time is shortened, and the timeliness of bad disk replacement is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of virtualization technology, and in particular to a method, device, equipment, medium and program product for replacing a virtual machine transparent transmission disk. Background Art

[0002] In order to maximize resource utilization in a small hyper-converged environment, components that provide basic services will be run on the same host as business virtual machines. In order to isolate resources, all basic service components will run in separate virtual machines on the host. The storage service is also one of the basic services. It will run in a virtual machine that has the host's physical disk transparently transmitted. The storage service then manages the disk inside the virtual machine and provides services to the outside world.

[0003] However, after running for a long time, physical disk damage is inevitable. In this case, the physical disk needs to be replaced and the new disk needs to be transmitted to the virtual machine. At the same time, the bad disk needs to be removed from the virtual machine so that the storage service can update its status.

[0004] In the prior art, this entire process is completed manually. For example, after a bad disk is found, the physical disk is manually replaced, the previous bad disk is manually uninstalled from the virtual machine, a new disk is re-mounted, and finally the service status is manually restored in the virtual machine. However, this process involves personnel from different fields, and the process is relatively long. Moreover, the personnel who mount the disk to the virtual machine and restore the storage service usually belong to different fields. In addition, the time interval from the appearance of the bad disk to the discovery of the bad disk may be very long, which leads to untimely replacement of the disk. Summary of the invention

[0005] In view of this, the present invention provides a method, device, equipment, medium and program product for replacing a virtual machine transparent disk to solve the problem of untimely replacement of a bad disk.

[0006] In a first aspect, the present invention provides a method for replacing a virtual machine transparent disk, which is applied to a host machine, and the method includes:

[0007] Get the bad disk information of the virtual machine;

[0008] Determine the physical disk information that needs to be replaced on the host machine based on the bad disk information;

[0009] After the bad physical disk is removed according to the physical disk information, check whether a new physical disk is inserted;

[0010] If a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on the preset management tool, and the new physical disk is transparently transmitted to the virtual machine.

[0011] The method for replacing a virtual machine transparent disk provided by an embodiment of the present invention determines the physical disk information that needs to be replaced by the host machine according to the bad disk information of the acquired virtual disk. After the bad physical disk is pulled out, it is detected whether a new physical disk is inserted. If a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on a preset management tool, and the new physical disk is transparently transmitted to the virtual machine. The present invention can automatically monitor bad disks, complete automatic disk replacement and service recovery of virtual machines, realize semi-automatic replacement of the entire process of virtual machine transparent disk, avoid manual operation to the greatest extent, shorten the disk replacement time, and improve the timeliness of bad disk replacement.

[0012] In an optional implementation, obtaining bad disk information of a virtual machine includes: when the virtual machine performs a system log scan based on a scheduled monitoring task to obtain bad disk information, obtaining the bad disk information based on a scheduled reading task.

[0013] The present invention can realize automatic monitoring of bad disks through timing tasks, thereby avoiding the situation that a bad disk cannot be discovered in time after it occurs, resulting in a long bad disk replacement process.

[0014] In an optional implementation, determining the physical disk information that needs to be replaced in the host machine based on the bad disk information includes: obtaining a configuration file of the virtual machine, the configuration file including: address information containing a preset identifier, wherein the preset identifier represents the same physical disk in the host machine and the virtual machine; determining a target identifier for disk replacement based on the bad disk information, and comparing the target identifier with the preset identifier in the configuration file to determine the physical disk information corresponding to the bad disk.

[0015] The present invention can convert the information of the internal system of the virtual machine into the physical disk information of the host machine by identifying the bad disk information, thereby determining the physical disk of the host machine specifically corresponding to the bad disk monitored by the virtual machine, and providing bad disk indication to the technicians.

[0016] In an optional implementation, after determining the physical disk information of the host machine that needs to be replaced according to the bad disk information, the method further includes: generating alarm information according to the physical disk information.

[0017] The present invention can promptly notify operation and maintenance personnel of the occurrence of a bad disk by generating alarm information, so that the subsequent physical disk can be replaced in time, shortening the time interval for replacing the bad disk.

[0018] In an optional implementation, detecting whether to insert a new physical disk includes: determining a device file generation path of the host machine; monitoring whether a change occurs in the device file generation path based on a preset interface, and if so, inserting the new physical disk.

[0019] The present invention can automatically realize the subsequent operation of replacing the physical disk for the virtual machine and restoring the related services in the virtual machine by automatically sensing whether a new disk is inserted, thereby improving the intelligence of bad disk replacement.

[0020] In an optional implementation, the bad physical disk is deleted from the virtual machine based on a preset management tool, and a new physical disk is transmitted to the virtual machine, including: querying whether the configuration file contains a device file corresponding to the bad physical disk, and if so, deleting the device file; generating a new configuration file based on the new physical disk, and mounting the new configuration file to the virtual machine; calling and executing the preset service recovery script of the virtual machine based on the preset management tool, so that the virtual machine recovers the service status based on the new physical disk.

[0021] The present invention can automatically remove the old disk and insert the new disk of the virtual machine by scanning the configuration file of the virtual machine, and can automatically restore the relevant services of the virtual machine by calling the service recovery script in the virtual machine, thereby realizing the semi-automatic replacement of the virtual machine transparent disk.

[0022] In a second aspect, the present invention provides a device for replacing a virtual machine transparent disk, which is applied to a host machine, and the device includes:

[0023] An information acquisition module, used to obtain bad disk information of a virtual machine;

[0024] An information identification module is used to determine the physical disk information that needs to be replaced on the host machine according to the bad disk information;

[0025] A disk replacement detection module is used to detect whether a new physical disk is inserted after a bad physical disk is pulled out according to the physical disk information;

[0026] The bad disk replacement module is used to delete the bad physical disk from the virtual machine based on a preset management tool if a new physical disk is inserted, and transparently transmit the new physical disk to the virtual machine.

[0027] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for replacing a virtual machine transparent disk of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0028] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for replacing a virtual machine transparent disk according to the first aspect or any corresponding embodiment thereof.

[0029] In a fifth aspect, the present invention provides a computer program product, including computer instructions, which are used to enable a computer to execute the method for replacing a virtual machine transparent disk according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0031] Figure 1 It is a flowchart of a method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0032] Figure 2 is a schematic diagram of a timed detection task script of a method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0033] Figure 3 is a schematic diagram of a bad disk detection result of a method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0034] Figure 4 1. It is a schematic diagram of a specific process of a method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0035] Figure 5 is a flow chart of another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0036] Figure 6 is a schematic diagram of bad disk information of another method for replacing a virtual machine transparent disk according to an embodiment of the present invention;

[0037] Figure 7 is a schematic diagram of information comparison results of another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0038] Figure 8 is an alarm schematic diagram of another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0039] Fig. 9 is a schematic diagram of monitoring the insertion of a new physical disk according to another method for replacing a virtual machine transparent disk according to an embodiment of the present invention;

[0040] Fig.10 is a flow chart of another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0041] Fig.11is a schematic diagram of scanning a configuration file of another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0042] Fig.12 It is a schematic diagram of removing an old disk of a virtual machine according to another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0043] Fig.13 is a schematic diagram of inserting a new disk into a virtual machine according to another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0044] Fig.14 This is a schematic diagram of a service recovery script of another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0045] Fig.15 is a schematic diagram of script execution of another method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0046] Fig.16 is a structural block diagram of a device for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention;

[0047] Fig.17 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0049] The embodiment of the present invention is applicable to the scenario where the storage service runs in a separate virtual machine on the host machine. The embodiment of the present invention provides a method for replacing a virtual machine transparent disk, which achieves the effect of timely replacing the virtual machine transparent disk by semi-automatically replacing the physical disk corresponding to the storage service after it is damaged.

[0050] According to an embodiment of the present invention, an embodiment of a method for replacing a virtual machine transparent disk is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0051] In this embodiment, a method for replacing a virtual machine transparent disk is provided, which can be used for the above-mentioned host machine, such as a computer, etc. Figure 1is a flow chart of a method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0052] Step S101, obtaining bad disk information of a virtual machine.

[0053] Specifically, in the embodiment of the present invention, since the physical disk of the host machine has been transmitted to the virtual machine, some bad disk conditions may not be directly reflected on the host machine, and therefore need to be monitored in the virtual machine. After the disk is damaged, there will be an error print in / var / log / messages when writing data in the virtual machine, and the relevant information will be recorded in the IO error log, such as a print error: print_req-error: I / O error, dev sdc, sector 19476, indicating that the physical disk / dev / sdc is damaged. The embodiment of the present invention pre-sets a script in the virtual machine to parse / var / log / messages to monitor whether a bad disk occurs. Assuming that the script name is check_bad_disk, crontab is used to generate a scheduled monitoring task, and the script check_bad_disk is automatically called at regular intervals, such as Figure 2 As shown, the IOerror log in the virtual machine system log is scanned regularly to determine whether there is bad disk information, and the monitored disk replacement information is saved to the file of the virtual machine, such as Figure 3 As shown in the figure, an error is detected in the sdc disk. The host needs to obtain the bad disk information, so a resident service program is set on the host in advance to regularly read the bad disk information in the virtual machine file through a scheduled reading task, and then determine whether there is bad disk information again, such as Figure 4 shown.

[0054] Step S102: determining the physical disk information of the host machine that needs to be replaced according to the bad disk information.

[0055] Specifically, in an embodiment of the present invention, the bad disk information read by the host machine corresponds to the information in the internal system of the virtual machine, and does not necessarily correspond to the information of the physical disk on the host machine. Therefore, it is necessary to convert the bad disk information into physical disk information, so as to determine which physical disk on the host machine the bad disk in the virtual machine corresponds to. In the actual operation of the virtual machine transparent transmission, the physical disk on the host machine is mounted on the PCI (Peripheral Component Interconnect, peripheral component interconnection standard) bus of the virtual machine through the SCSI protocol (Small Computer System Interface). The SCSI protocol is mainly used to transmit commands, states and block data between the host and the storage device. The PCI bus is a local parallel bus standard. In the virtual machine environment, the PCI bus is used to connect various virtual peripherals, such as virtual graphics cards, virtual network cards, etc. When the physical disk is hung to the virtual machine, each physical disk will have a PCI address in the virtual machine, and the SCSI number will be displayed in the address information. The PCI address is simulated by qemu (open source pc simulator), so it will be reflected in the qemu parameters (or virtual machine configuration files) and the two are consistent. The present invention converts bad disk information into logistics disk information according to the SCSI number in the PCI address, and at the same time determines whether the physical disk information can be obtained. If not, the program is exited or an alarm is issued to the maintenance personnel. Figure 4 shown.

[0056] Step S103, after the bad physical disk is removed according to the physical disk information, it is detected whether a new physical disk is inserted.

[0057] Specifically, in the embodiment of the present invention, after a bad disk is identified, the bad physical disk needs to be removed and a new physical disk needs to be inserted. This process still requires manual replacement by a technician. However, after the new physical disk is inserted, it is necessary to be able to automatically replace the physical disk for the virtual machine and restore the storage service in the virtual machine. Therefore, the host machine needs to be able to automatically sense the action of inserting the new physical disk, that is, to detect whether the new physical disk is inserted, and then automatically trigger the subsequent related operations of replacing the physical disk of the virtual machine.

[0058] Step S104: if a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on a preset management tool, and the new physical disk is transparently transmitted to the virtual machine.

[0059] Specifically, in an embodiment of the present invention, after replacing the physical disk, it is necessary to uninstall the previous bad disk from the virtual machine, re-mount the new disk, and finally restore the service status in the virtual machine. The present invention realizes the replacement of the transparent disk by updating the configuration file of the virtual machine. However, for the recovery of the service status, since the virtual machine is generally not connected to the host machine, it is impossible to log in directly to the virtual machine to perform related operations. Therefore, an embodiment of the present invention deploys a qemu-guest-agent tool in the virtual machine in advance. The tool is a daemon running inside the virtual machine, which can manage the application programs inside the virtual machine and execute the commands issued by the host machine, that is, the host machine can send relevant commands to the virtual machine for execution, and also includes executing the scripts and reading files in the virtual machine, thereby executing the service recovery script inside the virtual machine and restoring the service status of the virtual machine.

[0060] The method for replacing a virtual machine transparent disk provided by an embodiment of the present invention determines the physical disk information that needs to be replaced by the host machine according to the bad disk information of the acquired virtual disk. After the bad physical disk is pulled out, it is detected whether a new physical disk is inserted. If a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on a preset management tool, and the new physical disk is transparently transmitted to the virtual machine. The present invention can automatically monitor bad disks, complete automatic disk replacement and service recovery of virtual machines, realize semi-automatic replacement of the entire process of virtual machine transparent disk, avoid manual operation to the greatest extent, shorten the disk replacement time, and improve the timeliness of bad disk replacement.

[0061] In this embodiment, a method for replacing a virtual machine transparent disk is provided, which can be used for the above-mentioned host machine, such as a computer, etc. Figure 5 is a flow chart of a method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:

[0062] Step S501, obtain the bad disk information of the virtual machine. For details, see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.

[0063] Step S502: Determine the physical disk information of the host machine that needs to be replaced according to the bad disk information.

[0064] Specifically, the above step S502 includes:

[0065] Step S5021, obtaining a configuration file of the virtual machine, the configuration file including: address information including a preset identifier, wherein the preset identifier represents the same physical disk in the host machine and the virtual machine.

[0066] Step S5022: determine the target identifier of the disk replacement according to the bad disk information, and compare the target identifier with the preset identifier in the configuration file to determine the physical disk information corresponding to the bad disk.

[0067] Specifically, in the embodiment of the present invention, physical bad disk identification mainly converts the bad disk information in the virtual machine into the physical disk information on the host machine, wherein the SCSI number of the physical disk in the virtual machine is consistent with the configuration file of the virtual machine, and the information of the physical disk on the host machine can be obtained according to the configuration file. For example, the bad physical disk detected by the virtual machine is / dev / sdc, and its internal SCSI number of the virtual machine is 0:0:0:3. Figure 6 As shown. Based on this SCSI number, you can search in the virtual machine's configuration file to obtain physical disk information. The sdc in the virtual machine just corresponds to the sdc physical disk on the host machine, as shown Figure 7 As shown in (a) and (b).

[0068] Step S5023, generating warning information according to the physical disk information.

[0069] Specifically, in the embodiment of the present invention, Figure 4 As shown in the figure, the resident program on the host machine can read the bad disk information recorded by the virtual machine and obtain the corresponding physical disk information, and then promptly notify the operation and maintenance personnel of the physical disk information of the bad disk through alarms or emails, so that the subsequent physical disk can be replaced in time. The specific alarm information is as follows: Figure 8 shown.

[0070] Step S503: after the bad physical disk is removed according to the physical disk information, it is detected whether a new physical disk is inserted.

[0071] Specifically, the above step S503 includes:

[0072] Step S5031, determine the device file generation path of the host machine.

[0073] Step S5032: monitor whether a change occurs in the device file generation path based on a preset interface, and if a change occurs, insert a new physical disk.

[0074] Specifically, in an embodiment of the present invention, since all devices in the Linux operating system kernel of the host machine can be regarded as a file, when a new disk is inserted, a device file will be generated under / dev / by-path via the kernel and udev rules, so the embodiment of the present invention can monitor the insertion of the new disk under this path. Among them, udev is a tool for managing device files in the Linux system. Udev runs as a daemon process and manages device files under the / dev directory by monitoring uevents sent by the kernel. Udev rules are configuration files used to tell udev how to handle specific devices, and are composed of a series of key / value pairs, and the key / value pairs are separated by commas.

[0075] In some optional implementations, considering that there is an inotify interface in the Linux kernel, which can provide a mechanism for monitoring file system events, the embodiment of the present invention uses this interface and related tools to directly monitor changes in the / dev / by-path directory on the host machine, and determines whether a new physical disk is inserted by monitoring the create event, such as Fig. 9 As shown in (a) and (b), a new physical disk sdb is inserted into the host machine, and the SCSI number is 0:0:0:2.

[0076] Step S504: If a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on the preset management tool, and the new physical disk is transparently transmitted to the virtual machine. Figure 1 Step S104 of the illustrated embodiment will not be described in detail here.

[0077] The method for replacing a virtual machine transparent disk provided by an embodiment of the present invention determines the physical disk information that needs to be replaced by the host machine according to the bad disk information of the acquired virtual disk. After the bad physical disk is pulled out, it is detected whether a new physical disk is inserted. If a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on a preset management tool, and the new physical disk is transparently transmitted to the virtual machine. The present invention can automatically monitor bad disks, complete automatic disk replacement and service recovery of virtual machines, realize semi-automatic replacement of the entire process of virtual machine transparent disk, avoid manual operation to the greatest extent, shorten the disk replacement time, and improve the timeliness of bad disk replacement.

[0078] In this embodiment, a method for replacing a virtual machine transparent disk is provided, which can be used for the above-mentioned host machine, such as a computer, etc. Fig.10 is a flow chart of a method for replacing a virtual machine transparent transmission disk according to an embodiment of the present invention. Fig.10 As shown, the process includes the following steps:

[0079] Step S1001, obtain the bad disk information of the virtual machine. For details, see Figure 5 Step S501 of the illustrated embodiment will not be described in detail here.

[0080] Step S1002: Determine the physical disk information that needs to be replaced on the host machine based on the bad disk information. Figure 5 Step S502 of the illustrated embodiment will not be described in detail here.

[0081] Step S1003: After the bad physical disk is removed according to the physical disk information, it is detected whether a new physical disk is inserted. Figure 5 Step S503 of the illustrated embodiment will not be described in detail here.

[0082] Step S1004: if a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on a preset management tool, and the new physical disk is transparently transmitted to the virtual machine.

[0083] Specifically, the above step S1004 includes:

[0084] Step S10041, query whether there is a device file corresponding to the bad physical disk in the configuration file, if so, delete the device file.

[0085] Step S10042: Generate a new configuration file according to the new physical disk, and mount the new configuration file to the virtual machine.

[0086] Step S10043: Call and execute a preset service recovery script of the virtual machine based on a preset management tool, so that the virtual machine recovers the service status based on the new physical disk.

[0087] Specifically, in the embodiment of the present invention, the virtual machine disk replacement involves two parts: removing the old disk (detach disk) and inserting the new disk (attach disk). Among them, to remove the old disk of the virtual machine, the embodiment of the present invention adopts scanning the virtual machine configuration file to obtain all the disks in use, and then checks whether the disks exist on the host machine in turn to achieve the purpose. The command used to scan the virtual machine configuration file is as follows: Fig.11 For example, if the physical disk sdd used by the virtual machine is damaged, when the physical bad disk sdd is unplugged on the host machine, there is no corresponding file under / dev / disk / by-id in the virtual machine configuration file. Therefore, the embodiment of the present invention can sequentially search under / dev / disk / by-id to find whether the device file corresponding to the physical bad disk sdd exists. If it exists, the device file is deleted in the virtual machine. The corresponding command is as follows: Fig.12 As shown. When a new disk is inserted, the configuration file of the new disk can be directly generated and then attached to the virtual machine. The corresponding command is as follows Fig.13 shown.

[0088] In some optional implementations, after replacing the disk for the virtual machine, it is necessary to execute relevant commands or scripts in the virtual machine to restore the storage service. For example, the service recovery script name in the virtual machine is / opt / test.sh. Fig.14 The embodiment of the present invention uses the qemu-guest-agent tool to send commands to execute the service recovery script prepared in advance in the virtual machine, such as Fig.15 shown.

[0089] The method for replacing a virtual machine transparent disk provided by an embodiment of the present invention determines the physical disk information that needs to be replaced by the host machine according to the bad disk information of the acquired virtual disk. After the bad physical disk is pulled out, it is detected whether a new physical disk is inserted. If a new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on a preset management tool, and the new physical disk is transparently transmitted to the virtual machine. The present invention can automatically monitor bad disks, complete automatic disk replacement and service recovery of virtual machines, realize semi-automatic replacement of the entire process of virtual machine transparent disk, avoid manual operation to the greatest extent, shorten the disk replacement time, and improve the timeliness of bad disk replacement.

[0090] In this embodiment, a device for replacing a virtual machine transparent disk is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0091] This embodiment provides a device for replacing a virtual machine transparent disk. Fig.16 As shown, including:

[0092] The information acquisition module 1601 is used to acquire bad disk information of the virtual machine.

[0093] The information identification module 1602 is used to determine the physical disk information that needs to be replaced in the host machine according to the bad disk information.

[0094] The disk replacement detection module 1603 is used to detect whether a new physical disk is inserted after the bad physical disk is pulled out according to the physical disk information.

[0095] The bad disk replacement module 1604 is used to delete the bad physical disk from the virtual machine based on a preset management tool if a new physical disk is inserted, and transparently transmit the new physical disk to the virtual machine.

[0096] In some optional implementations, the information acquisition module 1601 includes: when the virtual machine performs system log scanning based on the scheduled monitoring task and obtains the bad disk information, obtaining the bad disk information based on the scheduled reading task.

[0097] In some optional implementations, the information identification module 1602 includes:

[0098] The file acquisition unit is used to acquire a configuration file of the virtual machine, wherein the configuration file includes: address information including a preset identifier, wherein the preset identifier represents the same physical disk in the host machine and the virtual machine.

[0099] The information comparison unit is used to determine the target identifier of the disk replacement according to the bad disk information, and compare the target identifier with the preset identifier in the configuration file to determine the physical disk information corresponding to the bad disk.

[0100] In some optional implementations, the information identification module 1602 further includes: an alarm unit, configured to generate alarm information according to the physical disk information.

[0101] In some optional implementations, the disk change detection module 1603 includes:

[0102] The path determination unit is used to determine the device file generation path of the host machine.

[0103] The path monitoring unit is used to monitor whether changes occur in the device file generation path based on a preset interface, and if changes occur, insert a new physical disk.

[0104] In some optional implementations, the bad disk replacement module 1604 includes:

[0105] The disk swap unit is used to query whether there is a device file corresponding to the bad physical disk in the configuration file. If it exists, the device file is deleted.

[0106] The new disk insertion unit is used to generate a new configuration file according to the new physical disk and mount the new configuration file to the virtual machine.

[0107] The service recovery unit is used to call and execute a preset service recovery script of the virtual machine based on a preset management tool, so that the virtual machine can recover the service state based on the new physical disk.

[0108] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0109] The replacement device of the virtual machine transparent disk in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0110] The embodiment of the present invention also provides a computer device having the above Fig.16 The replacement device of the virtual machine transparent transmission disk is shown.

[0111] See also Fig.17 , Fig.17 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig.17As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.17 A processor 10 is taken as an example.

[0112] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0113] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0114] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0115] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0116] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0117] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0118] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0119] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for replacing a virtual machine transparent disk, characterized in that: Applied to a host machine, the method includes: Get the bad disk information of the virtual machine; Determine the physical disk information of the host machine that needs to be replaced according to the bad disk information; After the bad physical disk is pulled out according to the physical disk information, detecting whether a new physical disk is inserted; If the new physical disk is inserted, the bad physical disk is deleted from the virtual machine based on a preset management tool, and the new physical disk is transparently transmitted to the virtual machine.

2. The method according to claim 1, characterized in that The obtaining of bad disk information of the virtual machine includes: When the virtual machine performs system log scanning based on the scheduled monitoring task and obtains the bad disk information, the bad disk information is obtained based on the scheduled reading task.

3. The method according to claim 2, characterized in that The determining, according to the bad disk information, the physical disk information of the host machine that needs to be replaced includes: Obtaining a configuration file of the virtual machine, the configuration file comprising: address information including a preset identifier, wherein the preset identifier represents the same physical disk in the host machine and the virtual machine; A target identifier for disk replacement is determined according to the bad disk information, and the target identifier is compared with the preset identifier in the configuration file to determine the physical disk information corresponding to the bad disk.

4. The method according to claim 1, characterized in that: After determining the physical disk information of the host machine that needs to be replaced according to the bad disk information, the method further includes: Generate warning information according to the physical disk information.

5. The method according to claim 1, characterized in that The detecting whether a new physical disk is inserted comprises: Determine a device file generation path of the host machine; Based on a preset interface, whether a change occurs in the device file generation path is monitored, and if a change occurs, the new physical disk is inserted.

6. The method according to claim 3, characterized in that The method of deleting the bad physical disk from the virtual machine based on a preset management tool and transparently transmitting the new physical disk to the virtual machine includes: Checking whether the configuration file has a device file corresponding to the bad physical disk, and if so, deleting the device file; Generate a new configuration file according to the new physical disk, and mount the new configuration file to the virtual machine; Based on the preset management tool, the preset service recovery script of the virtual machine is called and executed, so that the virtual machine recovers the service status based on the new physical disk.

7. A device for replacing a virtual machine transparent disk, characterized in that: Applied to a host machine, the device comprises: An information acquisition module, used to obtain bad disk information of a virtual machine; An information identification module, used to determine the physical disk information of the host machine that needs to be replaced according to the bad disk information; A disk replacement detection module, used for detecting whether a new physical disk is inserted after a bad physical disk is pulled out according to the physical disk information; The bad disk replacement module is used to delete the bad physical disk from the virtual machine based on a preset management tool if the new physical disk is inserted, and transparently transmit the new physical disk to the virtual machine.

8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for replacing a virtual machine transparent disk according to any one of claims 1 to 6 by executing the computer instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for replacing a virtual machine transparent disk according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to enable a computer to execute the method for replacing a virtual machine transparent disk according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Virtual machine-based equipment heat replacing method and device

    CN105279010A

  • Distributed storage calling method, device and apparatus

    CN109375874A

  • Disk health inspection method and device, electronic equipment, medium and product

    CN114721850A

  • Hard disk replacement method and device, equipment and medium

    CN117851304A

  • Virtual machine block substitution

    US20130007733A1