CN114265905A - Data monitoring method and device - Google Patents
Data monitoring method and device Download PDFInfo
- Publication number
- CN114265905A CN114265905A CN202111658035.0A CN202111658035A CN114265905A CN 114265905 A CN114265905 A CN 114265905A CN 202111658035 A CN202111658035 A CN 202111658035A CN 114265905 A CN114265905 A CN 114265905A
- Authority
- CN
- China
- Prior art keywords
- data
- terminal
- detected
- database
- comparison result
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 103
- 238000012544 monitoring process Methods 0.000 title claims abstract description 48
- 230000002159 abnormal effect Effects 0.000 claims description 86
- 206010048669 Terminal state Diseases 0.000 claims description 42
- 238000001514 detection method Methods 0.000 claims description 24
- 230000004044 response Effects 0.000 claims description 16
- 230000004083 survival effect Effects 0.000 claims description 14
- 238000012545 processing Methods 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 9
- 230000005856 abnormality Effects 0.000 claims description 5
- 238000012806 monitoring device Methods 0.000 claims description 4
- 230000008569 process Effects 0.000 description 24
- 230000001360 synchronised effect Effects 0.000 description 13
- 238000010586 diagram Methods 0.000 description 8
- 230000006870 function Effects 0.000 description 6
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 239000003550 marker Substances 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请提供一种数据监控方法及装置,所述方法包括:获取多个待处理任务,并从终端集群中确定至少两个目标终端;为各个目标终端分配不同的待处理任务,以使所述目标终端根据分配的待处理任务从第一数据库中确定待检测数据,以及将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;获取待检测数据对应的数据比对结果,并根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态,实现数据比对的并发进行,减少数据比对所需的时间,从而有效提高数据比对的效率。
The present application provides a data monitoring method and device. The method includes: acquiring a plurality of tasks to be processed, and determining at least two target terminals from a terminal cluster; assigning different tasks to be processed to each target terminal, so that the The target terminal determines the data to be detected from the first database according to the assigned task to be processed, and compares the data to be detected with the backup data in the second database to obtain a data comparison result corresponding to the data to be detected; Obtain the data comparison result corresponding to the data to be detected, and determine the data synchronization state between the first database and the second database according to the data comparison result corresponding to the data to be detected, so as to realize the concurrent data comparison. , reducing the time required for data comparison, thereby effectively improving the efficiency of data comparison.
Description
技术领域technical field
本公开涉及数据库技术领域,尤其涉及数据监控方法及装置。The present disclosure relates to the technical field of databases, and in particular, to a data monitoring method and device.
背景技术Background technique
在数据库日常运行维护工作中,经常需要进行数据同步,即将主数据库中的源数据同步到从数据库。在进行同步数据后,需要进行数据比对以校验主从数据库中的数据的一致性,从而确定主从数据库之间的数据同步状态。In the daily operation and maintenance of the database, data synchronization is often required, that is, the source data in the master database is synchronized to the slave database. After synchronizing the data, data comparison needs to be performed to verify the consistency of the data in the master-slave database, so as to determine the data synchronization state between the master-slave database.
目前,在进行数据比对时,一般是采用单点比对方式进行比对,即单个终端设备将主数据库中的需比对的源数据与从数据库中的备份数据进行比对,以确定数据比对结果。At present, when comparing data, a single-point comparison method is generally used for comparison, that is, a single terminal device compares the source data to be compared in the master database with the backup data in the slave database to determine the data. Compare results.
然而,由于是采用比对方式进行数据比对,当需比对的源数据的数量较多时,数据比对所需的时间较长,导致数据比对效率较低。However, since the comparison method is used for data comparison, when the number of source data to be compared is large, the time required for data comparison is longer, resulting in low data comparison efficiency.
发明内容SUMMARY OF THE INVENTION
为克服相关技术中存在的问题,本公开提供了数据监控方法及装置。In order to overcome the problems existing in the related art, the present disclosure provides a data monitoring method and apparatus.
根据本公开实施例的第一方面,提供一种数据监控方法,所述方法包括:According to a first aspect of the embodiments of the present disclosure, there is provided a data monitoring method, the method comprising:
获取多个待处理任务,并从终端集群中确定至少两个目标终端;Acquire multiple pending tasks, and determine at least two target terminals from the terminal cluster;
为各个目标终端分配不同的待处理任务,以使所述目标终端根据分配的待处理任务从第一数据库中确定待检测数据,以及将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;Allocate different tasks to be processed for each target terminal, so that the target terminal determines the data to be detected from the first database according to the allocated tasks to be processed, and compares the data to be detected with the backup data in the second database. Yes, obtain the data comparison result corresponding to the data to be detected;
获取所述待检测数据对应的数据比对结果,并根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态。A data comparison result corresponding to the data to be detected is acquired, and a data synchronization state between the first database and the second database is determined according to the data comparison result corresponding to the data to be detected.
可选的,所述方法应用于终端集群中的第一终端,所述终端集群还包括第二终端;Optionally, the method is applied to a first terminal in a terminal cluster, and the terminal cluster further includes a second terminal;
所述从终端集群中确定至少两个目标终端,包括:The determining of at least two target terminals from the terminal cluster includes:
获取所述第二终端的状态信息和/或所述第一终端的状态信息;acquiring status information of the second terminal and/or status information of the first terminal;
根据所述第二终端的状态信息和/或所述第一终端的状态信息,从所述第二终端和所述第一终端中确定至少两个目标终端。At least two target terminals are determined from the second terminal and the first terminal according to the state information of the second terminal and/or the state information of the first terminal.
可选的,所述状态信息包括终端状态和/或运行状态;Optionally, the status information includes terminal status and/or running status;
所述根据所述第二终端的状态信息和/或所述第一终端的状态信息,从所述第二终端和所述第一终端中确定至少两个目标终端,包括:The determining at least two target terminals from the second terminal and the first terminal according to the state information of the second terminal and/or the state information of the first terminal includes:
响应于所述第二终端的状态信息和/或所述第一终端的状态信息满足第一预设条件,将所述第二终端和/或所述第一终端作为目标终端;其中,所述第一预设条件包括运行状态为空闲状态和/或终端状态为存活状态。In response to the state information of the second terminal and/or the state information of the first terminal meeting a first preset condition, the second terminal and/or the first terminal are used as target terminals; wherein the The first preset condition includes that the running state is an idle state and/or the terminal state is an alive state.
可选的,所述方法还包括:Optionally, the method further includes:
每隔预设时间,对第一预设存储装置中的所述第一终端对应的心跳记录时间进行更新。The heartbeat recording time corresponding to the first terminal in the first preset storage device is updated every preset time.
可选的,所述第一预设存储装置还包括各个第二终端对应的心跳记录时间;Optionally, the first preset storage device further includes the heartbeat recording time corresponding to each second terminal;
所述方法还包括:The method also includes:
计算当前时刻与所述第二终端对应的心跳记录时间的时间差值;Calculate the time difference between the heartbeat recording time corresponding to the current moment and the second terminal;
在所述时间差值小于第一预设时间阈值的情况下,确定所述第二终端的终端状态为存活状态;In the case that the time difference value is less than the first preset time threshold, determining that the terminal state of the second terminal is the alive state;
在所述时间差值大于或等于第一预设时间阈值的情况下,确定所述第二终端的终端状态为非存活状态。When the time difference is greater than or equal to the first preset time threshold, it is determined that the terminal state of the second terminal is a non-survival state.
可选的,所述第一数据库存储有源数据;所述备份数据第二数据库中的是对所述源数据进行同步得到的;Optionally, the first database stores source data; the backup data in the second database is obtained by synchronizing the source data;
所述待处理任务包含待检测时间段和/或待检测数据表标识。The to-be-processed task includes the to-be-detected time period and/or the to-be-detected data table identifier.
可选的,通过所述第一终端提供第一页面,所述第一页面包括第一重检测按键;Optionally, a first page is provided by the first terminal, and the first page includes a first re-detection button;
所述方法还包括:The method also includes:
响应于所述第一重检测按键的第一触发操作,获取异常数据;其中,所述异常数据包括数据比对结果为数据异常结果的待检测数据;Obtaining abnormal data in response to the first trigger operation of the first re-detection button; wherein the abnormal data includes data to be detected whose data comparison result is a data abnormal result;
将所述异常数据与所述第二数据库中的备份数据进行比对,得到所述异常数据对应的数据比对结果。The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
可选的,所述方法还包括:Optionally, the method further includes:
根据所述待检测数据对应的数据比对结果生成报警信息,并将所述报警信息发送至用户端。Generate alarm information according to the data comparison result corresponding to the data to be detected, and send the alarm information to the user terminal.
根据本公开实施例的第二方面,提供一种数据监控方法,应用于终端集群中的第二终端,所述方法包括:According to a second aspect of the embodiments of the present disclosure, a data monitoring method is provided, which is applied to a second terminal in a terminal cluster, and the method includes:
获取第一终端分配的待处理任务,并根据所述待处理任务从第一数据库中确定待检测数据;Acquire the task to be processed assigned by the first terminal, and determine the data to be detected from the first database according to the task to be processed;
将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;Comparing the data to be detected with the backup data in the second database to obtain a data comparison result corresponding to the data to be detected;
将所述待检测数据对应的数据比对结果发送至所述第一终端,以使所述第一终端根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态。Send the data comparison result corresponding to the data to be detected to the first terminal, so that the first terminal determines the first database and the second database according to the data comparison result corresponding to the data to be detected Data synchronization status between databases.
可选的,所述将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果,包括:Optionally, comparing the data to be detected with the backup data in the second database to obtain a data comparison result corresponding to the data to be detected, including:
获取所述待检测数据中的目标字段信息;其中,所述目标字段信息包括目标字段以及目标字段值;Obtain target field information in the data to be detected; wherein, the target field information includes a target field and a target field value;
从所述备份数据中确定目标字段名称对应的字段值为所述目标字段值的目标数据;Determine from the backup data that the field value corresponding to the target field name is the target data of the target field value;
计算所述目标数据对应的校验值,并计算所述待检测数据对应的校验值;Calculate the check value corresponding to the target data, and calculate the check value corresponding to the data to be detected;
在所述目标数据对应的校验值与所述待检测数据对应的校验值不同的情况下,确定所述待检测数据对应的数据比对结果为数据异常结果。When the check value corresponding to the target data is different from the check value corresponding to the data to be detected, it is determined that the data comparison result corresponding to the data to be detected is a data abnormality result.
可选的,所述方法还包括:Optionally, the method further includes:
将数据比对结果为数据异常结果的待检测数据保存至第二预设存储装置中。The data to be detected whose data comparison result is an abnormal data result is stored in the second preset storage device.
可选的,通过所述第二终端提供第二页面,所述第二页面包括第二重检测按键;Optionally, a second page is provided by the second terminal, and the second page includes a second re-detection button;
所述方法还包括:The method also includes:
响应于所述第二重检测按键的第二触发操作,获取异常数据;其中,所述异常数据包括第二预设存储装置中的数据比对结果为数据异常结果的待检测数据;Acquiring abnormal data in response to the second trigger operation of the second re-detection button; wherein the abnormal data includes data to be detected whose data comparison result in the second preset storage device is a data abnormal result;
将所述异常数据与所述第二数据库中的备份数据进行比对,得到所述异常数据对应的数据比对结果。The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
可选的,所述待处理任务包含待检测时间段和/或待检测数据表标识;Optionally, the to-be-processed task includes a to-be-detected time period and/or a to-be-detected data table identifier;
所述根据所述待处理任务从第一数据库中确定待检测数据,包括:The determining of the data to be detected from the first database according to the task to be processed includes:
从所述第一数据库中确定保存时间在所述待检测时间段,和/或数据表标识为所述待检测数据表标识的源数据,并将确定的源数据作为所述待检测数据。It is determined from the first database that the storage time is in the to-be-detected time period, and/or the data table identifier is the source data identified by the to-be-detected data table, and the determined source data is used as the to-be-detected data.
可选的,所述方法还包括:Optionally, the method further includes:
根据所述待检测数据对应的数据比对结果生成报警信息,并将所述报警信息发送至用户端。Generate alarm information according to the data comparison result corresponding to the data to be detected, and send the alarm information to the user terminal.
可选的,所述方法还包括:Optionally, the method further includes:
判断第一预设存储装置中是否存在领导者终端标记信息;judging whether there is leader terminal mark information in the first preset storage device;
若未存在领导者终端标记信息,则确定当前第一终端的信息,并根据所述当前第一终端的信息确定所述领导者终端标记信息;其中,所述第一终端为工作状态为领导者状态的终端;If there is no leader terminal marking information, the current first terminal information is determined, and the leader terminal marking information is determined according to the current first terminal information; wherein, the first terminal is in a working state of the leader state terminal;
将所述领导者终端标记信息保存至第一预设存储装置中;saving the leader terminal marking information into a first preset storage device;
若存在领导者终端标记信息,则获取所述领导者终端标记信息中的第一终端的信息,并获取与所述第一终端的信息对应的第一终端的终端状态;If there is leader terminal marking information, acquiring the information of the first terminal in the leader terminal marking information, and acquiring the terminal state of the first terminal corresponding to the information of the first terminal;
在所述第一终端的终端状态为非存活状态的情况下,确定新的第一终端,并根据所述新的第一终端的信息对所述第一预设存储装置中的所述领导者终端标记信息进行更新。In the case where the terminal state of the first terminal is a non-survival state, a new first terminal is determined, and the leader in the first preset storage device is updated according to the information of the new first terminal. The terminal tag information is updated.
根据本公开实施例的第三方面,提供一种数据监控装置,所述装置包括:According to a third aspect of the embodiments of the present disclosure, there is provided a data monitoring device, the device comprising:
终端确定模块,用于获取多个待处理任务,并从终端集群中确定至少两个目标终端;a terminal determination module, used for acquiring a plurality of tasks to be processed, and determining at least two target terminals from the terminal cluster;
任务分配模块,用于为各个目标终端分配不同的待处理任务,以使所述目标终端根据分配的待处理任务从第一数据库中确定待检测数据,以及将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;The task allocation module is used for allocating different tasks to be processed for each target terminal, so that the target terminal determines the data to be detected from the first database according to the allocated tasks to be processed, and compares the data to be detected with the second database. Compare the backup data in the to-be-detected data to obtain a data comparison result corresponding to the data to be detected;
状态确定模块,用于获取所述待检测数据对应的数据比对结果,并根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态。A state determination module, configured to obtain the data comparison result corresponding to the data to be detected, and determine the data synchronization state between the first database and the second database according to the data comparison result corresponding to the data to be detected .
可选的,所述装置应用于终端集群中的第一终端,所述终端集群还包括第二终端;Optionally, the apparatus is applied to a first terminal in a terminal cluster, and the terminal cluster further includes a second terminal;
所述终端确定模块具体用于:The terminal determination module is specifically used for:
获取所述第二终端的状态信息和/或所述第一终端的状态信息;acquiring status information of the second terminal and/or status information of the first terminal;
根据所述第二终端的状态信息和/或所述第一终端的状态信息,从所述第二终端和所述第一终端中确定至少两个目标终端。At least two target terminals are determined from the second terminal and the first terminal according to the state information of the second terminal and/or the state information of the first terminal.
可选的,所述状态信息包括终端状态和/或运行状态;Optionally, the status information includes terminal status and/or running status;
所述终端确定模块还具体用于:The terminal determination module is also specifically used for:
响应于所述第二终端的状态信息和/或所述第一终端的状态信息满足第一预设条件,将所述第二终端和/或所述第一终端作为目标终端;其中,所述第一预设条件包括运行状态为空闲状态和/或终端状态为存活状态。In response to the state information of the second terminal and/or the state information of the first terminal meeting a first preset condition, the second terminal and/or the first terminal are used as target terminals; wherein the The first preset condition includes that the running state is an idle state and/or the terminal state is an alive state.
可选的,所述装置还包括时间更新模块;Optionally, the device further includes a time update module;
所述时间更新模块用于:The time update module is used for:
每隔预设时间,对第一预设存储装置中的所述第一终端对应的心跳记录时间进行更新。The heartbeat recording time corresponding to the first terminal in the first preset storage device is updated every preset time.
可选的,所述第一预设存储装置还包括各个第二终端对应的心跳记录时间;Optionally, the first preset storage device further includes the heartbeat recording time corresponding to each second terminal;
所述终端确定模块还用于:The terminal determination module is also used for:
计算当前时刻与所述第二终端对应的心跳记录时间的时间差值;Calculate the time difference between the heartbeat recording time corresponding to the current moment and the second terminal;
在所述时间差值小于第一预设时间阈值的情况下,确定所述第二终端的终端状态为存活状态;In the case that the time difference value is less than the first preset time threshold, determining that the terminal state of the second terminal is the alive state;
在所述时间差值大于或等于第一预设时间阈值的情况下,确定所述第二终端的终端状态为非存活状态。When the time difference is greater than or equal to the first preset time threshold, it is determined that the terminal state of the second terminal is a non-survival state.
可选的,所述第一数据库存储有源数据;所述备份数据第二数据库中的是对所述源数据进行同步得到的;Optionally, the first database stores source data; the backup data in the second database is obtained by synchronizing the source data;
所述待处理任务包含待检测时间段和/或待检测数据表标识。The to-be-processed task includes the to-be-detected time period and/or the to-be-detected data table identifier.
可选的,通过所述第一终端提供第一页面,所述第一页面包括第一重检测按键;Optionally, a first page is provided by the first terminal, and the first page includes a first re-detection button;
所述状态确定模块还用于:The state determination module is also used for:
响应于所述第一重检测按键的第一触发操作,获取异常数据;其中,所述异常数据包括数据比对结果为数据异常结果的待检测数据;Obtaining abnormal data in response to the first trigger operation of the first re-detection button; wherein the abnormal data includes data to be detected whose data comparison result is a data abnormal result;
将所述异常数据与所述第二数据库中的备份数据进行比对,得到所述异常数据对应的数据比对结果。The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
可选的,所述状态确定模块还用于:Optionally, the state determination module is further used for:
根据所述待检测数据对应的数据比对结果生成报警信息,并将所述报警信息发送至用户端。Generate alarm information according to the data comparison result corresponding to the data to be detected, and send the alarm information to the user terminal.
根据本公开实施例的第四方面,提供一种数据监控装置,应用于终端集群中的第二终端,所述装置包括:According to a fourth aspect of the embodiments of the present disclosure, a data monitoring apparatus is provided, which is applied to a second terminal in a terminal cluster, and the apparatus includes:
数据确定模块,用于获取第一终端分配的待处理任务,并根据所述待处理任务从第一数据库中确定待检测数据;a data determination module, configured to acquire the task to be processed assigned by the first terminal, and determine the data to be detected from the first database according to the task to be processed;
数据比对模块,用于将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;a data comparison module, configured to compare the data to be detected with the backup data in the second database to obtain a data comparison result corresponding to the data to be detected;
结果处理模块,用于将所述待检测数据对应的数据比对结果发送至所述第一终端,以使所述第一终端根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态。A result processing module, configured to send the data comparison result corresponding to the data to be detected to the first terminal, so that the first terminal determines the first terminal according to the data comparison result corresponding to the data to be detected Data synchronization status between the database and the second database.
可选的,所述数据比对模块具体用于:Optionally, the data comparison module is specifically used for:
获取所述待检测数据中的目标字段信息;其中,所述目标字段信息包括目标字段以及目标字段值;Obtain target field information in the data to be detected; wherein, the target field information includes a target field and a target field value;
从所述备份数据中确定目标字段名称对应的字段值为所述目标字段值的目标数据;Determine from the backup data that the field value corresponding to the target field name is the target data of the target field value;
计算所述目标数据对应的校验值,并计算所述待检测数据对应的校验值;Calculate the check value corresponding to the target data, and calculate the check value corresponding to the data to be detected;
在所述目标数据对应的校验值与所述待检测数据对应的校验值不同的情况下,确定所述待检测数据对应的数据比对结果为数据异常结果。When the check value corresponding to the target data is different from the check value corresponding to the data to be detected, it is determined that the data comparison result corresponding to the data to be detected is a data abnormality result.
可选的,所述结果处理模块还用于:Optionally, the result processing module is also used for:
将数据比对结果为数据异常结果的待检测数据保存至第二预设存储装置中。The data to be detected whose data comparison result is an abnormal data result is stored in the second preset storage device.
可选的,通过所述第二终端提供第二页面,所述第二页面包括第二重检测按键;Optionally, a second page is provided by the second terminal, and the second page includes a second re-detection button;
可选的,所述数据比对模块还用于:Optionally, the data comparison module is also used for:
响应于所述第二重检测按键的第二触发操作,获取异常数据;其中,所述异常数据包括第二预设存储装置中的数据比对结果为数据异常结果的待检测数据;Acquiring abnormal data in response to the second trigger operation of the second re-detection button; wherein the abnormal data includes data to be detected whose data comparison result in the second preset storage device is a data abnormal result;
将所述异常数据与所述第二数据库中的备份数据进行比对,得到所述异常数据对应的数据比对结果。The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
可选的,所述待处理任务包含待检测时间段和/或待检测数据表标识;Optionally, the to-be-processed task includes a to-be-detected time period and/or a to-be-detected data table identifier;
所述数据确定模块具体用于:The data determination module is specifically used for:
从所述第一数据库中确定保存时间在所述待检测时间段,和/或数据表标识为所述待检测数据表标识的源数据,并将确定的源数据作为所述待检测数据。It is determined from the first database that the storage time is in the to-be-detected time period, and/or the data table identifier is the source data identified by the to-be-detected data table, and the determined source data is used as the to-be-detected data.
可选的,所述结果处理模块还用于:Optionally, the result processing module is also used for:
根据所述待检测数据对应的数据比对结果生成报警信息,并将所述报警信息发送至用户端。Generate alarm information according to the data comparison result corresponding to the data to be detected, and send the alarm information to the user terminal.
可选的,所述装置还包括标记信息设置模块;Optionally, the device further includes a marking information setting module;
所述标记信息设置模块具体用于:The marking information setting module is specifically used for:
判断第一预设存储装置中是否存在领导者终端标记信息;judging whether there is leader terminal mark information in the first preset storage device;
若未存在领导者终端标记信息,则确定当前第一终端的信息,并根据所述当前第一终端的信息确定所述领导者终端标记信息;其中,所述第一终端为工作状态为领导者状态的终端;If there is no leader terminal marking information, the current first terminal information is determined, and the leader terminal marking information is determined according to the current first terminal information; wherein, the first terminal is in a working state of the leader state terminal;
将所述领导者终端标记信息保存至第一预设存储装置中;saving the leader terminal marking information into a first preset storage device;
若存在领导者终端标记信息,则获取所述领导者终端标记信息中的第一终端的信息,并获取与所述第一终端的信息对应的第一终端的终端状态;If there is leader terminal marking information, acquiring the information of the first terminal in the leader terminal marking information, and acquiring the terminal state of the first terminal corresponding to the information of the first terminal;
在所述第一终端的终端状态为非存活状态的情况下,确定新的第一终端,并根据所述新的第一终端的信息对所述第一预设存储装置中的所述领导者终端标记信息进行更新。In the case where the terminal state of the first terminal is a non-survival state, a new first terminal is determined, and the leader in the first preset storage device is updated according to the information of the new first terminal. The terminal tag information is updated.
根据本公开实施例的第五方面,提供一种计算机设备,包括:According to a fifth aspect of the embodiments of the present disclosure, there is provided a computer device, comprising:
处理器;processor;
用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;
其中,所述处理器被配置为:wherein the processor is configured to:
获取多个待处理任务,并根据所述第一终端和/或所述第二终端确定至少两个目标终端;Acquiring multiple tasks to be processed, and determining at least two target terminals according to the first terminal and/or the second terminal;
为各个目标终端分配不同的待处理任务,以使所述目标终端根据分配的待处理任务从所述第一数据库中确定待检测数据,以及将所述待检测数据与所述第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;Allocate different tasks to be processed for each target terminal, so that the target terminal determines the data to be detected from the first database according to the allocated tasks to be processed, and compares the data to be detected with the data in the second database. The backup data is compared to obtain a data comparison result corresponding to the data to be detected;
获取所述待检测数据对应的数据比对结果,并根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态。A data comparison result corresponding to the data to be detected is acquired, and a data synchronization state between the first database and the second database is determined according to the data comparison result corresponding to the data to be detected.
根据本公开实施例的第六方面,提供一种计算机设备,包括:According to a sixth aspect of the embodiments of the present disclosure, there is provided a computer device, comprising:
处理器;processor;
用于存储处理器可执行指令的存储器;memory for storing processor-executable instructions;
其中,所述处理器被配置为:wherein the processor is configured to:
获取第一终端分配的待处理任务,并根据所述待处理任务从第一数据库中确定待检测数据;acquiring the task to be processed assigned by the first terminal, and determining the data to be detected from the first database according to the task to be processed;
将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;Comparing the data to be detected with the backup data in the second database to obtain a data comparison result corresponding to the data to be detected;
将所述待检测数据对应的数据比对结果发送至所述第一终端,以使所述第一终端根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态。Send the data comparison result corresponding to the data to be detected to the first terminal, so that the first terminal determines the first database and the second database according to the data comparison result corresponding to the data to be detected Data synchronization status between databases.
根据本公开实施例的第七方面,提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第一方面以及第一方面各种可能的设计所述的数据监控方法。According to a seventh aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, where computer-executable instructions are stored in the computer-readable storage medium, and when a processor executes the computer-executable instructions, the above first aspect and the The data monitoring method described in the various possible designs of the first aspect.
根据本公开实施例的第八方面,提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第二方面以及第二方面各种可能的设计所述的数据监控方法。According to an eighth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and when a processor executes the computer-executable instructions, the above second aspect and Various possible designs of the second aspect describe the data monitoring method.
根据本公开实施例的第九方面,提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时,实现如上第一方面以及第一方面各种可能的设计所述的数据监控方法。According to a ninth aspect of the embodiments of the present disclosure, there is provided a computer program product, including a computer program that, when executed by a processor, implements the data monitoring described in the first aspect and various possible designs of the first aspect method.
根据本公开实施例的第十方面,提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时,实现如上第二方面以及第二方面各种可能的设计所述的数据监控方法。According to a tenth aspect of the embodiments of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the data monitoring described in the second aspect and various possible designs of the second aspect method.
本公开的实施例提供的技术方案可以包括以下有益效果:The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects:
本公开实施例中,在获取到多个待处理任务的情况下,从终端集群中确定可以处理待处理任务的多个目标终端。对目标终端进行任务分配,即为每个目标终端分配不同的待处理任务,以使目标终端基于分配的待处理任务从第一数据库中确定需进行同步检查,即数据比对的源数据,以得到待检测数据,并将该待检测数据与第二数据库中的备份数据进行数据比对,以确定该待检测数据是否已经同步至第二数据库,从而得到该待检测数据对应的数据比对结果。根据目标终端确定的待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态,实现第一数据库和第二数据库之间数据同步情况的监控,且是利用多个目标终端进行数据比对,每个目标终端仅需执行其分配到的待处理任务,即仅需对部分数据进行数据比对,实现数据比对的并发进行,减少数据比对所需的时间,从而有效提高数据比对的效率。In the embodiment of the present disclosure, when multiple tasks to be processed are acquired, multiple target terminals that can process the tasks to be processed are determined from the terminal cluster. Assign tasks to the target terminals, that is, assign different tasks to be processed to each target terminal, so that the target terminal determines from the first database based on the assigned tasks to be processed that synchronization checks are required, that is, the source data for data comparison, to Obtain the data to be detected, and compare the data to be detected with the backup data in the second database to determine whether the data to be detected has been synchronized to the second database, so as to obtain the data comparison result corresponding to the data to be detected . The data synchronization state between the first database and the second database is determined according to the data comparison result corresponding to the data to be detected determined by the target terminal, so as to realize the monitoring of the data synchronization between the first database and the second database, and use multiple The target terminal performs data comparison, and each target terminal only needs to perform its assigned task to be processed, that is, it only needs to perform data comparison on part of the data, realize the concurrent data comparison, and reduce the time required for data comparison. This effectively improves the efficiency of data comparison.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure.
附图说明Description of drawings
此处的附图被并入说明书中并构成本公开的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this disclosure, illustrate embodiments consistent with the disclosure, and together with the description serve to explain the principles of the disclosure.
图1是本公开根据一示例性实施例示出的一种数据监控系统的结构图。FIG. 1 is a structural diagram of a data monitoring system according to an exemplary embodiment of the present disclosure.
图2是本公开根据一示例性实施例示出的一种数据监控方法的流程图。FIG. 2 is a flowchart of a data monitoring method according to an exemplary embodiment of the present disclosure.
图3是本公开根据一示例性实施例示出的另一种数据监控方法的流程图。FIG. 3 is a flowchart of another data monitoring method according to an exemplary embodiment of the present disclosure.
图4是本公开根据一示例性实施例示出的又一种数据监控方法的流程图。Fig. 4 is a flowchart of yet another data monitoring method according to an exemplary embodiment of the present disclosure.
图5是本公开根据一示例性实施例示出的再一种数据监控方法的流程图。FIG. 5 is a flowchart of still another data monitoring method according to an exemplary embodiment of the present disclosure.
图6是本公开实施例数据监控装置所在计算机设备的一种硬件结构图。FIG. 6 is a hardware structure diagram of the computer equipment where the data monitoring apparatus according to the embodiment of the present disclosure is located.
图7是本公开根据一示例性实施例示出的一种数据监控装置的框图。Fig. 7 is a block diagram of a data monitoring apparatus according to an exemplary embodiment of the present disclosure.
图8本公开根据一示例性实施例示出的另一种数据监控装置的框图。FIG. 8 is a block diagram of another data monitoring apparatus according to an exemplary embodiment of the present disclosure.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本说明书相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本说明书的一些方面相一致的装置和方法的例子。Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. Where the following description refers to the drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the illustrative examples below are not intended to represent all implementations consistent with this specification. Rather, they are merely examples of apparatus and methods consistent with some aspects of this specification as recited in the appended claims.
在本说明书使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书。在本说明书和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terms used in this specification are for the purpose of describing particular embodiments only and are not intended to limit the specification. As used in this specification and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It will also be understood that the term "and/or" as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
本说明书所涉及的数据可以为经用户授权或者经过各方充分授权的数据。The data involved in this manual can be the data authorized by the user or fully authorized by the parties.
应当理解,尽管在本说明书可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本说明书范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information, without departing from the scope of the present specification. Depending on the context, the word "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determining."
接下来对本公开实施例进行详细说明。Next, the embodiments of the present disclosure will be described in detail.
如图1所示,图1是本公开根据一示例性实施例示出的一种数据监控系统的结构图,该系统包括第一终端101以及至少一个第二终端102。第一终端101获取待处理任务(即任务1和任务2),并将其分配至自身或者第二终端102,以使第二终端102处理分配的待处理任务,即基于分配的待处理任务,对第一数据库103和第二数据库104进行同步检查,即数据比对。As shown in FIG. 1 , FIG. 1 is a structural diagram of a data monitoring system according to an exemplary embodiment of the present disclosure. The system includes a
其中,第一数据库表示主数据库。第二数据库表示从数据库。所述第一数据库存储有源数据;所述第二数据库存储有备份数据;所述备份数据是对所述源数据进行同步得到的。Wherein, the first database represents the main database. The second database represents the slave database. The first database stores source data; the second database stores backup data; the backup data is obtained by synchronizing the source data.
可选的,第一终端可以为领导者终端,领导者终端为工作状态为领导者状态的终端。第二终端可以为跟随者终端,跟随者终端为工作状态为跟随者状态的终端。当然,第一终端也可以为数据监控系统,即终端集群中的任意一个终端,第二终端为数据监控系统中的其它终端。Optionally, the first terminal may be a leader terminal, and the leader terminal is a terminal whose working state is the leader state. The second terminal may be a follower terminal, and the follower terminal is a terminal whose working state is a follower state. Of course, the first terminal may also be a data monitoring system, that is, any terminal in the terminal cluster, and the second terminal may be another terminal in the data monitoring system.
其中,第一终端包括电脑、服务器等计算机设备。第二终端包括电脑、服务器等计算机设备。The first terminal includes computer equipment such as a computer and a server. The second terminal includes computer equipment such as a computer and a server.
其中,待处理任务的数量为多个。相应的,各个第二终端分配的待处理任务不同。可以理解,图1中待处理任务所包括的任务,即待处理惹怒的数量以及第二终端的数量仅为一种示例,在此,不对其进行限制。The number of tasks to be processed is multiple. Correspondingly, the to-be-processed tasks assigned by each second terminal are different. It can be understood that the tasks included in the tasks to be processed in FIG. 1 , that is, the number of anger to be processed and the number of second terminals are only an example, and are not limited here.
如图2所示,图2是本公开根据一示例性实施例示出的一种数据监控方法的流程图,所述方法用于监控第一数据库和第二数据库之间的数据同步状态,所述方法应用于数据监控系统,即终端集群中的一个终端,具体可以为第一终端,该终端集群还包括至少一个第二终端。所述方法包括以下步骤:As shown in FIG. 2 , FIG. 2 is a flowchart of a data monitoring method according to an exemplary embodiment of the present disclosure. The method is used to monitor the data synchronization state between the first database and the second database. The method is applied to a data monitoring system, that is, a terminal in a terminal cluster, specifically a first terminal, and the terminal cluster further includes at least one second terminal. The method includes the following steps:
步骤201、获取多个待处理任务,并根据从终端集群确定至少两个目标终端。Step 201: Acquire multiple tasks to be processed, and determine at least two target terminals according to the slave terminal cluster.
在本实施例中,获取需处理的同步检查任务,即获取待处理任务,并且为了提高数据同步检查,即数据比对的效率,从终端集群,即数据监控系统所包括的终端中确定多个可用的终端,即目标终端以供利用多个目标终端并发进行数据比对。In this embodiment, the synchronization check task to be processed is obtained, that is, the task to be processed is obtained, and in order to improve the efficiency of data synchronization check, that is, data comparison, a plurality of The available terminal, that is, the target terminal, is used for concurrent data comparison using multiple target terminals.
可选的,待处理任务的数目可以是一个。当待处理任务的数目为一个时,仅需确定一个目标终端即可。Optionally, the number of tasks to be processed may be one. When the number of tasks to be processed is one, only one target terminal needs to be determined.
步骤202、为各个目标终端分配不同的待处理任务,以使目标终端根据分配的待处理任务从第一数据库中确定待检测数据,以及将待检测数据与第二数据库中的备份数据进行比对,得到待检测数据对应的数据比对结果。Step 202: Allocate different tasks to be processed for each target terminal, so that the target terminal determines the data to be detected from the first database according to the allocated tasks to be processed, and compares the data to be detected with the backup data in the second database , to obtain the data comparison result corresponding to the data to be detected.
在本实施例中,在确定目标终端后,对于每个目标终端,从多个待处理任务中选取至少一个待处理任务,并将选取的待处理任务分配至该目标终端,目标终端在得到第一终端分配的待处理任务后,基于分配的待处理任务从第一数据库中获取相应的源数据,以得到待检测数据,并将该待检测数据与第二数据库中的备份数据进行同步检查,即数据比对,以得到待检测数据对应的数据比对结果。In this embodiment, after the target terminal is determined, for each target terminal, at least one to-be-processed task is selected from a plurality of to-be-processed tasks, and the selected to-be-processed task is allocated to the target terminal. After the task to be processed is allocated by a terminal, the corresponding source data is obtained from the first database based on the allocated task to be processed to obtain the data to be detected, and the data to be detected is checked synchronously with the backup data in the second database, That is, data comparison, to obtain a data comparison result corresponding to the data to be detected.
可选的,待检测数据对应的数据比对结果包括数据异常结果和数据正常结果。其中,数据异常结果指示待检测数据未同步至第二数据库中,即第二数据库不存在该待检测数据。数据正常结果指示待检测数据已同步至第二数据库中,即第二数据库存在该待检测数据。Optionally, the data comparison results corresponding to the data to be detected include abnormal data results and normal data results. The abnormal data result indicates that the data to be detected is not synchronized to the second database, that is, the data to be detected does not exist in the second database. The data normal result indicates that the data to be detected has been synchronized to the second database, that is, the data to be detected exists in the second database.
可选的,在为各个目标终端分配不同的待处理任务时,可以基于轮询方式进行分配,即依次为每个目标终端分配一个待处理任务,若存在剩余的待处理任务,即存在未分配的待处理任务,则继续为每个终端分配一个待处理任务,直至待处理任务分配完成,实现终端的负载均衡。例如,目标终端包括终端1和终端2。待处理任务包括任务1、任务2和任务3。则先将任务1分配给终端1,将任务2分配给终端2,还存在剩余的待处理任务,即任务3。将任务3分配给终端1。Optionally, when allocating different tasks to be processed for each target terminal, the allocation can be based on a polling method, that is, each target terminal is allocated a task to be processed in turn, if there are remaining tasks to be processed, that is, there are unallocated tasks. If there are pending tasks, each terminal will continue to be assigned a pending task until the assignment of the pending tasks is completed, so as to achieve load balancing of the terminals. For example, the target terminals include terminal 1 and terminal 2. The pending tasks include task 1, task 2 and task 3. Then, first assign task 1 to terminal 1, and assign task 2 to terminal 2, and there are remaining tasks to be processed, that is, task 3. Assign task 3 to terminal 1.
其中,第一数据库存储有源数据。具体的,相关终端将采集到的业务数据(即源数据)保存至第一数据库。Wherein, the first database stores active data. Specifically, the relevant terminal saves the collected service data (ie, source data) to the first database.
可选的,在将业务数据保存至第一数据库时,将当前时刻作为该条业务数据对应的保存时间。Optionally, when the business data is stored in the first database, the current time is used as the storage time corresponding to the piece of business data.
可选的,待处理任务包含指示待检测时间段和/或待检测数据表标识,以供第二终端根据待检测时间段和/或待检测数据表标识确定待检测数据。Optionally, the task to be processed includes indicating the time period to be detected and/or the identifier of the data table to be detected, so that the second terminal can determine the data to be detected according to the time period to be detected and/or the identifier of the data table to be detected.
其中,待检测数据表标识指示需进行同步检测的数据表的标识。Wherein, the identifier of the data table to be detected indicates the identifier of the data table to be synchronously detected.
在本实施例中,通过对需进行同步检查的数据进行拆分,得到多个待处理任务,即将任务进行分片,从而当目标终端处理待处理任务时,可以减少目标终端需进行比对的数据,进而减少数据比对所需的时间,提高数据比对的效率。In this embodiment, multiple tasks to be processed are obtained by splitting the data to be synchronously checked, that is, the tasks are divided into pieces, so that when the target terminal processes the tasks to be processed, the number of tasks to be compared by the target terminal can be reduced. data, thereby reducing the time required for data comparison and improving the efficiency of data comparison.
步骤203、获取待检测数据对应的数据比对结果,并根据待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态。Step 203: Acquire a data comparison result corresponding to the data to be detected, and determine a data synchronization state between the first database and the second database according to the data comparison result corresponding to the data to be detected.
在本实施例中,目标终端在得到待检测数据对应的数据比对结果后,若目标终端为第二终端,则将待检测数据对应的数据比对结果发送至第一终端。若目标终端为第一终端,则第一终端可以直接进行获取。第一终端对接收到和/或获取到的所有待检测数据对应的数据比对结果进行统计,以确定是否存在数据比对结果为数据异常结果的待检测数据。In this embodiment, after obtaining the data comparison result corresponding to the data to be detected, the target terminal sends the data comparison result corresponding to the data to be detected to the first terminal if the target terminal is the second terminal. If the target terminal is the first terminal, the first terminal may directly acquire. The first terminal performs statistics on the data comparison results corresponding to all the received and/or acquired data to be detected, to determine whether there is data to be detected whose data comparison result is an abnormal data result.
若存在数据比对结果为数据异常结果的待检测数据,表明第一数据库存在待检测数据未同步至第二数据库,则确定第一数据库与第二数据库之间的数据同步状态为同步失败。If there is data to be detected whose data comparison result is an abnormal data result, indicating that there is data to be detected in the first database that is not synchronized to the second database, it is determined that the data synchronization state between the first database and the second database is synchronization failure.
若不存在数据比对结果为数据异常结果的待检测数据,表明待检测数据已经全部同步至第二数据库,则确定第一数据库与第二数据库之间的数据同步状态为同步成功。If there is no data to be detected whose data comparison result is an abnormal data result, indicating that all the data to be detected has been synchronized to the second database, it is determined that the data synchronization status between the first database and the second database is successful.
可选的,在得到第一数据库与第二数据库之间的数据同步状态后,输出数据同步状态,以使相关人员可以获知数据同步情况。Optionally, after obtaining the data synchronization status between the first database and the second database, output the data synchronization status, so that the relevant personnel can know the data synchronization status.
可选的,在数据同步状态为同步失败的情况下,可以输出数据比对结果为数据异常结果的待检测数据,以使相关人员可以获知同步异常的数据。Optionally, when the data synchronization status is synchronization failure, the data to be detected whose data comparison result is an abnormal data result may be output, so that the relevant personnel can know the abnormal synchronization data.
从上述描述可知,在获取到多个待处理任务的情况下,从终端集群中确定可以处理待处理任务的多个目标终端。对目标终端进行任务分配,即为每个目标终端分配不同的待处理任务,以使目标终端基于分配的待处理任务从第一数据库中确定需进行同步检查,即数据比对的源数据,以得到待检测数据,并将该待检测数据与第二数据库中的备份数据进行数据比对,以确定该待检测数据是否已经同步至第二数据库,从而得到该待检测数据对应的数据比对结果。根据目标终端确定的待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态,实现第一数据库和第二数据库之间数据同步情况的监控,且是利用多个目标终端进行数据比对,每个目标终端仅需执行其分配到的待处理任务,即仅需对部分数据进行数据比对,实现数据比对的并发进行,减少数据比对所需的时间,从而有效提高数据比对的效率。It can be seen from the above description that in the case of acquiring multiple tasks to be processed, multiple target terminals that can process the tasks to be processed are determined from the terminal cluster. Assign tasks to the target terminals, that is, assign different tasks to be processed to each target terminal, so that the target terminal determines from the first database based on the assigned tasks to be processed that synchronization checks are required, that is, the source data for data comparison, to Obtain the data to be detected, and compare the data to be detected with the backup data in the second database to determine whether the data to be detected has been synchronized to the second database, so as to obtain the data comparison result corresponding to the data to be detected . The data synchronization state between the first database and the second database is determined according to the data comparison result corresponding to the data to be detected determined by the target terminal, so as to realize the monitoring of the data synchronization between the first database and the second database, and use multiple The target terminal performs data comparison, and each target terminal only needs to perform its assigned task to be processed, that is, it only needs to perform data comparison on part of the data, realize the concurrent data comparison, and reduce the time required for data comparison. This effectively improves the efficiency of data comparison.
如图3所示,是根据一示例性实施例示出的另一种数据监控方法的流程图,本实施方式在前述实施例的基础上,描述了如何确定目标终端的过程,包括如下步骤:As shown in FIG. 3, it is a flow chart of another data monitoring method according to an exemplary embodiment. Based on the foregoing embodiment, this embodiment describes the process of how to determine the target terminal, including the following steps:
步骤301、获取待处理任务。Step 301: Acquire a task to be processed.
步骤302、获取第二终端的状态信息和/或第一终端的状态信息。Step 302: Acquire status information of the second terminal and/or status information of the first terminal.
步骤303、根据第二终端的状态信息和/或第一终端的状态信息,从第二终端和/或第一终端中确定至少两个目标终端。Step 303: Determine at least two target terminals from the second terminal and/or the first terminal according to the state information of the second terminal and/or the state information of the first terminal.
在本实施例中,在确定执行待处理任务的目标终端时,获取各个第二终端的状态信息和/或第一终端的状态信息,并根据各个第二终端的状态信息和/或自身的状态信息,从所有第二终端和/第一终端自身中的确定可用的终端,以得到目标终端,实现目标终端的准确确定。In this embodiment, when determining the target terminal to perform the task to be processed, the state information of each second terminal and/or the state information of the first terminal is acquired, and the state information of each second terminal and/or its own state are obtained according to the state information of each second terminal and/or its own state. information, from all the second terminals and/or the first terminal itself to determine the available terminals to obtain the target terminal, so as to realize the accurate determination of the target terminal.
具体的,当第二终端的数目为一个时,可以根据第二终端和第一终端自身确定目标终端;当第二终端为多个时,可以仅从第二终端中确定目标终端,也可以从自身以及第二终端中确定目标终端。Specifically, when the number of second terminals is one, the target terminal may be determined according to the second terminal and the first terminal itself; when there are multiple second terminals, the target terminal may be determined only from the second terminals, or the target terminal may be determined from the second terminals. The target terminal is determined among itself and the second terminal.
可选的,状态信息包括终端状态和/或运行状态。Optionally, the status information includes terminal status and/or running status.
其中,终端状态包括存活状态和非存活状态。当第二终端处于存活状态时,表明第二终端可以正常运行的,即可以处理待处理任务。当第二终端处于非存活状态时,表明第二终端无法正常运行,已经失活,无法执行待处理任务。Among them, the terminal state includes a surviving state and a non-surviving state. When the second terminal is in the alive state, it indicates that the second terminal can run normally, that is, the to-be-processed task can be processed. When the second terminal is in a non-survival state, it indicates that the second terminal cannot run normally, has been deactivated, and cannot execute the pending task.
其中,运行状态包括空闲状态和繁忙状态。当第二终端处于空闲状态时,表明第二终端当前未处理待处理任务,可以处理新的待处理任务;当第二终端处于繁忙状态时,表明第二终端正在处理待处理任务,当将新的待处理任务分配给该第二终端时,需要进行等待。The running state includes an idle state and a busy state. When the second terminal is in an idle state, it indicates that the second terminal is not currently processing pending tasks and can process new pending tasks; when the second terminal is in a busy state, it indicates that the second terminal is processing pending tasks. When the to-be-processed task is allocated to the second terminal, it needs to wait.
在本实施例中,在第一终端启动的情况下,将第一终端对应的终端信息存储至第一预设存储装置。其中,终端信息包括终端标识。具体的,第一终端可以为一个服务器实例,相应的,第一终端对应的终端信息,也即实例信息包括服务器实例标识(例如,服务器实例名称)。In this embodiment, when the first terminal is activated, terminal information corresponding to the first terminal is stored in the first preset storage device. The terminal information includes a terminal identifier. Specifically, the first terminal may be a server instance. Correspondingly, the terminal information corresponding to the first terminal, that is, the instance information, includes a server instance identifier (eg, a server instance name).
在本实施例中,集群系统,即数据监控系统采用领导者/跟随者模式,且在集群系统中的终端启动的情况下,终端将其对应的终端信息至第一预设存储装置。相应的,第一终端在确定第二终端时,可以根据第一预设存储装置中的终端信息确定第二终端。当增加新的终端,也即新的服务器实例时,在该终端启动的情况下,将其对应的终端信息,也即实例信息保存至第一预设存储装置中,从而保证集群系统的水平扩展能力。In this embodiment, the cluster system, that is, the data monitoring system adopts the leader/follower mode, and when a terminal in the cluster system is activated, the terminal stores its corresponding terminal information to the first preset storage device. Correspondingly, when determining the second terminal, the first terminal may determine the second terminal according to the terminal information in the first preset storage device. When adding a new terminal, that is, a new server instance, when the terminal is started, the corresponding terminal information, that is, the instance information, is saved in the first preset storage device, so as to ensure the horizontal expansion of the cluster system. ability.
可选的,第一预设存储装置还存储有第一终端对应的心跳记录时间。为了确定终端的存活状态,还可以采用心跳保活机制,即每隔预设时间,对第一预设存储装置中的第一终端对应的心跳记录时间进行更新,也即相当于每隔预设时间,第一终端发送心跳消息至第一预设存储装置,该心跳记录时间表示第一预设存储装置接收到该心跳消息的时间。Optionally, the first preset storage device further stores the heartbeat recording time corresponding to the first terminal. In order to determine the survival state of the terminal, a heartbeat keep-alive mechanism can also be used, that is, the heartbeat recording time corresponding to the first terminal in the first preset storage device is updated every preset time, which is equivalent to every preset time. time, the first terminal sends a heartbeat message to the first preset storage device, and the heartbeat recording time represents the time when the first preset storage device receives the heartbeat message.
其中,第一终端在对第一预设存储装置中的第一终端对应的心跳记录时间进行更新时,获取当前时刻,并将该心跳记录时间更新为当前时刻。Wherein, when updating the heartbeat recording time corresponding to the first terminal in the first preset storage device, the first terminal acquires the current time, and updates the heartbeat recording time to the current time.
同理,第一预设存储装置还存储有第二终端对应的心跳记录时间。第二终端每隔预设时间,对第一预设存储装置中的第二终端对应的心跳记录时间进行更新,以供第一终端可以根据第二终端对应的心跳记录时间确定第二终端是否存活。Similarly, the first preset storage device also stores the heartbeat recording time corresponding to the second terminal. The second terminal updates the heartbeat recording time corresponding to the second terminal in the first preset storage device every preset time, so that the first terminal can determine whether the second terminal is alive according to the heartbeat recording time corresponding to the second terminal .
其中,第二终端对第一预设存储装置中的第二终端对应的心跳记录时间进行更新的过程与上述第一终端对心跳记录时间进行更新的过程类似,在此,不在对其进行赘述。The process of updating the heartbeat recording time corresponding to the second terminal in the first preset storage device by the second terminal is similar to the above-mentioned process of updating the heartbeat recording time by the first terminal, which will not be repeated here.
可选的,在确定第二终端的终端状态时,可以根据第一预设存储装置中的第二终端对应的心跳记录时间确定第二终端是否存活。其中,确定第二终端的终端状态的具体过程为:计算当前时刻与第二终端对应的心跳记录时间的时间差值。在时间差值小于第一预设时间阈值的情况下,确定第二终端的终端状态为存活状态。在时间差值大于或等于第一预设时间阈值的情况下,确定第二终端的终端状态为非存活状态。Optionally, when the terminal state of the second terminal is determined, whether the second terminal is alive may be determined according to the heartbeat recording time corresponding to the second terminal in the first preset storage device. Wherein, the specific process of determining the terminal state of the second terminal is: calculating the time difference between the current moment and the heartbeat recording time corresponding to the second terminal. In the case that the time difference is smaller than the first preset time threshold, it is determined that the terminal state of the second terminal is the alive state. When the time difference is greater than or equal to the first preset time threshold, it is determined that the terminal state of the second terminal is a non-survival state.
具体的,对于每个第二终端,从第一预设存储装置中获取该第二终端对应的心跳记录时间,计算当前时刻与该第二终端对应的心跳记录时间之间的差值,得到相应的时间差值,在该时间差值大于或等于第一预设时间阈值的情况下,表明第二终端已经较长时间未更新其对应的心跳标记时间,即表明第二终端已经较长时间未发送心跳消息至第一预设存储装置,该第二终端已经失活,则确定该第二终端的终端状态为非存活状态。Specifically, for each second terminal, the heartbeat recording time corresponding to the second terminal is obtained from the first preset storage device, the difference between the current moment and the heartbeat recording time corresponding to the second terminal is calculated, and the corresponding heartbeat recording time is obtained. When the time difference is greater than or equal to the first preset time threshold, it indicates that the second terminal has not updated its corresponding heartbeat mark time for a long time, that is, it indicates that the second terminal has not been updated for a long time. A heartbeat message is sent to the first preset storage device, and the second terminal has been deactivated, then it is determined that the terminal state of the second terminal is a non-survival state.
在该时间差值小于第一预设时间阈值的情况下,表明第二终端距离上次更新其对应的心跳标记时间的时间较短,即表明第二终端在当前时刻之前的较短时间内发送心跳消息至第一预设存储装置,该第二终端仍是活跃的,则确定该第二终端的终端状态为存活状态。In the case that the time difference is less than the first preset time threshold, it indicates that the time from the second terminal to the last update of its corresponding heartbeat mark time is short, that is, it indicates that the second terminal sends the data in a short time before the current moment. The heartbeat message is sent to the first preset storage device, and the second terminal is still active, then it is determined that the terminal state of the second terminal is the alive state.
其中,第一预设存储装置包括数据库等具有存储功能的装置。Wherein, the first preset storage device includes a device with a storage function such as a database.
其中,第一终端确定自身的状态信息与上述确定第二终端的状态信息的过程类似,在此,不在对其进行赘述。The process of determining the state information of the first terminal itself is similar to the above-mentioned process of determining the state information of the second terminal, which will not be repeated here.
可选的,根据第二终端的状态信息和/或第一终端的状态信息,从第二终端和/或第一终端中确定至少两个目标终端,包括:Optionally, according to the state information of the second terminal and/or the state information of the first terminal, at least two target terminals are determined from the second terminal and/or the first terminal, including:
响应于第二终端的状态信息和/或第一终端的状态信息满足第一预设条件,将第二终端和/或所述第一终端作为目标终端。其中,第一预设条件包括运行状态为空闲状态和/或终端状态为存活状态。In response to the state information of the second terminal and/or the state information of the first terminal satisfying the first preset condition, the second terminal and/or the first terminal are used as the target terminal. The first preset condition includes that the running state is an idle state and/or the terminal state is an alive state.
具体的,对于每个第二终端,在该第二终端的状态信息满足第一预设条件的情况下,表明该第二终端当前是可用的,可以处理待处理任务,则将该第二终端作为目标终端。和/或,在第一终端的状态信息满足第一预设条件的情况下,表明第一终端自身也可以处理待处理任务,则可以将该第一终端作为目标终端Specifically, for each second terminal, if the state information of the second terminal satisfies the first preset condition, it indicates that the second terminal is currently available and can process pending tasks, then the second terminal is as the target terminal. And/or, when the state information of the first terminal satisfies the first preset condition, indicating that the first terminal itself can also process the task to be processed, the first terminal can be used as the target terminal
其中,以第一预设条件包括运行状态为空闲状态为例,第二终端的状态信息包括运行状态。在第二终端的运行状态为空闲状态的情况下,将该第二终端作为目标终端。Wherein, taking the first preset condition including that the running state is the idle state as an example, the state information of the second terminal includes the running state. When the running state of the second terminal is the idle state, the second terminal is used as the target terminal.
其中,以第一预设条件包括终端状态为存活状态为例,第二终端的状态信息包括终端状态。在第二终端的终端状态为存活状态的情况下,将该第二终端作为目标终端。Wherein, taking the first preset condition including that the terminal state is an alive state as an example, the state information of the second terminal includes the terminal state. When the terminal state of the second terminal is the live state, the second terminal is used as the target terminal.
其中,以第一预设条件包括终端状态为存活状态和运行状态为空闲状态为例,第二终端的状态信息包括终端状态和运行状态。在第二终端的终端状态为存活状态,以运行状态为空闲状态的情况下,将该第二终端作为目标终端。Wherein, taking the first preset condition including that the terminal state is the alive state and the running state being the idle state as an example, the state information of the second terminal includes the terminal state and the running state. When the terminal state of the second terminal is the live state and the running state is the idle state, the second terminal is used as the target terminal.
可选的,还可以利用待处理任务的数目确定目标终端,即在得到状态信息满足第一预设条件的第二终端和/或第一终端后,从状态信息满足第一预设条件的第二终端和/或第一终端选取数目为待处理任务的数目的终端,并将选取的终端作为目标终端。Optionally, the number of tasks to be processed may also be used to determine the target terminal, that is, after obtaining the second terminal and/or the first terminal whose status information satisfies the first preset condition, select the second terminal whose status information satisfies the first preset condition. The second terminal and/or the first terminal select terminals whose number is the number of tasks to be processed, and use the selected terminal as the target terminal.
具体的,在基于第一终端和第二终端确定目标终端的情况下,若确定状态信息满足第一预设条件的第二终端以及确定自身的状态信息满足第一预设条件,则从状态信息满足第一预设条件的第二终端和第一终端自身中选取数目为待处理任务的数目的终端,并将其作为目标终端。Specifically, when the target terminal is determined based on the first terminal and the second terminal, if it is determined that the second terminal whose state information satisfies the first preset condition and that its own state information satisfies the first preset condition, the state information From the second terminal that satisfies the first preset condition and the first terminal itself, the terminal whose number is the number of tasks to be processed is selected as the target terminal.
在仅基于第二终端确定目标终端的情况下,在得到状态信息满足第一预设条件的第二终端后,从状态信息满足第一预设条件的第二终端中选取数目为待处理任务的数目的第二终端,并将选取的第二终端作为目标终端。In the case where the target terminal is determined only based on the second terminal, after obtaining the second terminal whose state information satisfies the first preset condition, the number of the second terminals whose state information satisfies the first preset condition is selected as the task to be processed. number of second terminals, and the selected second terminal is used as the target terminal.
其中,在从第一终端和/或第二终端中选取目标终端时,可以随机选取,也可以基于其它方式进行选取,例如,基于终端对应的优先级,在此,不对其进行限制。Wherein, when the target terminal is selected from the first terminal and/or the second terminal, the target terminal may be selected randomly, or may be selected based on other methods, for example, based on the priority corresponding to the terminal, which is not limited here.
可选的,还提供相关页面,以使用户可以利用该页面对第一预设存储装置/第二预设存储装置中的数据进行修改。Optionally, a related page is also provided, so that the user can use the page to modify the data in the first preset storage device/second preset storage device.
可选的,用户还可以动态修改、创建、删除待处理任务。Optionally, the user can also dynamically modify, create, and delete pending tasks.
步骤304、为各个目标终端分配不同的待处理任务,以使目标终端根据分配的待处理任务从第一数据库中确定待检测数据,以及将待检测数据与第二数据库中的备份数据进行比对,得到待检测数据对应的数据比对结果。Step 304: Allocate different tasks to be processed for each target terminal, so that the target terminal determines the data to be detected from the first database according to the allocated tasks to be processed, and compares the data to be detected with the backup data in the second database , to obtain the data comparison result corresponding to the data to be detected.
步骤305、获取待检测数据对应的数据比对结果,并根据待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态。Step 305: Acquire a data comparison result corresponding to the data to be detected, and determine a data synchronization state between the first database and the second database according to the data comparison result corresponding to the data to be detected.
在本实施例中,通过第一终端提供第一页面,第一页面包括第一重检测按键。相应的,响应于第一重检测按键的第一触发操作,获取异常数据。其中,异常数据包括数据比对结果为数据异常结果的待检测数据。将异常数据与第二数据库中的备份数据进行比对,得到异常数据对应的数据比对结果。In this embodiment, the first page is provided by the first terminal, and the first page includes the first re-detection button. Correspondingly, in response to the first triggering operation of the first re-detection button, abnormal data is acquired. The abnormal data includes data to be detected whose data comparison result is an abnormal data result. The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
具体的,在检测到用户触发第一终端上的第一页面上的第一重检测按键的情况,表明需要确定异常数据是否由于同步延迟导致的,则获取异常数据,即数据比对结果为数据异常结果的待检测数据,并对于每条异常数据,将该条异常数据与该第二数据库中的备份数据进行比对,得到该条异常数据对应的数据比对结果。Specifically, when it is detected that the user triggers the first re-detection button on the first page on the first terminal, it indicates that it is necessary to determine whether the abnormal data is caused by synchronization delay, and then the abnormal data is acquired, that is, the data comparison result is data The data to be detected of the abnormal result, and for each abnormal data, the abnormal data is compared with the backup data in the second database to obtain the data comparison result corresponding to the abnormal data.
可选的,可以从第二预设存储装置中获取异常数据。Optionally, abnormal data may be acquired from the second preset storage device.
可选的,在异常数据对应的数据比对结果为数据正常结果的情况下,表明是由于同步延迟导致之前确定的数据比对结果错误,该异常数据已经同步至第二数据库,则从第二预设存储装置中删除该异常数据。Optionally, in the case where the data comparison result corresponding to the abnormal data is the normal data result, it indicates that the previously determined data comparison result is wrong due to the synchronization delay. The abnormal data is deleted from the default storage device.
可选的,根据所述待检测数据对应的数据比对结果生成报警信息,并将所述报警信息发送至用户端。Optionally, alarm information is generated according to a data comparison result corresponding to the data to be detected, and the alarm information is sent to the user terminal.
具体的,获取数据比对结果为数据异常结果的待检测数据,并生成包含该待检测数据的报警信息。通过预设报警方式,将该报警信息发送至用户端,以使相关人员可以及时获知同步出现问题的数据,实现及时报警。Specifically, the data to be detected whose data comparison result is an abnormal data result is acquired, and alarm information including the to-be-detected data is generated. By presetting the alarm method, the alarm information is sent to the user terminal, so that the relevant personnel can be informed of the data of synchronization problems in time, so as to realize the timely alarm.
在本实施例中,获取各个第二终端的状态信息,以供利用第二终端的状态信息确定可以处理待处理任务的第二终端,即确定稳定可靠的目标终端,并为目标终端分配待处理任务,使得目标终端可以处理分配的待处理任务,即进行数据比对,保证数据比对的正常进行,避免由于处理待处理任务的终端不可用,导致数据比对失败。In this embodiment, the status information of each second terminal is acquired, so as to use the status information of the second terminal to determine the second terminal that can process the task to be processed, that is, to determine a stable and reliable target terminal, and assign the target terminal to be processed task, so that the target terminal can process the assigned pending task, that is, perform data comparison, ensure the normal progress of the data comparison, and avoid data comparison failure due to the unavailability of the terminal processing the pending task.
如图4所示,图4是本公开根据一示例性实施例示出的又一种数据监控方法的流程图,所述方法应用于终端集群中的第二终端,所述方法包括以下步骤:As shown in FIG. 4, FIG. 4 is a flowchart of another data monitoring method shown in the present disclosure according to an exemplary embodiment. The method is applied to a second terminal in a terminal cluster, and the method includes the following steps:
步骤401、获取第一终端分配的待处理任务,并根据待处理任务从第一数据库中确定待检测数据。Step 401: Acquire the tasks to be processed assigned by the first terminal, and determine the data to be detected from the first database according to the tasks to be processed.
步骤402、将待检测数据与第二数据库中的备份数据进行比对,得到待检测数据对应的数据比对结果。其中,第二数据库中的备份数据是对源数据进行同步得到的。Step 402: Compare the data to be detected with the backup data in the second database to obtain a data comparison result corresponding to the data to be detected. The backup data in the second database is obtained by synchronizing the source data.
在本实施例中,在得到第一终端分配的待处理任务后,处理分配的待处理任务,即对于每个分配的待处理任务,从第一数据库中确定需进行同步检测的源数据,以得到待检测数据。将该待检测数据与第二数据库中的备份数据进行比对,以确定是否已经将该待检测数据同步至第二数据库,得到待检测数据对应的数据比对结果,实现数据的同步检测,即数据比对。In this embodiment, after obtaining the to-be-processed tasks allocated by the first terminal, the allocated to-be-processed tasks are processed, that is, for each allocated to-be-processed task, the source data to be synchronously detected is determined from the first database to Get the data to be detected. The data to be detected is compared with the backup data in the second database to determine whether the data to be detected has been synchronized to the second database, the data comparison result corresponding to the data to be detected is obtained, and the synchronous detection of the data is realized, that is, Data comparison.
可选的,待处理任务指示,即包含待检测时间段和/或待检测数据表标识。相应的,在基于该分配的待处理任务从第一数据库中确定待检测数据时,从第一数据库中确定保存时间在待检测时间段,和/或数据表标识为待检测数据表标识的源数据,并将确定的源数据作为待检测数据。Optionally, the to-be-processed task indication includes the to-be-detected time period and/or the to-be-detected data table identifier. Correspondingly, when the data to be detected is determined from the first database based on the assigned task to be processed, it is determined from the first database that the storage time is in the time period to be detected, and/or the data table is identified as the source of the identification of the data table to be detected. data, and use the determined source data as the data to be detected.
具体的,若该分配的待处理任务包含待检测时间段,则从第一数据库中的各个数据表中查找保存时间在该待检测时间段内的源数据,即业务数据,并将查找到的源数据作为待检测数据。Specifically, if the assigned to-be-processed task includes a to-be-detected time period, search for source data stored in the to-be-detected time period, that is, business data, from each data table in the first database, and retrieve the found data. The source data is used as the data to be detected.
若该分配的待处理任务包含待检测数据表标识,则从第一数据库中查找该待检测数据表标识对应的数据表,并将该数据表中的所有源数据作为待检测数据。If the assigned task to be processed includes the identifier of the data table to be detected, the data table corresponding to the identifier of the data table to be detected is searched from the first database, and all the source data in the data table are used as the data to be detected.
若该分配的待处理任务包含待检测时间段和待检测数据表标识,则从第一数据库中查找该待检测数据表标识对应的数据表,并从该数据表中查找保存时间在该待检测时间段内的源数据,以得到待检测数据。If the assigned to-be-processed task includes the time period to be detected and the identifier of the data table to be detected, search for the data table corresponding to the identifier of the data table to be detected from the first database, and find the storage time in the to-be-detected data table from the data table. The source data in the time period to obtain the data to be detected.
步骤403、将待检测数据对应的数据比对结果发送至第一终端,以使第一终端根据待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态。Step 403: Send the data comparison result corresponding to the data to be detected to the first terminal, so that the first terminal determines the data synchronization state between the first database and the second database according to the data comparison result corresponding to the data to be detected.
在本实施例中,在得到待检测数据对应的数据比对结果后,将待检测数据对应的数据比对结果发送至第一终端,以供第一终端利用待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态。In this embodiment, after the data comparison result corresponding to the data to be detected is obtained, the data comparison result corresponding to the data to be detected is sent to the first terminal, so that the first terminal can use the data comparison result corresponding to the data to be detected A data synchronization state between the first database and the second database is determined.
在本实施例中,由于第二终端仅需处理分配的待处理任务,无需执行所有待处理任务,即仅需对部分数据进行数据比对,减少数据比对所需的时间,即减少同步检查所需的时间,提高数据比对的效率。In this embodiment, since the second terminal only needs to process the assigned tasks to be processed, it does not need to execute all the tasks to be processed, that is, it only needs to perform data comparison on part of the data, which reduces the time required for data comparison, that is, reduces the synchronization check. The time required to improve the efficiency of data comparison.
如图5所示,图5是根据一示例性实施例示出的再一种数据监控方法的流程图,本实施方式在前述实施例的基础上,描述了如何确定待检测数据对应的数据比对结果的过程,包括如下步骤:As shown in FIG. 5 , FIG. 5 is a flow chart of still another data monitoring method according to an exemplary embodiment. Based on the foregoing embodiment, this embodiment describes how to determine the data comparison corresponding to the data to be detected. The resulting process includes the following steps:
步骤501、获取第一终端分配的待处理任务,并根据待处理任务从第一数据库中确定待检测数据。Step 501: Acquire the tasks to be processed assigned by the first terminal, and determine the data to be detected from the first database according to the tasks to be processed.
步骤502、获取待检测数据中的目标字段信息。其中,目标字段信息包括目标字段以及目标字段值。Step 502: Obtain target field information in the data to be detected. The target field information includes a target field and a target field value.
步骤503、从备份数据中确定目标字段名称对应的字段值为目标字段值的目标数据。Step 503: Determine from the backup data that the field value corresponding to the target field name is the target data of the target field value.
在本实施例中,在得到待检测数据后,对于每条待检测数据,提取该条待检测数据中的目标字段信息。该目标字段信息包括目标字段以及该目标字段对应的目标字段值。判断第二数据库是否存在该目标字段信息对应的备份数据,即判断第二数据库中是否存在目标字段名称对应的字段值为该目标字段值的备份数据。In this embodiment, after the data to be detected is obtained, for each piece of data to be detected, target field information in the piece of data to be detected is extracted. The target field information includes a target field and a target field value corresponding to the target field. Determining whether backup data corresponding to the target field information exists in the second database, that is, judging whether there is backup data with a field value corresponding to the target field name in the second database with the target field value.
在第二数据库存在该目标字段信息对应的备份数据的情况下,即在第二数据库中存在目标字段名称对应的字段值为该目标字段值的备份数据的情况下,将该目标字段信息对应的备份数据作为该条待检测数据对应的目标数据,也即将目标字段名称对应的字段值为目标字段值的备份数据作为该条待检测数据对应的目标数据,以进一步确定该目标数据与该条待检测数据是否相同,从而确定该目标数据对应的数据比对结果。In the case where the backup data corresponding to the target field information exists in the second database, that is, in the case where the backup data corresponding to the target field name and the field value corresponding to the target field value exists in the second database, the target field information corresponds to the backup data. The backup data is used as the target data corresponding to the piece of data to be detected, that is, the backup data with the field value corresponding to the target field name being the value of the target field is used as the target data corresponding to the piece of data to be detected, so as to further determine the target data and the piece of data to be detected. Check whether the data are the same, so as to determine the data comparison result corresponding to the target data.
在第二数据库不存在该目标字段信息对应的备份数据的情况下,确定第二数据库不存在该条待检测数据,也即还未将该条待检测数据同步至目标数据库,则确定该条待检测数据对应的数据比对结果为数据异常结果。In the case where the backup data corresponding to the target field information does not exist in the second database, it is determined that the piece of data to be detected does not exist in the second database, that is, the piece of data to be detected has not been synchronized to the target database, then it is determined that the piece of data to be detected has not been synchronized to the target database. The data comparison result corresponding to the detection data is the abnormal data result.
可选的,目标字段可以根据实际需求进行设置,例如,目标字段为主键。Optionally, the target field can be set according to actual requirements, for example, the target field is the primary key.
可选的,为了提高数据比对效率,可以基于待处理任务包括待检测时间段和/或待检测数据表标识,从第二数据库中确定相应的备份数据,并从确定的备份数据中确定目标字段名称对应的字段值为目标字段值的目标数据。Optionally, in order to improve the data comparison efficiency, based on the task to be processed including the time period to be detected and/or the identifier of the data table to be detected, the corresponding backup data can be determined from the second database, and the target can be determined from the determined backup data. The field value corresponding to the field name is the target data of the target field value.
步骤504、计算目标数据对应的校验值,并计算待检测数据对应的校验值。Step 504: Calculate the check value corresponding to the target data, and calculate the check value corresponding to the data to be detected.
在本实施例中,对于每条待检测数据,计算该条待检测数据对应的校验值,并计算与该条待检测数据对应的目标数据的校验值。In this embodiment, for each piece of data to be detected, a check value corresponding to the piece of data to be detected is calculated, and a check value of target data corresponding to the piece of data to be detected is calculated.
其中,校验值可以为哈希值,哈希值是通过对数据进行哈希运算得到的,其可以用来快速比较数据的异同。当然,校验值也可以为其它类型的可以用来校验数据是否相同的值,例如,校验值为消息摘要值。The check value may be a hash value, and the hash value is obtained by performing a hash operation on the data, which can be used to quickly compare the similarities and differences of the data. Of course, the check value can also be other types of values that can be used to check whether the data are the same, for example, the check value is a message digest value.
步骤505、在目标数据对应的校验值与待检测数据对应的校验值不同的情况下,确定待检测数据对应的数据比对结果为数据异常结果。Step 505: In the case that the check value corresponding to the target data is different from the check value corresponding to the data to be detected, determine that the data comparison result corresponding to the data to be detected is a data abnormality result.
在本实施例中,对于每条待检测数据,判断该条待检测数据对应的校验值与该条待检测数据对应的目标数据对应的校验值是否相同;若相同,表明该条待检测数据与该目标数据相同,即表明第二数据库已经存在该待检测数据,也即表明该待检测数据已经同步至第二数据库,则确定该条待检测数据对应的数据比对结果为数据正常结果。若不相同,表明该条待检测数据与该目标数据不相同,即表明第二数据库未存在该待检测数据,也即表明该待检测数据未同步至第二数据库,则确定该条待检测数据对应的数据比对结果为数据异常结果。In this embodiment, for each piece of data to be detected, it is determined whether the check value corresponding to the piece of data to be checked is the same as the check value corresponding to the target data corresponding to the piece of data to be checked; if they are the same, it indicates that the piece of data to be checked is the same. The data is the same as the target data, which means that the data to be detected already exists in the second database, that is, it means that the data to be detected has been synchronized to the second database, then it is determined that the data comparison result corresponding to the data to be detected is a normal data result . If it is not the same, it means that the piece of data to be detected is not the same as the target data, that is, it means that the data to be detected does not exist in the second database, that is, it means that the data to be detected is not synchronized to the second database, then the piece of data to be detected is determined. The corresponding data comparison results are abnormal data results.
可选的,将数据比对结果为数据异常结果的待检测数据保存至第二预设存储装置中。Optionally, the data to be detected whose data comparison result is an abnormal data result is stored in the second preset storage device.
具体的,在目标数据对应的校验值与待检测数据对应的校验值不同的情况下,即在确定该条待检测数据对应的数据比对结果为数据异常结果时,该条待检测数据为异常数据,则将该条待检测数据保存至第二预设存储装置。Specifically, when the check value corresponding to the target data is different from the check value corresponding to the data to be detected, that is, when it is determined that the data comparison result corresponding to the data to be detected is an abnormal data result, the data to be detected is determined to be abnormal. If it is abnormal data, the piece of data to be detected is saved to the second preset storage device.
其中,第二预设存储装置可以与第一预设存储装置为同一个存储装置,也可以为不同的存储装置,在此,不对其进行限制。The second preset storage device and the first preset storage device may be the same storage device, or may be different storage devices, which are not limited herein.
可选的,根据待检测数据对应的数据比对结果生成报警信息,并将报警信息发送至用户端。Optionally, alarm information is generated according to the data comparison result corresponding to the data to be detected, and the alarm information is sent to the user terminal.
具体的,获取数据比对结果为数据异常结果的待检测数据,并生成包含该待检测数据的报警信息。通过预设报警方式,将该报警信息发送至用户端,以使相关人员可以及时获知同步出现问题的数据,实现及时报警。Specifically, the data to be detected whose data comparison result is an abnormal data result is acquired, and alarm information including the to-be-detected data is generated. By presetting the alarm method, the alarm information is sent to the user terminal, so that the relevant personnel can be informed of the data of synchronization problems in time, so as to realize the timely alarm.
可选的,在获取数据比对结果为数据异常结果的待检测数据时,可以从第二预设存储装置中进行获取。Optionally, when acquiring the to-be-detected data whose data comparison result is an abnormal data result, it may be acquired from a second preset storage device.
可选的,在目标数据对应的校验值与待检测数据对应的校验值不同的情况下,可以直接生成包含该待检测数据的报警信息,以实现快速报警。Optionally, when the check value corresponding to the target data is different from the check value corresponding to the data to be detected, alarm information including the data to be detected may be directly generated, so as to realize a quick alarm.
可选的,预设报警方式包括邮件、短信、指定应用程序等方式,在此,不对其进行限制。Optionally, the preset alarm methods include emails, short messages, and designated application programs, which are not limited here.
可选的,为了由于同步延迟导致数据比对结果的误判,从而导致误报警,通过第二终端提供第二页面,第二页面包括第二重检测按键,以提高一键重检查功能。该功能具体为:响应于第二重检测按键的第二触发操作,获取异常数据。其中,异常数据包括第二预设存储装置中的数据比对结果为数据异常结果的待检测数据。将异常数据与第二数据库中的备份数据进行比对,得到异常数据对应的数据比对结果。Optionally, in order to cause a misjudgment of the data comparison result due to synchronization delay, thereby causing a false alarm, a second page is provided through the second terminal, and the second page includes a second re-check button to improve the one-key re-check function. The function is specifically: acquiring abnormal data in response to the second triggering operation of the second re-detection button. The abnormal data includes the data to be detected whose data comparison result in the second preset storage device is a data abnormal result. The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
具体的,在检测到用户触发第二页面上的第二重检测按键的情况,表明需要确定第二预设存储装置中的异常数据是否由于同步延迟导致的,则获取第二预设存储装置中的异常数据,即数据比对结果为数据异常结果的待检测数据,并对于每条异常数据,将该条异常数据与该第二数据库中的备份数据进行比对,得到该条异常数据对应的数据比对结果。Specifically, when it is detected that the user triggers the second re-detection button on the second page, it indicates that it is necessary to determine whether the abnormal data in the second preset storage device is caused by synchronization delay, and then obtain the information in the second preset storage device. For each abnormal data, the abnormal data is compared with the backup data in the second database, and the corresponding abnormal data is obtained. Data comparison results.
其中,将异常数据与第二数据库中的备份数据进行比对的过程与将待检测数据与第二数据库中的备份数据进行比对的过程类似,在此,不在对其进行赘述。The process of comparing the abnormal data with the backup data in the second database is similar to the process of comparing the data to be detected with the backup data in the second database, which will not be repeated here.
可选的,在异常数据对应的数据比对结果为数据正常结果的情况下,表明是由于同步延迟导致之前确定的数据比对结果错误,该异常数据已经同步至第二数据库,则从第二预设存储装置中删除该异常数据。Optionally, in the case where the data comparison result corresponding to the abnormal data is the normal data result, it indicates that the previously determined data comparison result is wrong due to the synchronization delay. The abnormal data is deleted from the default storage device.
可选的,第二终端可以对第一预设存储装置中的相关信息及时确定领导者终端,以保证集群系统的性能,即判断第一预设存储装置中是否存在领导者终端标记信息。若未存在领导者终端标记信息,则确定当前第一终端的信息,并根据当前第一终端的信息确定领导者终端标记信息。其中,领导者终端为工作状态为领导者状态的终端。将领导者终端标记信息保存至第一预设存储装置中。若存在领导者终端标记信息,则获取领导者终端标记信息中的领导者终端标识,并获取与领导者终端标识对应的领导者终端的终端状态。在领导者终端的终端状态为非存活状态的情况下,确定新的领导者终端,并根据新的领导者终端的信息对第一预设存储装置中的领导者终端标记信息进行更新。Optionally, the second terminal may determine the leader terminal in time for the relevant information in the first preset storage device to ensure the performance of the cluster system, that is, determine whether there is leader terminal marking information in the first preset storage device. If there is no leader terminal marking information, the current first terminal information is determined, and the leader terminal marking information is determined according to the current first terminal information. The leader terminal is a terminal whose working state is the leader state. The leader terminal marking information is saved in the first preset storage device. If there is leader terminal marking information, the leader terminal identifier in the leader terminal marking information is acquired, and the terminal state of the leader terminal corresponding to the leader terminal identifier is acquired. When the terminal state of the leader terminal is a non-survival state, a new leader terminal is determined, and the leader terminal mark information in the first preset storage device is updated according to the information of the new leader terminal.
具体的,判断第一预设存储装置中是否领导者终端标记信息,若不存在领导者终端标记信息,则确定当前是否存在领导者终端,即是否存在第一终端。若存在领导者终端,表明已经从集群系统所包括的终端中选举出领导者终端,则获取领导者终端的信息,即第一终端的信息,并生成包括该第一终端的信息的领导者终端标记信息。将该领导者终端标记信息保存至第一预设存储装置。若不存在领导者终端,表明还未存在领导者终端,则选举出第一终端(即领导者终端),将生成包括该第一终端的信息的领导者终端标记信息,将该领导者终端标记信息保存至第一预设存储装置。Specifically, it is determined whether there is leader terminal marking information in the first preset storage device, and if there is no leader terminal marking information, it is determined whether there is currently a leader terminal, that is, whether there is a first terminal. If there is a leader terminal, it indicates that the leader terminal has been elected from the terminals included in the cluster system, then obtain the information of the leader terminal, that is, the information of the first terminal, and generate a leader terminal including the information of the first terminal Tag information. The leader terminal marking information is saved to the first preset storage device. If there is no leader terminal, it indicates that there is no leader terminal, then the first terminal (ie, the leader terminal) is elected, and the leader terminal marking information including the information of the first terminal will be generated, and the leader terminal will be marked. The information is saved to the first preset storage device.
在第一预设存储装置中存在领导者终端标记信息的情况下,判断是否需要对该领导者终端标记信息进行更新,即判断当前领导者终端是否仍处于存活状态,则从领导者终端标记信息中获取当前领导者终端(即第一终端)的信息,并获取该当前第一终端的信息对应的第一终端的终端状态,在该终端状态为非存活状态的情况下,表明当前领导者终端已经失活,无法正常工作,则重新进行选举,以确定新的领导者终端,即确定新的第一终端,并将第一预设存储位置中的领导者终端标记信息更新为该新的第一终端的信息,实现领导者终端及时确定,从而保证系统的性能,进而可以保证数据比对的正常进行。In the case where the leader terminal marking information exists in the first preset storage device, it is judged whether the leader terminal marking information needs to be updated, that is, whether the current leader terminal is still in a live state, and the leader terminal marking information is determined from the leader terminal. Obtain the information of the current leader terminal (that is, the first terminal) in , and obtain the terminal state of the first terminal corresponding to the information of the current first terminal, in the case that the terminal state is a non-survival state, it indicates that the current leader terminal It has been deactivated and cannot work normally, then re-election is performed to determine the new leader terminal, that is, to determine the new first terminal, and update the leader terminal mark information in the first preset storage location to the new first terminal. The information of a terminal can be determined in time by the leader terminal, so as to ensure the performance of the system and thus ensure the normal progress of data comparison.
在当前第一终端的终端状态为存活状态的情况下,表明当前领导者终端仍可以正常工作,无需重新选举。In the case that the current terminal state of the first terminal is in the alive state, it indicates that the current leader terminal can still work normally, and no re-election is required.
其中,第一终端的信息包括第一终端的终端标识。The information of the first terminal includes a terminal identifier of the first terminal.
其中,第一终端的终端状态的确定过程与上述第二终端的终端状态的确定过程类似,在此,不再对其进行赘述。The process of determining the terminal state of the first terminal is similar to the above-mentioned process of determining the terminal state of the second terminal, and details are not described herein again.
可选的,可以在第二终端启动的情况下,访问第一预设存储装置,以判断第一预设存储装置中是否存在领导者终端标记信息;也可以每隔一定时间,访问第一预设存储装置,以判断第一预设存储装置中是否存在领导者终端标记信息,在此,不对其进行限定。Optionally, when the second terminal is activated, the first preset storage device may be accessed to determine whether there is leader terminal marking information in the first preset storage device; or the first preset storage device may be accessed at regular intervals. A storage device is provided to determine whether the leader terminal marker information exists in the first preset storage device, which is not limited herein.
可选的,在分配的待处理任务处理完成的情况下,获取分配的待处理任务对应的任务类型,也即分配的待处理任务指示的任务类型,响应于任务类型为实时监控任务类型,则基于该待处理任务指示的待检测数据标识和目标时间段,生成新的待处理任务;将新的待处理任务发送至第一终端,以使第一终端对新的待处理任务进行分配。其中,目标时间段指示在待处理任务对应的结束时刻之后,且与结束时刻的差值在预设时间范围内的时间。待处理任务对应的结束时刻表示待处理任务处理完成的时刻。Optionally, when the assigned pending task is processed, obtain the task type corresponding to the assigned pending task, that is, the task type indicated by the assigned pending task, and respond that the task type is the real-time monitoring task type, then Based on the to-be-detected data identifier and target time period indicated by the to-be-processed task, a new to-be-processed task is generated; the new to-be-processed task is sent to the first terminal, so that the first terminal allocates the new to-be-processed task. The target time period indicates the time after the end time corresponding to the task to be processed and the difference from the end time is within the preset time range. The end time corresponding to the to-be-processed task indicates the time when the to-be-processed task is processed.
其中,任务类型包括实时监控任务类型以及非实时监控任务类型。当待处理任务对应的任务类型为实时监控任务类型时,表明待处理任务指示的待检测数据表标识所对应的数据表为需实时监控的数据表,即该数据表内的源数据需要实时监控同步情况。当待处理任务对应的任务类型为非实时监控任务类型时,表明待处理任务指示的待检测数据表标识所对应的数据表不为需实时监控的数据表,即该数据表内的源数据无需实时监控同步情况。The task types include real-time monitoring task types and non-real-time monitoring task types. When the task type corresponding to the task to be processed is the real-time monitoring task type, it indicates that the data table corresponding to the identifier of the data table to be detected indicated by the task to be processed is the data table that needs real-time monitoring, that is, the source data in the data table needs to be monitored in real time Synchronization situation. When the task type corresponding to the task to be processed is a non-real-time monitoring task type, it indicates that the data table corresponding to the identifier of the data table to be detected indicated by the task to be processed is not a data table that needs real-time monitoring, that is, the source data in the data table does not need to be Monitor synchronization in real time.
具体的,对于每个分配的待处理任务,当该分配的待处理任务对应的待检测数据已经全部比对完成时,表明该分配的待处理任务处理完成,则获取该分配的待处理任务对应的任务类型。在该任务类型为实时监控任务类型的情况下,表明需对该分配的待处理任务指示的待检测数据表标识所对应的数据表进行实时监控,则主动创建新的待处理任务,该新的待处理任务指示该待检测数据表标识以及目标时间段。将该待处理任务发送至第一终端,以使第一终端进行分配,实现数据表的实时监控。Specifically, for each allocated task to be processed, when all the data to be detected corresponding to the allocated task to be processed have been compared and completed, indicating that the allocated task to be processed has been processed, the corresponding to-be-processed task of the allocated task is obtained. task type. In the case that the task type is a real-time monitoring task type, it indicates that the data table corresponding to the data table identifier to be detected indicated by the assigned task to be processed needs to be monitored in real time, and a new task to be processed is actively created. The pending task indicates the identification of the data table to be detected and the target time period. The to-be-processed task is sent to the first terminal, so that the first terminal performs allocation, and real-time monitoring of the data table is realized.
其中,在待处理任务对应的结束时刻之后,且与结束时刻的差值在预设时间范围内的时间。例如,预设时间范围为10分钟,处理完成待处理任务的时刻为9:00,则目标时间段为9:00-9:10。The time after the end time corresponding to the task to be processed and the difference between the end time and the end time is within the preset time range. For example, the preset time range is 10 minutes, the time when the pending task is processed is 9:00, and the target time period is 9:00-9:10.
步骤506、将待检测数据对应的数据比对结果发送至第一终端,以使第一终端根据待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态。Step 506: Send the data comparison result corresponding to the data to be detected to the first terminal, so that the first terminal determines the data synchronization state between the first database and the second database according to the data comparison result corresponding to the data to be detected.
可以理解,当第一终端为目标终端时,第一终端执行的操作,例如,进行相关操作以确定数据比对结果、对数据比对结果进行相关处理(例如,报警、重检测)与上述第二终端执行的操作类似,在此,不在对其进行赘述。It can be understood that when the first terminal is the target terminal, the operations performed by the first terminal, for example, performing related operations to determine the data comparison result, and performing relevant processing (eg, alarming, re-detection) on the data comparison result are the same as those described in the above paragraph. The operations performed by the two terminals are similar, and are not repeated here.
在本实施例中,利用校验值确定目标数据与待检测数据是否相同,即将目标数据与待检测数据进行数据比对,而不是逐字段比较两者是否相同,可以快速确定目标数据与待检测数据是否相同,从而提高数据比对的效率,进行实现同步出现问题的数据的快速确定。In this embodiment, the check value is used to determine whether the target data is the same as the to-be-detected data, that is, the target data and the to-be-detected data are compared, rather than the field-by-field comparison of whether the two are the same, and the target data and the to-be-detected data can be quickly determined. Whether the data are the same, thereby improving the efficiency of data comparison, and quickly determining the data with synchronization problems.
与前述方法的实施例相对应,本公开还提供了装置及其所应用的终端的实施例。Corresponding to the foregoing method embodiments, the present disclosure also provides embodiments of an apparatus and a terminal to which it is applied.
本公开数据监控装置的实施例可以应用在计算机设备上,例如服务器或终端设备。装置实施例可以通过软件实现,也可以通过硬件或者软硬件结合的方式实现。以软件实现为例,作为一个逻辑意义上的装置,是通过其所在文件处理的处理器将非易失性存储器中对应的计算机程序指令读取到内存中运行形成的。从硬件层面而言,如图6所示,为本公开实施例数据监控装置所在计算机设备的一种硬件结构图,除了图6所示的处理器610、内存630、网络接口620、以及非易失性存储器640之外,实施例中数据监控装置631所在的服务器或终端设备,通常根据该计算机设备的实际功能,还可以包括其他硬件,对此不再赘述。The embodiments of the data monitoring apparatus of the present disclosure can be applied to computer equipment, such as a server or a terminal equipment. The apparatus embodiment may be implemented by software, or may be implemented by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory for operation by the processor where the file is processed. From the perspective of hardware, as shown in FIG. 6 , it is a hardware structure diagram of the computer equipment where the data monitoring apparatus according to the embodiment of the present disclosure is located, except for the
如图7所示,图7是本公开根据一示例性实施例示出的一种数据监控装置的框图,所述装置包括:As shown in FIG. 7 , FIG. 7 is a block diagram of a data monitoring apparatus according to an exemplary embodiment of the present disclosure, and the apparatus includes:
终端确定模块710,用于获取多个待处理任务,并从终端集群中确定至少两个目标终端。The
任务分配模块720,用于为各个目标终端分配不同的待处理任务,以使目标终端根据分配的待处理任务从第一数据库中确定待检测数据,以及将待检测数据与第二数据库中的备份数据进行比对,得到待检测数据对应的数据比对结果。The
状态确定模块730,用于获取各个目标终端发送的待检测数据对应的数据比对结果,并根据待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态。The
可选的,所述装置应用于终端集群中的第一终端,终端集群还包括第二终端;Optionally, the apparatus is applied to a first terminal in a terminal cluster, and the terminal cluster further includes a second terminal;
终端确定模块710具体用于:The
获取第二终端的状态信息和/或第一终端的状态信息。Acquire status information of the second terminal and/or status information of the first terminal.
根据第二终端的状态信息和/或第一终端的状态信息,从第二终端和/或第一终端中确定至少两个目标终端。At least two target terminals are determined from the second terminal and/or the first terminal according to the state information of the second terminal and/or the state information of the first terminal.
可选的,状态信息包括终端状态和/或运行状态。Optionally, the status information includes terminal status and/or running status.
终端确定模块710还具体用于:The
响应于第二终端的状态信息和/或第一终端满足第一预设条件,将第二终端和/或第一终端作为目标终端。其中,第一预设条件包括运行状态为空闲状态和/或终端状态为存活状态。In response to the state information of the second terminal and/or the first terminal meeting the first preset condition, the second terminal and/or the first terminal are used as the target terminal. The first preset condition includes that the running state is an idle state and/or the terminal state is an alive state.
可选的,数据监控装置还包括时间更新模块;Optionally, the data monitoring device further includes a time update module;
时间更新模块用于:The time update module is used to:
每隔预设时间,对第一预设存储装置中的第一终端对应的心跳记录时间进行更新。The heartbeat recording time corresponding to the first terminal in the first preset storage device is updated every preset time.
可选的,第一预设存储装置还包括各个第二终端对应的心跳记录时间。Optionally, the first preset storage device further includes a heartbeat recording time corresponding to each second terminal.
终端确定模块710还用于:The
计算当前时刻与第二终端对应的心跳记录时间的时间差值。Calculate the time difference between the current moment and the heartbeat recording time corresponding to the second terminal.
在时间差值小于第一预设时间阈值的情况下,确定第二终端的终端状态为存活状态。In the case that the time difference is smaller than the first preset time threshold, it is determined that the terminal state of the second terminal is the alive state.
在时间差值大于或等于第一预设时间阈值的情况下,确定第二终端的终端状态为非存活状态。When the time difference is greater than or equal to the first preset time threshold, it is determined that the terminal state of the second terminal is a non-survival state.
可选的,第一数据库存储有源数据;备份数据第二数据库中的是对源数据进行同步得到的;Optionally, the first database stores the source data; the backup data in the second database is obtained by synchronizing the source data;
待处理任务包含待检测时间段和/或待检测数据表标识。The task to be processed includes the time period to be detected and/or the identifier of the data table to be detected.
可选的,通过第一终端提供第一页面,第一页面包括第一重检测按键。Optionally, a first page is provided by the first terminal, and the first page includes a first re-detection button.
状态确定模块还用于:The state determination module is also used to:
响应于第一重检测按键的第一触发操作,获取异常数据。其中,异常数据包括数据比对结果为数据异常结果的待检测数据。Abnormal data is acquired in response to the first trigger operation of the first re-detection key. The abnormal data includes data to be detected whose data comparison result is an abnormal data result.
将异常数据与第二数据库中的备份数据进行比对,得到异常数据对应的数据比对结果。The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
可选的,状态确定模块还用于:Optionally, the state determination module is also used to:
根据待检测数据对应的数据比对结果生成报警信息,并将报警信息发送至用户端。Generate alarm information according to the data comparison result corresponding to the data to be detected, and send the alarm information to the user terminal.
如图8所示,图8是本公开根据一示例性实施例示出的另一种数据监控装置的框图,所述装置包括:As shown in FIG. 8, FIG. 8 is a block diagram of another data monitoring apparatus shown in the present disclosure according to an exemplary embodiment, and the apparatus includes:
数据确定模块810,用于获取第一终端分配的待处理任务,并根据待处理任务从第一数据库中确定待检测数据。The
数据比对模块820,用于将待检测数据与第二数据库中的备份数据进行比对,得到待检测数据对应的数据比对结果。The
结果处理模块830,用于将待检测数据对应的数据比对结果发送至第一终端,以使第一终端根据待检测数据对应的数据比对结果确定第一数据库与第二数据库之间的数据同步状态。The
可选的,数据比对模块820具体用于:Optionally, the
获取待检测数据中的目标字段信息。其中,目标字段信息包括目标字段以及目标字段值。Get the target field information in the data to be detected. The target field information includes a target field and a target field value.
从备份数据中确定目标字段名称对应的字段值为目标字段值的目标数据。It is determined from the backup data that the field value corresponding to the target field name is the target data of the target field value.
计算目标数据对应的校验值,并计算待检测数据对应的校验值。Calculate the check value corresponding to the target data, and calculate the check value corresponding to the data to be detected.
在目标数据对应的校验值与待检测数据对应的校验值不同的情况下,确定待检测数据对应的数据比对结果为数据异常结果。In the case where the check value corresponding to the target data is different from the check value corresponding to the data to be detected, it is determined that the data comparison result corresponding to the data to be detected is a data abnormality result.
可选的,结果处理模块830还用于:Optionally, the
将数据比对结果为数据异常结果的待检测数据保存至第二预设存储装置中。The data to be detected whose data comparison result is an abnormal data result is stored in the second preset storage device.
可选的,通过第二终端提供第二页面,第二页面包括第二重检测按键。Optionally, a second page is provided through the second terminal, and the second page includes a second re-detection button.
可选的,数据比对模块820还用于:Optionally, the
响应于第二重检测按键的第二触发操作,获取异常数据。其中,异常数据包括第二预设存储装置中的数据比对结果为数据异常结果的待检测数据。Abnormal data is acquired in response to the second triggering operation of the second re-detection key. The abnormal data includes the data to be detected whose data comparison result in the second preset storage device is a data abnormal result.
将异常数据与第二数据库中的备份数据进行比对,得到异常数据对应的数据比对结果。The abnormal data is compared with the backup data in the second database to obtain a data comparison result corresponding to the abnormal data.
可选的,待处理任务包含待检测时间段和/或待检测数据表标识。Optionally, the to-be-processed task includes a to-be-detected time period and/or a to-be-detected data table identifier.
数据确定模块810具体用于:The
从第一数据库中确定保存时间在待检测时间段,和/或数据表标识为待检测数据表标识的源数据,并将确定的源数据作为待检测数据。It is determined from the first database that the storage time is in the to-be-detected time period, and/or the data table is identified as the source data identified by the to-be-detected data table, and the determined source data is used as the to-be-detected data.
可选的,结果处理模块830还用于:Optionally, the
根据待检测数据对应的数据比对结果生成报警信息,并将报警信息发送至用户端。Generate alarm information according to the data comparison result corresponding to the data to be detected, and send the alarm information to the user terminal.
可选的,装置还包括标记信息设置模块。Optionally, the device further includes a marking information setting module.
标记信息设置模块具体用于:The tag information setting module is specifically used for:
判断第一预设存储装置中是否存在领导者终端标记信息。It is judged whether there is leader terminal mark information in the first preset storage device.
若未存在领导者终端标记信息,则确定当前第一终端的信息,并根据当前第一终端的信息确定领导者终端标记信息。其中,第一终端为工作状态为领导者状态的终端。If there is no leader terminal marking information, the current first terminal information is determined, and the leader terminal marking information is determined according to the current first terminal information. The first terminal is a terminal whose working state is the leader state.
将领导者终端标记信息保存至第一预设存储装置中。The leader terminal marking information is saved in the first preset storage device.
若存在领导者终端标记信息,则获取领导者终端标记信息中的第一终端的信息,并获取与第一终端的信息对应的第一终端的终端状态。If there is leader terminal marking information, the information of the first terminal in the leader terminal marking information is acquired, and the terminal state of the first terminal corresponding to the information of the first terminal is acquired.
在第一终端的终端状态为非存活状态的情况下,确定新的第一终端,并根据新的第一终端的信息对第一预设存储装置中的领导者终端标记信息进行更新。When the terminal state of the first terminal is a non-survival state, a new first terminal is determined, and the leader terminal mark information in the first preset storage device is updated according to the information of the new first terminal.
相应的,本公开还提供一种计算机设备,所述设备包括有处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为:Correspondingly, the present disclosure also provides a computer device, the device includes a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to:
获取多个待处理任务,并根据第一终端和/或第二终端确定至少两个目标终端;Acquire multiple tasks to be processed, and determine at least two target terminals according to the first terminal and/or the second terminal;
为各个目标终端分配不同的待处理任务,以使所述目标终端根据分配的待处理任务从所述第一数据库中确定待检测数据,以及将所述待检测数据与所述第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;Allocate different tasks to be processed for each target terminal, so that the target terminal determines the data to be detected from the first database according to the allocated tasks to be processed, and compares the data to be detected with the data in the second database. The backup data is compared to obtain a data comparison result corresponding to the data to be detected;
获取各个目标终端发送的待检测数据对应的数据比对结果,并根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态;Acquiring data comparison results corresponding to the data to be detected sent by each target terminal, and determining a data synchronization state between the first database and the second database according to the data comparison results corresponding to the data to be detected;
或者,or,
获取第一终端分配的待处理任务,并根据所述待处理任务从第一数据库中确定待检测数据;Acquire the task to be processed assigned by the first terminal, and determine the data to be detected from the first database according to the task to be processed;
将所述待检测数据与第二数据库中的备份数据进行比对,得到所述待检测数据对应的数据比对结果;Comparing the data to be detected with the backup data in the second database to obtain a data comparison result corresponding to the data to be detected;
将所述待检测数据对应的数据比对结果发送至所述第一终端,以使所述第一终端根据所述待检测数据对应的数据比对结果确定所述第一数据库与所述第二数据库之间的数据同步状态。Send the data comparison result corresponding to the data to be detected to the first terminal, so that the first terminal determines the first database and the second database according to the data comparison result corresponding to the data to be detected Data synchronization status between databases.
本公开还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如上所述的数据监控方法。The present disclosure also provides a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and when a processor executes the computer-executable instructions, the above-mentioned data monitoring method is implemented.
本公开还提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时,实现如上所述的数据监控方法。The present disclosure also provides a computer program product, including a computer program, which, when executed by a processor, implements the data monitoring method as described above.
上述装置中各个模块的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。For details of the implementation process of the functions and functions of each module in the above-mentioned device, please refer to the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本公开方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。For the apparatus embodiments, since they basically correspond to the method embodiments, reference may be made to the partial descriptions of the method embodiments for related parts. The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in One place, or it can be distributed over multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present disclosure. Those of ordinary skill in the art can understand and implement it without creative effort.
上述对本公开特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
本领域技术人员在考虑说明书及实践这里申请的发明后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未申请的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。Other embodiments of the present disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common general knowledge or techniques in the technical field to which this disclosure is not claimed . The specification and examples are to be regarded as exemplary only, with the true scope and spirit of the disclosure being indicated by the following claims.
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。It is to be understood that the present disclosure is not limited to the precise structures described above and illustrated in the accompanying drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
以上所述仅为本公开的较佳实施例而已,并不用以限制本公开,凡在本公开的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本公开保护的范围之内。The above descriptions are only preferred embodiments of the present disclosure, and are not intended to limit the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure shall be included in the present disclosure. within the scope of protection.
Claims (19)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111658035.0A CN114265905A (en) | 2021-12-30 | 2021-12-30 | Data monitoring method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111658035.0A CN114265905A (en) | 2021-12-30 | 2021-12-30 | Data monitoring method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114265905A true CN114265905A (en) | 2022-04-01 |
Family
ID=80832105
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111658035.0A Pending CN114265905A (en) | 2021-12-30 | 2021-12-30 | Data monitoring method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114265905A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115185965A (en) * | 2022-06-30 | 2022-10-14 | 中国电信股份有限公司 | Code warehouse operation method, system, device, equipment and storage medium |
US12307258B2 (en) | 2023-07-07 | 2025-05-20 | Quanta Computer Inc. | Systems and methods for efficient transfer of data to a baseboard management controller |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108337275A (en) * | 2017-01-19 | 2018-07-27 | 百度在线网络技术(北京)有限公司 | Task distribution method, device and equipment for Distributor |
CN109241068A (en) * | 2018-08-22 | 2019-01-18 | 中国平安人寿保险股份有限公司 | The method, apparatus and terminal device that foreground and background data compares |
CN110443695A (en) * | 2019-07-31 | 2019-11-12 | 中国工商银行股份有限公司 | Data processing method and its device, electronic equipment and medium |
CN110765162A (en) * | 2019-09-06 | 2020-02-07 | 上海陆家嘴国际金融资产交易市场股份有限公司 | Data comparison method and device, computer equipment and storage medium |
CN112905350A (en) * | 2021-03-22 | 2021-06-04 | 北京市商汤科技开发有限公司 | Task scheduling method and device, electronic equipment and storage medium |
-
2021
- 2021-12-30 CN CN202111658035.0A patent/CN114265905A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108337275A (en) * | 2017-01-19 | 2018-07-27 | 百度在线网络技术(北京)有限公司 | Task distribution method, device and equipment for Distributor |
CN109241068A (en) * | 2018-08-22 | 2019-01-18 | 中国平安人寿保险股份有限公司 | The method, apparatus and terminal device that foreground and background data compares |
CN110443695A (en) * | 2019-07-31 | 2019-11-12 | 中国工商银行股份有限公司 | Data processing method and its device, electronic equipment and medium |
CN110765162A (en) * | 2019-09-06 | 2020-02-07 | 上海陆家嘴国际金融资产交易市场股份有限公司 | Data comparison method and device, computer equipment and storage medium |
CN112905350A (en) * | 2021-03-22 | 2021-06-04 | 北京市商汤科技开发有限公司 | Task scheduling method and device, electronic equipment and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115185965A (en) * | 2022-06-30 | 2022-10-14 | 中国电信股份有限公司 | Code warehouse operation method, system, device, equipment and storage medium |
US12307258B2 (en) | 2023-07-07 | 2025-05-20 | Quanta Computer Inc. | Systems and methods for efficient transfer of data to a baseboard management controller |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109669762B (en) | Cloud computing resource management method, device, equipment and computer readable storage medium | |
US9367261B2 (en) | Computer system, data management method and data management program | |
CN111159233B (en) | Distributed caching method, system, computer equipment and storage medium | |
US9454575B2 (en) | Processing a metric of a component of a software-defined network | |
US9176798B2 (en) | Computer-readable recording medium, failure prediction device and applicability determination method | |
JP2017188117A (en) | Reliable generation of unique keys in distributed systems | |
CN108183971B (en) | Node election method in distributed system | |
EP3438847B1 (en) | Method and device for duplicating database in distributed system | |
CN111541762B (en) | Data processing method, management server, device and storage medium | |
CN114265905A (en) | Data monitoring method and device | |
CN105933407A (en) | Method and system for achieving high availability of Redis cluster | |
CN112231108A (en) | Task processing method, device, computer-readable storage medium, and server | |
WO2017157111A1 (en) | Method, device and system for preventing memory data loss | |
CN108880885B (en) | Message processing method and device | |
CN112100152A (en) | Service data processing method, system, server and readable storage medium | |
JP2012234333A (en) | Cluster system, synchronization control method, server device and synchronization control program | |
CN113064950A (en) | Data synchronization method, device, equipment and storage medium | |
US8359601B2 (en) | Data processing method, cluster system, and data processing program | |
CN109241182B (en) | Big data real-time synchronization method and device, computer equipment and storage medium | |
CN109586989B (en) | State checking method, device and cluster system | |
WO2019020084A1 (en) | Data storage method and system | |
CN112202895A (en) | Method and system for collecting monitoring index data, electronic equipment and storage medium | |
CN115510036A (en) | Data migration method, device, equipment and storage medium | |
CN113672665A (en) | Data processing method, data acquisition system, electronic device and storage medium | |
WO2016095716A1 (en) | Fault information processing method and related device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
EE01 | Entry into force of recordation of patent licensing contract |
Application publication date: 20220401 Assignee: Baisheng Consultation (Shanghai) Co.,Ltd. Assignor: Shengdoushi (Shanghai) Technology Development Co.,Ltd. Contract record no.: X2023310000138 Denomination of invention: Data monitoring methods and devices License type: Common License Record date: 20230714 |
|
EE01 | Entry into force of recordation of patent licensing contract |