WO2018192286A1 - Database switching method, master server and slave server - Google Patents

Database switching method, master server and slave server Download PDF

Info

Publication number
WO2018192286A1
WO2018192286A1 PCT/CN2018/074160 CN2018074160W WO2018192286A1 WO 2018192286 A1 WO2018192286 A1 WO 2018192286A1 CN 2018074160 W CN2018074160 W CN 2018074160W WO 2018192286 A1 WO2018192286 A1 WO 2018192286A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
databases
information
server
status information
Prior art date
Application number
PCT/CN2018/074160
Other languages
French (fr)
Chinese (zh)
Inventor
倪冬冬
田龙辉
Original Assignee
中国银联股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中国银联股份有限公司 filed Critical 中国银联股份有限公司
Publication of WO2018192286A1 publication Critical patent/WO2018192286A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1479Generic software techniques for error detection or fault masking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/80Database-specific techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software

Definitions

  • the embodiments of the present invention relate to the field of communications, and in particular, to a method for switching a database, a primary server, and a secondary server.
  • high availability refers to improving the high availability of the system by reducing the database abnormality caused by daily maintenance operations or sudden abnormalities.
  • the request related to the database can be transferred to other databases that can be in a normal state, so as to ensure the safe and efficient operation of the core business systems of the company and the enterprise.
  • the solution in the prior art is to select the node of the primary server in the database cluster, or the selection of multiple primary server boundary nodes in the same data and service processing, but if the database abnormality is caused by high frequency transactions or a large amount of data processing After switching to the normal working database, there will still be a database exception problem. Therefore, it is necessary to continuously switch the database, and it is necessary to continuously maintain an abnormal database, which seriously affects the operating efficiency and security of the system.
  • the embodiment of the invention provides a database switching method, a master server and a slave server, which are used for independent monitoring and switching between database groups by simple configuration, and contribute to high availability of the system.
  • an embodiment of the present invention provides a method for switching a database, including: obtaining, from a server, status information of each database in each group of at least two groups of databases; wherein each group of databases includes a primary database and At least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes a normal status And an abnormal state; the slave server sends the information of each database to the primary server, where the information of each database is used to cause the primary server to determine that the group identifier of the database is the same according to the state information of each database Whether the switching is performed between the databases; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database.
  • the state information of each database in each group of the at least two groups of databases is obtained from the server; wherein each of the groups of databases includes a primary database and at least one standby database, where each database corresponds to Any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status; and is classified according to a function type of the database.
  • At least two database groups form at least two sets of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, the primary server According to the status information of each database, it is determined whether the databases in the same group are switched; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups is realized through simple configuration, and thus Helps the high availability of the system.
  • the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one service type.
  • each group of the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold Corresponding to a set of databases.
  • the method further includes: the slave server periodically detecting each of the at least two groups of databases Status information of the database; the slave server performs an update operation on the historical state information of the database according to the state information of each database; the slave server acquires each database in each group of the at least two groups of databases
  • the status information includes: obtaining, by the server, status information of each database after the update, and the status information of each database after the new is the slave server according to the status information of each database to the database
  • the historical status information is obtained by the update operation.
  • the slave server periodically detects status information of each database in each of the at least two groups of databases, including: if the slave server determines that the total duration of the last update operation is not greater than the first pre- Setting the duration, starting from the last update operation, starting to detect the status information of each database of the at least two groups of databases after the first preset duration; if the slave server determines the total duration of the last update operation If it is greater than the first preset duration, the state information of each database of the at least two groups of databases is detected after the end of the last update operation.
  • an embodiment of the present invention provides a method for switching a database, including: a primary server receiving information of each database in each group of at least two groups of databases sent from a server; and the information of each database includes a database The identifier of the database, the group identifier of the database, and the state information of the database; the primary server determines, according to the state information of each database, whether to switch between databases with the same group identifier of the database.
  • the primary server determines, according to the status information of each database, whether to switch between databases with the same group identifier of the database, including: the primary server exists in a database that determines that the group identifier of the database is the same.
  • the database in which the database state information is an abnormal state switches the database in which the database state is a normal state.
  • the method includes:
  • the primary server determines, according to the status information of each database, whether the database with the same group identifier of the database is performed. Switching; when the primary server determines that the duration of transmitting the information of each database is greater than the second preset duration, the primary server sends a request for obtaining information of each database to the secondary server.
  • an embodiment of the present invention provides a slave server for switching a database, including: an acquiring unit, configured to acquire state information of each database in each group of databases in at least two groups of databases; wherein each group of databases Included as a primary database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function;
  • the status information includes a normal status and an abnormal status;
  • the sending unit is configured to send the information of each database to the primary server, where the information of each database is used to cause the primary server to determine according to status information of each database Whether the group of the database identifies the same database is switched; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the state information of the database.
  • the state information of each database in each group of the at least two groups of databases is obtained from the server; wherein each of the groups of databases includes a primary database and at least one standby database, where each database corresponds to Any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status; and is classified according to a function type of the database.
  • At least two database groups form at least two sets of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, the primary server According to the status information of each database, it is determined whether the databases in the same group are switched; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups is realized through simple configuration, and thus Helps the high availability of the system.
  • the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one service type.
  • each group of the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold Corresponding to a set of databases.
  • the method further includes: a detecting unit, configured to: periodically detect state information of each database in each of the at least two groups of databases; and further include an updating unit, configured to: according to each database The status information is used to update the historical status information of the database; the obtaining unit is configured to: obtain status information of each updated database, and the status information of each new database is the update The unit obtains an update operation on the historical state information of the database according to the state information of each database.
  • the detecting unit is configured to: if it is determined that the total duration of the last update operation is not greater than the first preset duration, start from the last update operation, and start the detection after the first preset duration State information of each database of at least two groups of databases; if the slave server determines that the total duration of the last update operation is greater than the first preset duration, detecting the at least two groups of databases from the end of the last update operation Status information for each database.
  • an embodiment of the present invention provides a primary server for database switching, including: a receiving unit, configured to receive information about each database in each group of databases in at least two groups of databases sent from a server; The information includes the identifier of the database, the group identifier of the database, and the state information of the database.
  • the determining unit is configured to determine, according to the state information of each database, whether to switch between databases with the same group identifier of the database.
  • the determining unit is configured to: when determining that the database having the same group identifier of the database has at least one database in which the database state information is in a normal state, the database state information is an abnormal state database switch
  • the database status is a database of normal status.
  • the determining unit is configured to: when determining that the duration of the information for transmitting each database is not greater than a second preset duration, the determining unit determines the group of the database according to the state information of each database Identifying whether switching is performed between the same databases; when the determining unit determines that the duration of transmitting the information of each database is greater than the second preset duration, the determining unit sends the information of obtaining each database to the slave server. Request.
  • an embodiment of the present invention provides an electronic device, including: a processor, a memory, a transceiver, and a bus interface, wherein a processor, a memory, a transceiver, and a bus interface are connected by a bus;
  • the processor is configured to read a program in the memory, and perform the following method: acquiring state information of each database in each group of at least two groups of databases; wherein each group of databases includes a primary database and At least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes a normal status And abnormal state;
  • the memory is configured to store one or more executable programs, and may store data used by the processor when performing operations;
  • the transceiver is configured to send information about each database to a primary server under control of the processor, where information of each database is used to cause the primary server to obtain status information according to each database Determining whether to switch between databases with the same group identifier of the database; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database.
  • another electronic device including: a processor, a memory, a transceiver, and a bus interface, wherein a processor, a memory, a transceiver, and a bus interface are connected by a bus;
  • the transceiver is configured to receive information about each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
  • the processor is configured to read a program in the memory, and perform the following method: determining, according to status information of each database, whether to switch between databases with the same group identifier of the database;
  • the memory is configured to store one or more executable programs, and may store data used by the processor when performing operations.
  • an embodiment of the present application provides a non-transitory computer readable storage medium, where a computer storage medium stores instructions that, when run on a computer, cause the computer to perform any of the first aspect or the first aspect.
  • an embodiment of the present application provides a computer program product comprising instructions, when executed on a computer, causing a computer to perform the method in the first aspect or any possible implementation manner of the first aspect, or cause the computer to execute The method of any of the second aspect or any possible implementation of the second aspect.
  • the state information of each database in each group of the at least two groups of databases is obtained from the server; wherein each of the groups of databases includes a primary database and at least one standby database, where each database corresponds to Any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status; and is classified according to a function type of the database.
  • At least two database groups form at least two sets of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, the primary server According to the status information of each database, it is determined whether the databases in the same group are switched; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups is realized through simple configuration, and thus Helps the high availability of the system.
  • FIG. 1 is a schematic structural diagram of a communication system according to an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a method for switching a database according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a slave server according to an embodiment of the present disclosure.
  • FIG. 4 is a schematic structural diagram of a main server according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of another electronic device according to an embodiment of the present invention.
  • GSM Global System of Mobile Communication
  • CDMA Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • GPRS General Packet Radio Service
  • LTE Long Term Evolution
  • FDD Frequency Division Duplex
  • TDD Time Division Duplex
  • UMTS Universal Mobile Telecommunication System
  • WiMAX Worldwide Interoperability for Microwave Access
  • FIG. 1 is a schematic block diagram showing a communication system to which an embodiment of the present invention is applied.
  • the communication system includes a database cluster 101, a slave server 102, and a master server 103.
  • the primary server and the secondary server are connected by wireless connection or wired connection or other means, and the server is connected to each database in the database cluster through a wireless connection or a wired connection or the like.
  • the database cluster 101 includes at least two groups of databases, a database group 104 and a database group 105.
  • the database groups 104 and 105 respectively include a primary database and at least one standby database.
  • the database group 104 includes a primary database 104a and a standby database 104b.
  • the database group 105 includes a primary database. Database 105a and standby database 105b.
  • the PSY is used for data synchronization between the primary database and the standby database to ensure synchronization of data in the primary database and the standby database.
  • Each set of databases corresponds to any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; for example, the database cluster includes two sets of databases 104 and 105, the two sets of databases.
  • the query function corresponds to a group of databases 104, and the adding function, deleting function, and changing function correspond to another group of databases 105; wherein each type of database corresponds to at least one set of data, and the query function corresponds to at least one set of databases; at least one Each group of databases in the group database corresponds to at least one type of service, wherein the types of services include: cash withdrawal, consumption, and query balance.
  • the slave module is deployed from the server 102.
  • the slave module includes a database detection process HCS_DB106a ⁇ HCS_DB106d, a database group monitoring process HCS_MON_AGENT107a and an HCS_MON_AGENT107b, and a database information sending process UDP_SEND108.
  • the database detecting process HCS_DB106 is used to detect the status of all databases connected to the slave server. Information, each data corresponding to a database detection process HCS_DB is used to detect the status information of the data; that is, in the system, the database detection process HCS_DB 106a is used to detect the database status information of the database 104a; the HCS_DB 106b is used to detect the database status information of the database 104b.
  • the HCS_DB 106c is used to detect the database state information of the database 105a, and the HCS_DB 106d is used to detect the database state information of the database 105b; each group of databases starts a database group monitoring process HCS_MON_AGENT to obtain the information of the database of each group, that is, the HCS_MON_AGENT 107a is used to acquire the database group.
  • the database information of 104, HCS_MON_AGENT 107b is used to obtain the database information of the database group 105; the information sending process of the database UDP_SEND 108 is used to serve the main service HCS_MON_AGENT107a ⁇ 103 transmits information database HCS_MON_AGENT107b each retrieved database group monitoring process.
  • the database monitoring and switching master module is deployed on the primary server 103.
  • the database monitoring and switching master module includes a receiving process Infcollection 109 and a decision process Infdecision 110.
  • the receiving process Infcollection 109 is configured to receive information of a database sent from the server;
  • the decision process Infdecision 110 is configured to determine whether the database needs to be switched according to the received information of the database sent from the server.
  • FIG. 2 exemplarily shows a flow chart of a method for switching a database according to an embodiment of the present invention.
  • the database switching method provided by the embodiment of the present invention includes the following steps. :
  • Step S201 Obtain state information of each database in each group of the at least two groups of databases from the server; wherein each group of databases includes a primary database and at least one standby database, and each group of databases corresponds to any one of four functional types. Or any of a variety of; four types of functions include adding functions, deleting functions, changing functions, and query functions; status information includes normal status and abnormal status;
  • Step S202 the information of each database is sent from the server to the primary server, where the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
  • Step S203 the primary server receives information of each database in each of the at least two groups of databases sent from the server;
  • Step S204 The primary server determines, according to the status information of each database, whether to switch between databases with the same group identifier of the database.
  • the status information of each database in each group of the at least two groups of databases is obtained from the server; wherein each group of databases includes a primary database and at least one standby database, and each group of databases corresponds to four functional types. Any one or more of the four types of functions include adding functions, deleting functions, changing functions, and query functions; status information includes normal status and abnormal status; and dividing into at least two database groups according to the function type of the database to form mutual Independent at least two groups of databases, each of which is independent of data; information of each database in each of the at least two groups of databases is sent to the primary service, and the primary server determines based on the status information of each database Whether to switch between databases in the same group; thus, data between the same group identifier can be switched, and independent monitoring and switching between database groups can be realized through simple configuration, thereby contributing to high availability of the database.
  • the status information of each database in each group of the at least two groups of databases is obtained from the server, and each group of databases corresponds to any one or more of the four types of functions, and the four functions include adding functions. , delete function, change function and query function; among them, the database query function is used frequently.
  • the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one type of service.
  • the query function corresponds to at least one set of databases
  • the add function, the delete function, and the change function correspond to at least another set of databases
  • each set of databases corresponds to at least one service type, and the service type includes cash withdrawal, transfer, consumption, pre-authorization. Or the account settlement, etc.
  • the set of databases corresponding to the query function includes at least one set of databases, and the database corresponding to the query function may also be divided into multiple sets of databases according to the service type
  • the function of adding, deleting, and changing functions is correspondingly
  • a set of databases which can also correspond to a set of databases or groups of databases based on the type of business.
  • the query function corresponds to at least one group of databases, each of the at least one group of databases corresponding to at least one type of service, including: a transaction type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; A business type with a quantity greater than the quantity threshold corresponds to a set of databases.
  • the query function corresponds to a set of databases
  • the set of databases includes a primary database and at least one standby database.
  • the group of databases corresponding to the query function the group can continue to be divided into multiple groups, for example, a service type whose transaction frequency is greater than the frequency threshold corresponds to a group of databases, and a service type whose transaction frequency is not greater than the frequency threshold corresponds to another group of databases;
  • the service type whose transaction quantity is greater than the quantity threshold corresponds to a group of databases, and the service type whose transaction quantity is not greater than the quantity threshold corresponds to another group of databases; or in the group of databases corresponding to the query function, the transaction frequency is greater than
  • the service type of the frequency threshold and the number of transactions is greater than the quantity threshold corresponds to one set of databases, and the other corresponds to another set of databases.
  • any one or more of the plurality of function types corresponding to the group of databases wherein each group of databases corresponds to at least one type of service, and the group of databases corresponding to any one or more of the plurality of types of functions may be selected according to the type of the service.
  • the grouping continues, for example, the service type whose transaction frequency is greater than the frequency threshold corresponds to a group of databases; and/or; the service type whose transaction quantity is greater than the quantity threshold corresponds to a group of databases.
  • the method further includes: periodically detecting, by the server, status information of each database in each group of the at least two groups of databases;
  • the slave server updates the historical state information of the database according to the state information of each database; and obtains, from the server, state information of each database in each group of the at least two groups of databases, including: obtaining each database after the update from the server The status information, and the status information of each new database is obtained by the server updating the historical status information of the database according to the status information of each database.
  • a plurality of databases are associated from the server, and the database detection process HCS_DB on the server is used to periodically detect the state information of each data associated with the slave server, assuming that the database detection process HCS_DB probes the database period.
  • the database detection process HCS_DB performs a probe on the associated database every cycle T, and the slave server updates the history state information of the database according to the state information of each database.
  • the update operation takes a certain amount of time to complete. The time to start the database probe process HCS_DB next time is determined according to the time of the update operation process.
  • the server periodically detects status information of each database in each group of the at least two groups of databases, including: if the slave server determines that the total duration of the last update operation is not greater than the first preset duration, then Starting from an update operation, starting to detect status information of each database of at least two groups of databases after a first preset duration; if the slave server determines that the total duration of the last update operation is greater than the first preset duration, then updating from the previous update At the end of the operation, the status information of each database of at least two groups of databases is detected.
  • the first preset duration may be equal to the period T.
  • the historical state information of the database is updated according to the state information of each database; after the database detection process HCS_DB updates the state information of the database,
  • the server starts the database group monitoring process HCS_MON_AGENT to obtain the status information of the updated database.
  • the database group monitoring process HCS_MON_AGENT determines whether the time for obtaining the state information of the updated database is greater than the third preset duration, wherein the third preset duration may be the same as the period.
  • the historical state information of the database in the database group monitoring process HCS_MON_AGENT is updated according to each database state information acquired; after the update is completed, the next acquisition of each of the at least two groups of databases is performed.
  • Status information of each database in the database determining the database group identifier corresponding to each database obtained according to the mapping relationship between the identifier of the preset database and the database group identifier.
  • the database group monitoring process HCS_MON_AGENT re-acquires the database state information after the database detection process HCS_DB is updated, until the database group monitoring process HCS_MON_AGENT determines that the time of obtaining the updated database state information is not greater than the third pre-
  • the duration is set, the historical state information of the database in the database group monitoring process HCS_MON_AGENT is updated according to each database state information acquired, and after the sleep T duration, the next database in each group of at least two groups of databases is acquired next time. Status information.
  • the database detection process HCS_DB is detecting the corresponding data state information, and the corresponding database state information to be updated is in the protection zone, and the database group monitoring process HCS_MON_AGENT cannot read the database state information in the protection zone.
  • the information sending process UDP_SEND of the database on the server sends information of each database in each of the at least two groups of databases updated in the database group monitoring process HCS_MON_AGENT to the primary server, on the primary server.
  • the receiving process Infcollection receives information of each database in each of the at least two sets of databases in the updated database.
  • the method further includes: determining, by the primary server, whether the duration of the process of receiving the process from the server to the primary server is greater than a second preset duration, and the primary server determines to transmit each database.
  • the primary server determines whether to switch between databases with the same group identifier of the database according to the state information of each database.
  • the primary server sends a request for obtaining information of each database to the secondary server when determining that the information of each database is transmitted for each database to be longer than the second predetermined duration. In this way, it is possible to prevent the primary server from obtaining the history database information due to the link interruption between the primary server and the secondary server.
  • the decision process Infdecision on the primary server each The status information of the database determines whether the database has the same group ID for the switch.
  • An embodiment of the present invention provides an optional implementation manner: when the primary server determines that at least one database whose state information is in a normal state exists in a database having the same group identifier of the database, the database state information is an abnormal state database. Switch the database whose database status is normal. In the embodiment of the present invention, independent monitoring and switching of multiple groups of databases is realized by a simple configuration, and multiple groups of databases are not interfered with each other. When it is determined that the database status information is abnormal, it can be automatically switched to the database of other normal status of the group.
  • the primary server determines whether there is a database in which the database state information is an abnormal state in the database with the same group identifier of the database, and if so, whether there is a database in which the database state information is in a normal state in the database having the same group identifier. If it exists, the database whose database state information is abnormal is switched to the data whose database state information is normal. If there is no abnormal database in the same database with the same group ID, the database will not be processed. If the database has the same group ID, the database will not be processed. That is, the switching of the database is only performed in the group, and no switching is performed between different groups. In this way, independent monitoring and switching between multiple groups of databases can be realized, thereby contributing to high availability of the system.
  • the primary server receives database information of two groups of databases.
  • the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database.
  • group 1 includes two databases, and the identifiers of the database are 1A and 1B, respectively.
  • the standby database 1B indicates the standby database, the status information of the primary database 1A is the normal state, and the state information of the standby database 1B is the abnormal state; then the standby database 1B is switched to the primary database 1A; the group 2 includes two databases, the identification of the database 2A and 2B, 2A represents the primary database, 2B represents the standby database, the status information of the primary database 2A is abnormal, and the state of the standby database 2B is abnormal; no switching is performed. Even if the database in the normal state in the group 1 does not perform the switching operation, the database switching is not performed, so that the high-availability independent monitoring and switching of the multiple groups of databases can be guaranteed.
  • FIG. 3 is a schematic structural diagram of a slave server for database switching according to an embodiment of the present invention.
  • the slave server 300 includes an obtaining unit 301, a sending unit 302, and a detecting unit 303 and an updating unit 304. among them:
  • An obtaining unit configured to obtain state information of each database in each group of databases in at least two groups of databases; wherein each group of databases includes a primary database and at least one standby database, and each group of databases corresponds to any one of four functional types Or a plurality of types; the four function types include an add function, a delete function, a change function, and a query function; the status information includes a normal state and an abnormal state; and a sending unit is configured to send information of each database to the primary server, each database The information is used to enable the primary server to determine whether to switch between databases with the same group identifier of the database according to the status information of each database; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the state information of the database.
  • the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one type of service.
  • each group of the database in the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold corresponds to a Group database.
  • the method further includes: a detecting unit, configured to: periodically detect state information of each database in each group of the at least two groups of databases; and further include: an updating unit, configured to: use the state information of each database to the database The history status information is updated; the obtaining unit is configured to: obtain status information of each database after the update, and the status information of each database after the update is an update unit according to the status information of each database to the history of the database The status information is obtained by the update operation.
  • a detecting unit configured to: periodically detect state information of each database in each group of the at least two groups of databases
  • an updating unit configured to: use the state information of each database to the database The history status information is updated
  • the obtaining unit is configured to: obtain status information of each database after the update, and the status information of each database after the update is an update unit according to the status information of each database to the history of the database The status information is obtained by the update operation.
  • the detecting unit is configured to: if it is determined that the total duration of the last update operation is not greater than the first preset duration, start from the last update operation, and start detecting the at least two groups of databases after the first preset duration Status information of each database; if the slave server determines that the total duration of the last update operation is greater than the first preset duration, the status information of each database of at least two groups of databases is detected after the end of the last update operation.
  • each group of databases includes a primary database and at least one standby database
  • each The group database corresponds to any one or more of the four function types;
  • the four function types include an add function, a delete function, a change function, and a query function;
  • the status information includes a normal state and an abnormal state;
  • the at least according to the function type of the database is divided into at least Two database groups form at least two groups of databases independent of each other, and data between each group is independent of each other;
  • information of each database in each group database of at least two groups of databases is sent to the main service, and the main server is based on
  • the status information of each database determines whether the data is switched between the databases in the same group; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups can be realized through simple configuration, and thus Helps the high availability of the system.
  • FIG. 4 is a schematic structural diagram of a main server for database switching according to an embodiment of the present invention.
  • the primary server 400 includes a receiving unit 401 and a decision unit 402. among them:
  • a receiving unit configured to receive information about each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
  • the determining unit is configured to determine, according to the state information of each database, whether to switch between databases with the same group identifier of the database.
  • the determining unit is configured to: when the database having the same group identifier of the same database has at least one database whose state information is in a normal state, the database state information is an abnormal state, and the database switching database state is a normal state. database.
  • the determining unit is configured to: when determining that the duration of the information for transmitting each database is not greater than the second preset duration, the determining unit determines, according to the state information of each database, whether the database with the same group identifier of the database is performed. Switching; when the decision unit determines that the duration of transmitting the information of each database is greater than the second preset duration, the decision unit sends a request for obtaining information of each database to the slave server.
  • each group of databases includes a primary database and at least one standby database
  • each The group database corresponds to any one or more of the four function types;
  • the four function types include an add function, a delete function, a change function, and a query function;
  • the status information includes a normal state and an abnormal state;
  • the at least according to the function type of the database is divided into at least Two database groups form at least two groups of databases independent of each other, and data between each group is independent of each other;
  • information of each database in each group database of at least two groups of databases is sent to the main service, and the main server is based on
  • the status information of each database determines whether the data is switched between the databases in the same group; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups can be realized through simple configuration, and thus Helps the high availability of the system.
  • FIG. 5 is a schematic structural diagram of an electronic device provided by the present application.
  • the electronic device includes a processor 501, a memory 502, a transceiver 503, and a bus interface 504; wherein the processor 501, the memory 502, the transceiver 503, and the bus interface 504 are connected to one another via a bus 505.
  • the memory 502 is for storing a program; specifically, the program may include program code, and the program code includes computer operation instructions.
  • the memory 502 may include a volatile memory such as a random-access memory (RAM); the memory may also include a non-volatile memory such as a flash memory (flash) Memory), hard disk drive (HDD) or solid-state drive (SSD); the memory 502 may also include a combination of the above types of memory.
  • RAM random-access memory
  • flash flash memory
  • HDD hard disk drive
  • SSD solid-state drive
  • the memory 502 stores the following elements, executable modules or data structures, or a subset thereof, or an extended set thereof:
  • Operation instructions include various operation instructions for implementing various operations.
  • Operating system Includes a variety of system programs for implementing various basic services and handling hardware-based tasks.
  • the bus 505 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in Figure 5, but it does not mean that there is only one bus or one type of bus.
  • the bus interface 504 can be a wired communication access port, a wireless bus interface, or a combination thereof, wherein the wired bus interface can be, for example, an Ethernet interface.
  • the Ethernet interface can be an optical interface, an electrical interface, or a combination thereof.
  • the wireless bus interface can be a WLAN interface.
  • the processor 501 can be a central processing unit (CPU), a network processor (NP) or a combination of a CPU and an NP. It can also be a hardware chip.
  • the hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof.
  • the PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (GAL) or any combination.
  • the processor 501 is configured to read a program in the memory 502, and perform the following method: acquiring state information of each database in each group of at least two groups of databases; wherein each group of databases includes one master a database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes Normal state and abnormal state;
  • the memory 502 is configured to store one or more executable programs, and may store data used by the processor 501 when performing operations;
  • the transceiver 503 is configured to send information about each database to a primary server under control of the processor 501, where the information of each database is used to make the primary server according to each database
  • the status information determines whether a switch is performed between databases having the same group identifier of the database; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database. .
  • the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one service type.
  • each group of the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold Corresponding to a set of databases.
  • the processor is configured to periodically detect state information of each database in each of the at least two groups of databases; and historical state of the database according to status information of each database The information is updated; the status information of each database after the update is obtained, and the status information of each database after the update is historical status information of the database by the update unit according to the status information of each database. Get the update operation.
  • the processor is configured to: if it is determined that the total duration of the last update operation is not greater than the first preset duration, start from the last update operation, and start the detection after the first preset duration State information of each database of at least two groups of databases; if it is determined that the total duration of the last update operation is greater than the first preset duration, detecting each database of the at least two groups of databases from the end of the last update operation status information.
  • the sending unit 302 can be implemented by a transceiver, and the obtaining unit 301, the detecting unit 303, and the updating unit 304 can be implemented by a processor.
  • the electronic device 500 can include a processor 501, a transceiver 503, and a memory 502.
  • the memory 502 can be used to store a program/code pre-installed at the time of shipment of the electronic device 500, and can also store a code or the like for execution of the processor 501.
  • each group of databases includes one master a database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes Normal state and abnormal state; according to the function type of the database, it is divided into at least two database groups to form at least two groups of databases independent of each other, and the data between each group is independent of each other;
  • the information of each database is sent to the main service, and the main server determines whether to switch between the databases in the same group according to the status information of each database; thus, the data between the same group identifiers can be switched, through simple configuration. Implement independent monitoring and switching between database groups, which in turn helps the system Availability.
  • FIG. 6 is a schematic structural diagram of another electronic device provided by the present application.
  • the electronic device includes a processor 601, a memory 602, a transceiver 603, and a bus interface 604; wherein the processor 601, the memory 602, the transceiver 603, and the bus interface 604 are connected to one another via a bus 605.
  • the memory 602 is for storing a program; specifically, the program may include program code, and the program code includes computer operation instructions.
  • the memory 602 may include a volatile memory such as a random-access memory (RAM); the memory may also include a non-volatile memory such as a flash memory (flash) Memory), hard disk drive (HDD) or solid-state drive (SSD); the memory 602 may also include a combination of the above types of memory.
  • RAM random-access memory
  • flash flash memory
  • HDD hard disk drive
  • SSD solid-state drive
  • Memory 602 stores the following elements, executable modules or data structures, or subsets thereof, or their extended sets:
  • Operation instructions include various operation instructions for implementing various operations.
  • Operating system Includes a variety of system programs for implementing various basic services and handling hardware-based tasks.
  • the bus 605 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in Figure 6, but it does not mean that there is only one bus or one type of bus.
  • the bus interface 604 can be a wired communication access port, a wireless bus interface, or a combination thereof, wherein the wired bus interface can be, for example, an Ethernet interface.
  • the Ethernet interface can be an optical interface, an electrical interface, or a combination thereof.
  • the wireless bus interface can be a WLAN interface.
  • the processor 601 can be a central processing unit (CPU), a network processor (NP) or a combination of a CPU and an NP. It can also be a hardware chip.
  • the hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof.
  • the PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (GAL) or any combination.
  • the processor 601 is configured to read a program in the memory 602, and perform the following method: determining, according to status information of each database, whether to switch between databases with the same group identifier of the database;
  • the memory 602 is configured to store one or more executable programs, and may store data used by the processor 601 when performing an operation;
  • the transceiver 603 is configured to receive, under the control of the processor 601, information of each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, The group ID of the database and the status information of the database.
  • the processor 601 is configured to: when the database in which the at least one database state information is in a normal state exists in a database in which the group identifier of the database is the same, the database state information is an abnormal state database switch.
  • the database status is a database of normal status.
  • the processor 601 is configured to: when determining that the duration of the information for transmitting each database is not greater than the second preset duration, determine, according to the state information of each database, a database with the same group identifier of the database. Whether switching is performed between; when it is determined that the duration of transmitting the information of each database is greater than the second preset duration, a request to acquire information of each database is sent to the slave server.
  • the receiving unit 401 can be implemented by a transceiver
  • the determining unit 402 can be implemented by a processor.
  • the electronic device 600 can include a processor 601, a transceiver 603, and a memory 602.
  • the memory 602 can be used to store a program/code pre-installed when the electronic device 600 is shipped from the factory, or a code for the execution of the processor 601, and the like.
  • each group of databases includes one master a database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes Normal state and abnormal state; according to the function type of the database, it is divided into at least two database groups to form at least two groups of databases independent of each other, and the data between each group is independent of each other;
  • the information of each database is sent to the main service, and the main server determines whether to switch between the databases in the same group according to the status information of each database; thus, the data between the same group identifiers can be switched, through simple configuration. Implement independent monitoring and switching between database groups, which in turn helps the system High availability.
  • embodiments of the invention may be provided as a method, system, or computer program product.
  • embodiments of the invention may be in the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware.
  • embodiments of the invention may take the form of a computer program product embodied on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • Embodiments of the invention are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG.
  • These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Databases & Information Systems (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Disclosed are a database switching method, master server and slave server, the method comprising: acquiring state information of each database from each group of databases of at least two groups of databases, wherein each group of databases comprises one main database and at least one standby database, and each group of databases corresponds to one or more of four function types comprising an addition function, a deletion function, a modification function and a query function, and the state information comprises a normal state and an abnormal state; sending information of each database to a master server, the information of each database being used to enable the master server to determine, according to the state information of each database, whether to perform switching between databases having the same database group identifier, wherein the information of each database comprises a database identifier, a database group identifier and state information of a database.

Description

一种数据库的切换方法、主服务器以及从服务器Method for switching database, primary server and secondary server
本申请要求在2017年04月18日提交中国专利局、申请号为201710253569.2、发明名称为“一种数据库的切换方法、主服务器以及从服务器”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to Chinese Patent Application No. 200910253569.2, entitled "A database switching method, master server and slave server", filed on April 18, 2017, the entire contents of which are incorporated by reference. Combined in this application.
技术领域Technical field
本发明实施例涉及通信领域,尤其涉及一种数据库的切换方法、主服务器以及从服务器。The embodiments of the present invention relate to the field of communications, and in particular, to a method for switching a database, a primary server, and a secondary server.
背景技术Background technique
随着信息化技术的快速发展,数据呈现爆炸式增长,随之用于管理数据的数据库就越来越重要了。当数据库出现异常时,需要维护数据导致数据停止工作,甚至由于数据库异常导致数据库中数据丢失,如此可能会给企业和用户带来难以估计的经济损失。因此,采取适当的措施来确保数据库集群的高可用性是非常必要的,这里高可用性是指通过减少因日常维护操作或突发异常导致数据库异常的现象,以提高系统的高可用性。例如,当某一数据库发生异常时,可以将与该数据库相关的请求转移到其他可以处于正常状态的数据库上,这样可以保证公司和企业的核心业务系统安全、高效的运行。With the rapid development of information technology, data is exploding, and the database for managing data is becoming more and more important. When an abnormality occurs in the database, maintenance of data is required to stop the data, and even data loss in the database due to database anomalies may cause economic losses that are difficult to estimate for enterprises and users. Therefore, it is necessary to take appropriate measures to ensure the high availability of the database cluster. Here, high availability refers to improving the high availability of the system by reducing the database abnormality caused by daily maintenance operations or sudden abnormalities. For example, when an abnormality occurs in a database, the request related to the database can be transferred to other databases that can be in a normal state, so as to ensure the safe and efficient operation of the core business systems of the company and the enterprise.
现有技术中解决方法是针对数据库集群中主服务器的节点选取,或是相同数据和业务处理中多个主服务器界节点的选取,但是如果数据库异常是由于高频交易或者大量的数据处理导致的,在切换到正常工作的数据库后仍会出现数据库异常的问题,如此,需要不停的切换数据库,而且需要不停的维护出现异常的数据库,严重影响到系统的运行效率和安全性。The solution in the prior art is to select the node of the primary server in the database cluster, or the selection of multiple primary server boundary nodes in the same data and service processing, but if the database abnormality is caused by high frequency transactions or a large amount of data processing After switching to the normal working database, there will still be a database exception problem. Therefore, it is necessary to continuously switch the database, and it is necessary to continuously maintain an abnormal database, which seriously affects the operating efficiency and security of the system.
发明内容Summary of the invention
本发明实施例提供一种数据库的切换方法、主服务器以及从服务器,用 于通过简单的配置实现数据库组之间的独立监控与切换,有助于系统的的高可用性。The embodiment of the invention provides a database switching method, a master server and a slave server, which are used for independent monitoring and switching between database groups by simple configuration, and contribute to high availability of the system.
第一方面,本发明实施例提供一种数据库的切换方法,包括:从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;所述从服务器向主服务器发送所述每个数据库的信息,所述每个数据库的信息用于使所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。In a first aspect, an embodiment of the present invention provides a method for switching a database, including: obtaining, from a server, status information of each database in each group of at least two groups of databases; wherein each group of databases includes a primary database and At least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes a normal status And an abnormal state; the slave server sends the information of each database to the primary server, where the information of each database is used to cause the primary server to determine that the group identifier of the database is the same according to the state information of each database Whether the switching is performed between the databases; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database.
由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,通过简单的配置实现数据库组之间的独立监控与切换,进而有助于系统的的高可用性。In the embodiment of the present invention, the state information of each database in each group of the at least two groups of databases is obtained from the server; wherein each of the groups of databases includes a primary database and at least one standby database, where each database corresponds to Any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status; and is classified according to a function type of the database. At least two database groups form at least two sets of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, the primary server According to the status information of each database, it is determined whether the databases in the same group are switched; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups is realized through simple configuration, and thus Helps the high availability of the system.
可选地,所述查询功能对应至少一组数据库;所述至少一组数据库中的每组数据库分别对应至少一种业务类型。Optionally, the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one service type.
可选地,所述至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:交易频率大于频率阈值的业务类型对应一组数据库;和/或;交易数量大于数量阈值的业务类型对应一组数据库。Optionally, each group of the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold Corresponding to a set of databases.
可选地,所述从服务器获取至少两组数据库中每组数据库中的每个数据 库的状态信息之前,还包括:所述从服务器周期性探测所述至少两组数据库中每组数据库中的每个数据库的状态信息;所述从服务器根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作;所述从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息,包括:所述从服务器获取更新后的每个数据库的状态信息,所述跟新后的每个数据库的状态信息是所述从服务器根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作得到的。Optionally, before the obtaining, by the server, status information of each database in each of the two groups of databases, the method further includes: the slave server periodically detecting each of the at least two groups of databases Status information of the database; the slave server performs an update operation on the historical state information of the database according to the state information of each database; the slave server acquires each database in each group of the at least two groups of databases The status information includes: obtaining, by the server, status information of each database after the update, and the status information of each database after the new is the slave server according to the status information of each database to the database The historical status information is obtained by the update operation.
可选地,所述从服务器周期性探测所述至少两组数据库中每组数据库中的每个数据库的状态信息,包括:所述从服务器若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过所述第一预设时长后开始探测所述至少两组数据库的每个数据库的状态信息;所述从服务器若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测所述至少两组数据库的每个数据库的状态信息。Optionally, the slave server periodically detects status information of each database in each of the at least two groups of databases, including: if the slave server determines that the total duration of the last update operation is not greater than the first pre- Setting the duration, starting from the last update operation, starting to detect the status information of each database of the at least two groups of databases after the first preset duration; if the slave server determines the total duration of the last update operation If it is greater than the first preset duration, the state information of each database of the at least two groups of databases is detected after the end of the last update operation.
第二方面,本发明实施例提供一种数据库的切换方法,包括:主服务器接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。In a second aspect, an embodiment of the present invention provides a method for switching a database, including: a primary server receiving information of each database in each group of at least two groups of databases sent from a server; and the information of each database includes a database The identifier of the database, the group identifier of the database, and the state information of the database; the primary server determines, according to the state information of each database, whether to switch between databases with the same group identifier of the database.
可选地,所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换,包括:所述主服务器在确定所述数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的所述数据库时,则将数据库状态信息为异常状态的数据库切换所述数据库状态为正常状态的数据库。Optionally, the primary server determines, according to the status information of each database, whether to switch between databases with the same group identifier of the database, including: the primary server exists in a database that determines that the group identifier of the database is the same. When at least one database state information is the database in a normal state, the database in which the database state information is an abnormal state switches the database in which the database state is a normal state.
可选地,所述主服务器接收从服务器发送的每个数据库的信息之后,包括:Optionally, after the primary server receives the information of each database sent from the server, the method includes:
所述主服务器在确定所述传输每个数据库的信息的时长不大于第二预设时长时,所述主服务器根据所述每个数据库的状态信息确定数据库的组标识 相同的数据库之间是否进行切换;所述主服务器在确定所述传输每个数据库的信息的时长大于第二预设时长时,所述主服务器向所述从服务器发送获取每个数据库的信息的请求。When the primary server determines that the length of the information for transmitting each database is not greater than the second preset duration, the primary server determines, according to the status information of each database, whether the database with the same group identifier of the database is performed. Switching; when the primary server determines that the duration of transmitting the information of each database is greater than the second preset duration, the primary server sends a request for obtaining information of each database to the secondary server.
第三方面,本发明实施例提供一种数据库的切换的从服务器,包括:获取单元,用于获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;发送单元,用于向主服务器发送所述每个数据库的信息,所述每个数据库的信息用于使所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。In a third aspect, an embodiment of the present invention provides a slave server for switching a database, including: an acquiring unit, configured to acquire state information of each database in each group of databases in at least two groups of databases; wherein each group of databases Included as a primary database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; The status information includes a normal status and an abnormal status; the sending unit is configured to send the information of each database to the primary server, where the information of each database is used to cause the primary server to determine according to status information of each database Whether the group of the database identifies the same database is switched; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the state information of the database.
由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,通过简单的配置实现数据库组之间的独立监控与切换,进而有助于系统的的高可用性。In the embodiment of the present invention, the state information of each database in each group of the at least two groups of databases is obtained from the server; wherein each of the groups of databases includes a primary database and at least one standby database, where each database corresponds to Any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status; and is classified according to a function type of the database. At least two database groups form at least two sets of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, the primary server According to the status information of each database, it is determined whether the databases in the same group are switched; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups is realized through simple configuration, and thus Helps the high availability of the system.
可选地,所述查询功能对应至少一组数据库;所述至少一组数据库中的每组数据库分别对应至少一种业务类型。Optionally, the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one service type.
可选地,所述至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:交易频率大于频率阈值的业务类型对应一组数据库;和/或;交易数量大于数量阈值的业务类型对应一组数据库。Optionally, each group of the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold Corresponding to a set of databases.
可选地,还包括探测单元,用于:周期性探测所述至少两组数据库中每组数据库中的每个数据库的状态信息;还包括更新单元,用于:所根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作;所述获取单元,用于:所获取更新后的每个数据库的状态信息,所述跟新后的每个数据库的状态信息是所述更新单元根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作得到的。Optionally, the method further includes: a detecting unit, configured to: periodically detect state information of each database in each of the at least two groups of databases; and further include an updating unit, configured to: according to each database The status information is used to update the historical status information of the database; the obtaining unit is configured to: obtain status information of each updated database, and the status information of each new database is the update The unit obtains an update operation on the historical state information of the database according to the state information of each database.
可选地,所述探测单元,用于:若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过所述第一预设时长后开始探测所述至少两组数据库的每个数据库的状态信息;所述从服务器若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测所述至少两组数据库的每个数据库的状态信息。Optionally, the detecting unit is configured to: if it is determined that the total duration of the last update operation is not greater than the first preset duration, start from the last update operation, and start the detection after the first preset duration State information of each database of at least two groups of databases; if the slave server determines that the total duration of the last update operation is greater than the first preset duration, detecting the at least two groups of databases from the end of the last update operation Status information for each database.
第四方面,本发明实施例提供一种数据库切换的主服务器,包括:接收单元,用于接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;所决策单元,用于根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。In a fourth aspect, an embodiment of the present invention provides a primary server for database switching, including: a receiving unit, configured to receive information about each database in each group of databases in at least two groups of databases sent from a server; The information includes the identifier of the database, the group identifier of the database, and the state information of the database. The determining unit is configured to determine, according to the state information of each database, whether to switch between databases with the same group identifier of the database.
可选地,所述决策单元,用于:所在确定所述数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的所述数据库时,则将数据库状态信息为异常状态的数据库切换所述数据库状态为正常状态的数据库。Optionally, the determining unit is configured to: when determining that the database having the same group identifier of the database has at least one database in which the database state information is in a normal state, the database state information is an abnormal state database switch The database status is a database of normal status.
可选地,所述决策单元,用于:所在确定所述传输每个数据库的信息的时长不大于第二预设时长时,所述决策单元根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;所述决策单元在确定所述传输每个数据库的信息的时长大于第二预设时长时,所述决策单元向所述从服务器发送获取每个数据库的信息的请求。Optionally, the determining unit is configured to: when determining that the duration of the information for transmitting each database is not greater than a second preset duration, the determining unit determines the group of the database according to the state information of each database Identifying whether switching is performed between the same databases; when the determining unit determines that the duration of transmitting the information of each database is greater than the second preset duration, the determining unit sends the information of obtaining each database to the slave server. Request.
第五方面,本发明实施例中提供了一种电子设备,包括:处理器、存储器、收发器和总线接口,其中,处理器、存储器、收发器和总线接口之间通过总线连接;In a fifth aspect, an embodiment of the present invention provides an electronic device, including: a processor, a memory, a transceiver, and a bus interface, wherein a processor, a memory, a transceiver, and a bus interface are connected by a bus;
所述处理器,用于读取所述存储器中的程序,执行下列方法:获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;The processor is configured to read a program in the memory, and perform the following method: acquiring state information of each database in each group of at least two groups of databases; wherein each group of databases includes a primary database and At least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes a normal status And abnormal state;
所述存储器,用于存储一个或多个可执行程序,可以存储所述处理器在执行操作时所使用的数据;The memory is configured to store one or more executable programs, and may store data used by the processor when performing operations;
所述收发器,用于在所述处理器的控制下向主服务器发送所述每个数据库的信息,所述每个数据库的信息用于使所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。The transceiver is configured to send information about each database to a primary server under control of the processor, where information of each database is used to cause the primary server to obtain status information according to each database Determining whether to switch between databases with the same group identifier of the database; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database.
第六方面,本发明实施例中提供了另一种电子设备,包括:处理器、存储器、收发器和总线接口,其中,处理器、存储器、收发器和总线接口之间通过总线连接;In a sixth aspect, another electronic device is provided in the embodiment of the present invention, including: a processor, a memory, a transceiver, and a bus interface, wherein a processor, a memory, a transceiver, and a bus interface are connected by a bus;
所述收发器,用于接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;The transceiver is configured to receive information about each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
所述处理器,用于读取所述存储器中的程序,执行下列方法:根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;The processor is configured to read a program in the memory, and perform the following method: determining, according to status information of each database, whether to switch between databases with the same group identifier of the database;
所述存储器,用于存储一个或多个可执行程序,可以存储所述处理器在执行操作时所使用的数据。The memory is configured to store one or more executable programs, and may store data used by the processor when performing operations.
第七方面,本申请实施例提供一种非暂态计算机可读存储介质,计算机存储介质中存储有指令,当其在计算机上运行时,使得计算机执行第一方面或第一方面的任意可能的实现方式中的方法,或者使得计算机执行第二方面或第二方面的任意可能的实现方式中的方法。In a seventh aspect, an embodiment of the present application provides a non-transitory computer readable storage medium, where a computer storage medium stores instructions that, when run on a computer, cause the computer to perform any of the first aspect or the first aspect. A method in an implementation, or causing a computer to perform the method of the second aspect or any possible implementation of the second aspect.
第八方面,本申请实施例提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行第一方面或第一方面的任意可能的实现方式中的方法,或者使得计算机执行第二方面或第二方面的任意可能的实现方式中的方法。In an eighth aspect, an embodiment of the present application provides a computer program product comprising instructions, when executed on a computer, causing a computer to perform the method in the first aspect or any possible implementation manner of the first aspect, or cause the computer to execute The method of any of the second aspect or any possible implementation of the second aspect.
由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,通过简单的配置实现数据库组之间的独立监控与切换,进而有助于系统的的高可用性。In the embodiment of the present invention, the state information of each database in each group of the at least two groups of databases is obtained from the server; wherein each of the groups of databases includes a primary database and at least one standby database, where each database corresponds to Any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status; and is classified according to a function type of the database. At least two database groups form at least two sets of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, the primary server According to the status information of each database, it is determined whether the databases in the same group are switched; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups is realized through simple configuration, and thus Helps the high availability of the system.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below.
图1为本发明实施例提供的一种通信系统架构示意图;1 is a schematic structural diagram of a communication system according to an embodiment of the present invention;
图2为本发明实施例提供的一种数据库的切换方法流程示意图;2 is a schematic flowchart of a method for switching a database according to an embodiment of the present invention;
图3为本发明实施例提供的一种从服务器的结构示意图;FIG. 3 is a schematic structural diagram of a slave server according to an embodiment of the present disclosure;
图4为本发明实施例提供的一种主服务器的结构示意图;4 is a schematic structural diagram of a main server according to an embodiment of the present invention;
图5为本发明实施例提供的一种电子设备的结构示意图;FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
图6为本发明实施例提供的另一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of another electronic device according to an embodiment of the present invention.
具体实施方式detailed description
为了使本发明的目的、技术方案及有益效果更加清楚明白,以下结合附 图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the objects, technical solutions and advantageous effects of the present invention more comprehensible, the present invention will be further described in detail below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
应理解,本发明实施例的技术方案可以应用于各种通信系统,例如:全球移动通讯(Global System of Mobile Communication,简称GSM)系统、码分多址(Code Division Multiple Access,简称CDMA)系统、宽带码分多址(Wideband Code Division Multiple Access,简称WCDMA)通用分组无线业务(General Packet Radio Service,简称GPRS)系统、长期演进(Long Term Evolution,简称LTE)系统、LTE频分双工(Frequency Division Duplex,简称FDD)系统、LTE时分双工(Time Division Duplex,简称TDD)、通用移动通信系统(Universal Mobile Telecommunication System,简称UMTS)、全球互联微波接入(Worldwide Interoperability for Microwave Access,简称WiMAX)通信系统,以及未来的5G通信系统等。It should be understood that the technical solutions of the embodiments of the present invention can be applied to various communication systems, such as a Global System of Mobile Communication (GSM) system, a Code Division Multiple Access (CDMA) system, Wideband Code Division Multiple Access (WCDMA) General Packet Radio Service (GPRS) system, Long Term Evolution (LTE) system, LTE frequency division duplex (Frequency Division) Duplex (referred to as FDD) system, LTE Time Division Duplex (TDD), Universal Mobile Telecommunication System (UMTS), Worldwide Interoperability for Microwave Access (WiMAX) communication System, and future 5G communication systems.
图1示出了应用本发明实施例的一种通信系统的构架示意图。如图1所示,该通信系统包括数据库集群101、从服务器102、主服务器103。主服务器与从服务器通过无线连接或有线连接或其它方式连接,从服务器与数据库集群中的每个数据库通过无线连接或有线连接或其它方式连接。FIG. 1 is a schematic block diagram showing a communication system to which an embodiment of the present invention is applied. As shown in FIG. 1, the communication system includes a database cluster 101, a slave server 102, and a master server 103. The primary server and the secondary server are connected by wireless connection or wired connection or other means, and the server is connected to each database in the database cluster through a wireless connection or a wired connection or the like.
数据库集群101包括至少两组数据库,数据库组104和数据库组105,数据库组104和105分别包括一个主数据库和至少一个备数据库,数据库组104包括主数据库104a和备数据库104b,数据库组105包括主数据库105a和备数据库105b。主数据库和备数据库之间采用PSY进行数据同步,确保主数据库和备数据库中数据的同步。每组数据库对应四种功能类型中任一种或者任多种;四种功能类型包括增加功能、删除功能、更改功能以及查询功能;比如该数据库集群包括两组数据库104和105,这两组数据库分别是:查询功能对应一组数据库104,增加功能、删除功能、更改功能对应另一组数据库105;其中,每种功能类型的数据库对应至少一组数据,查询功能对应至少一组数据库;至少一组数据库中的每组数据库分别对应至少一种业务类型,其中业务类型包括:取现、消费、查询余额等。The database cluster 101 includes at least two groups of databases, a database group 104 and a database group 105. The database groups 104 and 105 respectively include a primary database and at least one standby database. The database group 104 includes a primary database 104a and a standby database 104b. The database group 105 includes a primary database. Database 105a and standby database 105b. The PSY is used for data synchronization between the primary database and the standby database to ensure synchronization of data in the primary database and the standby database. Each set of databases corresponds to any one or more of the four functional types; the four functional types include an add function, a delete function, a change function, and a query function; for example, the database cluster includes two sets of databases 104 and 105, the two sets of databases. The query function corresponds to a group of databases 104, and the adding function, deleting function, and changing function correspond to another group of databases 105; wherein each type of database corresponds to at least one set of data, and the query function corresponds to at least one set of databases; at least one Each group of databases in the group database corresponds to at least one type of service, wherein the types of services include: cash withdrawal, consumption, and query balance.
从服务器102上部署slave模块,slave模块包括数据库探测进程HCS_DB106a~HCS_DB106d、数据库组监控进程HCS_MON_AGENT107a和HCS_MON_AGENT107b以及数据库的信息发送进程UDP_SEND108;数据库探测进程HCS_DB106用于探测与该从服务器连接的所有数据库的状态信息,每一个数据对应启动一个数据库探测进程HCS_DB用来探测该数据的状态信息;即在该系统中数据库探测进程HCS_DB106a用于探测数据库104a的数据库状态信息;HCS_DB106b用于探测数据库104b的数据库状态信息、HCS_DB106c用于探测数据库105a的数据库状态信息,HCS_DB106d用于探测数据库105b的数据库状态信息;每一组数据库启动一个数据库组监控进程HCS_MON_AGENT来获取每组的数据库的信息,即HCS_MON_AGENT107a用于获取数据库组104的数据库信息,HCS_MON_AGENT107b用于获取数据库组105的数据库信息;数据库的信息发送进程UDP_SEND108用来向主服务器103发送数据库组监控进程HCS_MON_AGENT107a~HCS_MON_AGENT107b获取的每组数据库的信息。The slave module is deployed from the server 102. The slave module includes a database detection process HCS_DB106a~HCS_DB106d, a database group monitoring process HCS_MON_AGENT107a and an HCS_MON_AGENT107b, and a database information sending process UDP_SEND108. The database detecting process HCS_DB106 is used to detect the status of all databases connected to the slave server. Information, each data corresponding to a database detection process HCS_DB is used to detect the status information of the data; that is, in the system, the database detection process HCS_DB 106a is used to detect the database status information of the database 104a; the HCS_DB 106b is used to detect the database status information of the database 104b. The HCS_DB 106c is used to detect the database state information of the database 105a, and the HCS_DB 106d is used to detect the database state information of the database 105b; each group of databases starts a database group monitoring process HCS_MON_AGENT to obtain the information of the database of each group, that is, the HCS_MON_AGENT 107a is used to acquire the database group. The database information of 104, HCS_MON_AGENT 107b is used to obtain the database information of the database group 105; the information sending process of the database UDP_SEND 108 is used to serve the main service HCS_MON_AGENT107a ~ 103 transmits information database HCS_MON_AGENT107b each retrieved database group monitoring process.
主服务器103上部署数据库监控与切换master模块,数据库监控与切换master模块包括接收进程Infcollection109和决策进程Infdecision110。接收进程Infcollection109用于接收从服务器发送的数据库的信息;决策进程Infdecision110用于根据接收到的从服务器发送的数据库的信息,确定数据库是否需要切换。The database monitoring and switching master module is deployed on the primary server 103. The database monitoring and switching master module includes a receiving process Infcollection 109 and a decision process Infdecision 110. The receiving process Infcollection 109 is configured to receive information of a database sent from the server; the decision process Infdecision 110 is configured to determine whether the database needs to be switched according to the received information of the database sent from the server.
基于图1所示的系统架构,图2示例性示出了本发明实施例提供的一种数据库的切换方法流程示意图,如图2所示,本发明实施例提供的数据库切换方法,包括以下步骤:Based on the system architecture shown in FIG. 1 , FIG. 2 exemplarily shows a flow chart of a method for switching a database according to an embodiment of the present invention. As shown in FIG. 2 , the database switching method provided by the embodiment of the present invention includes the following steps. :
步骤S201,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,每组数据库包括一个主数据库和至少一个备数据库,每组数据库对应四种功能类型中任一种或者任多种;四种功能类型包括增加功能、删除功能、更改功能以及查询功能;状态信息包括正常状态和异常状态;Step S201: Obtain state information of each database in each group of the at least two groups of databases from the server; wherein each group of databases includes a primary database and at least one standby database, and each group of databases corresponds to any one of four functional types. Or any of a variety of; four types of functions include adding functions, deleting functions, changing functions, and query functions; status information includes normal status and abnormal status;
步骤S202,从服务器向主服务器发送每个数据库的信息,其中,每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;Step S202, the information of each database is sent from the server to the primary server, where the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
步骤S203,主服务器接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;Step S203, the primary server receives information of each database in each of the at least two groups of databases sent from the server;
步骤S204,主服务器根据每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。Step S204: The primary server determines, according to the status information of each database, whether to switch between databases with the same group identifier of the database.
由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,每组数据库包括一个主数据库和至少一个备数据库,每组数据库对应四种功能类型中任一种或者任多种;四种功能类型包括增加功能、删除功能、更改功能以及查询功能;状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,可以通过简单的配置实现数据库组之间的独立监控与切换,进而有助于数据库的高可用性。In the embodiment of the present invention, the status information of each database in each group of the at least two groups of databases is obtained from the server; wherein each group of databases includes a primary database and at least one standby database, and each group of databases corresponds to four functional types. Any one or more of the four types of functions include adding functions, deleting functions, changing functions, and query functions; status information includes normal status and abnormal status; and dividing into at least two database groups according to the function type of the database to form mutual Independent at least two groups of databases, each of which is independent of data; information of each database in each of the at least two groups of databases is sent to the primary service, and the primary server determines based on the status information of each database Whether to switch between databases in the same group; thus, data between the same group identifier can be switched, and independent monitoring and switching between database groups can be realized through simple configuration, thereby contributing to high availability of the database.
在本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息,每组数据库对应四种功能类型中任一种或者任多种,四种功能包括增加功能、删除功能、更改功能以及查询功能;其中,数据库的查询功能的使用频率较高。可选地,查询功能对应至少一组数据库;至少一组数据库中的每组数据库分别对应至少一种业务类型。In the embodiment of the present invention, the status information of each database in each group of the at least two groups of databases is obtained from the server, and each group of databases corresponds to any one or more of the four types of functions, and the four functions include adding functions. , delete function, change function and query function; among them, the database query function is used frequently. Optionally, the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one type of service.
本发明实施例中,查询功能对应至少一组数据库,增加功能、删除功能和更改功能对应至少另一组数据库;每组数据库对应至少一种业务类型,业务类型包括取现、转账、消费、预授权或者销户结清等;查询功能对应的该组数据库包括至少一组数据库,查询功能对应的该数据库也可以根据业务类型分为多组数据库;可选地,增加功能、删除功能和更改功能对应一组数据库,该组数据库也可以根据业务类型对应一组数据库或者多组数据库。In the embodiment of the present invention, the query function corresponds to at least one set of databases, and the add function, the delete function, and the change function correspond to at least another set of databases; each set of databases corresponds to at least one service type, and the service type includes cash withdrawal, transfer, consumption, pre-authorization. Or the account settlement, etc.; the set of databases corresponding to the query function includes at least one set of databases, and the database corresponding to the query function may also be divided into multiple sets of databases according to the service type; optionally, the function of adding, deleting, and changing functions is correspondingly A set of databases, which can also correspond to a set of databases or groups of databases based on the type of business.
可选地,查询功能对应至少一组数据库,该至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:交易频率大于频率阈值的业务类型对应一组数据库;和/或;交易数量大于数量阈值的业务类型对应一组数据库。Optionally, the query function corresponds to at least one group of databases, each of the at least one group of databases corresponding to at least one type of service, including: a transaction type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; A business type with a quantity greater than the quantity threshold corresponds to a set of databases.
本发明实施例中,查询功能对应一组数据库,该组数据库中包括一个主数据库和至少一个备数据库。在查询功能对应的该组数据库中,可以继续分为多个组,比如交易频率大于频率阈值的业务类型对应一组数据库,交易频率不大于频率阈值的业务类型对应另一组数据库;或者在查询功能对应的该组数据库中,交易数量大于数量阈值的业务类型对应一组数据库,交易数量不大于数量阈值的业务类型对应另一组数据库;或者在查询功能对应的该组数据库中,交易频率大于频率阈值且交易数量大于数量阈值的业务类型对应一组数据库,其他的对应另一组数据库。In the embodiment of the present invention, the query function corresponds to a set of databases, and the set of databases includes a primary database and at least one standby database. In the group of databases corresponding to the query function, the group can continue to be divided into multiple groups, for example, a service type whose transaction frequency is greater than the frequency threshold corresponds to a group of databases, and a service type whose transaction frequency is not greater than the frequency threshold corresponds to another group of databases; In the group of databases corresponding to the function, the service type whose transaction quantity is greater than the quantity threshold corresponds to a group of databases, and the service type whose transaction quantity is not greater than the quantity threshold corresponds to another group of databases; or in the group of databases corresponding to the query function, the transaction frequency is greater than The service type of the frequency threshold and the number of transactions is greater than the quantity threshold corresponds to one set of databases, and the other corresponds to another set of databases.
可选地,任一种或者任多种功能类型对应的一组数据库,其中,每组数据库对应至少一种业务类型,根据业务类型可以将任一种或者任多种功能类型对应的该组数据库继续分组,比如交易频率大于频率阈值的业务类型对应一组数据库;和/或;交易数量大于数量阈值的业务类型对应一组数据库。如此,在原通信系统的构建中,可以降低数据库的压力,特别是存在高频交易导致数据库崩溃时,通过分组的方式可以有效解决针对同类大量数据处理的压力问题。Optionally, any one or more of the plurality of function types corresponding to the group of databases, wherein each group of databases corresponds to at least one type of service, and the group of databases corresponding to any one or more of the plurality of types of functions may be selected according to the type of the service. The grouping continues, for example, the service type whose transaction frequency is greater than the frequency threshold corresponds to a group of databases; and/or; the service type whose transaction quantity is greater than the quantity threshold corresponds to a group of databases. In this way, in the construction of the original communication system, the pressure of the database can be reduced, especially when there is a high frequency transaction causing the database to collapse, the grouping method can effectively solve the pressure problem for a large amount of data processing of the same kind.
可选地,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息之前,还包括:从服务器周期性探测至少两组数据库中每组数据库中的每个数据库的状态信息;从服务器根据每个数据库的状态信息对数据库的历史状态信息进行更新操作;从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息,包括:从服务器获取更新后的每个数据库的状态信息,跟新后的每个数据库的状态信息是从服务器根据每个数据库的状态信息对数据库的历史状态信息进行更新操作得到的。Optionally, before obtaining, by the server, status information of each database in each group of the at least two groups of databases, the method further includes: periodically detecting, by the server, status information of each database in each group of the at least two groups of databases; The slave server updates the historical state information of the database according to the state information of each database; and obtains, from the server, state information of each database in each group of the at least two groups of databases, including: obtaining each database after the update from the server The status information, and the status information of each new database is obtained by the server updating the historical status information of the database according to the status information of each database.
在本发明实施例中,从服务器关联有多个数据库,从服务器上的数据库探测进程HCS_DB用来周期性探测该从服务器所关联的每个数据的状态信 息,假设数据库探测进程HCS_DB探测数据库的周期为T,数据库探测进程HCS_DB每隔周期T对所关联的数据库进行一次探测,从服务器根据每个数据库的状态信息对数据库的历史状态信息进行更新操作。更新操作需要一定的时间来完成。根据更新操作过程的时间来确定下一次启动数据库探测进程HCS_DB的时间。In the embodiment of the present invention, a plurality of databases are associated from the server, and the database detection process HCS_DB on the server is used to periodically detect the state information of each data associated with the slave server, assuming that the database detection process HCS_DB probes the database period. For T, the database detection process HCS_DB performs a probe on the associated database every cycle T, and the slave server updates the history state information of the database according to the state information of each database. The update operation takes a certain amount of time to complete. The time to start the database probe process HCS_DB next time is determined according to the time of the update operation process.
可选地,从服务器周期性探测至少两组数据库中每组数据库中的每个数据库的状态信息,包括:从服务器若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过第一预设时长后开始探测至少两组数据库的每个数据库的状态信息;从服务器若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测至少两组数据库的每个数据库的状态信息。如此,既可以确保数据库探测进程HCS_DB能及时探测数据库的状态信息,又可以保证数据库探测进程HCS_DB不浪费网络资源。本发明实施例中,第一预设时长可以与周期T相等。Optionally, the server periodically detects status information of each database in each group of the at least two groups of databases, including: if the slave server determines that the total duration of the last update operation is not greater than the first preset duration, then Starting from an update operation, starting to detect status information of each database of at least two groups of databases after a first preset duration; if the slave server determines that the total duration of the last update operation is greater than the first preset duration, then updating from the previous update At the end of the operation, the status information of each database of at least two groups of databases is detected. In this way, it can ensure that the database detection process HCS_DB can detect the state information of the database in time, and can ensure that the database detection process HCS_DB does not waste network resources. In the embodiment of the present invention, the first preset duration may be equal to the period T.
本发明实施例中,从服务器上的数据库探测进程HCS_DB进行数据库的探测之后,根据每个数据库的状态信息对数据库的历史状态信息进行更新操作;数据库探测进程HCS_DB将数据库的状态信息更新之后,从服务器启动数据库组监控进程HCS_MON_AGENT,获取更新后的数据库的状态信息。数据库组监控进程HCS_MON_AGENT确定获取更新后的数据库的状态信息的时间是否大于第三预设时长,其中,第三预设时长可以与周期相同。在确定不大于第三预设时长时,根据获取的每个数据库状态信息对数据库组监控进程HCS_MON_AGENT中的数据库的历史状态信息进行更新操作;更新完成后进行下一次获取至少两组数据库中每组数据库中的每个数据库的状态信息;根据预设的数据库的标识与数据库组标识的映射关系确定获取的每个数据库对应的数据库组标识。在确定大于第三预设时长时,数据库组监控进程HCS_MON_AGENT重新获取数据库探测进程HCS_DB更新后的数据库状态信息,直到数据库组监控进程HCS_MON_AGENT确定获取更新后的数据库的状态信息的时间不大于第三预设时长时,根据获取的每个数据库状态信息 对数据库组监控进程HCS_MON_AGENT中的数据库的历史状态信息进行更新操作,休眠T时长之后,下一次获取至少两组数据库中每组数据库中的每个数据库的状态信息。In the embodiment of the present invention, after the database detection process HCS_DB on the server performs the detection of the database, the historical state information of the database is updated according to the state information of each database; after the database detection process HCS_DB updates the state information of the database, The server starts the database group monitoring process HCS_MON_AGENT to obtain the status information of the updated database. The database group monitoring process HCS_MON_AGENT determines whether the time for obtaining the state information of the updated database is greater than the third preset duration, wherein the third preset duration may be the same as the period. When it is determined that the third preset duration is not greater than the third preset duration, the historical state information of the database in the database group monitoring process HCS_MON_AGENT is updated according to each database state information acquired; after the update is completed, the next acquisition of each of the at least two groups of databases is performed. Status information of each database in the database; determining the database group identifier corresponding to each database obtained according to the mapping relationship between the identifier of the preset database and the database group identifier. When the determination is greater than the third preset duration, the database group monitoring process HCS_MON_AGENT re-acquires the database state information after the database detection process HCS_DB is updated, until the database group monitoring process HCS_MON_AGENT determines that the time of obtaining the updated database state information is not greater than the third pre- When the duration is set, the historical state information of the database in the database group monitoring process HCS_MON_AGENT is updated according to each database state information acquired, and after the sleep T duration, the next database in each group of at least two groups of databases is acquired next time. Status information.
本发明实施例中,数据库探测进程HCS_DB在探测相应的数据状态信息,相应的待更新的数据库状态信息处于保护区域,数据库组监控进程HCS_MON_AGENT无法读取该保护区域中的数据库状态信息。通过确定获取更新后的数据库的状态信息的时间是否大于第三预设时长,可以及时获取到数据库的状态信息中的最近一次的状态信息。In the embodiment of the present invention, the database detection process HCS_DB is detecting the corresponding data state information, and the corresponding database state information to be updated is in the protection zone, and the database group monitoring process HCS_MON_AGENT cannot read the database state information in the protection zone. By determining whether the time for obtaining the state information of the updated database is greater than the third preset duration, the latest state information in the state information of the database may be obtained in time.
本发明实施例中,从服务器上的数据库的信息发送进程UDP_SEND将数据库组监控进程HCS_MON_AGENT中更新后的至少两组数据库中每组数据库中的每个数据库的信息发送到主服务器上,主服务器上的接收进程Infcollection接收更新后的至少两组数据库中每组数据库中的每个数据库的信息。In the embodiment of the present invention, the information sending process UDP_SEND of the database on the server sends information of each database in each of the at least two groups of databases updated in the database group monitoring process HCS_MON_AGENT to the primary server, on the primary server. The receiving process Infcollection receives information of each database in each of the at least two sets of databases in the updated database.
可选地,主服务器接收从服务器发送的每个数据库的信息之后还包括:主服务器判断从服务器发送到主服务器接收过程的时长是否大于第二预设时长,主服务器在确定传输每个数据库的信息的时长不大于第二预设时长时,主服务器根据每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。主服务器在确定每个数据库的信息的传输每个数据库的信息的时长大于第二预设时长时,主服务器向从服务器发送获取每个数据库的信息的请求。如此,可以防止主服务器和从服务器之间因链路中断造成主服务器获得历史数据库的信息。Optionally, after the primary server receives the information of each database sent from the server, the method further includes: determining, by the primary server, whether the duration of the process of receiving the process from the server to the primary server is greater than a second preset duration, and the primary server determines to transmit each database. When the duration of the information is not greater than the second preset duration, the primary server determines whether to switch between databases with the same group identifier of the database according to the state information of each database. The primary server sends a request for obtaining information of each database to the secondary server when determining that the information of each database is transmitted for each database to be longer than the second predetermined duration. In this way, it is possible to prevent the primary server from obtaining the history database information due to the link interruption between the primary server and the secondary server.
本发明实施例中,主服务器接收到从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息且传输的时间小于第二预设时长时,主服务器上的决策进程Infdecision每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。本发明实施例中提供了一种可选地实现方式:主服务器在确定数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的数据库时,则将数据库状态信息为异常状态的数据库切换数 据库状态为正常状态的数据库。本发明实施例中通过简单的配置实现了多组数据库的独立监控与切换,并且保证了多组数据库之间互不干扰。在确定数据库状态信息异常时,可以自动切换到该组其他正常状态的数据库上。In the embodiment of the present invention, when the primary server receives the information of each database in each of the at least two groups of databases sent from the server and the transmission time is less than the second preset duration, the decision process Infdecision on the primary server each The status information of the database determines whether the database has the same group ID for the switch. An embodiment of the present invention provides an optional implementation manner: when the primary server determines that at least one database whose state information is in a normal state exists in a database having the same group identifier of the database, the database state information is an abnormal state database. Switch the database whose database status is normal. In the embodiment of the present invention, independent monitoring and switching of multiple groups of databases is realized by a simple configuration, and multiple groups of databases are not interfered with each other. When it is determined that the database status information is abnormal, it can be automatically switched to the database of other normal status of the group.
本发明实施例中,主服务器判断数据库的组标识相同的数据库中是否存在数据库状态信息为异常状态的数据库,若存在,则在判断组标识相同的数据库中是否存在数据库状态信息为正常状态的数据库,若存在,则将该数据库状态信息为异常的数据库切换到数据库状态信息为正常状态的数据上。若数据库的组标识相同的数据库中不存在异常数据库则不处理;若数据库的组标识相同的数据库中均为异常数据库则也不处理。即数据库的切换只在组内进行,不同组之间不进行切换,如此,可以实现多组数据库之间的独立监控与切换,进而有助于系统的高可用性。In the embodiment of the present invention, the primary server determines whether there is a database in which the database state information is an abnormal state in the database with the same group identifier of the database, and if so, whether there is a database in which the database state information is in a normal state in the database having the same group identifier. If it exists, the database whose database state information is abnormal is switched to the data whose database state information is normal. If there is no abnormal database in the same database with the same group ID, the database will not be processed. If the database has the same group ID, the database will not be processed. That is, the switching of the database is only performed in the group, and no switching is performed between different groups. In this way, independent monitoring and switching between multiple groups of databases can be realized, thereby contributing to high availability of the system.
为了便于问题的理解,用一个具体的例子来说明主服务器的切换过程。假设主服务器接收到两组数据库的数据库信息,每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;比如组1包括两个数据库,数据库的标识分别为1A和1B,1A表示主数据库,1B表示备数据库,主数据库1A的状态信息为正常状态,备数据库1B的状态信息为异常状态;则将备数据库1B切换到主数据库1A;组2包括两个数据库,数据库的标识分别为2A和2B,2A表示主数据库,2B表示备数据库,主数据库2A的状态信息为异常,备数据库2B的状态为异常;不进行切换。即便组1中有正常状态的数据库也不进行切换操作,不会跨足进行数据库的切换,如此,可以保证多组数据库的高可用的独立监控与切换。In order to facilitate the understanding of the problem, a specific example is used to illustrate the switching process of the primary server. Suppose the primary server receives database information of two groups of databases. The information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database. For example, group 1 includes two databases, and the identifiers of the database are 1A and 1B, respectively. Indicates the primary database, 1B indicates the standby database, the status information of the primary database 1A is the normal state, and the state information of the standby database 1B is the abnormal state; then the standby database 1B is switched to the primary database 1A; the group 2 includes two databases, the identification of the database 2A and 2B, 2A represents the primary database, 2B represents the standby database, the status information of the primary database 2A is abnormal, and the state of the standby database 2B is abnormal; no switching is performed. Even if the database in the normal state in the group 1 does not perform the switching operation, the database switching is not performed, so that the high-availability independent monitoring and switching of the multiple groups of databases can be guaranteed.
图3示例性示出了本发明实施例提供的一种数据库切换的从服务器的结构示意图。FIG. 3 is a schematic structural diagram of a slave server for database switching according to an embodiment of the present invention.
基于相同构思,本发明实施例提供一种从服务器,如图3所示,从服务器用300包括获取单元301、发送单元302,还包括探测单元303和更新单元304。其中:Based on the same concept, an embodiment of the present invention provides a slave server. As shown in FIG. 3, the slave server 300 includes an obtaining unit 301, a sending unit 302, and a detecting unit 303 and an updating unit 304. among them:
获取单元,用于获取至少两组数据库中每组数据库中的每个数据库的状 态信息;其中,每组数据库包括一个主数据库和至少一个备数据库,每组数据库对应四种功能类型中任一种或者任多种;四种功能类型包括增加功能、删除功能、更改功能以及查询功能;状态信息包括正常状态和异常状态;发送单元,用于向主服务器发送每个数据库的信息,每个数据库的信息用于使主服务器根据每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。An obtaining unit, configured to obtain state information of each database in each group of databases in at least two groups of databases; wherein each group of databases includes a primary database and at least one standby database, and each group of databases corresponds to any one of four functional types Or a plurality of types; the four function types include an add function, a delete function, a change function, and a query function; the status information includes a normal state and an abnormal state; and a sending unit is configured to send information of each database to the primary server, each database The information is used to enable the primary server to determine whether to switch between databases with the same group identifier of the database according to the status information of each database; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the state information of the database.
可选地,查询功能对应至少一组数据库;至少一组数据库中的每组数据库分别对应至少一种业务类型。Optionally, the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one type of service.
可选地,至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:交易频率大于频率阈值的业务类型对应一组数据库;和/或;交易数量大于数量阈值的业务类型对应一组数据库。Optionally, each group of the database in the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold corresponds to a Group database.
可选地,还包括探测单元,用于:周期性探测至少两组数据库中每组数据库中的每个数据库的状态信息;还包括更新单元,用于:所根据每个数据库的状态信息对数据库的历史状态信息进行更新操作;获取单元,用于:所获取更新后的每个数据库的状态信息,跟新后的每个数据库的状态信息是更新单元根据每个数据库的状态信息对数据库的历史状态信息进行更新操作得到的。Optionally, the method further includes: a detecting unit, configured to: periodically detect state information of each database in each group of the at least two groups of databases; and further include: an updating unit, configured to: use the state information of each database to the database The history status information is updated; the obtaining unit is configured to: obtain status information of each database after the update, and the status information of each database after the update is an update unit according to the status information of each database to the history of the database The status information is obtained by the update operation.
可选地,探测单元,用于:若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过第一预设时长后开始探测至少两组数据库的每个数据库的状态信息;从服务器若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测至少两组数据库的每个数据库的状态信息。Optionally, the detecting unit is configured to: if it is determined that the total duration of the last update operation is not greater than the first preset duration, start from the last update operation, and start detecting the at least two groups of databases after the first preset duration Status information of each database; if the slave server determines that the total duration of the last update operation is greater than the first preset duration, the status information of each database of at least two groups of databases is detected after the end of the last update operation.
从上述内容可以看出:由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,每组数据库包括一个主数据库和至少一个备数据库,每组数据库对应四种功能类型中任一种或者任多种;四种功能类型包括增加功能、删除功能、更改功能以及查询功能; 状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,可以通过简单的配置实现数据库组之间的独立监控与切换,进而有助于系统的的高可用性。It can be seen from the foregoing that, in the embodiment of the present invention, status information of each database in each group of databases in at least two groups of databases is obtained from a server; wherein each group of databases includes a primary database and at least one standby database, each The group database corresponds to any one or more of the four function types; the four function types include an add function, a delete function, a change function, and a query function; the status information includes a normal state and an abnormal state; and the at least according to the function type of the database is divided into at least Two database groups form at least two groups of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, and the main server is based on The status information of each database determines whether the data is switched between the databases in the same group; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups can be realized through simple configuration, and thus Helps the high availability of the system.
图4示例性示出了本发明实施例提供的一种数据库切换的主服务器的结构示意图。FIG. 4 is a schematic structural diagram of a main server for database switching according to an embodiment of the present invention.
基于相同构思,本发明实施例提供一种主服务器,如图4所示,主服务器用400包括接收单元401、决策单元402。其中:Based on the same concept, an embodiment of the present invention provides a primary server. As shown in FIG. 4, the primary server 400 includes a receiving unit 401 and a decision unit 402. among them:
接收单元,用于接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;a receiving unit, configured to receive information about each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
所决策单元,用于根据每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。The determining unit is configured to determine, according to the state information of each database, whether to switch between databases with the same group identifier of the database.
可选地,决策单元,用于:所在确定数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的数据库时,则将数据库状态信息为异常状态的数据库切换数据库状态为正常状态的数据库。Optionally, the determining unit is configured to: when the database having the same group identifier of the same database has at least one database whose state information is in a normal state, the database state information is an abnormal state, and the database switching database state is a normal state. database.
可选地,决策单元,用于:所在确定传输每个数据库的信息的时长不大于第二预设时长时,决策单元根据每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;决策单元在确定传输每个数据库的信息的时长大于第二预设时长时,决策单元向从服务器发送获取每个数据库的信息的请求。Optionally, the determining unit is configured to: when determining that the duration of the information for transmitting each database is not greater than the second preset duration, the determining unit determines, according to the state information of each database, whether the database with the same group identifier of the database is performed. Switching; when the decision unit determines that the duration of transmitting the information of each database is greater than the second preset duration, the decision unit sends a request for obtaining information of each database to the slave server.
从上述内容可以看出:由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,每组数据库包括一个主数据库和至少一个备数据库,每组数据库对应四种功能类型中任一种或者任多种;四种功能类型包括增加功能、删除功能、更改功能以及查询功能; 状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,可以通过简单的配置实现数据库组之间的独立监控与切换,进而有助于系统的的高可用性。It can be seen from the foregoing that, in the embodiment of the present invention, status information of each database in each group of databases in at least two groups of databases is obtained from a server; wherein each group of databases includes a primary database and at least one standby database, each The group database corresponds to any one or more of the four function types; the four function types include an add function, a delete function, a change function, and a query function; the status information includes a normal state and an abnormal state; and the at least according to the function type of the database is divided into at least Two database groups form at least two groups of databases independent of each other, and data between each group is independent of each other; information of each database in each group database of at least two groups of databases is sent to the main service, and the main server is based on The status information of each database determines whether the data is switched between the databases in the same group; thus, the data between the same group identifiers can be switched, and the independent monitoring and switching between the database groups can be realized through simple configuration, and thus Helps the high availability of the system.
基于相同构思,本申请提供一种电子设备,可用于执行上述从服务器侧的方法流程。图5为本申请提供的一种电子设备的结构示意图。该电子设备包括处理器501、存储器502、收发器503和总线接口504;其中,处理器501、存储器502、收发器503和总线接口504通过总线505相互连接。Based on the same concept, the present application provides an electronic device that can be used to perform the above-described method flow from the server side. FIG. 5 is a schematic structural diagram of an electronic device provided by the present application. The electronic device includes a processor 501, a memory 502, a transceiver 503, and a bus interface 504; wherein the processor 501, the memory 502, the transceiver 503, and the bus interface 504 are connected to one another via a bus 505.
存储器502用于存储程序;具体地,程序可以包括程序代码,程序代码包括计算机操作指令。存储器502可以包括易失性存储器(volatile memory),例如随机存取存储器(random-access memory,简称RAM);存储器也可以包括非易失性存储器(non-volatile memory),例如快闪存储器(flash memory),硬盘(hard disk drive,简称HDD)或固态硬盘(solid-state drive,简称SSD);存储器502还可以包括上述种类的存储器的组合。The memory 502 is for storing a program; specifically, the program may include program code, and the program code includes computer operation instructions. The memory 502 may include a volatile memory such as a random-access memory (RAM); the memory may also include a non-volatile memory such as a flash memory (flash) Memory), hard disk drive (HDD) or solid-state drive (SSD); the memory 502 may also include a combination of the above types of memory.
存储器502存储了如下的元素,可执行模块或者数据结构,或者它们的子集,或者它们的扩展集:The memory 502 stores the following elements, executable modules or data structures, or a subset thereof, or an extended set thereof:
操作指令:包括各种操作指令,用于实现各种操作。Operation instructions: include various operation instructions for implementing various operations.
操作系统:包括各种系统程序,用于实现各种基础业务以及处理基于硬件的任务。Operating system: Includes a variety of system programs for implementing various basic services and handling hardware-based tasks.
总线505可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图5中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The bus 505 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in Figure 5, but it does not mean that there is only one bus or one type of bus.
总线接口504可以为有线通信接入口,无线总线接口或其组合,其中, 有线总线接口例如可以为以太网接口。以太网接口可以是光接口,电接口或其组合。无线总线接口可以为WLAN接口。The bus interface 504 can be a wired communication access port, a wireless bus interface, or a combination thereof, wherein the wired bus interface can be, for example, an Ethernet interface. The Ethernet interface can be an optical interface, an electrical interface, or a combination thereof. The wireless bus interface can be a WLAN interface.
处理器501可以是中央处理器(central processing unit,简称CPU),网络处理器(network processor,简称NP)或者CPU和NP的组合。还可以是硬件芯片。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,简称ASIC),可编程逻辑器件(programmable logic device,简称PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(complex programmable logic device,简称CPLD),现场可编程逻辑门阵列(field-programmable gate array,简称FPGA),通用阵列逻辑(generic array logic,简称GAL)或其任意组合。The processor 501 can be a central processing unit (CPU), a network processor (NP) or a combination of a CPU and an NP. It can also be a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (GAL) or any combination.
所述处理器501,用于读取所述存储器502中的程序,执行下列方法:获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;The processor 501 is configured to read a program in the memory 502, and perform the following method: acquiring state information of each database in each group of at least two groups of databases; wherein each group of databases includes one master a database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes Normal state and abnormal state;
所述存储器502,用于存储一个或多个可执行程序,可以存储所述处理器501在执行操作时所使用的数据;The memory 502 is configured to store one or more executable programs, and may store data used by the processor 501 when performing operations;
所述收发器503,用于在所述处理器501的控制下向主服务器发送所述每个数据库的信息,所述每个数据库的信息用于使所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。。The transceiver 503 is configured to send information about each database to a primary server under control of the processor 501, where the information of each database is used to make the primary server according to each database The status information determines whether a switch is performed between databases having the same group identifier of the database; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database. .
可选地,所述查询功能对应至少一组数据库;所述至少一组数据库中的每组数据库分别对应至少一种业务类型。Optionally, the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one service type.
可选地,所述至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:交易频率大于频率阈值的业务类型对应一组数据库;和/或;交易数量大于数量阈值的业务类型对应一组数据库。Optionally, each group of the at least one group of databases respectively corresponds to at least one type of service, including: a service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases; and/or; a service type whose transaction quantity is greater than a quantity threshold Corresponding to a set of databases.
可选地,所述处理器,用于:周期性探测所述至少两组数据库中每组数 据库中的每个数据库的状态信息;根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作;获取更新后的每个数据库的状态信息,所述跟新后的每个数据库的状态信息是所述更新单元根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作得到的。Optionally, the processor is configured to periodically detect state information of each database in each of the at least two groups of databases; and historical state of the database according to status information of each database The information is updated; the status information of each database after the update is obtained, and the status information of each database after the update is historical status information of the database by the update unit according to the status information of each database. Get the update operation.
可选地,所述处理器,用于:若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过所述第一预设时长后开始探测所述至少两组数据库的每个数据库的状态信息;若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测所述至少两组数据库的每个数据库的状态信息。Optionally, the processor is configured to: if it is determined that the total duration of the last update operation is not greater than the first preset duration, start from the last update operation, and start the detection after the first preset duration State information of each database of at least two groups of databases; if it is determined that the total duration of the last update operation is greater than the first preset duration, detecting each database of the at least two groups of databases from the end of the last update operation status information.
应理解,以上各个单元的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。本申请实施例中,发送单元302可以由收发器实现,获取单元301、探测单元303和更新单元304可以由处理器实现。如图5所示,电子设备500可以包括处理器501、收发器503和存储器502。其中,存储器502可以用于存储电子设备500出厂时预装的程序/代码,也可以存储用于处理器501执行时的代码等。It should be understood that the division of each unit above is only a division of a logical function, and the actual implementation may be integrated into one physical entity in whole or in part, or may be physically separated. In the embodiment of the present application, the sending unit 302 can be implemented by a transceiver, and the obtaining unit 301, the detecting unit 303, and the updating unit 304 can be implemented by a processor. As shown in FIG. 5, the electronic device 500 can include a processor 501, a transceiver 503, and a memory 502. The memory 502 can be used to store a program/code pre-installed at the time of shipment of the electronic device 500, and can also store a code or the like for execution of the processor 501.
从上述内容可以看出:本发明实施例中,由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,通过简单的配置实现数据库组之间的独立监控与切换,进而有助于系统的的高可用性。It can be seen from the foregoing that, in the embodiment of the present invention, in the embodiment of the present invention, state information of each database in each group of databases in at least two groups of databases is obtained from a server; wherein each group of databases includes one master a database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes Normal state and abnormal state; according to the function type of the database, it is divided into at least two database groups to form at least two groups of databases independent of each other, and the data between each group is independent of each other; The information of each database is sent to the main service, and the main server determines whether to switch between the databases in the same group according to the status information of each database; thus, the data between the same group identifiers can be switched, through simple configuration. Implement independent monitoring and switching between database groups, which in turn helps the system Availability.
基于相同构思,本申请提供另一种电子设备,可用于执行上述主服务器 侧的方法流程。图6为本申请提供的另一种电子设备的结构示意图。该电子设备包括处理器601、存储器602、收发器603和总线接口604;其中,处理器601、存储器602、收发器603和总线接口604通过总线605相互连接。Based on the same concept, the present application provides another electronic device that can be used to execute the method flow on the main server side described above. FIG. 6 is a schematic structural diagram of another electronic device provided by the present application. The electronic device includes a processor 601, a memory 602, a transceiver 603, and a bus interface 604; wherein the processor 601, the memory 602, the transceiver 603, and the bus interface 604 are connected to one another via a bus 605.
存储器602用于存储程序;具体地,程序可以包括程序代码,程序代码包括计算机操作指令。存储器602可以包括易失性存储器(volatile memory),例如随机存取存储器(random-access memory,简称RAM);存储器也可以包括非易失性存储器(non-volatile memory),例如快闪存储器(flash memory),硬盘(hard disk drive,简称HDD)或固态硬盘(solid-state drive,简称SSD);存储器602还可以包括上述种类的存储器的组合。The memory 602 is for storing a program; specifically, the program may include program code, and the program code includes computer operation instructions. The memory 602 may include a volatile memory such as a random-access memory (RAM); the memory may also include a non-volatile memory such as a flash memory (flash) Memory), hard disk drive (HDD) or solid-state drive (SSD); the memory 602 may also include a combination of the above types of memory.
存储器602存储了如下的元素,可执行模块或者数据结构,或者它们的子集,或者它们的扩展集: Memory 602 stores the following elements, executable modules or data structures, or subsets thereof, or their extended sets:
操作指令:包括各种操作指令,用于实现各种操作。Operation instructions: include various operation instructions for implementing various operations.
操作系统:包括各种系统程序,用于实现各种基础业务以及处理基于硬件的任务。Operating system: Includes a variety of system programs for implementing various basic services and handling hardware-based tasks.
总线605可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图6中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The bus 605 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in Figure 6, but it does not mean that there is only one bus or one type of bus.
总线接口604可以为有线通信接入口,无线总线接口或其组合,其中,有线总线接口例如可以为以太网接口。以太网接口可以是光接口,电接口或其组合。无线总线接口可以为WLAN接口。The bus interface 604 can be a wired communication access port, a wireless bus interface, or a combination thereof, wherein the wired bus interface can be, for example, an Ethernet interface. The Ethernet interface can be an optical interface, an electrical interface, or a combination thereof. The wireless bus interface can be a WLAN interface.
处理器601可以是中央处理器(central processing unit,简称CPU),网络处理器(network processor,简称NP)或者CPU和NP的组合。还可以是硬件芯片。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,简称ASIC),可编程逻辑器件(programmable logic device,简称PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(complex programmable logic  device,简称CPLD),现场可编程逻辑门阵列(field-programmable gate array,简称FPGA),通用阵列逻辑(generic array logic,简称GAL)或其任意组合。The processor 601 can be a central processing unit (CPU), a network processor (NP) or a combination of a CPU and an NP. It can also be a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (GAL) or any combination.
所述处理器601,用于读取所述存储器602中的程序,执行下列方法:根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;The processor 601 is configured to read a program in the memory 602, and perform the following method: determining, according to status information of each database, whether to switch between databases with the same group identifier of the database;
所述存储器602,用于存储一个或多个可执行程序,可以存储所述处理器601在执行操作时所使用的数据;The memory 602 is configured to store one or more executable programs, and may store data used by the processor 601 when performing an operation;
所述收发器603,用于在所述处理器601的控制下接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。The transceiver 603 is configured to receive, under the control of the processor 601, information of each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, The group ID of the database and the status information of the database.
可选地,所述处理器601,用于在确定所述数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的所述数据库时,则将数据库状态信息为异常状态的数据库切换所述数据库状态为正常状态的数据库。Optionally, the processor 601 is configured to: when the database in which the at least one database state information is in a normal state exists in a database in which the group identifier of the database is the same, the database state information is an abnormal state database switch. The database status is a database of normal status.
可选地,所述处理器601,用于在确定所述传输每个数据库的信息的时长不大于第二预设时长时,根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;在确定所述传输每个数据库的信息的时长大于第二预设时长时,向所述从服务器发送获取每个数据库的信息的请求。Optionally, the processor 601 is configured to: when determining that the duration of the information for transmitting each database is not greater than the second preset duration, determine, according to the state information of each database, a database with the same group identifier of the database. Whether switching is performed between; when it is determined that the duration of transmitting the information of each database is greater than the second preset duration, a request to acquire information of each database is sent to the slave server.
应理解,以上各个单元的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。本申请实施例中,接收单元401可以由收发器实现,决策单元402可以由处理器实现。如图6所示,电子设备600可以包括处理器601、收发器603和存储器602。其中,存储器602可以用于存储电子设备600出厂时预装的程序/代码,也可以存储用于处理器601执行时的代码等。It should be understood that the division of each unit above is only a division of a logical function, and the actual implementation may be integrated into one physical entity in whole or in part, or may be physically separated. In the embodiment of the present application, the receiving unit 401 can be implemented by a transceiver, and the determining unit 402 can be implemented by a processor. As shown in FIG. 6, the electronic device 600 can include a processor 601, a transceiver 603, and a memory 602. The memory 602 can be used to store a program/code pre-installed when the electronic device 600 is shipped from the factory, or a code for the execution of the processor 601, and the like.
从上述内容可以看出:本发明实施例中,由于本发明实施例中,从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除 功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;根据数据库的功能类型分为至少两个数据库组,形成相互独立的至少两组数据库,各每组之间的数据相互独立;将至少两组数据库中的每个组数据库中的每个数据库的信息发送到主服务,主服务器根据每个数据库的状态信息确定在同一组中的数据库之间是否进行切换;如此,相同组标识之间的数据才能进行切换,通过简单的配置实现数据库组之间的独立监控与切换,进而有助于系统的的高可用性。It can be seen from the foregoing that, in the embodiment of the present invention, in the embodiment of the present invention, state information of each database in each group of databases in at least two groups of databases is obtained from a server; wherein each group of databases includes one master a database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes Normal state and abnormal state; according to the function type of the database, it is divided into at least two database groups to form at least two groups of databases independent of each other, and the data between each group is independent of each other; The information of each database is sent to the main service, and the main server determines whether to switch between the databases in the same group according to the status information of each database; thus, the data between the same group identifiers can be switched, through simple configuration. Implement independent monitoring and switching between database groups, which in turn helps the system High availability.
本领域内的技术人员应明白,本发明实施例可提供为方法、系统、或计算机程序产品。因此,本发明实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the invention may be provided as a method, system, or computer program product. Thus, embodiments of the invention may be in the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, embodiments of the invention may take the form of a computer program product embodied on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本发明实施例是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。Embodiments of the invention are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的 处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
显然,本领域的技术人员可以对本发明实施例进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本发明实施例的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。It is apparent that those skilled in the art can make various modifications and variations to the embodiments of the present invention without departing from the spirit and scope of the application. Thus, it is intended that the present invention cover the modifications and variations of the embodiments of the invention.

Claims (26)

  1. 一种数据库的切换方法,其特征在于,包括:A method for switching a database, comprising:
    从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;Obtaining, from the server, status information of each database in each group of the at least two groups of databases; wherein each of the groups of databases includes a primary database and at least one standby database, and each of the groups of databases corresponds to any one of four functional types Or any of the plurality of types; the four function types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status;
    所述从服务器向主服务器发送所述每个数据库的信息,所述每个数据库的信息用于使所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。Sending, by the server, the information of each database to the primary server, where the information of each database is used to enable the primary server to determine, according to the status information of each database, whether the database with the same group identifier of the database is The switching is performed; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database.
  2. 如权利要求1所述的方法,其特征在于,所述查询功能对应至少一组数据库;所述至少一组数据库中的每组数据库分别对应至少一种业务类型。The method of claim 1 wherein said query function corresponds to at least one set of databases; each of said at least one set of databases corresponds to at least one type of service.
  3. 如权利要求2所述的方法,其特征在于,所述至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:The method of claim 2, wherein each of the at least one set of databases corresponds to at least one type of service, respectively:
    交易频率大于频率阈值的业务类型对应一组数据库;A service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases;
    和/或;and / or;
    交易数量大于数量阈值的业务类型对应一组数据库。A business type with a transaction quantity greater than the quantity threshold corresponds to a set of databases.
  4. 如权利要求1所述的方法,其特征在于,所述从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息之前,还包括:The method according to claim 1, wherein before the obtaining, by the server, the status information of each of the databases in each of the two sets of databases, the method further comprises:
    所述从服务器周期性探测所述至少两组数据库中每组数据库中的每个数据库的状态信息;The slave server periodically detects status information of each database in each of the at least two groups of databases;
    所述从服务器根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作;And the slave server performs an update operation on the historical state information of the database according to the state information of each database;
    所述从服务器获取至少两组数据库中每组数据库中的每个数据库的状态信息,包括:And obtaining, by the server, status information of each database in each group of the at least two groups of databases, including:
    所述从服务器获取更新后的每个数据库的状态信息,所述跟新后的每个数据库的状态信息是所述从服务器根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作得到的。Obtaining, from the server, status information of each database after the update, and the status information of each new database is that the slave server performs historical state information of the database according to status information of each database. The update operation was obtained.
  5. 如权利要求4所述的方法,其特征在于,所述从服务器周期性探测所述至少两组数据库中每组数据库中的每个数据库的状态信息,包括:The method of claim 4, wherein the slave server periodically detects status information of each database in each of the at least two groups of databases, including:
    所述从服务器若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过所述第一预设时长后开始探测所述至少两组数据库的每个数据库的状态信息;If the slave server determines that the total duration of the last update operation is not greater than the first preset duration, starting from the last update operation, starting to detect each of the at least two groups of databases after the first preset duration Status information of the database;
    所述从服务器若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测所述至少两组数据库的每个数据库的状态信息。If the slave server determines that the total duration of the last update operation is greater than the first preset duration, the status information of each database of the at least two groups of databases is detected after the last update operation ends.
  6. 一种数据库的切换方法,其特征在于,包括A database switching method, characterized in that it comprises
    主服务器接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;The primary server receives information of each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
    所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。The primary server determines, according to the status information of each database, whether to switch between databases with the same group identifier of the database.
  7. 如权利要求6所述的方法,其特征在于,所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换,包括:The method of claim 6, wherein the primary server determines whether to switch between databases having the same group identifier of the database according to the status information of each database, including:
    所述主服务器在确定所述数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的所述数据库时,则将数据库状态信息为异常状态的数据库切换所述数据库状态为正常状态的数据库。When the primary server determines that the database in which the database state information is in a normal state exists in the database having the same group identifier of the database, the database in which the database state information is in an abnormal state switches the database state to a normal state. database.
  8. 如权利要求6所述的方法,其特征在于,所述主服务器接收从服务器发送的每个数据库的信息之后,包括:The method according to claim 6, wherein after the primary server receives the information of each database sent from the server, the method includes:
    所述主服务器在确定所述传输每个数据库的信息的时长不大于第二预设时长时,所述主服务器根据所述每个数据库的状态信息确定数据库的组标识 相同的数据库之间是否进行切换;When the primary server determines that the length of the information for transmitting each database is not greater than the second preset duration, the primary server determines, according to the status information of each database, whether the database with the same group identifier of the database is performed. Switch
    所述主服务器在确定所述传输每个数据库的信息的时长大于第二预设时长时,所述主服务器向所述从服务器发送获取每个数据库的信息的请求。When the primary server determines that the duration of the information for transmitting each database is greater than the second preset duration, the primary server sends a request for obtaining information of each database to the secondary server.
  9. 一种数据库切换的从服务器,其特征在于,包括:A slave server for database switching, characterized in that it comprises:
    获取单元,用于获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;An obtaining unit, configured to acquire state information of each database in each group of the at least two groups of databases; wherein each of the groups of databases includes a primary database and at least one standby database, where each database group corresponds to four functional types Any one or more of the following; the four functional types include an add function, a delete function, a change function, and a query function; the status information includes a normal status and an abnormal status;
    发送单元,用于向主服务器发送所述每个数据库的信息,所述每个数据库的信息用于使所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息。a sending unit, configured to send, to the primary server, the information of each database, where the information of each database is used to cause the primary server to determine, according to the status information of each database, a database with the same group identifier of the database Whether to perform handover; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database.
  10. 如权利要求9所述的从服务器,其特征在于,所述查询功能对应至少一组数据库;所述至少一组数据库中的每组数据库分别对应至少一种业务类型。The slave server of claim 9, wherein the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one type of service.
  11. 如权利要求10所述的从服务器,其特征在于,所述至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:The slave server according to claim 10, wherein each of the at least one group of databases corresponds to at least one type of service, respectively:
    交易频率大于频率阈值的业务类型对应一组数据库;A service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases;
    和/或;and / or;
    交易数量大于数量阈值的业务类型对应一组数据库。A business type with a transaction quantity greater than the quantity threshold corresponds to a set of databases.
  12. 如权利要求9所述的从服务器,其特征在于,还包括探测单元,用于:The slave server according to claim 9, further comprising a detecting unit, configured to:
    周期性探测所述至少两组数据库中每组数据库中的每个数据库的状态信息;Periodically detecting status information of each database in each of the at least two groups of databases;
    还包括更新单元,用于:Also included is an update unit for:
    根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新 操作;Updating the historical state information of the database according to the state information of each database;
    所述获取单元,用于:The obtaining unit is configured to:
    获取更新后的每个数据库的状态信息,所述跟新后的每个数据库的状态信息是所述更新单元根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作得到的。Obtaining status information of each database after the update, and the status information of each database after the update is obtained by the update unit performing an update operation on the historical state information of the database according to the state information of each database. .
  13. 如权利要求12所述的从服务器,其特征在于,所述探测单元,用于:The slave server according to claim 12, wherein the detecting unit is configured to:
    若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过所述第一预设时长后开始探测所述至少两组数据库的每个数据库的状态信息;若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测所述至少两组数据库的每个数据库的状态信息。If it is determined that the total duration of the last update operation is not greater than the first preset duration, starting from the last update operation, starting to detect status information of each database of the at least two groups of databases after the first preset duration If it is determined that the total duration of the last update operation is greater than the first preset duration, the state information of each database of the at least two groups of databases is detected from the end of the last update operation.
  14. 一种数据库切换的主服务器,其特征在于,包括A master server for database switching, characterized in that it comprises
    接收单元,用于接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;a receiving unit, configured to receive information about each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
    决策单元,用于根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。And a determining unit, configured to determine, according to the state information of each database, whether to switch between databases with the same group identifier of the database.
  15. 如权利要求14所述的主服务器,其特征在于,所述决策单元,用于:The master server according to claim 14, wherein the decision unit is configured to:
    在确定所述数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的所述数据库时,则将数据库状态信息为异常状态的数据库切换所述数据库状态为正常状态的数据库。When it is determined that at least one database in which the database state information is in a normal state exists in a database having the same group identifier of the database, the database in which the database state information is an abnormal state switches the database in which the database state is a normal state.
  16. 如权利要求14所述的主服务器,其特征在于,所述决策单元,用于:The master server according to claim 14, wherein the decision unit is configured to:
    在确定所述传输每个数据库的信息的时长不大于第二预设时长时,所述决策单元根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;When determining that the duration of the information for transmitting each database is not greater than the second preset duration, the determining unit determines, according to the state information of each database, whether to switch between databases with the same group identifier of the database;
    所述决策单元在确定所述传输每个数据库的信息的时长大于第二预设时长时,所述决策单元向所述从服务器发送获取每个数据库的信息的请求。The determining unit sends a request for acquiring information of each database to the slave server when determining that the duration of the information for transmitting each database is greater than a second preset duration.
  17. 一种电子设备,其特征在于,包括处理器、存储器、收发器、总线接口,其中处理器、存储器与收发器之间通过总线连接;An electronic device, comprising: a processor, a memory, a transceiver, a bus interface, wherein a processor, a memory and a transceiver are connected by a bus;
    所述处理器,用于读取所述存储器中的程序,执行下列方法:用于获取至少两组数据库中每组数据库中的每个数据库的状态信息;其中,所述每组数据库包括一个主数据库和至少一个备数据库,所述每组数据库对应四种功能类型中任一种或者任多种;所述四种功能类型包括增加功能、删除功能、更改功能以及查询功能;所述状态信息包括正常状态和异常状态;The processor is configured to read a program in the memory, and execute the following method: acquiring state information of each database in each group of at least two groups of databases; wherein each group of databases includes a master a database and at least one standby database, each set of databases corresponding to any one or more of four functional types; the four functional types including an add function, a delete function, a change function, and a query function; the status information includes Normal state and abnormal state;
    所述收发器,用于向主服务器发送所述每个数据库的信息,所述每个数据库的信息用于使所述主服务器根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;其中,所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;The transceiver is configured to send information about each database to a primary server, where the information of each database is used to enable the primary server to determine a database with the same group identifier of the database according to status information of each database. Whether the switching is performed; wherein the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
    所述存储器,用于存储一个或多个可执行程序,可以存储所述处理器在执行操作时所使用的数据。The memory is configured to store one or more executable programs, and may store data used by the processor when performing operations.
  18. 如权利要求17所述的电子设备,其特征在于,所述查询功能对应至少一组数据库;所述至少一组数据库中的每组数据库分别对应至少一种业务类型。The electronic device of claim 17, wherein the query function corresponds to at least one set of databases; each of the at least one set of databases corresponds to at least one type of service.
  19. 如权利要求18所述的电子设备,其特征在于,所述至少一组数据库中的每组数据库分别对应至少一种业务类型,包括:The electronic device according to claim 18, wherein each of the at least one set of databases corresponds to at least one type of service, respectively:
    交易频率大于频率阈值的业务类型对应一组数据库;A service type whose transaction frequency is greater than a frequency threshold corresponds to a group of databases;
    和/或;and / or;
    交易数量大于数量阈值的业务类型对应一组数据库。A business type with a transaction quantity greater than the quantity threshold corresponds to a set of databases.
  20. 如权利要求17所述的电子设备,其特征在于,所述处理器,用于:The electronic device according to claim 17, wherein the processor is configured to:
    周期性探测所述至少两组数据库中每组数据库中的每个数据库的状态信息;根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作;获取更新后的每个数据库的状态信息,所述跟新后的每个数据库的状态信息是所述处理器根据所述每个数据库的状态信息对所述数据库的历史状态信息进行更新操作得到的。Periodically detecting status information of each database in each of the at least two groups of databases; performing update operations on historical state information of the database according to status information of each database; acquiring each database after update Status information, the state information of each database after the new is obtained by the processor performing an update operation on the historical state information of the database according to the state information of each database.
  21. 如权利要求20所述的电子设备,其特征在于,所述处理器,用于:The electronic device according to claim 20, wherein the processor is configured to:
    若确定上一次更新操作的总时长不大于第一预设时长,则从上一次更新操作起始,经过所述第一预设时长后开始探测所述至少两组数据库的每个数据库的状态信息;若确定上一次更新操作的总时长大于第一预设时长,则从上一次更新操作结束后开始探测所述至少两组数据库的每个数据库的状态信息。If it is determined that the total duration of the last update operation is not greater than the first preset duration, starting from the last update operation, starting to detect status information of each database of the at least two groups of databases after the first preset duration If it is determined that the total duration of the last update operation is greater than the first preset duration, the state information of each database of the at least two groups of databases is detected from the end of the last update operation.
  22. 一种电子设备,其特征在于,包括:处理器、存储器、收发器和总线接口,其中,处理器、存储器、收发器和总线接口之间通过总线连接;An electronic device, comprising: a processor, a memory, a transceiver, and a bus interface, wherein a processor, a memory, a transceiver, and a bus interface are connected by a bus;
    所述收发器,用于接收从服务器发送的至少两组数据库中每组数据库中的每个数据库的信息;所述每个数据库的信息包括数据库的标识、数据库的组标识以及数据库的状态信息;The transceiver is configured to receive information about each database in each of the at least two groups of databases sent from the server; the information of each database includes an identifier of the database, a group identifier of the database, and status information of the database;
    所述处理器,用于根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换。The processor is configured to determine, according to the status information of each database, whether to switch between databases with the same group identifier of the database.
  23. 如权利要求22所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 22, wherein the processor is further configured to:
    在确定所述数据库的组标识相同的数据库中存在至少一个数据库状态信息为正常状态的所述数据库时,则将数据库状态信息为异常状态的数据库切换所述数据库状态为正常状态的数据库。When it is determined that at least one database in which the database state information is in a normal state exists in a database having the same group identifier of the database, the database in which the database state information is an abnormal state switches the database in which the database state is a normal state.
  24. 如权利要求23所述的电子设备,其特征在于,所述处理器,还用于:The electronic device according to claim 23, wherein the processor is further configured to:
    在确定所述传输每个数据库的信息的时长不大于第二预设时长时,所述决策单元根据所述每个数据库的状态信息确定数据库的组标识相同的数据库之间是否进行切换;在确定所述传输每个数据库的信息的时长大于第二预设时长时,向所述从服务器发送获取每个数据库的信息的请求。When determining that the duration of the information for transmitting each database is not greater than the second preset duration, the decision unit determines, according to the state information of each database, whether to switch between databases with the same group identifier of the database; When the duration of transmitting the information of each database is greater than the second preset duration, a request for acquiring information of each database is sent to the slave server.
  25. 一种非暂态计算机可读存储介质,其特征在于,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行权利要求1~5任一所述方法,或者所述计算机指令用于使所述计算机执行权利要求6~8任一所述方法。A non-transitory computer readable storage medium, wherein the non-transitory computer readable storage medium stores computer instructions for causing the computer to perform the method of any one of claims 1 to 5. Or the computer instructions are for causing the computer to perform the method of any of claims 6-8.
  26. 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储 在非暂态计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行权利要求1~5任一所述方法;或者使所述计算机执行权利要求6~8任一所述方法。A computer program product, comprising: a computing program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, The computer executes the method of any one of claims 1 to 5; or causes the computer to perform the method of any of claims 6-8.
PCT/CN2018/074160 2017-04-18 2018-01-25 Database switching method, master server and slave server WO2018192286A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710253569.2 2017-04-18
CN201710253569.2A CN107066354B (en) 2017-04-18 2017-04-18 Database switching method, master server and slave server

Publications (1)

Publication Number Publication Date
WO2018192286A1 true WO2018192286A1 (en) 2018-10-25

Family

ID=59600554

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/074160 WO2018192286A1 (en) 2017-04-18 2018-01-25 Database switching method, master server and slave server

Country Status (3)

Country Link
CN (1) CN107066354B (en)
TW (1) TWI669620B (en)
WO (1) WO2018192286A1 (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107066354B (en) * 2017-04-18 2021-01-05 中国银联股份有限公司 Database switching method, master server and slave server
CN107632906A (en) * 2017-09-30 2018-01-26 北京九桥同步软件有限公司 Database data backup method and device
CN108647113B (en) * 2018-03-30 2022-02-18 创新先进技术有限公司 Disaster recovery method and server
CN108924772B (en) * 2018-08-02 2021-12-03 平安科技(深圳)有限公司 Short message sending method and device, computer equipment and storage medium
CN110928945B (en) * 2018-09-04 2023-06-20 阿里巴巴集团控股有限公司 Data processing method and device for database and data processing system
CN110019535B (en) * 2018-09-07 2021-08-27 网联清算有限公司 Database management method, database management device, storage medium and computer equipment
CN109756555A (en) * 2018-11-13 2019-05-14 北京码牛科技有限公司 Big data processing method and processing device based on Internet of Things
TWI661322B (en) * 2018-11-28 2019-06-01 中華電信股份有限公司 Database accessing system and database accessing method
TWI772685B (en) * 2019-09-26 2022-08-01 兆豐國際商業銀行股份有限公司 Business message monitoring system
CN113688101A (en) * 2021-08-11 2021-11-23 杭州网易云音乐科技有限公司 Retrieval method, medium, device and computing equipment based on file fingerprint database
CN115277378B (en) * 2022-05-19 2024-03-19 亿点云计算(珠海)有限公司 Service switching method, device, terminal and storage medium based on stateful service

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102761528A (en) * 2011-04-28 2012-10-31 中兴通讯股份有限公司 System and method for data management
CN103019875A (en) * 2012-12-19 2013-04-03 北京世纪家天下科技发展有限公司 Method and device for realizing double main reconstruction of database
CN103795553A (en) * 2012-10-29 2014-05-14 中国银联股份有限公司 Switching of main and standby servers on the basis of monitoring
CN107066354A (en) * 2017-04-18 2017-08-18 中国银联股份有限公司 A kind of switching method of database, master server and from server

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101876924B (en) * 2009-04-30 2013-10-30 升东网络科技发展(上海)有限公司 Database fault automatic detection and transfer method
US20120173490A1 (en) * 2010-12-30 2012-07-05 Verisign, Inc. Method and system for implementing business logic
CN103853634B (en) * 2014-02-26 2017-02-01 北京优炫软件股份有限公司 Disaster recovery system and disaster recovery method
CN104486155A (en) * 2014-12-15 2015-04-01 北京趣拿软件科技有限公司 Database cluster monitoring method and system
US10127095B2 (en) * 2015-11-04 2018-11-13 Quanta Computer Inc. Seamless automatic recovery of a switch device
CN105468717B (en) * 2015-11-20 2020-11-10 北京百度网讯科技有限公司 Database operation method and device
CN105550065A (en) * 2015-12-11 2016-05-04 广州华多网络科技有限公司 Database server communication management method and device
CN105721200A (en) * 2016-01-21 2016-06-29 北京乐动卓越科技有限公司 Master-slave server system application method and system thereof
CN106294795A (en) * 2016-08-15 2017-01-04 合肥华凌股份有限公司 A kind of data base's changing method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102761528A (en) * 2011-04-28 2012-10-31 中兴通讯股份有限公司 System and method for data management
CN103795553A (en) * 2012-10-29 2014-05-14 中国银联股份有限公司 Switching of main and standby servers on the basis of monitoring
CN103019875A (en) * 2012-12-19 2013-04-03 北京世纪家天下科技发展有限公司 Method and device for realizing double main reconstruction of database
CN107066354A (en) * 2017-04-18 2017-08-18 中国银联股份有限公司 A kind of switching method of database, master server and from server

Also Published As

Publication number Publication date
TW201839636A (en) 2018-11-01
TWI669620B (en) 2019-08-21
CN107066354B (en) 2021-01-05
CN107066354A (en) 2017-08-18

Similar Documents

Publication Publication Date Title
WO2018192286A1 (en) Database switching method, master server and slave server
EP3839749B1 (en) Data storage method, device and server
US11907561B2 (en) Data backup method and apparatus
JP6325001B2 (en) Method and system using recursive event listeners in nodes of hierarchical data structures
US9367261B2 (en) Computer system, data management method and data management program
EP3562096B1 (en) Method and device for timeout monitoring
US10762109B2 (en) Asynchronous deletion in non-relational databases
US10956383B2 (en) Device backup and wipe
US11132265B2 (en) Multi-replica data restoration method and apparatus
CN110119304B (en) Interrupt processing method and device and server
CN106777126B (en) Data online migration method supporting heterogeneous time sequence database
CN103984768B (en) A kind of data-base cluster manages method, node and the system of data
US11184435B2 (en) Message transmission method and apparatus in cluster file system
WO2020015116A1 (en) Database monitoring method and terminal device
US11032371B2 (en) Data migration using read function triggers
CN115344551A (en) Data migration method and data node
US9973440B2 (en) Resource notification method, device and system
CN104850416A (en) Upgrading system, method and device and cloud computing node
CN103019847A (en) Method and system for migrating data of virtual machine
CN115510036A (en) Data migration method, device, equipment and storage medium
EP4066117B1 (en) Managing provenance information for data processing pipelines
US10809939B2 (en) Disk synchronization
CN110659259B (en) Database migration method, server and computer storage medium
KR20170020290A (en) Method for handling sequential transactions in IoT network, IoT communication node for the same, and IoT network using the same
CN117891563A (en) Control method and device of virtual machine, storage medium and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18786997

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18786997

Country of ref document: EP

Kind code of ref document: A1