Main and standby switching method and system based on online and offline mechanism and terminal
Through the main and backup switching method based on the upper and lower-line mechanism, dynamic evaluation and selection of backup equipment is solved, the complex and cumbersome problem of main and backup switching in the existing technology is solved, and the rapid switching and business continuity in the event of main equipment failure is achieved, which reduces development Cost and complexity.
Patent Information
- Application Number
- CN202411115666.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-05
AI Technical Summary
In the prior art, when using the heartbeat mechanism to switch main and backup, the three-party library needs to be transplanted or redeveloped and implemented, resulting in the process of main and backup switching, and the lack of simple and efficient methods.
Using the main and backup switching method based on the upper and lower line mechanism, the role configuration is achieved by obtaining the devices in the target system, monitoring the operating status of the main and backup devices, dynamically assessing the weight of the backup devices, and synchronizing the distributed data when the main device fails. To the backup device with the largest weight, complete the switch between the main and spare devices.
Quickly switch to the backup device when the main device fails, ensuring business continuity, reducing development costs and thresholds, no need to transplant third-party libraries or redevelop heartbeat mechanisms, and improving the ease of switching between main devices.
Smart Images

Figure CN118900231A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of active-standby switching, and in particular to an active-standby switching method, system, terminal and computer-readable storage medium based on an online and offline mechanism. Background Art
[0002] Active-standby switching is a strategy used to ensure that the system can quickly switch to the standby server when the primary server fails, which can maintain the continuity and availability of the system; this mechanism usually involves steps such as automatically detecting the status of the primary server, determining the failure of the primary server, and starting the standby server.
[0003] Active / standby switching usually adopts the following methods: Manual switching: This is the most common method. The administrator manually switches the standby server to the active server through the console or command line. Heartbeat monitoring switching: The active and standby servers monitor each other's operating status through heartbeat packets. When the active server fails, the standby server will automatically detect and take over the service. Heartbeat monitoring can be implemented through software or hardware, and usually cooperates with software for status synchronization and data replication.
[0004] However, although manual switching is simple to operate, it requires manual intervention by the administrator and will cause a brief interruption of system services, resulting in low automatic performance and efficiency; and the heartbeat mechanism requires the transplantation of third-party libraries or redevelopment and implementation, making the primary and standby switching process more complicated and cumbersome.
[0005] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0006] The main purpose of the present invention is to provide a master-slave switching method, system, terminal and computer-readable storage medium based on the online and offline mechanism, aiming to solve the problems in the prior art that when using the heartbeat mechanism for master-slave switching, a third-party library needs to be transplanted or redeveloped, the master-slave switching is complicated and cumbersome, and there is a lack of a simple and efficient master-slave switching method.
[0007] To achieve the above object, the present invention provides a method for active / standby switching based on an online / offline mechanism, wherein the method comprises the following steps:
[0008] Obtain all devices in the target system, configure roles for each device, and set a master device and multiple backup devices;
[0009] Performing monitoring operations on the main device and the plurality of backup devices, and obtaining weights corresponding to the plurality of backup devices;
[0010] When the offline of the master device is detected, a device with the largest weight is selected from the plurality of backup devices as the backup master device;
[0011] The distributed data of the master device is synchronized to the backup master device to complete the master-backup device switching.
[0012] Optionally, in the active-standby switching method based on online and offline mechanisms, the target system is a system with online and offline mechanisms.
[0013] Optionally, in the active / standby switching method based on the online / offline mechanism, the steps of respectively configuring roles for each device and setting a primary device and multiple standby devices specifically include:
[0014] Respectively obtain the memory resources of each of the devices, sort the multiple memory resources, and obtain the device corresponding to the largest memory resource;
[0015] The device with the largest memory resource is used as the primary device, and the remaining devices are used as backup devices.
[0016] Optionally, in the master-slave switching method based on the online and offline mechanism, the monitoring operation on the master device and the plurality of the backup devices specifically includes:
[0017] Detecting the operating status of the main device and the plurality of backup devices in real time, and determining that the main device is offline when detecting that the operating status of the main device is abnormal;
[0018] The operating status includes the CPU status and memory resource status of the device;
[0019] When it is detected that there is an abnormal standby device with an abnormal operating status among the multiple standby devices, the abnormal standby device is removed from the multiple standby devices, and the information of the abnormal standby device is uploaded to the user end and the cloud.
[0020] Optionally, the active / standby switching method based on the online / offline mechanism, wherein the real-time detection of the operating status of the active device and the plurality of standby devices further comprises:
[0021] A temporary storage space is set, the distributed data of the master device is acquired in advance, and the distributed data is stored in the temporary storage space.
[0022] Optionally, in the active / standby switching method based on the online / offline mechanism, the step of obtaining weights corresponding to the active device and the plurality of standby devices specifically includes:
[0023] Dynamically collect the CPU status and memory resource status of multiple backup devices, and obtain the historical resource usage status of multiple backup devices;
[0024] Integrate the CPU status, memory resource status and historical resource usage status corresponding to each of the backup devices respectively to obtain a current performance evaluation result of each of the backup devices;
[0025] Different weights are set for each of the backup devices in turn according to the magnitude of the performance evaluation results.
[0026] Optionally, the master-slave switching method based on the online and offline mechanism, wherein the step of synchronizing the distributed data of the master device to the backup master device to complete the master-slave device switching, specifically includes:
[0027] Acquire the distributed data in the temporary storage space, and send the distributed data to the backup master device for data synchronization;
[0028] When the data synchronization is completed, the service of the target system is handed over to the backup master device to complete the master-slave device switching.
[0029] In addition, to achieve the above-mentioned purpose, the present invention further provides a master-slave switching system based on an online and offline mechanism, wherein the master-slave switching system based on an online and offline mechanism comprises:
[0030] A master-slave configuration module is used to obtain all devices in the target system, configure the role of each device, and set a master device and multiple backup devices;
[0031] A weight allocation module, used to monitor the main device and the plurality of backup devices, and obtain weights corresponding to the plurality of backup devices;
[0032] A master device switching module, configured to select a device with the largest weight from the plurality of backup devices as a backup master device when the master device is detected to be offline;
[0033] The data synchronization module is used to synchronize the distributed data of the master device to the backup master device to complete the master-backup device switching.
[0034] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a master-standby switching program based on the online and offline mechanism stored in the memory and executable on the processor, wherein the master-standby switching program based on the online and offline mechanism, when executed by the processor, implements the steps of the master-standby switching method based on the online and offline mechanism as described above.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a master-standby switching program based on the online and offline mechanism, and when the master-standby switching program based on the online and offline mechanism is executed by the processor, the steps of the master-standby switching method based on the online and offline mechanism as described above are implemented.
[0036] In the present invention, all devices in the target system are obtained, and roles are configured for each of the devices, and a master device and multiple backup devices are set; the master device and the multiple backup devices are monitored, and the weights corresponding to the multiple backup devices are obtained; when the master device is monitored to be offline, the device with the largest weight is selected from the multiple backup devices as the backup master device; the distributed data of the master device is synchronized to the backup master device to complete the master-backup device switching. The present invention can quickly use the backup device to take over the service when the master device fails to ensure that the business is not affected, and through the system's own online and offline mechanism, it can greatly reduce the development cost, lower the development threshold, and improve the simplicity of the master device switching. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a flow chart of a preferred embodiment of the active-standby switching method based on the online and offline mechanism of the present invention;
[0038] Figure 2 It is a schematic diagram of the principle of a preferred embodiment of the active-standby switching system based on the online and offline mechanism of the present invention;
[0039] Figure 3 Schematic diagram of the operating environment of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0040] The present application provides a master-slave switching method based on an online and offline mechanism and related equipment. In order to make the purpose, technical solution and effect of the present application clearer and more specific, the present application is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0041] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with those in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0042] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0043] The master-slave switching method based on the online and offline mechanism described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the active / standby switching method based on the online / offline mechanism includes the following steps:
[0044] Step S10: Acquire all devices in the target system, configure roles for each device, and set a master device and multiple backup devices.
[0045] The master device is the main working device, responsible for handling major business needs and data processing. Under normal circumstances, the master device is responsible for providing external services, processing read and write operations, and ensuring the normal operation of the system. The backup device, also known as the standby machine, is mainly used to back up the data and status of the master device to prevent the master device from failing and quickly take over the service. Under normal circumstances, the backup device does not directly provide services to the outside world, but serves as a backup resource, waiting to take over the service when the master device fails, ensuring service continuity and data integrity.
[0046] This active-standby architecture is designed to improve system reliability and availability by spreading the risk to the standby device and reducing service interruptions caused by single point failures. In actual applications, the configuration of the active-standby architecture is relatively simple, but attention should be paid to ensuring data synchronization and status updates between the active and standby devices to ensure that the standby device can quickly take over the service when needed.
[0047] Specifically, respectively obtain the memory resources of each of the devices, sort the multiple memory resources, and obtain the device corresponding to the largest memory resource;
[0048] The device with the largest memory resource is used as the primary device, and the remaining devices are used as backup devices.
[0049] It is understandable that memory resources are a major component in a computer system, used to store programs and data when a process is running. It is called executable memory, and its main function is to serve as a running place for programs, store and access data and instructions required during program execution. The CPU accesses the memory unit through a specific address to perform data reading and writing or instruction execution. Memory resources can be divided into physical address space and memory space allocated by the system to user programs. In addition, memory can also further expand its functions by expanding memory space, such as increasing memory size and virtual memory. This embodiment obtains the memory resources of each of the devices by calculation, and sorts multiple memory resources to obtain the device corresponding to the largest memory resource, and uses the device corresponding to the largest memory resource as the main device, so that the main device can be kept with sufficient resources and powerful performance.
[0050] Furthermore, the target system is a system with an on-line and off-line mechanism, which is a key mechanism to ensure that services can respond quickly and effectively to changes in their status, whether in a microservice architecture or in a broader system design. The implementation of this mechanism involves multiple aspects, including service registration and discovery, heartbeat detection, load balancing strategy, etc., to ensure that services can dynamically adapt to the increase and decrease of their components;
[0051] As an example, the target system in this embodiment is preferably the Openharmony system (OpenHarmony is an open source project incubated and operated by the Open Atom Open Source Foundation. It aims to build a framework and platform for the operating system of intelligent terminal devices in an open source manner for the full-scenario, full-connection, and full-intelligence era, so as to promote the prosperity and development of the Internet of Things industry. OpenHarmony adopts a componentized design scheme, and the system functions are gradually expanded according to "system> subsystem> component", and support the cutting of certain non-essential components according to actual needs). The online and offline mechanism of the Openharmony system can be understood as follows: when devices A and B are networked, A will receive a notification that B is online; when B is powered off or disconnected from the network, A will receive a notification that B is offline. The online and offline mechanism of the Openharmony system can greatly reduce development costs, lower the threshold for development, and improve the ease of switching of master devices.
[0052] Step S20: monitor the main device and the plurality of backup devices, and obtain weights corresponding to the plurality of backup devices.
[0053] The monitoring operation on the main device and the plurality of backup devices specifically includes: detecting the operating status of the main device and the plurality of backup devices in real time, and determining that the main device is offline when an abnormality is detected in the operating status of the main device; wherein the operating status includes the CPU status and memory resource status of the device;
[0054] When it is detected that there is an abnormal standby device with an abnormal operating status among the multiple standby devices, the abnormal standby device is removed from the multiple standby devices, and the information of the abnormal standby device is uploaded to the user end and the cloud.
[0055] In this embodiment, the CPU status and memory resource status of the main device and multiple backup devices are detected in real time through the resource controller. When it is detected that the operating status of the main device is abnormal (such as CPU overload, etc.), it indicates that the main device is faulty and it is determined that the main device is offline.
[0056] It can be understood that in addition to detecting the main device, this embodiment also detects multiple backup devices. When it is detected that there is an abnormal backup device with an abnormal operating status among the multiple backup devices, the abnormal backup device cannot work normally, so the abnormal backup device is removed from the multiple backup devices, and the information of the abnormal backup device is uploaded to the user end and the cloud to remind the user or staff to deal with it in time.
[0057] Furthermore, the real-time detection of the operating status of the main device and the plurality of backup devices further includes:
[0058] A temporary storage space is set, the distributed data of the master device is acquired in advance, and the distributed data is stored in the temporary storage space.
[0059] In this embodiment, a temporary storage space is pre-set, and the size of the storage space can be set according to an empirical value; the distributed data of the master device is pre-acquired, the distributed data is stored in the temporary storage space, and the distributed data of the master device is re-acquired every preset time, and is put into the temporary storage space again, and the original distributed data of the temporary storage space is updated. The present invention sets a temporary storage space, extracts and stores the distributed data of the master device in advance, and avoids the problem that the distributed data cannot be synchronized normally when an abnormality occurs in the master device.
[0060] Furthermore, the obtaining weights corresponding to the plurality of standby devices specifically includes:
[0061] Dynamically collect the CPU status and memory resource status of multiple backup devices, and obtain the historical resource usage status of multiple backup devices;
[0062] Integrate the CPU status, memory resource status and historical resource usage status corresponding to each of the backup devices respectively to obtain a current performance evaluation result of each of the backup devices;
[0063] Different weights are set for each of the backup devices in turn according to the magnitude of the performance evaluation results.
[0064] In this embodiment, the weight of each of the backup devices changes in real time. This embodiment first dynamically collects the CPU status and memory resource status of multiple backup devices through dynamic acquisition, and obtains the historical resource usage status of multiple backup devices; then integrates the CPU status, memory resource status and historical resource usage status corresponding to each of the backup devices respectively. Taking two backup devices as an example, the current CPU status of the first backup device is a CPU usage rate of 10%, and the memory resource status is 50% (4G); the current CPU status of the second backup device is a CPU usage rate of 5%, and the memory resource status is 40%. It can be seen that the CPU usage rate and memory resource status of the second backup device are lower than those of the first backup device, which means that the second backup device has higher performance than the first backup device at the current time. Therefore, the performance evaluation result of the second backup device is higher than the performance evaluation result of the first backup device.
[0065] In addition, the historical resource usage of the backup device can also be used as a basis for performance evaluation. For example, if the current CPU status and memory resource status of the first backup device and the second backup device are the same or close, then the historical resource usage of the first backup device and the second backup device can be obtained. If the historical resource usage of the first backup device is lower than that of the second backup device, it means that the probability that the CPU status of the first backup device changes (increases) in the subsequent time is lower than that of the second backup device. In order to ensure the relative stability of the performance evaluation results and reduce the amount of calculation (when the CPU status and memory resource status between devices are the same or close, if the performance evaluation results of the device with high historical resource usage are ranked ahead of the device with low historical resource usage, the subsequent resource usage of the device with high historical resource usage is likely to continue to increase, resulting in the need to redistribute the entire weight), therefore, the first backup device with low historical resource usage can obtain a higher performance evaluation result than the second backup device. Finally, different weights are set for each of the backup devices in turn according to the size of the performance evaluation results, and the total weight size is 1.
[0066] Furthermore, in addition to being dynamically acquired, the weights may also be pre-set as fixed values, and the specific numerical settings may be set according to actual conditions and needs, and are not limited here.
[0067] Step S30: When the offline of the master device is detected, a device with the largest weight is selected from the plurality of backup devices as the backup master device.
[0068] Specifically, when the main device is monitored to have a failure, the main device goes offline. At this time, the device with the largest weight at the current time is selected from the multiple backup devices as the backup main device to replace the offline main device to complete the core operation function.
[0069] Step S40: Synchronize the distributed data of the master device to the backup master device to complete the master-backup device switching.
[0070] Specifically, obtaining the distributed data in the temporary storage space, and sending the distributed data to the backup master device for data synchronization;
[0071] When the data synchronization is completed, the service of the target system is handed over to the backup master device to complete the master-slave device switching.
[0072] It can be understood that after selecting the device with the largest weight as the backup master device, since the distributed data of the master device has been stored in the temporary storage space in advance, the distributed data in the temporary storage space is directly read and sent to the backup master device for data synchronization. At this point, the backup master device completes the master-slave device switching.
[0073] It can be seen that the present invention can quickly adopt a backup device to take over the service when the main device fails to ensure that the business is not affected, and through the system's own online and offline mechanism, the development cost can be greatly reduced. There is no need to transplant a third-party library or redevelop a heartbeat mechanism to achieve active-standby switching, which lowers the development threshold and improves the simplicity of switching the main device.
[0074] Furthermore, if Figure 2 As shown, based on the above-mentioned active-standby switching method based on the online and offline mechanism, the present invention also provides an active-standby switching system based on the online and offline mechanism, wherein the active-standby switching system based on the online and offline mechanism includes:
[0075] The master-slave configuration module 41 is used to obtain all devices in the target system, configure the role of each device, and set a master device and multiple backup devices;
[0076] A weight distribution module 42 is used to monitor the main device and the plurality of backup devices and obtain weights corresponding to the plurality of backup devices;
[0077] A master device switching module 43 is used to select a device with the largest weight from the plurality of backup devices as a backup master device when the master device is offline.
[0078] The data synchronization module 44 is used to synchronize the distributed data of the master device to the backup master device to complete the master-backup device switching.
[0079] Furthermore, if Figure 3 As shown, based on the above-mentioned active-standby switching method and system based on the online and offline mechanism, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 3 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0080] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the terminal, such as the program code of the installation terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a master-slave switching program 40 based on an online and offline mechanism is stored on the memory 20, and the master-slave switching program 40 based on an online and offline mechanism can be executed by the processor 10, thereby realizing the master-slave switching method based on an online and offline mechanism in the present application.
[0081] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the master-slave switching method based on the online and offline mechanism.
[0082] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.
[0083] In one embodiment, when the processor 10 executes the active / standby switching program 40 based on the online / offline mechanism in the memory 20, the following steps are implemented:
[0084] Obtain all devices in the target system, configure roles for each device, and set a master device and multiple backup devices;
[0085] Performing monitoring operations on the main device and the plurality of backup devices, and obtaining weights corresponding to the plurality of backup devices;
[0086] When the offline of the master device is detected, a device with the largest weight is selected from the plurality of backup devices as the backup master device;
[0087] The distributed data of the master device is synchronized to the backup master device to complete the master-backup device switching.
[0088] The target system is a system with an online and offline mechanism.
[0089] The steps of respectively configuring roles for each device and setting a master device and multiple backup devices specifically include:
[0090] Respectively obtain the memory resources of each of the devices, sort the multiple memory resources, and obtain the device corresponding to the largest memory resource;
[0091] The device with the largest memory resource is used as the primary device, and the remaining devices are used as backup devices.
[0092] The monitoring operation on the main device and the plurality of backup devices specifically includes:
[0093] Detecting the operating status of the main device and the plurality of backup devices in real time, and determining that the main device is offline when detecting that the operating status of the main device is abnormal;
[0094] The operating status includes the CPU status and memory resource status of the device;
[0095] When it is detected that there is an abnormal standby device with an abnormal operating status among the multiple standby devices, the abnormal standby device is removed from the multiple standby devices, and the information of the abnormal standby device is uploaded to the user end and the cloud.
[0096] The real-time detection of the operating status of the master device and the plurality of backup devices further includes:
[0097] A temporary storage space is set, the distributed data of the master device is acquired in advance, and the distributed data is stored in the temporary storage space.
[0098] The obtaining of weights corresponding to the plurality of standby devices specifically includes:
[0099] Dynamically collect the CPU status and memory resource status of multiple backup devices, and obtain the historical resource usage status of multiple backup devices;
[0100] Integrate the CPU status, memory resource status and historical resource usage status corresponding to each of the backup devices respectively to obtain a current performance evaluation result of each of the backup devices;
[0101] Different weights are set for each of the backup devices in turn according to the magnitude of the performance evaluation results.
[0102] The step of synchronizing the distributed data of the master device to the backup master device to complete the master-slave device switching specifically includes:
[0103] Acquire the distributed data in the temporary storage space, and send the distributed data to the backup master device for data synchronization;
[0104] When the data synchronization is completed, the service of the target system is handed over to the backup master device to complete the master-slave device switching.
[0105] In summary, the present invention provides a method, system and terminal for master-slave switching based on the online and offline mechanism, the method comprising: obtaining all devices in the target system, configuring roles for each of the devices, setting a master device and multiple backup devices; monitoring the master device and multiple backup devices, and obtaining the weights corresponding to the multiple backup devices; when the master device is monitored to be offline, selecting the device with the largest weight from the multiple backup devices as the backup master device; synchronizing the distributed data of the master device to the backup master device to complete the master-slave device switching. The present invention can quickly use the backup device to take over the service when the master device fails to ensure that the business is not affected, and through the system's own online and offline mechanism, the development cost can be greatly reduced, and there is no need to transplant a third-party library or redevelop the heartbeat mechanism to achieve master-slave switching, which reduces the development threshold and improves the simplicity of master device switching.
[0106] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.
[0107] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0108] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A master-slave switching method based on online and offline mechanism, characterized in that: The active / standby switching method based on the online / offline mechanism includes: Obtain all devices in the target system, configure roles for each device, and set a master device and multiple backup devices; Performing monitoring operations on the main device and the plurality of backup devices, and obtaining weights corresponding to the plurality of backup devices; When the offline of the master device is detected, a device with the largest weight is selected from the plurality of backup devices as the backup master device; The distributed data of the master device is synchronized to the backup master device to complete the master-backup device switching.
2. The active / standby switching method based on the online / offline mechanism according to claim 1 is characterized in that: The target system is a system with an online and offline mechanism.
3. The active / standby switching method based on the online / offline mechanism according to claim 1 is characterized in that: The step of respectively configuring roles for each device and setting a master device and multiple backup devices specifically includes: Respectively obtain the memory resources of each of the devices, sort the multiple memory resources, and obtain the device corresponding to the largest memory resource; Set the device with the largest memory resource as the primary device, and set the remaining devices as backup devices.
4. The active / standby switching method based on the online / offline mechanism according to claim 1 is characterized in that: The monitoring operation on the main device and the plurality of backup devices specifically includes: Detecting the operating status of the main device and the plurality of backup devices in real time, and determining that the main device is offline when detecting that the operating status of the main device is abnormal; The operating status includes the CPU status and memory resource status of the device; When it is detected that there is an abnormal standby device with an abnormal operating status among the multiple standby devices, the abnormal standby device is removed from the multiple standby devices, and the information of the abnormal standby device is uploaded to the user end and the cloud.
5. The active / standby switching method based on the online / offline mechanism according to claim 4 is characterized in that: The real-time detection of the operating status of the main device and the plurality of the backup devices further comprises: A temporary storage space is set, the distributed data of the master device is acquired in advance, and the distributed data is stored in the temporary storage space.
6. The active / standby switching method based on the online / offline mechanism according to claim 5 is characterized in that: The obtaining weights corresponding to the plurality of standby devices specifically includes: Dynamically collect the CPU status and memory resource status of multiple backup devices, and obtain the historical resource usage status of multiple backup devices; Integrate the CPU status, memory resource status and historical resource usage status corresponding to each of the backup devices respectively to obtain a current performance evaluation result of each of the backup devices; Different weights are set for each of the backup devices in turn according to the magnitude of the performance evaluation results.
7. The active / standby switching method based on the online / offline mechanism according to claim 6 is characterized in that: The step of synchronizing the distributed data of the master device to the backup master device to complete the master-backup device switching specifically includes: Acquire the distributed data in the temporary storage space, and send the distributed data to the backup master device for data synchronization; When the data synchronization is completed, the service of the target system is handed over to the backup master device to complete the master-slave device switching.
8. A master-slave switching system based on online and offline mechanism, characterized in that: The active / standby switching system based on the online / offline mechanism includes: A master-slave configuration module is used to obtain all devices in the target system, configure the role of each device, and set a master device and multiple backup devices; A weight allocation module, used to monitor the main device and the plurality of backup devices, and obtain weights corresponding to the plurality of backup devices; A master device switching module, configured to select a device with the largest weight from the plurality of backup devices as a backup master device when the master device is detected to be offline; The data synchronization module is used to synchronize the distributed data of the master device to the backup master device to complete the master-backup device switching.
9. A terminal, characterized in that: The terminal includes: a memory, a processor, and a master-standby switching program based on an online and offline mechanism stored in the memory and executable on the processor. When the master-standby switching program based on an online and offline mechanism is executed by the processor, the steps of the master-standby switching method based on an online and offline mechanism as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a master-slave switching program based on an online and offline mechanism, and when the master-slave switching program based on an online and offline mechanism is executed by a processor, the steps of the master-slave switching method based on an online and offline mechanism as described in any one of claims 1-7 are implemented.
Citation Information
Cited By
Switching method and device for panel equipment and computer readable storage medium
CN121193554A
