Data synchronization method and device and urban rail signal system

By determining the host and backup machine based on the target status of the dual-machine devices in the cluster in the urban rail signal system, and using the Stream message queue for data synchronization, the problem of insufficient data synchronization delay, loss and expansion capabilities in the prior art is solved. Efficient and flexible data synchronization and scaling are achieved.

CN119449818APending Publication Date: 2025-02-14CRSC URBAN RAIL TRANSIT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411323577.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

When facing high concurrent data synchronization in urban rail signal systems, the existing data synchronization method lacks switching flexibility, has problems such as data synchronization delay and data loss, and cannot expand data for new services.

Method used

By determining the host and backup machine based on the target status of the dual-machine devices in the cluster, the host and backup machine are determined, and data is synchronized in the target format using the Stream message queue. The target state includes the network card status and the heartbeat connection status, and the target format includes the backup machine unique identifier and preset data fields and packets.

Benefits of technology

It improves the flexibility of switching between master and spare machines, reduces data synchronization delay, avoids data loss, and realizes flexible expansion of new business data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119449818A_ABST
    Figure CN119449818A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data synchronization, and provides a data synchronization method and device and an urban rail signal system. The method comprises the following steps: based on a target state of dual-computer equipment in a cluster, determining a host computer and a standby computer in the dual-computer equipment; based on a Stream message queue, synchronizing data in the host to the standby machine in a target format; the target state comprises a network card state of each device in the dual-computer device and a heartbeat connection state between the dual-computer devices; the target format comprises a unique identifier of the standby machine, a preset data field and a data packet of a data object to which the preset data field belongs. According to the data synchronization method and device and the urban rail signal system provided by the invention, the host and the standby are determined based on the target state of the dual-computer equipment, the switching flexibility can be improved, the synchronization time delay can be reduced by introducing the message queue for data transmission, and the flexible expansion of new service data can be realized by designing the target format.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data synchronization, and in particular to a data synchronization method, device and urban rail signal system. Background Art

[0002] With the development of urban rail signal systems, the interaction of various services has become diverse and complex. The signal system has relatively stringent requirements for data synchronization. In order to synchronize the high-concurrency data brought about by the expansion of new urban rail signal services, the current conventional data synchronization method is one master and multiple backups. That is, when the program starts, a certain machine is configured as the master by default, and other machines are backup machines. Then the master machine sends data to the backup machine all the time. When the master machine has a network failure or the machine crashes, the backup machine is promoted to the master machine.

[0003] However, on the one hand, this data synchronization method only considers the original host side environment for switching between the master and the standby machine, and lacks switching flexibility; on the other hand, multiple confirmations are required when switching between the master and the standby machine, so there is a delay in data synchronization, and when the network in the computer room where the original host is located is paralyzed, the standby machine cannot obtain data from the host, resulting in data loss; on the other hand, the host synchronizes data to the standby machine in a fixed form, and data expansion cannot be performed for new services. Summary of the invention

[0004] The embodiments of the present application provide a data synchronization method, device and urban rail signal system to solve the technical problems that the existing data synchronization method lacks switching flexibility on the one hand, has data synchronization delay and data loss on the other hand, and cannot expand data for new services on the other hand.

[0005] In a first aspect, an embodiment of the present application provides a data synchronization method, including: Based on the target state of the dual-machine devices in the cluster, determining the master and backup machines in the dual-machine devices; Based on the Stream message queue, synchronize the data in the host machine to the standby machine in a target format; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; the target format includes a data packet of a standby machine unique identifier, a preset data field, and a data object to which the preset data field belongs.

[0006] In one embodiment, determining the master and the backup machine in the dual-machine device based on the target state of the dual-machine device in the cluster includes: When the heartbeat connection state between the two-machine devices is normal and each device in the two-machine device is qualified to become the master, based on the current master and standby states of each device in the two-machine device, determining the master and standby in the two-machine device; Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in any device.

[0007] In one embodiment, determining the master and the backup machine in the dual-machine device based on the current master and backup status of each device in the dual-machine device includes: If the current master and standby states of the devices in the dual-machine device are different, determining the master and standby devices in the dual-machine device according to the current master and standby states; If the current master / slave states of the devices in the dual-machine device are the same, comparing the priority parameters of the devices in the dual-machine device; If the priority parameters of the devices in the dual-machine device are different, the device with the larger priority parameter is determined as the master device, and the device with the smaller priority parameter is determined as the backup device; If the priority parameters of the devices in the dual-machine device are the same, comparing the random numbers generated by the devices in the dual-machine device; If the random numbers generated by each device in the dual-machine device are the same, control each device in the dual-machine device to regenerate random numbers until the random numbers generated by each device in the dual-machine device are different, and determine the device with the larger random number as the host, and determine the device with the smaller random number as the backup.

[0008] In one embodiment, determining the master and the backup machine in the dual-machine device based on the target state of the dual-machine device in the cluster includes: When the heartbeat connection state between the two-machine devices is abnormal, and the first device in the two-machine device is qualified to be the master device, and the second device in the two-machine device is not qualified to be the master device, the first device is determined as the master device, and the second device is determined as the standby device; Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in any device.

[0009] In one embodiment, whether any device is qualified to be a host is determined based on the following: If both the host network card status and the standby network card status in the device are abnormal, it is determined that the device is not qualified to become the host; If at least one of the host network card status and the standby network card status in the device is normal, it is determined that the device is qualified to become a host.

[0010] In one embodiment, determining the master machine and the backup machine in the dual-machine device includes: Adding a target drift IP address to the host network card and the standby network card of the host, and deleting the target drift IP address to the host network card and the standby network card of the standby; The target drift IP is generated based on the original IP of the dual-machine device.

[0011] In one embodiment, the standby machine unique identifier includes a target drift IP and port number corresponding to the standby machine; The preset data field includes a function code and a type code of the data object.

[0012] In a second aspect, an embodiment of the present application provides a data synchronization device, including: The master-slave state determination module is used to determine the master and the standby in the dual-machine device based on the target state of the dual-machine device in the cluster; A data synchronization module, used to: synchronize the data in the host machine to the standby machine in a target format based on a Stream message queue; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; the target format includes a data packet of a standby machine unique identifier, a preset data field, and a data object to which the preset data field belongs.

[0013] In a third aspect, an embodiment of the present application provides an urban rail signal system, comprising the data synchronization device described in the second aspect.

[0014] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, wherein the processor implements the steps of the data synchronization method described in the first aspect when executing the program.

[0015] The data synchronization method, device and urban rail signal system provided by the present application determine the master and standby machines in the dual-machine device based on the target state of the dual-machine device in the cluster, and synchronize the data in the master to the standby machine based on the Stream message queue in the target format. On the one hand, since the target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices, the present application determines the master and standby machines based on the network card state of each device in the dual-machine device and the heartbeat connection state between the two devices, and can switch the master and standby machines based on the consideration of the environment of each device in the dual-machine device and the environment between the devices, thereby improving the switching flexibility; on the other hand, the present application adopts the Stream message queue for master-standby data transmission, which can improve the data transmission efficiency, reduce the data synchronization delay, and can use the message queue to perform redundant backup of data to avoid data loss; on the other hand, since the target format includes the unique identifier of the standby machine, the preset data field and the data packet of the data object to which the preset data field belongs, the present application can pre-set the data field according to its own needs, thereby realizing flexible expansion of data when facing new business. In summary, this application determines the master and backup machines based on the target status of dual-machine devices, which can improve switching flexibility, introduce message queues for data transmission to reduce synchronization delays, and design target formats to achieve flexible expansion of new business data. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0017] Figure 1 This is one of the flow charts of the data synchronization method provided in the embodiment of the present application; Figure 2 is a data transmission diagram of the data synchronization method provided in an embodiment of the present application; Figure 3 This is the second flow chart of the data synchronization method provided in the embodiment of the present application; Figure 4 This is the third flow chart of the data synchronization method provided in the embodiment of the present application; Figure 5 is a structural diagram of a data synchronization device provided in an embodiment of the present application; Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0019] It should be noted that in the description of the embodiments of the present application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device 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 device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. The orientation or position relationship indicated by the terms "upper", "lower" and the like is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. Unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those skilled in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0020] The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0021] Figure 1 This is one of the flow charts of the data synchronization method provided in the embodiment of the present application; Figure 2 It is a data transmission diagram of the data synchronization method provided in an embodiment of the present application.

[0022] Reference Figure 1 , an embodiment of the present application provides a data synchronization method, which may include: 101. Based on the target state of the dual-machine devices in the cluster, determine the master and backup machines in the dual-machine devices; 102. Based on the Stream message queue, synchronize the data in the host machine to the standby machine in the target format.

[0023] The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; the target format includes a data packet of the standby machine unique identifier, a preset data field and a data object to which the preset data field belongs.

[0024] In step 102, the host, as a producer, packages the data in the target format and synchronizes it to the standby machine, and the standby machine, as a consumer, consumes the data synchronized by the host. The target format can be It indicates that, Represents the unique identifier of the standby machine. Represents a preset data field, A data packet representing a data object to which a preset data field belongs.

[0025] Reference Figure 2 The data of the host is cached in its own Redis memory. After the data is packaged, it is synchronized to the Redis memory of the backup machine through the Stream message queue. The backup machine can actively detect data updates in the message queue.

[0026] It should be noted that before step 101, all devices in the cluster may be initialized first. The initialization steps for any device may be as follows: 1. Set the device to an unknown state and publish it as a backup device; 2. Traverse other devices in the cluster and send status information acquisition requests to other devices according to a specific period; 3. After receiving the status information of all other devices or waiting for 3 specific cycles without receiving the status information of all other devices, start the automatic fallback timer to monitor the switching of the main and standby machines.

[0027] A specific period may be set according to actual needs. In this embodiment, it may be set to 1 second, that is, a status information acquisition request is sent once per second.

[0028] The data synchronization method provided in this embodiment determines the master and standby in the dual-machine device based on the target state of the dual-machine device in the cluster, and synchronizes the data in the master to the standby in the target format based on the Stream message queue. On the one hand, since the target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices, this embodiment determines the master and standby based on the network card state of each device in the dual-machine device and the heartbeat connection state between the two devices, and can switch the master and standby based on the consideration of the environment of each device in the dual-machine device and the environment between the devices, thereby improving the switching flexibility; on the other hand, this embodiment uses the Stream message queue for master-standby data transmission, which can improve data transmission efficiency, reduce data synchronization delay, and can use the message queue to perform redundant backup of data to avoid data loss; on the other hand, since the target format includes the unique identifier of the standby machine, the preset data field and the data packet of the data object to which the preset data field belongs, this embodiment can pre-set the data field according to its own needs, thereby realizing flexible expansion of data when facing new business. In summary, this embodiment determines the master and backup machines based on the target status of the dual-machine devices, which can improve switching flexibility, introduce message queues for data transmission to reduce synchronization delays, and design target formats to achieve flexible expansion of new business data.

[0029] Furthermore, in traditional data synchronization methods, when a network failure occurs in the cluster, the master and standby machines may not be able to switch. This embodiment can adopt a manual switching method when determining the master and standby machines in the dual-machine device, thereby realizing master-standby machine switching in the network failure scenario, further improving switching flexibility.

[0030] Figure 3 This is the second flow chart of the data synchronization method provided in the embodiment of the present application; Figure 4 This is the third flow chart of the data synchronization method provided in the embodiment of the present application.

[0031] Reference Figure 3 In one embodiment, determining the master and backup machines in the dual-machine device based on the target state of the dual-machine device in the cluster may include: 301. When the heartbeat connection between the two devices is normal and each device in the two devices is qualified to become the master, compare the current master and standby states of each device in the two devices; 302. If the current master and backup states of the devices in the dual-machine device are different, determine the master and backup devices in the dual-machine device according to the current master and backup states; 303. If the current master / slave states of the devices in the dual-machine device are the same, compare the priority parameters of the devices in the dual-machine device; 304. If the priority parameters of the devices in the dual-machine device are different, the device with the larger priority parameter is determined as the master device, and the device with the smaller priority parameter is determined as the backup device; 305. If the priority parameters of the devices in the dual-machine device are the same, the random numbers generated by the devices in the dual-machine device are compared; 306. If the random numbers generated by the devices in the dual-machine device are the same, control the devices in the dual-machine device to regenerate random numbers until the random numbers generated by the devices in the dual-machine device are different, and determine the device with the larger random number as the master device, and determine the device with the smaller random number as the backup device.

[0032] Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in the device.

[0033] In step 306, if the random numbers generated by the devices in the dual-machine device are different, the device with the larger random number is directly determined as the master device, and the device with the smaller random number is determined as the backup device.

[0034] Reference Figure 4 , devices 1 to 4 all record local information, including local status and local priority parameters, and broadcast local information, and receive other device information broadcasted by other devices, including other device status and other device priority parameters. For example, device 1 records and broadcasts the local status 0xD8 and local priority parameter 7, and receives its own status 0xD8 and priority parameter 9 broadcasted by device 2, its own status 0xA1 and priority parameter 7 broadcasted by device 3, and its own status 0xBB and priority parameter 7 broadcasted by device 4.

[0035] Assuming that the heartbeat connection status between each two devices in devices 1 to 4 is normal, and devices 1 to 4 are all qualified to be the host, at the current moment, device 3 is the host, and the other devices are standby devices, according to the determination method of this embodiment, it can be known that: When comparing the current master-slave status, since the current master-slave status of device 3 is different from that of any other device, while the current master-slave status of other devices is the same, it is possible to determine that device 3 continues to be the master and other devices continue to be the slave for the situation where the current master-slave status is different, and prepare to start comparing priority parameters for the situation where the current master-slave status is the same.

[0036] In this embodiment, it is assumed that the device 3 is manually set as a standby machine according to actual needs, so that after the current active and standby states are compared, all devices are determined to be standby machines.

[0037] It should be noted that when the program for manually switching the master and standby machines is running, it can display the master and standby status of the two machines, the interface status, the network card status, and the connectivity of the two-machine channels, and provide a user interface to allow the user to manually switch the master and standby machines and send the manual switching command to the dual-machine program.

[0038] When comparing priority parameters, since the priority parameters of device 2 are larger than those of any other device, and the priority parameters of other devices are the same, device 2 can be determined as the host and other devices as backup devices for situations where the priority parameters are different, and random number comparison can be started for situations where the priority parameters are the same. The comparison of random numbers is similar to the comparison of priority parameters and will not be repeated here.

[0039] In this embodiment, when the heartbeat connection between the two devices is normal and each device in the two devices is qualified to become the master, the master-slave switch is finally completed based on the current master-slave status, priority parameters and random number layers of each device. By fully considering the inherent properties and associated properties of each device and its associated devices, accurate and flexible switching of the master-slave machine can be achieved.

[0040] In one embodiment, determining the master and the backup in the dual-machine device based on the target state of the dual-machine device in the cluster may include: When the heartbeat connection state between the two-machine devices is abnormal, and the first device in the two-machine device is qualified to be the master, and the second device in the two-machine device is not qualified to be the master, the first device is determined as the master, and the second device is determined as the standby; Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in the device.

[0041] In this embodiment, when the heartbeat connection status between the two-machine devices is abnormal, and the first device in the two-machine devices is qualified to be the host, and the second device in the two-machine devices is not qualified to be the host, the first device is directly determined as the host and the second device is determined as the backup device, thereby realizing efficient switching between the master and backup devices.

[0042] In one embodiment, whether any device is qualified to be a host is determined based on the following: If the status of the host network card and the backup network card in the device are both abnormal, it is determined that the device is not qualified to become the host; If at least one of the host network card status and the standby network card status in the device is normal, it is determined that the device is qualified to become the host.

[0043] Among them, before obtaining the status of the host network card and the backup network card in the device, the failure time determined by the network card status can be tested multiple times through the network card detection program to determine a final target failure time. For example, a pairing instruction is sent to the host network card and the backup network card of a certain test device through the network card detection program, and the time from sending the pairing instruction to receiving the network card response is recorded. If the response of the host network card is received later and the response of the backup network card is received earlier, the time between sending the pairing instruction and receiving the response of the host network card is determined as the failure time corresponding to the test device. If the response of the backup network card is received later and the response of the host network card is received earlier, the time between sending the pairing instruction and receiving the response of the backup network card is determined as the failure time corresponding to the test device. Repeat the above steps to perform the same test on multiple test devices, obtain the failure times corresponding to multiple test devices, and determine the maximum failure time as the target failure time.

[0044] It should be noted that, if during the above test, no response is received from at least one network card within the preset time, the test will be invalidated and other test equipment will be selected to re-test.

[0045] When this embodiment determines whether a device is qualified to become a host, it also uses a network card detection program to send a pairing instruction to the host network card and the standby network card of the device, and starts timing. If a response from the host network card is received within the target expiration time, it is determined that the host network card is in a normal state. If no response from the host network card is received, it is determined that the host network card is abnormal. Similarly, if a response from the standby network card is received within the target expiration time, it is determined that the standby network card is in a normal state. If no response from the standby network card is received, it is determined that the standby network card is abnormal.

[0046] This embodiment determines the target failure time through multiple tests, and determines whether the network card status of the device is normal based on the target failure time and the pairing instruction. It can accurately determine the host qualification of the device by giving the device network card sufficient response time and fault tolerance space.

[0047] In one embodiment, determining the master machine and the backup machine in the dual-machine device may include: Add the target drift IP address to the host NIC and standby NIC of the master, and delete the target drift IP address from the host NIC and standby NIC of the standby; The target drift IP is generated based on the original IP of the dual-machine device.

[0048] Multiple target drift IP addresses can be generated between two devices.

[0049] After adding the target drift IP to the host network card and the backup network card of the host, the current host status information and the master-slave switch notification can be published. In addition, if the target drift IP is added to the host network card or the backup network card of the host fails, an alarm can be immediately issued, and the local priority parameters can be lowered and broadcasted.

[0050] After deleting the target drift IP on the host network card and the standby network card of the standby machine, the current standby machine status information and the master-slave switch notification can be released. In addition, if the target drift IP fails to be deleted on the host network card or the standby network card of the standby machine, an alarm can be immediately issued.

[0051] This embodiment uses the drift IP mechanism to allow an IP address to be dynamically transferred between different devices. When a device fails, its IP address can be automatically transferred to another device, thereby ensuring service continuity and availability, achieving high availability and load balancing of devices, and ensuring real-time data synchronization.

[0052] In one embodiment, the standby machine unique identifier includes the target drift IP and port number corresponding to the standby machine; The preset data field includes the function code and type code of the data object.

[0053] The target format can be as shown in the following table: Table 1 Target format table

[0054] With the expansion of signal system business, considering that the urban rail field will develop towards the line network level in the future, The design is carried out by using the target drift IP+port number combination corresponding to the backup machine; in addition, according to different business data, Based on the structure, add fields that are adapted to the business.

[0055] For urban rail equipment change information, such as train set change information, function code + type code + train set ID can be used as the final Among them, the function code indicates the functions performed by the train set and platform involved in the train set change information, the type code indicates whether the train set change information involves all train sets or part of the train sets, the train set ID indicates the train set identification involved in the train set change information, and the data packet is the data packet of the train set and platform involved in the train set change information.

[0056] For urban rail fixed equipment information, such as signal light information, function code + type code + signal light ID can be used as the final , where the function code indicates the functions performed by the signal lights and platforms involved in the signal light information, the type code indicates whether the signal light information involves all signal lights or some signal lights, the signal light ID indicates the signal light identification involved in the signal light information, and the data packet is the data packet of the signal lights and platforms involved in the signal light information; for another example, the turnout information can use the function code + type code + turnout ID as the final , where the function code indicates the functions performed by the turnouts and platforms involved in the turnout information, the type code indicates whether the turnout information involves all turnouts or part of the turnouts, the turnout ID indicates the turnout identification involved in the turnout information, and the data packet is the data packet of the turnouts and platforms involved in the turnout information.

[0057] This embodiment reserves expansion space for data fields by designing the target format. When a new service is added, the adaptation to the new service data can be achieved through the customized expansion of the data field without changing the existing synchronization framework, and the new service data packet can be expanded synchronously. In the face of the actual demand for upgrading the existing lines of the urban rail signal system, relatively sufficient expandable space is reserved for the upgrade of the existing lines, ensuring the versatility of the synchronous data packet transmission and ensuring the stability, consistency and security of the system operation.

[0058] The data synchronization device provided in an embodiment of the present application is described below. The data synchronization device described below and the data synchronization method described above can refer to each other.

[0059] Figure 5 Schematic diagram of the structure of the data synchronization device provided by the embodiment of the present application. Figure 5 , an embodiment of the present application provides a data synchronization device, which may include: The master-slave state determination module 501 is used to determine the master and the standby in the dual-machine device based on the target state of the dual-machine device in the cluster; The data synchronization module 502 is used to: synchronize the data in the host machine to the standby machine in a target format based on a Stream message queue; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; the target format includes a data packet of a standby machine unique identifier, a preset data field, and a data object to which the preset data field belongs.

[0060] The data synchronization device provided in this embodiment determines the master and standby in the dual-machine device based on the target state of the dual-machine device in the cluster, and synchronizes the data in the master to the standby in the target format based on the Stream message queue. On the one hand, since the target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices, this embodiment determines the master and standby based on the network card state of each device in the dual-machine device and the heartbeat connection state between the two devices, and can switch the master and standby based on the consideration of the environment of each device in the dual-machine device and the environment between the devices, thereby improving the switching flexibility; on the other hand, this embodiment uses the Stream message queue for master-standby data transmission, which can improve data transmission efficiency, reduce data synchronization delay, and can use the message queue to perform redundant backup of data to avoid data loss; on the other hand, since the target format includes the unique identifier of the standby machine, the preset data field and the data packet of the data object to which the preset data field belongs, this embodiment can pre-set the data field according to its own needs, thereby realizing flexible expansion of data when facing new business. In summary, this embodiment determines the master and backup machines based on the target status of the dual-machine devices, which can improve switching flexibility, introduce message queues for data transmission to reduce synchronization delays, and design target formats to achieve flexible expansion of new business data.

[0061] In one embodiment, the active / standby status determination module 501 is specifically configured to: When the heartbeat connection state between the two-machine devices is normal and each device in the two-machine device is qualified to become the master, based on the current master and standby states of each device in the two-machine device, determining the master and standby in the two-machine device; Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in any device.

[0062] In one embodiment, the active / standby status determination module 501 is specifically configured to: If the current master and standby states of the devices in the dual-machine device are different, determining the master and standby devices in the dual-machine device according to the current master and standby states; If the current master / slave states of the devices in the dual-machine device are the same, comparing the priority parameters of the devices in the dual-machine device; If the priority parameters of the devices in the dual-machine device are different, the device with the larger priority parameter is determined as the master device, and the device with the smaller priority parameter is determined as the backup device; If the priority parameters of the devices in the dual-machine device are the same, comparing the random numbers generated by the devices in the dual-machine device; If the random numbers generated by each device in the dual-machine device are the same, control each device in the dual-machine device to regenerate random numbers until the random numbers generated by each device in the dual-machine device are different, and determine the device with the larger random number as the host, and determine the device with the smaller random number as the backup.

[0063] In one embodiment, the active / standby status determination module 501 is specifically configured to: When the heartbeat connection state between the two-machine devices is abnormal, and the first device in the two-machine device is qualified to be the master device, and the second device in the two-machine device is not qualified to be the master device, the first device is determined as the master device, and the second device is determined as the standby device; Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in any device.

[0064] In one embodiment, the active / standby status determination module 501 is specifically configured to: If both the host network card status and the standby network card status in the device are abnormal, it is determined that the device is not qualified to become the host; If at least one of the host network card status and the standby network card status in the device is normal, it is determined that the device is qualified to become a host.

[0065] In one embodiment, the active / standby status determination module 501 is specifically configured to: Adding a target drift IP address to the host network card and the standby network card of the host, and deleting the target drift IP address to the host network card and the standby network card of the standby; The target drift IP is generated based on the original IP of the dual-machine device.

[0066] In one embodiment, the standby machine unique identifier includes a target drift IP and port number corresponding to the standby machine; The preset data field includes a function code and a type code of the data object.

[0067] An embodiment of the present application provides an urban rail signal system, which may include the aforementioned data synchronization device.

[0068] Therefore, the urban rail signal system has the same technical advantages as the aforementioned data synchronization device, which will not be repeated here.

[0069] Figure 6 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 6As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call a computer program in the memory 630 to execute the steps of the data synchronization method, for example including: Based on the target state of the dual-machine devices in the cluster, determining the master and backup machines in the dual-machine devices; Based on the Stream message queue, synchronize the data in the host machine to the standby machine in a target format; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; the target format includes a data packet of a standby machine unique identifier, a preset data field, and a data object to which the preset data field belongs.

[0070] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0071] On the other hand, an embodiment of the present application further provides a computer program product, the computer program product comprising a computer program, the computer program may be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer can perform the steps of the data synchronization method provided in the above embodiments, for example, including: Based on the target state of the dual-machine devices in the cluster, determining the master and backup machines in the dual-machine devices; Based on the Stream message queue, synchronize the data in the host machine to the standby machine in a target format; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; the target format includes a data packet of a standby machine unique identifier, a preset data field, and a data object to which the preset data field belongs.

[0072] On the other hand, an embodiment of the present application further provides a non-transitory computer-readable storage medium on which a computer program is stored, wherein the computer program is used to enable a processor to execute the steps of the data synchronization method provided in the above embodiments, for example, including: Based on the target state of the dual-machine devices in the cluster, determining the master and backup machines in the dual-machine devices; Based on the Stream message queue, synchronize the data in the host machine to the standby machine in a target format; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; the target format includes a data packet of a standby machine unique identifier, a preset data field, and a data object to which the preset data field belongs.

[0073] The non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.

[0074] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0075] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0076] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data synchronization method, characterized in that: include: Based on the target state of the dual-machine devices in the cluster, determining the master and backup machines in the dual-machine devices; Based on the Stream message queue, synchronize the data in the host machine to the standby machine in a target format; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; The target format includes a data packet of a standby machine unique identifier, a preset data field, and a data object to which the preset data field belongs.

2. The data synchronization method according to claim 1, characterized in that: The determining the master and the backup machine in the dual-machine device based on the target state of the dual-machine device in the cluster includes: When the heartbeat connection state between the two-machine devices is normal and each device in the two-machine device is qualified to become the master, based on the current master and standby states of each device in the two-machine device, determining the master and standby in the two-machine device; Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in any device.

3. The data synchronization method according to claim 2, characterized in that: The determining the master and the backup machine in the dual-machine device based on the current master and backup states of each device in the dual-machine device includes: If the current master and standby states of the devices in the dual-machine device are different, determining the master and standby devices in the dual-machine device according to the current master and standby states; If the current master / slave states of the devices in the dual-machine device are the same, comparing the priority parameters of the devices in the dual-machine device; If the priority parameters of the devices in the dual-machine device are different, the device with the larger priority parameter is determined as the master device, and the device with the smaller priority parameter is determined as the backup device; If the priority parameters of the devices in the dual-machine device are the same, comparing the random numbers generated by the devices in the dual-machine device; If the random numbers generated by each device in the dual-machine device are the same, control each device in the dual-machine device to regenerate random numbers until the random numbers generated by each device in the dual-machine device are different, and determine the device with the larger random number as the host, and determine the device with the smaller random number as the backup.

4. The data synchronization method according to claim 1, characterized in that: The determining the master and the backup machine in the dual-machine device based on the target state of the dual-machine device in the cluster includes: When the heartbeat connection state between the two-machine devices is abnormal, and the first device in the two-machine device is qualified to be the master device, and the second device in the two-machine device is not qualified to be the master device, the first device is determined as the master device, and the second device is determined as the standby device; Whether any device is qualified to become a host is determined based on the status of the primary and standby network cards in any device.

5. The data synchronization method according to claim 2 or 4, characterized in that: Whether a device qualifies as a host is determined based on the following: If both the host network card status and the standby network card status in the device are abnormal, it is determined that the device is not qualified to become the host; If at least one of the host network card status and the standby network card status in the device is normal, it is determined that the device is qualified to become a host.

6. The data synchronization method according to claim 1, characterized in that: The determining of the master machine and the backup machine in the dual-machine device includes: Adding a target drift IP address to the host network card and the standby network card of the host, and deleting the target drift IP address to the host network card and the standby network card of the standby; The target drift IP is generated based on the original IP of the dual-machine device.

7. The data synchronization method according to claim 6, characterized in that: The standby machine unique identifier includes the target drift IP and port number corresponding to the standby machine; The preset data field includes a function code and a type code of the data object.

8. A data synchronization device, characterized in that: include: The master-slave state determination module is used to determine the master and the standby in the dual-machine device based on the target state of the dual-machine device in the cluster; A data synchronization module, used to: synchronize the data in the host machine to the standby machine in a target format based on a Stream message queue; The target state includes the network card state of each device in the dual-machine device and the heartbeat connection state between the dual-machine devices; The target format includes a unique identifier of the standby machine, a preset data field, and a data packet of a data object to which the preset data field belongs.

9. An urban rail signal system, characterized in that: Includes the data synchronization device as described in claim 8.

10. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the steps of the data synchronization method according to any one of claims 1 to 7 are implemented.