A dual-machine mirror processing method and device
By periodically detecting and simulating the network connection status, we ensure that the Rabbit MQ service can restart and provide services normally when the main device or standby device fails, solving the problem that the service is unavailable in the existing technology of the dual-machine mirror architecture when the network fails, and achieving high availability.
Patent Information
- Application Number
- CN202111240471.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-25
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-10-25
AI Technical Summary
When the existing Rabbit MQ dual-machine mirror architecture fails in the primary node or network failure, the backup node may not work properly, resulting in unavailability of services and the inability to deploy multiple mirror nodes in the dual-machine, affecting high service availability.
Periodically detect the network connection status of the peer device. If it is not connected, set the local second network address to the network address of the peer device to simulate the connection status to ensure that the Rabbit MQ service can restart and provide services normally. At the same time, the Rabbit MQ service is started independently in cluster mode, and the business structure is rebuilt through data synchronization services to decouple the mirror node relationship.
When the main device or standby device fails, the unfailed party can ensure that the Rabbit MQ service is restarted normally and provides services, achieving high availability of dual-machine mirroring, and avoiding service interruptions caused by network failure.
Smart Images

Figure CN113886107B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a dual-machine image processing method and device. Background Art
[0002] Rabbit MQ is an open source message broker software (also known as message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). If a Rabbit MQ cluster has only one node, the failure of that node will cause the entire service cluster to be temporarily unavailable and may cause the loss of business messages. In addition, Rabbit MQ's mirror queue mechanism is to mirror the queue to other nodes in the cluster. In this way, when a node in the cluster fails, other nodes can provide services normally, improving the high availability of the overall cluster service.
[0003] The closest technical solution to the existing technology is the Rabbit MQ dual-machine mirroring solution, which is a universal solution. The specific description is as follows. Two devices, the host address is 10.0.0.1, the backup node address is 10.0.0.2, the master and backup nodes synchronize data through the network, and the business accesses Rabbit MQ through the host address 10.0.0.1. The specific relationship Figure 1 shown.
[0004] 1) Modify / etc / hosts on the host and backup machine to implement dual-machine alias
[0005] 10.0.0.1rabbit-10-0-0-1
[0006] 10.0.0.2rabbit-10-0-0-2
[0007] 2) Rabbit MQ is configured as cluster mode on both devices
[0008] 3) Generate the erlang.cookie file and copy it to the root directory of the host and backup machines
[0009] The file content is a unique identifier generated using MD5, and the cluster uses this identifier to identify the cluster node.
[0010] 4) The backup machine joins the host's cluster and sets the mirror synchronization strategy according to business needs.
[0011] The working principle and switching process of Rabbit MQ mirroring between the master and the slave are as follows:
[0012] 1) Business requests are sent to the host (mq-10-0-01). Specific business requests may include creating new queues, message communication, etc.
[0013] 2) The host (mq-10-0-01) service synchronizes business requests to the backup machine (mq-10-0-0-2) based on the mirroring mechanism, including creating new queues, message communication, etc.
[0014] 3) When the host fails to provide services due to a fault, a dual-machine switch occurs and the business request is sent to the backup machine (mq-10-0-0-2). Since the data consistency is maintained between the mirror nodes, the business can run normally.
[0015] The following defects were found in the actual business application of this dual-machine mirroring technology solution.
[0016] 1. There is a very strong coupling between the mirror nodes. When the main node is down, the backup node sometimes needs to wait for the main node to recover before it can work normally. When the main node cannot start, the backup node sometimes always waits for the main node to start, making the dual-machine mirror architecture unavailable.
[0017] 2. After the dual-machine mirror cluster is successfully built, the network between the primary and backup nodes fails, and the Rabbit MQ service is sometimes unable to restart and provide business services.
[0018] Since Rabbit MQ occupies a large number of resources and it is impossible to deploy multiple mirror nodes in dual machines, the above problem has seriously interfered with the high availability of the business. Summary of the invention
[0019] The present invention provides a dual-machine mirror processing method and device which can ensure high availability under the condition of dual-machine mirroring.
[0020] In order to solve the above technical problems, an embodiment of the present invention provides a dual-machine mirror processing method, which is applied to a master device and a backup device. The method includes:
[0021] Start dual-machine services, including Rabbit MQ services, data synchronization services, and dual-machine status management services;
[0022] Build a Rabbit dual-machine mirror cluster with the peer device;
[0023] Periodically determine whether the network is connected to the peer device. If the network is not connected, set the local second network address to the network address of the peer device to simulate the connected network state locally, ensuring that the Rabbit MQ service can be restarted normally and provide services.
[0024] As an optional embodiment, when the network is reconnected and the dual-machine service of the peer device is restarted, the method further includes:
[0025] Eliminate the previously stored Rabbit dual-machine mirror cluster relationship based on the dual-machine state management service that has completed startup;
[0026] The Rabbit MQ service is started independently in cluster mode;
[0027] Based on the data synchronization service that has been started, the service data is retrieved to rebuild the service structure of the Rabbit MQ service.
[0028] As an optional embodiment, after the Rabbit MQ service of the peer device is restarted, the method further includes:
[0029] Determine whether the Rabbit MQ service of the peer device has joined the Rabbit dual-machine mirror cluster based on the dual-machine status management service;
[0030] If yes, then delete the Rabbit dual-machine mirror cluster relationship stored in the peer device, and re-build the Rabbit dual-machine mirror cluster with the peer device;
[0031] If not, directly re-build the Rabbit dual-machine mirror cluster with the opposite device.
[0032] As an optional embodiment, the step of building a Rabbit dual-machine mirror cluster with a peer device includes:
[0033] The Rabbit MQ services of the master device and the backup device jointly configure a mirror synchronization strategy according to the business situation, and implement data synchronization based on the mirror synchronization strategy to complete the construction of the Rabbit dual-machine mirror cluster.
[0034] As an optional embodiment, the method further includes:
[0035] When both the primary device and the backup device fail, at least the backup device, after startup, eliminates the previously stored Rabbit dual-machine mirror cluster relationship based on the dual-machine status management service, so that the Rabbit MQ service can be started independently in cluster mode, and can read the business data in the data synchronization service to complete reconstruction and independently provide business services.
[0036] As an optional embodiment, the method further includes:
[0037] When the main device fails and the backup device can provide services independently, the backup device is switched to the main device based on the dual-machine state management service;
[0038] When the failed main device completes restart, it determines its own identity as a backup device based on the dual-machine status management service, and synchronously obtains and stores business data based on the data synchronization service.
[0039] As an optional embodiment, the master device and the backup device have the same hardware and software.
[0040] The embodiment of the present invention also provides a dual-machine mirror processing device, which is installed in a master device and a backup device, and the device includes:
[0041] The first startup module is used to start the dual-machine service, which includes Rabbit MQ service, data synchronization service, and dual-machine status management service;
[0042] Building a module to build a Rabbit dual-machine mirror cluster with the peer device;
[0043] The detection module is used to periodically determine whether the network with the peer device is connected. If the network is not connected, the local second network address is set to the network address of the peer device, so that the local simulates the connected network state to ensure that the Rabbit MQ service can be restarted normally and provide services.
[0044] As an optional embodiment, when the network is reconnected and the dual-machine service of the peer device is restarted, the dual-machine image processing device further includes:
[0045] A deletion module, used to delete the previously stored Rabbit dual-machine mirror cluster relationship according to the dual-machine state management service that has completed startup;
[0046] A second startup module, used to enable the Rabbit MQ service to start independently in a cluster mode;
[0047] The reconstruction module is used to call the business data according to the data synchronization service that has been started to rebuild the business structure of the RabbitMQ service.
[0048] As an optional embodiment, when the Rabbit MQ service of the peer device is restarted, the dual-machine image processing device further includes:
[0049] A processing module, used for determining whether the Rabbit MQ service of the peer device has joined the Rabbit dual-machine mirror cluster according to the dual-machine status management service;
[0050] If yes, then delete the Rabbit dual-machine mirror cluster relationship stored in the peer device, and re-build the Rabbit dual-machine mirror cluster with the peer device;
[0051] If not, directly re-build the Rabbit dual-machine mirror cluster with the opposite device.
[0052] Based on the disclosure of the above embodiments, it can be known that the beneficial effects of the embodiments of the present invention include that after the RabbitMQ dual-machine mirror is successfully established, if either the primary device or the backup device fails, resulting in a network failure and making it impossible for the two devices to communicate, the non-faulty party can configure the second URL of its own device as the peer address to simulate an environment in which each node in the Rabbit MQ cluster is in a network connected state within the local machine, thereby ensuring that the Rabbit MQ service of the local machine can be restarted normally and can independently provide services to the outside world, ensuring that the business is not interrupted, and effectively achieving the high availability of the Rabbit MQ dual-machine mirror.
[0053] In addition, when restarting the dual-machine service after any device fails, the Rabbit MQ service is started independently in cluster mode, decoupling the relationship between the mirror nodes and the peer device, and rebuilding the business structure through the data synchronization service to ensure that the local Rabbit MQ service can be started normally and the business can be used normally. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 This is a diagram of the normal working status of dual machines in the prior art.
[0055] Figure 2 The figure is a flow chart of a dual-machine image processing method in an embodiment of the present invention.
[0056] Figure 3 This is a dual-machine deployment diagram in an embodiment of the present invention.
[0057] Figure 4 This is a diagram of the dual-machine service startup process in an embodiment of the present invention.
[0058] Figure 5 The figure is a process diagram of building a Rabbit MQ dual-machine mirror in an embodiment of the present invention.
[0059] Figure 6 It is a schematic diagram of an abnormal dual-machine network status in an embodiment of the present invention.
[0060] Figure 7 4 is a diagram of a periodic check process of network connectivity status in an embodiment of the present invention.
[0061] Figure 8 It is a structural block diagram of a dual-machine image processing device in an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings, but are not intended to limit the present invention.
[0063] It should be understood that various modifications may be made to the embodiments disclosed herein. Therefore, the following description should not be considered as limiting, but merely as an example of an embodiment. Other modifications within the scope and spirit of the present disclosure will occur to those skilled in the art.
[0064] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the general description of the present disclosure given above and the detailed description of the embodiments given below, serve to explain the principles of the present disclosure.
[0065] These and other characteristics of the invention will become apparent from the following description of a preferred form of embodiment given as a non-limiting example, with reference to the accompanying drawings.
[0066] It should also be understood that, although the invention has been described with reference to some specific examples, those skilled in the art will be able to realize many other equivalent forms of the invention that have the characteristics recited in the claims and are therefore within the scope of protection defined thereby.
[0067] The above and other aspects, features and advantages of the present disclosure will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.
[0068] Specific embodiments of the present disclosure are described hereinafter with reference to the accompanying drawings; however, it should be understood that the disclosed embodiments are merely examples of the present disclosure, which may be implemented in a variety of ways. Well-known and / or repeated functions and structures are not described in detail to avoid obscuring the present disclosure with unnecessary or redundant details. Therefore, the specific structural and functional details disclosed herein are not intended to be limiting, but merely serve as a basis and representative basis for the claims to teach those skilled in the art to use the present disclosure in a variety of ways with substantially any suitable detailed structure.
[0069] This specification may use the phrases "in one embodiment," "in another embodiment," "in a further embodiment," or "in other embodiments," all of which may refer to one or more of the same or different embodiments according to the present disclosure.
[0070] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0071] like Figure 1 As shown, an embodiment of the present invention provides a dual-machine mirror processing method, which is applied to a master device and a backup device, and the method includes:
[0072] Start dual-machine services, including Rabbit MQ service, data synchronization service, and dual-machine status management service;
[0073] Build a Rabbit dual-machine mirror cluster with the peer device;
[0074] Periodically determine whether the network is connected to the peer device. If the network is not connected, set the local second network address to the network address of the peer device to simulate the connected network state locally, ensuring that the Rabbit MQ service can be restarted normally and provide services.
[0075] For example, two devices are configured as a master device and a backup device respectively, and dual-machine service software is deployed on the two devices. The dual-machine service software is a general term for a type of software, and the software is used to implement or assist in implementing dual-machine services. The dual-machine service software in this embodiment includes but is not limited to Rabbit MQ service (software), data synchronization service (software), and dual-machine status management service (software). When the master device and the backup device are started and run, the dual-machine service is started, that is, the Rabbit MQ service, the data synchronization service, and the dual-machine status management service are started, and then the two devices cooperate to build a Rabbit dual-machine mirror cluster based on the started dual-machine service software, establish a Rabbit MQ cluster relationship, and a cluster relationship between the two devices. When the above cluster relationship is established, the master device and the slave device perform business processing. In order to ensure that the business is not interrupted for a long time, in this embodiment, the master device and the backup device periodically detect whether the network is connected to the opposite device, or the backup device periodically detects whether the network is connected to the master device, that is, whether the business data can be received normally. If it is determined through detection that the opposite network is not connected, such as when the opposite device fails and the network is disconnected, the detection end device, that is, the device with no failure and normal network itself, sets the local second network address to the network address of the opposite device. For example, the address of the second network card can be set to the network address of the opposite device, or a virtual network card can be set and its network address can be set to the opposite network address, so that the local device can simulate a connected network state, that is, simulate an environment in which the network is connected to the opposite device, so as to ensure that the local Rabbit MQ service can be restarted normally and can provide business services to the outside world, thereby ensuring high availability of dual-machine mirroring.
[0076] Based on the disclosure of the above embodiments, it can be known that the beneficial effects of this embodiment include that after the Rabbit MQ dual-machine mirror is successfully built, if either the primary device or the backup device fails, resulting in a network failure, so that the two devices cannot be connected, the non-faulty party can configure the second website of its own device as the peer address, so as to simulate the environment in which each node in the RabbitMQ cluster is in a network connected state in the local machine, thereby ensuring that the Rabbit MQ service of the local machine can be restarted normally, and can independently provide services to the outside world, ensuring that the business is not interrupted, and realizing the high availability of the Rabbit MQ dual-machine mirror, and effectively solving the current technical problem that after the dual-machine mirror cluster is successfully built, the network failure between the primary and backup devices causes the Rabbit MQ service to be unable to restart, causing the service to be interrupted for a long time.
[0077] Furthermore, when the network is reconnected and the dual-machine service of the peer device is restarted, it also includes:
[0078] Based on the completed startup of the dual-machine state management service, the previously stored Rabbit dual-machine mirror cluster relationship is eliminated;
[0079] The Rabbit MQ service is started independently in cluster mode;
[0080] Based on the completed data synchronization service, the business data is retrieved to rebuild the business structure of the Rabbit MQ service.
[0081] For example, when the fault of the opposite device is repaired and the network is reconnected, the device will restart the system and restart the dual-machine service. Specifically, the dual-machine state management service and data synchronization service can be restarted first, and then the dual-machine state management service deletes the previously stored Rabbit dual-machine mirror cluster relationship between the master device and the backup device, so that the local Rabbit MQ service is started independently in cluster mode, but the Rabbit MQ service is not added to the cluster, so that the RabbitMQ service will not be coupled with the Rabbit MQ of another node in the cluster, affecting its restart, that is, based on the method of this embodiment, the decoupling between Rabbit MQ nodes can be achieved, ensuring that the local Rabbit MQ service can be started normally. When the Rabbit MQ service is started normally, the key business data in the data synchronization service is read to rebuild the business structure, thereby realizing the provision of business services to the outside world and ensuring the overall high availability of the dual-machine mirror system.
[0082] Furthermore, when the Rabbit MQ service of the peer device is restarted, the method in this embodiment further includes:
[0083] Determine whether the Rabbit MQ service of the peer device has joined the Rabbit dual-machine mirror cluster based on the dual-machine status management service;
[0084] If yes, delete the Rabbit dual-machine mirror cluster relationship stored in the peer device, and re-build the Rabbit dual-machine mirror cluster with the peer device;
[0085] If not, directly rebuild the Rabbit dual-machine mirror cluster with the peer device.
[0086] For example, the dual-machine state management module stores the relationship data about the Rabbit dual-machine mirror cluster. Assuming that the opposite device is a standby device, after it fails and restarts, it will determine whether the Rabbit MQ service of the main device has joined the Rabbit dual-machine mirror cluster based on the local dual-machine state management service. This is because the relationship status of the cluster is stored in the dual-machine state management module in the two devices. When one of the devices fails and restarts, its internal Rabbit MQ service status is a state of not joining the cluster, but the Rabbit MQ service status of the opposite device is a state of joining the cluster. At this time, the device that has been restarted after the failure cannot join the cluster normally, so it is necessary to determine whether the Rabbit MQ service of the opposite device is in a state of joining the cluster, and determine the next step based on this state. Continuing with the previous embodiment, when the standby device determines that the Rabbit MQ service of the main device is in a state of joining the cluster, the dual-machine state management module is used to change the configuration of the main device, delete the Rabbit dual-machine mirror cluster relationship stored in it, and then re-build the Rabbit dual-machine mirror cluster with the main device, that is, re-join the cluster. If it is determined that the master device is not in the cluster, the Rabbit dual-machine mirror cluster is rebuilt directly with the master device.
[0087] Among them, building a Rabbit dual-machine mirror cluster with the peer device includes:
[0088] The Rabbit MQ services of the primary and backup devices jointly configure the mirror synchronization strategy according to the business situation, and implement data synchronization based on the mirror synchronization strategy to complete the construction of the Rabbit dual-machine mirror cluster.
[0089] That is, the Rabbit MQ services of the two devices configure the mirror synchronization strategy according to the business situation to synchronize data between the mirror nodes, that is, to synchronize data between the two devices. Among them, the mirror synchronization strategy can include the synchronization strategy, which is mainly used for data synchronization. The synchronization strategy is determined according to the actual business situation, and the mirror synchronization strategy also includes other policy contents, which can be determined in combination with actual usage requirements.
[0090] Furthermore, the method in this embodiment also includes:
[0091] When both the primary device and the backup device fail, at least the backup device will, after startup, eliminate the previously stored Rabbit dual-machine mirror cluster relationship based on the dual-machine status management service, so that the Rabbit MQ service can be started independently in cluster mode, and can read the business data in the data synchronization service to complete the reconstruction and independently provide business services.
[0092] For example, when both the primary device and the backup device fail, the backup device can be started, and when the primary device cannot be started, the backup device can start some dual-machine services and then eliminate the previously stored Rabbit dual-machine mirror cluster relationship based on the dual-machine status management service, or it can also set the default configuration to automatically delete the previously stored Rabbit dual-machine mirror cluster relationship when the device restarts. Then, the backup device starts the Rabbit MQ service so that it starts in cluster mode, but it does not have an actual cluster relationship, that is, it does not join the cluster. After the Rabbit MQ service is started, it can read the business data in the data synchronization service to complete the reconstruction and provide business services independently. Of course, when the primary device is started, it can also be the above-mentioned startup process. When both devices are started normally and run, the Rabbit dual-machine mirror cluster can be rebuilt based on the above method.
[0093] Furthermore, the method in this embodiment also includes:
[0094] When the primary device fails and the backup device can provide services independently, the backup device will be switched to the primary device based on the dual-machine status management service;
[0095] When the failed master device completes the restart, it determines its identity as a backup device based on the dual-machine status management service, and synchronously obtains and stores business data based on the data synchronization service.
[0096] That is, when the Rabbit dual-machine mirror cluster relationship is established, when the master device fails, the backup device will switch to the master device, and the original master device will switch to the backup device, and the master-backup relationship can be determined based on the dual-machine status management service.
[0097] In order to better illustrate the method of the embodiment of the present application, the following is described in detail with reference to specific embodiments:
[0098] like Figure 3 As shown, the environment deployment:
[0099] 1) Select two devices with the same hardware and software as the primary and backup devices.
[0100] 2) Deploy dual-machine status management software on both devices, such as keepalived
[0101] 3) Rabbit MQ service is deployed on both devices
[0102] 4) Deploy custom data synchronization services on the two devices, such as MySQL dual-master services. Custom data synchronization services are used to save key business data so that the Rabbit MQ business structure can be rebuilt during the startup process. The amount of business data saved by the data synchronization service is defined according to business needs.
[0103] like Figure 4 As shown, the dual-machine service startup process:
[0104] 1) Start the dual-machine status management service (such as keepalived).
[0105] 2) Start the data synchronization service (such as MySQL).
[0106] 3) Rabbit MQ is started in cluster mode, but is not added to the cluster to achieve decoupling from other Rabbit MQ nodes in the original cluster.
[0107] 4) Business data is read through the data synchronization service to rebuild the key business structure of Rabbit MQ. The rebuilt Rabbit MQ can then directly provide business services to the outside world to ensure system availability.
[0108] In the above step 3), the Rabbit MQ service has no coupling relationship with other nodes when it is started, so successful startup can be guaranteed. In step 4), the core business data is read through the data synchronization service to rebuild the Rabbit MQ business structure, so that services can be provided to the outside after the startup is completed, and the availability of the business is not affected. Therefore, the above process of this embodiment solves the problem that when the faulty device is restarted, the Rabbit MQ service cannot be started normally due to the coupling relationship. Moreover, it also solves the problem that when the dual machines are down and the host cannot be started, the backup machine Rabbit MQ sometimes cannot provide business services when it is started.
[0109] like Figure 5 and Figure 6 As shown in the figure, the Rabbit dual-machine mirror cluster is built, and the execution subjects are the master device and the slave device:
[0110] 1) Delete the address of local network card 2 (i.e. the second network card).
[0111] 2) Check whether the peer network is connected. If yes, go to step 5); if no, go to the next step.
[0112] 3) Set the address of network card 2 to the peer address. This step can be used to solve the problem of network failure, such as Figure 6 As shown in the figure, the intact device can simulate a connected network status locally to ensure that the local Rabbit MQ service can be restarted smoothly.
[0113] 4) Sleep for 10 seconds (equivalent to a period of 10 seconds), go to step 1), and periodically detect the peer network.
[0114] 5) (Continue from step 2)) After the faulty device is restarted, check whether the Rabbit MQ service of the peer device has joined the cluster. If yes, proceed to the next step; if not, go to step 8).
[0115] 6) Configure the cluster status of the active node (i.e., the non-faulty device) and delete the cluster information of the boot node saved in the active node so that it can rejoin the cluster.
[0116] 7) Rabbit MQ of the two devices joins the mirror cluster;
[0117] 8) Rabbit MQ configuration mirror synchronization strategy for the two devices.
[0118] 9) The two devices configure synchronization strategies according to business conditions and synchronize data between mirror nodes.
[0119] 10) The two devices complete the construction of the Rabbit MQ dual-machine mirror cluster.
[0120] The above steps 5), 6) and 7) describe checking whether the Rabbit MQ service of the non-faulty device has joined the cluster. If not, it joins the cluster. Since the cluster status is stored in two devices, when a device is restarted, the Rabbit MQ service status of the device is not in the cluster status, but the other device is in the cluster status. Therefore, it is necessary to delete the cluster status relationship first and then rebuild the cluster relationship.
[0121] like Figure 7 As shown, during operation, the master device and the backup device periodically check each other's network status:
[0122] 1) Delete the address of network card 2.
[0123] 2) Check whether the peer network is connected. If yes, go to step 4); if not, proceed to the next step.
[0124] 3) Set the address of network card 2 to the peer address. This enables the local simulation of the connected network status when the network fails, ensuring that the local Rabbit MQ service can be restarted smoothly. Figure 5 shown.
[0125] 4) Sleep for 10 seconds and periodically check the peer network.
[0126] The above process means that during the operation, due to the uncertainty of the network status, the two devices will periodically check the network connectivity. This process can effectively solve the problem that after the dual-machine mirror cluster is successfully built, the network failure between the primary and standby nodes causes the Rabbit MQ service to be unable to restart and provide business services.
[0127] The above-mentioned faults include but are not limited to network card disabled, network cable disconnection, downtime, etc. In actual use, when the network address of the other end is unreachable, even if the mirror data of the local machine is complete, there is a certain probability that the Rabbit MQ service cannot be successfully restarted. However, this embodiment can ensure network reachability by configuring the address of the other end on the network card 2, that is, simulating the node network locally to complete the startup of the Rabbit MQ service.
[0128] like Figure 8 As shown, another embodiment of the present invention also provides a dual-machine mirror processing device, which is installed in a master device and a backup device, and the device includes:
[0129] The first startup module is used to start the dual-machine service, which includes Rabbit MQ service, data synchronization service, and dual-machine status management service;
[0130] Building a module to build a Rabbit dual-machine mirror cluster with the peer device;
[0131] The detection module is used to periodically determine whether the network with the peer device is connected. If the network is not connected, the local second network address is set to the network address of the peer device, so that the local simulates the connected network state to ensure that the Rabbit MQ service can be restarted normally and provide services.
[0132] As an optional embodiment, when the network is reconnected and the dual-machine service of the peer device is restarted, the dual-machine image processing device further includes:
[0133] The elimination module is used to eliminate the previously stored Rabbit dual-machine mirror cluster relationship according to the dual-machine state management service that has completed startup;
[0134] The second startup module is used to start the Rabbit MQ service independently in cluster mode;
[0135] The reconstruction module is used to call the business data of the started data synchronization service to rebuild the business structure of the Rabbit MQ service.
[0136] As an optional embodiment, when the Rabbit MQ service of the peer device is restarted, the dual-machine image processing device further includes:
[0137] The processing module is used to determine whether the Rabbit MQ service of the peer device has joined the Rabbit dual-machine mirror cluster according to the dual-machine status management service;
[0138] If yes, delete the Rabbit dual-machine mirror cluster relationship stored in the peer device, and re-build the Rabbit dual-machine mirror cluster with the peer device;
[0139] If not, directly rebuild the Rabbit dual-machine mirror cluster with the peer device.
[0140] As an optional embodiment, the step of building a Rabbit dual-machine mirror cluster with a peer device includes:
[0141] The Rabbit MQ services of the master device and the backup device jointly configure a mirror synchronization strategy according to the business situation, and implement data synchronization based on the mirror synchronization strategy to complete the construction of the Rabbit dual-machine mirror cluster.
[0142] As an optional embodiment, the device further includes:
[0143] A clearing module is used to, when both the primary device and the backup device fail, at least the backup device, after startup, eliminate the previously stored Rabbit dual-machine mirror cluster relationship based on the dual-machine status management service, so that the Rabbit MQ service can be started independently in cluster mode, and can read the business data in the data synchronization service to complete reconstruction and independently provide business services.
[0144] As an optional embodiment, the device further includes:
[0145] A switching module, configured to switch the standby device to the main device based on a dual-machine state management service when the main device fails and the standby device can provide services independently;
[0146] When the failed main device completes restart, it determines its own identity as a backup device based on the dual-machine status management service, and synchronously obtains and stores business data based on the data synchronization service.
[0147] As an optional embodiment, the master device and the backup device have the same hardware and software.
[0148] Another embodiment of the present application further provides an electronic device, comprising:
[0149] one or more processors;
[0150] a memory configured to store one or more programs;
[0151] When the one or more programs are executed by the one or more processors, the one or more processors implement the above processing method.
[0152] An embodiment of the present application further provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the processing method described above is implemented. It should be understood that each solution in this embodiment has the corresponding technical effect in the above method embodiment, which will not be repeated here.
[0153] The embodiment of the present application also provides a computer program product, which is tangibly stored on a computer-readable medium and includes computer-readable instructions, and the computer-executable instructions, when executed, cause at least one processor to perform a processing method such as in the above-described embodiment. It should be understood that each solution in this embodiment has the corresponding technical effect in the above-described method embodiment, which will not be repeated here.
[0154] It should be noted that the computer storage medium of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access storage medium (RAM), a read-only storage medium (ROM), an erasable programmable read-only storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only storage medium (CD-ROM), an optical storage medium, a magnetic storage medium, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program configured to be used by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, antenna, optical cable, RF, etc., or any suitable combination of the above.
[0155] It should be understood that although the present application is described according to various embodiments, not every embodiment contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
[0156] The above embodiments are only exemplary embodiments of the present invention and are not intended to limit the present invention. The protection scope of the present invention is defined by the claims. Those skilled in the art may make various modifications or equivalent substitutions to the present invention within the essence and protection scope of the present invention, and such modifications or equivalent substitutions shall also be deemed to fall within the protection scope of the present invention.
Claims
1. A dual-machine mirror processing method, applied to a master device and a backup device, characterized in that: The method comprises: Start dual-machine services, including Rabbit MQ services, data synchronization services, and dual-machine status management services; Build a Rabbit dual-machine mirror cluster with the peer device; Periodically determine whether the network is connected with the peer device. If the network is not connected, set the second local network address of the non-faulty party to the network address of the peer device, so that the local simulates a connected network state to ensure that the Rabbit MQ service can be restarted normally and provide services; wherein the peer device is the faulty party.
2. The method according to claim 1, characterized in that: When the network is reconnected and the dual-machine service of the peer device is restarted, the method further includes: Eliminate the previously stored Rabbit dual-machine mirror cluster relationship based on the dual-machine state management service that has completed startup; The Rabbit MQ service is started independently in cluster mode; Based on the data synchronization service that has been started, the service data is retrieved to rebuild the service structure of the Rabbit MQ service.
3. The method according to claim 2, characterized in that When the Rabbit MQ service of the peer device is restarted, the method further includes: Determine whether the Rabbit MQ service of the peer device has joined the Rabbit dual-machine mirror cluster based on the dual-machine status management service; If yes, then delete the Rabbit dual-machine mirror cluster relationship stored in the peer device, and re-build the Rabbit dual-machine mirror cluster with the peer device; If not, directly re-build the Rabbit dual-machine mirror cluster with the opposite device.
4. The method according to claim 1 or 3, characterized in that: The Rabbit dual-machine mirror cluster is built with the peer device, including: The Rabbit MQ services of the master device and the backup device jointly configure a mirror synchronization strategy according to the business situation, and implement data synchronization based on the mirror synchronization strategy to complete the construction of the Rabbit dual-machine mirror cluster.
5. The method according to claim 1, characterized in that The method further comprises: When both the primary device and the backup device fail, at least the backup device, after startup, eliminates the previously stored Rabbit dual-machine mirror cluster relationship based on the dual-machine status management service, so that the Rabbit MQ service can be started independently in cluster mode, and can read the business data in the data synchronization service to complete reconstruction and independently provide business services.
6. The method according to claim 2 or 5, characterized in that: The method further comprises: When the main device fails and the backup device can provide services independently, the backup device is switched to the main device based on the dual-machine state management service; When the failed main device completes restart, it determines its own identity as a backup device based on the dual-machine status management service, and synchronously obtains and stores business data based on the data synchronization service.
7. The method according to claim 1, characterized in that The master device and the backup device have the same hardware and software.
8. A dual-machine image processing device, installed in a master device and a backup device, characterized in that: The device comprises: The first startup module is used to start the dual-machine service, which includes Rabbit MQ service, data synchronization service, and dual-machine status management service; Building a module to build a Rabbit dual-machine mirror cluster with the peer device; The detection module is used to periodically determine whether the network with the opposite device is connected. If the network is not connected, the second network address of the local non-faulty party is set as the network address of the opposite device, so that the local simulates a connected network state to ensure that the Rabbit MQ service can be restarted normally and provide services; wherein the opposite device is the faulty party.
9. The dual-machine image processing device according to claim 8, characterized in that: When the network is reconnected and the dual-machine service of the peer device is restarted, the dual-machine image processing device further includes: A deletion module, used to delete the previously stored Rabbit dual-machine mirror cluster relationship according to the dual-machine state management service that has completed startup; A second startup module, used to enable the Rabbit MQ service to start independently in a cluster mode; The reconstruction module is used to call the business data according to the data synchronization service that has been started to rebuild the business structure of the Rabbit MQ service.
10. The dual-machine image processing device according to claim 9, characterized in that: When the RabbitMQ service of the peer device is restarted, the dual-machine image processing device further includes: A processing module, used for determining whether the Rabbit MQ service of the peer device has joined the Rabbit dual-machine mirror cluster according to the dual-machine status management service; If yes, then delete the Rabbit dual-machine mirror cluster relationship stored in the peer device, and re-build the Rabbit dual-machine mirror cluster with the peer device; If not, directly re-build the Rabbit dual-machine mirror cluster with the opposite device.