Database abnormal state repairing method and system based on maintenance mode

By building maintenance mode in the database, generating and verifying passwords, loading template files, performing data playback and operation audits, the problem of not being able to log in and recover data under abnormal state of the database is solved, and the database repair and recovery are achieved.

CN119493681AActive Publication Date: 2025-02-21SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN202411449252.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-21
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

When the database enters an abnormal state and cannot log in, it is difficult to enter the database and recover data.

Method used

Repair the abnormal state of the database by building maintenance modes, generating and verifying maintenance mode passwords, loading template files, performing data playback and operation audits.

Benefits of technology

It realizes repairing and restoring data in an abnormal state of the database, avoiding the impact of physical file corruption blocks and ensuring that the database runs normally in maintenance mode.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493681A_ABST
    Figure CN119493681A_ABST
Patent Text Reader

Abstract

The invention discloses a database abnormal state repairing method and system based on a maintenance mode, belongs to the technical field of databases, and aims to solve the technical problem of how to enter a database and recover data when the database enters an abnormal state and cannot log in. Comprising the steps that a maintenance mode runs on a server where a database is located; taking a password input when a database directory is initialized as a maintenance mode password, calculating a hash value of the maintenance mode password as a verification value, and storing the verification value in the directory of the database; when the maintenance mode is started, calculating a hash value of the input password, and comparing the generated hash value with the check value; when the database enters the maintenance mode, loading two specified template files, and if at least one template file is successfully loaded, enabling the database to enter the maintenance mode; in the maintenance mode, playing back the data added by the user through a data playback tool; and performing log recording on the operation process, and storing the recorded operation log in the audit log.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of databases, and in particular to a method and system for repairing abnormal state of a database based on a maintenance mode. Background Art

[0002] In the safe mode of the Linux operating system, the system runs in a minimized state, only the most basic services and drivers are loaded, and network services and other non-essential services are not started. Its main purpose is to provide a safe environment for system administrators to repair system problems, such as repairing damaged system files, recovering forgotten root passwords, solving startup problems, etc.

[0003] Referring to the security mode of Linux itself, when a major failure occurs in the database, such as forgetting the administrator account, being unable to log in to the system, physical file damage, and the database being unable to start, it is difficult to repair. When the database enters an abnormal state and cannot be logged in, how to enter the database and recover the data is a technical problem that needs to be solved. Summary of the invention

[0004] The technical task of the present invention is to address the above shortcomings and provide a maintenance mode-based database abnormal state repair method and system to solve the technical problem of how to enter the database and restore data when the database enters an abnormal state and cannot be logged in.

[0005] In a first aspect, the present invention provides a method for repairing an abnormal state of a database based on a maintenance mode, comprising the following steps:

[0006] Maintenance mode construction: Build the maintenance mode of the database. The maintenance mode runs on the server where the database is located and is started by the database master process;

[0007] Maintenance mode password generation: The password entered when the database directory is initialized is used as the maintenance mode password. When the database is initialized, the maintenance mode password is entered through the interactive interface returned by the database. The hash value of the maintenance mode password is calculated and stored in the database directory as a verification value.

[0008] Maintenance mode password verification: When the maintenance mode is started, the password used when the database directory is initialized is entered through the interactive interface returned by the database, the hash value of the entered password is calculated, and the generated hash value is compared with the checksum value. If they are the same, the verification is passed and the database can enter the maintenance mode.

[0009] Maintenance mode startup: When the database enters maintenance mode, it loads two specified template files. If at least one of the template files is loaded successfully, the database enters maintenance mode. The two specified template files are the initial form files formed after the database is initialized.

[0010] Data playback: In maintenance mode, the data added by the user can be played back through the data playback tool;

[0011] Operation audit: Log the operation process of maintenance mode password generation, maintenance mode password verification, maintenance mode startup and data playback, store the recorded operation log in the audit log, and view it through the audit log after the database recovers from the abnormal state.

[0012] Preferably, the maintenance mode password generation includes the following steps:

[0013] When the database is initialized, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is input through the interactive interface as the maintenance mode password;

[0014] The complexity check is performed on the maintenance mode password entered. The complexity check rules are: the minimum length is 8 characters and must include uppercase and lowercase letters, numbers, and characters;

[0015] Perform hash calculation on the maintenance mode password that has passed the complexity check, use the user's local network card physical address MAC address as the key, hash the maintenance mode password through the HMAC SM3 hash algorithm, store the obtained hash value as the check value in the MM.key file, and put the MM.key file into the data directory data of the database;

[0016] Correspondingly, maintenance mode password verification includes the following steps:

[0017] When the maintenance mode is started, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is entered through the interactive interface;

[0018] Using the user's local network card physical address MAC address as the key, the input password is hashed through the HMAC SM3 hash algorithm, and the generated hash value is compared with the check value in the MM.key file under the data directory data. If they are the same, the database can enter the maintenance mode after verification, otherwise it exits.

[0019] Preferably, during the startup of the maintenance mode, after the database enters the maintenance mode, the network connection is closed in the maintenance mode.

[0020] Preferably, the data playback tool is a Database Playback tool.

[0021] Preferably, data playback includes system data playback and user data playback;

[0022] When replaying system data, create a temporary system table, store the system table to be replayed in the temporary system table, and perform a connection test on the system table. If there is abnormal data in the original system table, read the abnormal system table line by line for the abnormal system table with abnormal data, and store the normal data in the abnormal system table in the temporary system table. When reading abnormal data, skip the abnormal data, record the position of the abnormal data in the abnormal log, and read the next line until the abnormal system table is finished reading. Copy the data in the temporary system table to the normal table, and discard the data recorded in the abnormal log;

[0023] The data file corresponding to the user data is a newly added physical file. When the user data is played back, the data is played back by copying the user data physical file.

[0024] In a second aspect, the present invention provides a maintenance mode-based database abnormal state repair system, which is used to implement database abnormal state repair through a maintenance mode-based database abnormal state repair method as described in any one of the first aspects, and the system includes a maintenance mode construction module, a maintenance mode password generation module, a maintenance mode password verification module, a maintenance mode startup module, a data playback module and an operation audit module;

[0025] The maintenance mode construction module is used to perform the following: construct the maintenance mode of the database, the maintenance mode runs on the server where the database is located, and is started by the database master process;

[0026] The maintenance mode password generation module is used to perform the following: taking the password entered when the database directory is initialized as the maintenance mode password, when the database is initialized, entering the maintenance mode password through the interactive interface returned by the database, calculating the hash value of the maintenance mode password as a check value and storing it in the database directory;

[0027] The maintenance mode password verification module is used to perform the following: when the maintenance mode is started, the password used when the database directory is initialized is input through the interactive interface returned by the database, the hash value of the input password is calculated, and the generated hash value is compared with the check value. If they are the same, the database can enter the maintenance mode after verification;

[0028] The maintenance mode startup module is used to perform the following: when the database enters the maintenance mode, two specified template files are loaded. If at least one of the template files is loaded successfully, the database enters the maintenance mode, wherein the two specified template files are the initial form files formed after the database is initialized;

[0029] The data playback module is used to perform the following: in maintenance mode, playback the data added by the user through the data playback tool;

[0030] The operation audit module is used to perform the following: log the operation process of maintenance mode password generation, maintenance mode password verification, maintenance mode startup and data playback, store the recorded operation log in the audit log, and view it through the audit log after the database recovers from the abnormal state.

[0031] Preferably, the maintenance mode password generation module is used to perform the following operations:

[0032] When the database is initialized, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is input through the interactive interface as the maintenance mode password;

[0033] The complexity check is performed on the maintenance mode password entered. The complexity check rules are: the minimum length is 8 characters and must include uppercase and lowercase letters, numbers, and characters;

[0034] Perform hash calculation on the maintenance mode password that has passed the complexity check, use the user's local network card physical address MAC address as the key, hash the maintenance mode password through the HMAC SM3 hash algorithm, store the obtained hash value as the check value in the MM.key file, and put the MM.key file into the data directory data of the database;

[0035] Correspondingly, the maintenance mode password verification module is used to perform the following operations:

[0036] When the maintenance mode is started, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is entered through the interactive interface;

[0037] Using the user's local network card physical address MAC address as the key, the input password is hashed through the HMAC SM3 hash algorithm, and the generated hash value is compared with the check value in the MM.key file under the data directory data. If they are the same, the database can enter the maintenance mode after verification, otherwise it exits.

[0038] Preferably, during the maintenance mode startup process, after the database enters the maintenance mode, the maintenance mode startup module is used to close the network connection in the maintenance mode.

[0039] Preferably, the data playback tool is a Database Playback tool.

[0040] Preferably, data playback includes system data playback and user data playback;

[0041] When replaying system data, the data replay module is used to perform the following: create a temporary system table, store the system table to be replayed in the temporary system table, and perform a connection test on the system table. If there is abnormal data in the original system table, for the abnormal system table with abnormal data, read the abnormal system table line by line, store the normal data in the abnormal system table in the temporary system table, and when the abnormal data is read, skip the abnormal data, record the position of the abnormal data in the abnormal log, and read the next line until the abnormal system table is finished reading, copy the data in the temporary system table to the normal table, and discard the data recorded in the abnormal log;

[0042] The data file corresponding to the user data is a newly added physical file. When replaying the user data, the data replay module is used to replay the data by copying the user data physical file.

[0043] The maintenance mode-based database abnormal state repair method and system of the present invention have the following advantages:

[0044] 1. The database can repair abnormal status in maintenance mode and complete the repair of abnormal status without initializing the database;

[0045] 2. The database can skip the damaged blocks of the physical files and complete the transfer of normal data, so that the database can run in maintenance mode and repair its abnormal status. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0047] The present invention is further described below in conjunction with the accompanying drawings.

[0048] Figure 1 This is a flowchart of a maintenance mode-based method for repairing abnormal database status in Example 1;

[0049] Figure 2 This is a flowchart of maintenance mode password generation and maintenance mode password verification in a maintenance mode-based database abnormal state repair method in Example 1. DETAILED DESCRIPTION

[0050] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.

[0051] The embodiment of the present invention provides a maintenance mode-based database abnormal state repair method and system, which are used to solve the technical problem of how to enter the database and restore data when the database enters an abnormal state and cannot be logged in.

[0052] Embodiment 1:

[0053] The invention discloses a maintenance mode-based database abnormal state repair method, which comprises six steps: maintenance mode construction, maintenance mode password generation, maintenance mode password verification, maintenance mode startup, data playback and operation audit.

[0054] Step S100: Building a maintenance mode: Building a maintenance mode of the database. The maintenance mode runs on the server where the database is located and is started by the database master process.

[0055] When the database is in an abnormal state, it is impossible to connect to the database normally, and it is impossible to enter the database through a normal database connection. This embodiment designs a maintenance mode, which can only be run on the server where the database is located and is started through the main process of the database. As a specific implementation of the startup, the following command is used to enter the maintenance mode of the database: database start Maintenance Mode -D database data directory.

[0056] Step S200: Generate maintenance mode password: Use the password entered when the database directory is initialized as the maintenance mode password. When the database is initialized, enter the maintenance mode password through the interactive interface returned by the database, and calculate the hash value of the maintenance mode password as the verification value and store it in the database directory.

[0057] As a specific implementation, the maintenance mode password generation includes the following steps:

[0058] (1) When the database is initialized, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is input through the interactive interface as the maintenance mode password;

[0059] (2) Perform a complexity check on the maintenance mode password entered. The complexity check rule is: the minimum length is 8 characters and must include uppercase and lowercase letters, numbers, and characters;

[0060] (3) Perform hash calculation on the maintenance mode password that passes the complexity check, use the user's local network card physical address MAC address as the key, hash the maintenance mode password using the HMAC SM3 hash algorithm, store the obtained hash value as the check value in the MM.key file, and place the MM.key file in the data directory data of the database.

[0061] When entering maintenance mode, you can do any operation, and the permissions are too large, so at startup, a key is needed to manage the current login. This key has nothing to do with the database user, but is related to the password entered when the database directory is initialized. The password is hashed by a hash function and stored in the database's data directory as the key for starting maintenance mode. This file is set to MM.key. When the database is normally used, the password will not be verified, which does not affect the normal use of the database. After the maintenance mode is turned on, the correctness of the password will be verified and verified.

[0062] Step S300 Maintenance mode password verification: When the maintenance mode is started, the password used when the database directory is initialized is entered through the interactive interface returned by the database, the hash value of the input password is calculated, and the generated hash value is compared with the check value. If they are the same, the database is verified and can enter the maintenance mode.

[0063] As a specific implementation, maintenance mode password verification includes the following steps:

[0064] (1) When the maintenance mode is started, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is entered through the interactive interface;

[0065] (2) Using the MAC address of the user's local network card as the key, the input password is hashed using the HMAC SM3 hash algorithm. The generated hash value is compared with the check value in the MM.key file under the data directory data. If they are the same, the database is verified and can enter maintenance mode. Otherwise, it exits.

[0066] Step S400 maintenance mode starts: when the database enters maintenance mode, two specified template files are loaded. If at least one of the template files is loaded successfully, the database enters maintenance mode, wherein the two specified template files are initial form files formed after the database is initialized.

[0067] When the database enters maintenance mode, since it is uncertain whether the user data files of the current database are damaged, the database will start in an initialized form. During the startup process, it will search for template files accordingly. Template files are the files in the initial form of the database. After the database is initialized, two template files will be formed, namely template0 and template1 files. When entering maintenance mode, the database will try to load these two template files in turn. If one of them can be loaded successfully, it can enter maintenance mode. In maintenance mode, the database is in a state of a brand new database. The advantage of this is that when the database is in an abnormal state, there is no need to reinitialize the database directory to get a brand new library. The brand new library does not consider the data currently written by users, and the data written by users will not affect the function of the database itself.

[0068] After the database enters maintenance mode, in order to prevent other users' connection data from affecting the current recovery operation, the network connection will be closed in maintenance mode and other users' connections will be prohibited. In this way, the maintainer can perform corresponding operations in maintenance mode without being affected by other users.

[0069] Step S500: Data playback: In the maintenance mode, the data added by the user is played back through the data playback tool.

[0070] The database playback tool, Database Playback Tool, referred to as DP Tool, performs data playback through the database playback tool in this embodiment for several situations of abnormal database status. Since the database is in a brand new database state under database maintenance, there is no other user data, but the database is eventually restored to a previously available state, so it is necessary to play back the data that the user has added.

[0071] Data playback includes system data playback and user data playback.

[0072] When replaying system data, replay the system data file through the following command: DP –sysdata.

[0073] When entering maintenance mode, the database itself processes the initialization state. At this time, the system data is already in the database. At this time, replay will affect the system data of the database itself. At this time, when the system data is replayed, a temporary system table is created, the system table to be replayed is stored in the temporary system table, and the system table is connected to a test. If there is abnormal data in the original system table, for the abnormal system table with abnormal data, the abnormal system table is read line by line, and the normal data in the abnormal system table is stored in the temporary system table. When the abnormal data is read, the abnormal data is skipped, and the position of the abnormal data is recorded in the abnormal log, and the next line is read until the abnormal system table is read. The data in the temporary system table is copied to the normal table, and the data recorded in the abnormal log is discarded.

[0074] For example, when replaying the sys_user table, the table is used to store user information. When the database is connected, the information in this table is used. When performing data playback, a new sys_user_temp table is created in the database system, and then a connection test is performed on each user row in the table to ensure that its data is normal. The following two situations may occur:

[0075] Case 1: If the maintenance mode is used because a super-privileged user has forgotten the password, you can perform a reset operation to reset the super-user password. The command is as follows: DP-sysdata-sys_user-superuser-reset. At this time, the super-user password is reset and the initial password can be used to connect.

[0076] Case 2: The data file of the system data itself is damaged. When reading the original data, when the damaged block is read, the database will report an error, resulting in database abnormality. At this time, the abnormal table needs to be read line by line, and the normal data is placed in a temporary table. When the reading is abnormal, the abnormal block is skipped, and the position of the abnormality is recorded in the abnormal log. The next line is read until the reading of this data file is completed. At this time, the temporary table is full of normal data. The data in the temporary table is copied to the formal table, and the data recorded in the abnormal log is discarded.

[0077] The data file corresponding to the user data is a newly added physical file. When the user data is played back, the data is played back by copying the user data physical file.

[0078] As a specific implementation of user data playback, the following command is used to play back the user data file: DP –userdata.

[0079] User data is in a database, and the system data in the database itself is in a different file, that is, data files are newly added physical files, and they are not the same file as system data files, and data files generally have a large amount of data. Therefore, when playing back user data, the method of directly copying the user data physical file is adopted to speed up the playback speed of data files.

[0080] Step S600 Operation Audit: Log the operation process of maintenance mode password generation, maintenance mode password verification, maintenance mode startup and data playback, store the recorded operation log in the audit log, and view it through the audit log after the database recovers from the abnormal state.

[0081] Since the maintenance mode is an extremely high-authority mode, the entire operation needs to be audited during the maintenance process, and the entire operation process must be logged and stored in the audit log. When the database recovers from the abnormal state, the auditor can check through the audit log to see if there is any unauthorized or illegal operation during the maintenance process.

[0082] The method of this embodiment adds a maintenance mode to the database. When the database is in an abnormal state, the database is started in a minimum state and entered into an initialization state. The maintenance personnel can perform corresponding operations on the database according to the current abnormal state to restore it to a normal state.

[0083] Embodiment 2:

[0084] The invention discloses a database abnormal state repair system based on maintenance mode, comprising a maintenance mode construction module, a maintenance mode password generation module, a maintenance mode password verification module, a maintenance mode startup module, a data playback module and an operation audit module.

[0085] The maintenance mode construction module is used to perform the following: construct the maintenance mode of the database, the maintenance mode runs on the server where the database is located, and is started by the database main process.

[0086] When the database is in an abnormal state, it is impossible to connect to the database normally, and it is impossible to enter the database through a normal database connection. This embodiment designs a maintenance mode, which can only be run on the server where the database is located and is started through the main process of the database. As a specific implementation of the startup, the following command is used to enter the maintenance mode of the database: database start Maintenance Mode -D database data directory.

[0087] The maintenance mode password generation module is used to perform the following: use the password entered when the database directory is initialized as the maintenance mode password, enter the maintenance mode password through the interactive interface returned by the database when the database is initialized, calculate the hash value of the maintenance mode password as the verification value and store it in the database directory.

[0088] As a specific implementation, the maintenance mode password generation module is used to perform the following operations:

[0089] (1) When the database is initialized, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is input through the interactive interface as the maintenance mode password;

[0090] (2) Perform a complexity check on the maintenance mode password entered. The complexity check rule is: the minimum length is 8 characters and must include uppercase and lowercase letters, numbers, and characters;

[0091] (3) Perform hash calculation on the maintenance mode password that passes the complexity check, use the user's local network card physical address MAC address as the key, hash the maintenance mode password using the HMAC SM3 hash algorithm, store the obtained hash value as the check value in the MM.key file, and place the MM.key file in the data directory data of the database.

[0092] When entering maintenance mode, you can do any operation, and the permissions are too large, so at startup, a key is needed to manage the current login. This key has nothing to do with the database user, but is related to the password entered when the database directory is initialized. The password is hashed by a hash function and stored in the database's data directory as the key for starting maintenance mode. This file is set to MM.key. When the database is normally used, the password will not be verified, which does not affect the normal use of the database. After the maintenance mode is turned on, the correctness of the password will be verified and verified.

[0093] The maintenance mode password verification module is used to perform the following: when the maintenance mode is started, the password used when the database directory is initialized is entered through the interactive interface returned by the database, the hash value of the input password is calculated, and the generated hash value is compared with the check value. If they are the same, the database is verified and can enter the maintenance mode.

[0094] As a specific implementation, the maintenance mode password verification module is used to perform the following operations:

[0095] (1) When the maintenance mode is started, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is entered through the interactive interface;

[0096] (2) Using the MAC address of the user's local network card as the key, the input password is hashed using the HMAC SM3 hash algorithm. The generated hash value is compared with the check value in the MM.key file under the data directory data. If they are the same, the database is verified and can enter maintenance mode. Otherwise, it exits.

[0097] The maintenance mode startup module is used to execute the following: when the database enters the maintenance mode, two specified template files are loaded. If at least one of the template files is loaded successfully, the database enters the maintenance mode, wherein the two specified template files are the initial form files formed after the database is initialized.

[0098] When the database enters maintenance mode, since it is uncertain whether the user data files of the current database are damaged, the database will start in an initialized form. During the startup process, it will search for template files accordingly. Template files are the files in the initial form of the database. After the database is initialized, two template files will be formed, namely template0 and template1 files. When entering maintenance mode, the database will try to load these two template files in turn. If one of them can be loaded successfully, it can enter maintenance mode. In maintenance mode, the database is in a state of a brand new database. The advantage of this is that when the database is in an abnormal state, there is no need to reinitialize the database directory to get a brand new library. The brand new library does not consider the data currently written by users, and the data written by users will not affect the function of the database itself.

[0099] After the database enters maintenance mode, in order to prevent other users' connection data from affecting the current recovery operation, the network connection will be closed in maintenance mode and other users' connections will be prohibited. In this way, the maintainer can perform corresponding operations in maintenance mode without being affected by other users.

[0100] The data playback module is used to perform the following: In maintenance mode, the data added by the user is played back through the data playback tool.

[0101] The database playback tool, Database Playback Tool, referred to as DP Tool, performs data playback through the database playback tool in this embodiment for several situations of abnormal database status. Since the database is in a brand new database state under database maintenance, there is no other user data, but the database is eventually restored to a previously available state, so it is necessary to play back the data that the user has added.

[0102] Data playback includes system data playback and user data playback.

[0103] When replaying system data, the data playback module is used to replay the system data file through the following command: DP – sysdata.

[0104] When entering the maintenance mode, the database itself processes the initialization state. At this time, the system data is already in the database. At this time, the playback will affect the system data of the database itself. When the system data is played back, the data playback module is used to perform the following operations: create a temporary system table, store the system table that needs to be played back in the temporary system table, and perform a connection test on the system table. If there is abnormal data in the original system table, for the abnormal system table with abnormal data, read the abnormal system table line by line, and store the normal data in the abnormal system table in the temporary system table. When reading abnormal data, skip the abnormal data, record the position of the abnormal data in the abnormal log, and read the next line until the abnormal system table is finished reading, copy the data in the temporary system table to the normal table, and discard the data recorded in the abnormal log.

[0105] For example, when replaying the sys_user table, the table is used to store user information. When the database is connected, the information in this table is used. When performing data playback, a new sys_user_temp table is created in the database system, and then a connection test is performed on each user row in the table to ensure that its data is normal. The following two situations may occur:

[0106] Case 1: If the maintenance mode is used because a super-privileged user has forgotten the password, you can perform a reset operation to reset the super-user password. The command is as follows: DP-sysdata-sys_user-superuser-reset. At this time, the super-user password is reset and the initial password can be used to connect.

[0107] Case 2: The data file of the system data itself is damaged. When reading the original data, when the damaged block is read, the database will report an error, resulting in database abnormality. At this time, the abnormal table needs to be read line by line, and the normal data is placed in a temporary table. When the reading is abnormal, the abnormal block is skipped, and the position of the abnormality is recorded in the abnormal log. The next line is read until the reading of this data file is completed. At this time, the temporary table is full of normal data. The data in the temporary table is copied to the formal table, and the data recorded in the abnormal log is discarded.

[0108] The data file corresponding to the user data is a newly added physical file. When the user data is played back, the data is played back by copying the user data physical file.

[0109] As a specific implementation of user data playback, the data playback module is used to play back the user data file using the following command: DP – userdata.

[0110] User data is in a database, and the system data in the database itself is in a different file, that is, the data files are newly added physical files, and they are not the same file as the system data files, and the data files generally have a large amount of data. Therefore, when playing back user data, the data playback module uses the method of directly copying the user data physical file to speed up the playback of the data file.

[0111] The operation audit module is used to perform the following: log the operation process of maintenance mode password generation, maintenance mode password verification, maintenance mode startup and data playback, store the recorded operation log in the audit log, and view it through the audit log after the database recovers from the abnormal state.

[0112] Since the maintenance mode is an extremely high-authority mode, the entire operation needs to be audited during the maintenance process, and the entire operation process must be logged and stored in the audit log. When the database recovers from the abnormal state, the auditor can check through the audit log to see if there is any unauthorized or illegal operation during the maintenance process.

[0113] The system of this embodiment can execute the method disclosed in Example 1 to repair the abnormal state of the database.

[0114] The present invention has been shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the means in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.

Claims

1. A method for repairing abnormal state of a database based on maintenance mode, characterized in that: The steps include: Maintenance mode construction: Build the maintenance mode of the database. The maintenance mode runs on the server where the database is located and is started by the database master process; Maintenance mode password generation: The password entered when the database directory is initialized is used as the maintenance mode password. When the database is initialized, the maintenance mode password is entered through the interactive interface returned by the database. The hash value of the maintenance mode password is calculated and stored in the database directory as a verification value. Maintenance mode password verification: When the maintenance mode is started, the password used when the database directory is initialized is entered through the interactive interface returned by the database, the hash value of the entered password is calculated, and the generated hash value is compared with the checksum value. If they are the same, the verification is passed and the database can enter the maintenance mode. Maintenance mode startup: When the database enters maintenance mode, it loads two specified template files. If at least one of the template files is loaded successfully, the database enters maintenance mode. The two specified template files are the initial form files formed after the database is initialized. Data playback: In maintenance mode, the data added by the user can be played back through the data playback tool; Operation audit: Log the operation process of maintenance mode password generation, maintenance mode password verification, maintenance mode startup and data playback, store the recorded operation log in the audit log, and view it through the audit log after the database recovers from the abnormal state.

2. The method for repairing abnormal state of database based on maintenance mode according to claim 1, characterized in that: Generating a maintenance mode password includes the following steps: When the database is initialized, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is input through the interactive interface as the maintenance mode password; The complexity check is performed on the maintenance mode password entered. The complexity check rules are: the minimum length is 8 characters and must include uppercase and lowercase letters, numbers, and characters; Perform hash calculation on the maintenance mode password that has passed the complexity check, use the user's local network card physical address MAC address as the key, hash the maintenance mode password through the HMAC SM3 hash algorithm, store the obtained hash value as the check value in the MM.key file, and put the MM.key file into the data directory data of the database; Correspondingly, maintenance mode password verification includes the following steps: When the maintenance mode is started, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is entered through the interactive interface; Using the user's local network card physical address MAC address as the key, the input password is hashed through the HMAC SM3 hash algorithm, and the generated hash value is compared with the check value in the MM.key file under the data directory data. If they are the same, the database can enter the maintenance mode after verification, otherwise it exits.

3. The method for repairing abnormal state of database based on maintenance mode according to claim 1, characterized in that: During maintenance mode startup, after the database enters maintenance mode, the network connection is closed in maintenance mode.

4. The method for repairing abnormal state of a database based on maintenance mode according to claim 1, characterized in that: The data playback tool is the Database Playback tool.

5. The method for repairing abnormal state of database based on maintenance mode according to claim 1, characterized in that: Data playback includes system data playback and user data playback; When replaying system data, create a temporary system table, store the system table to be replayed in the temporary system table, and perform a connection test on the system table. If there is abnormal data in the original system table, read the abnormal system table line by line for the abnormal system table with abnormal data, and store the normal data in the abnormal system table in the temporary system table. When reading abnormal data, skip the abnormal data, record the position of the abnormal data in the abnormal log, and read the next line until the abnormal system table is finished reading. Copy the data in the temporary system table to the normal table, and discard the data recorded in the abnormal log; The data file corresponding to the user data is a newly added physical file. When the user data is played back, the data is played back by copying the user data physical file.

6. A database abnormal state repair system based on maintenance mode, characterized in that: Used to implement database abnormal state repair through a database abnormal state repair method based on maintenance mode as described in any one of claims 1 to 5, the system includes a maintenance mode construction module, a maintenance mode password generation module, a maintenance mode password verification module, a maintenance mode startup module, a data playback module and an operation audit module; The maintenance mode construction module is used to perform the following: construct the maintenance mode of the database, the maintenance mode runs on the server where the database is located, and is started by the database master process; The maintenance mode password generation module is used to perform the following: taking the password entered when the database directory is initialized as the maintenance mode password, when the database is initialized, entering the maintenance mode password through the interactive interface returned by the database, calculating the hash value of the maintenance mode password as a check value and storing it in the database directory; The maintenance mode password verification module is used to perform the following: when the maintenance mode is started, the password used when the database directory is initialized is input through the interactive interface returned by the database, the hash value of the input password is calculated, and the generated hash value is compared with the check value. If they are the same, the database can enter the maintenance mode after verification; The maintenance mode startup module is used to perform the following: when the database enters the maintenance mode, two specified template files are loaded. If at least one of the template files is loaded successfully, the database enters the maintenance mode, wherein the two specified template files are the initial form files formed after the database is initialized; The data playback module is used to perform the following: in maintenance mode, playback the data added by the user through the data playback tool; The operation audit module is used to perform the following: log the operation process of maintenance mode password generation, maintenance mode password verification, maintenance mode startup and data playback, store the recorded operation log in the audit log, and view it through the audit log after the database recovers from the abnormal state.

7. The database abnormal state repair system based on maintenance mode according to claim 6 is characterized in that: The maintenance mode password generation module is used to perform the following operations: When the database is initialized, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is input through the interactive interface as the maintenance mode password; The complexity check is performed on the maintenance mode password entered. The complexity check rules are: the minimum length is 8 characters and must include uppercase and lowercase letters, numbers, and characters; Perform hash calculation on the maintenance mode password that has passed the complexity check, use the user's local network card physical address MAC address as the key, hash the maintenance mode password through the HMAC SM3 hash algorithm, store the obtained hash value as the check value in the MM.key file, and put the MM.key file into the data directory data of the database; Correspondingly, the maintenance mode password verification module is used to perform the following operations: When the maintenance mode is started, an interactive interface for the maintenance mode password is returned through the database, and the password entered when the database directory is initialized is entered through the interactive interface; Using the user's local network card physical address MAC address as the key, the input password is hashed through the HMAC SM3 hash algorithm, and the generated hash value is compared with the check value in the MM.key file under the data directory data. If they are the same, the database can enter the maintenance mode after verification, otherwise it exits.

8. The database abnormal state repair system based on maintenance mode according to claim 6 is characterized in that: During the maintenance mode startup process, after the database enters the maintenance mode, the maintenance mode startup module is used to close the network connection in the maintenance mode.

9. The database abnormal state repair system based on maintenance mode according to claim 6, characterized in that: The data playback tool is the Database Playback tool.

10. The database abnormal state repair system based on maintenance mode according to claim 6, characterized in that: Data playback includes system data playback and user data playback; When replaying system data, the data replay module is used to perform the following: create a temporary system table, store the system table to be replayed in the temporary system table, and perform a connection test on the system table. If there is abnormal data in the original system table, for the abnormal system table with abnormal data, read the abnormal system table line by line, store the normal data in the abnormal system table in the temporary system table, and when the abnormal data is read, skip the abnormal data, record the position of the abnormal data in the abnormal log, and read the next line until the abnormal system table is finished reading, copy the data in the temporary system table to the normal table, and discard the data recorded in the abnormal log; The data file corresponding to the user data is a newly added physical file. When replaying the user data, the data replay module is used to replay the data by copying the user data physical file.

Citation Information

Patent Citations

  • Method for initializing database based on dynamic password

    CN102426592A

  • Method and system for mobile phone backup and data recovery

    CN103885858A

  • Database maintenance method and system

    CN110088744A

  • Database recovery method and device

    CN112988456A

  • Data content right confirmation method and system

    CN113378239A