TWI669620B - Database switching method, server, storage medium, electronic device and product - Google Patents

Database switching method, server, storage medium, electronic device and product Download PDF

Info

Publication number
TWI669620B
TWI669620B TW107108986A TW107108986A TWI669620B TW I669620 B TWI669620 B TW I669620B TW 107108986 A TW107108986 A TW 107108986A TW 107108986 A TW107108986 A TW 107108986A TW I669620 B TWI669620 B TW I669620B
Authority
TW
Taiwan
Prior art keywords
database
status information
information
databases
group
Prior art date
Application number
TW107108986A
Other languages
Chinese (zh)
Other versions
TW201839636A (en
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 TW201839636A publication Critical patent/TW201839636A/en
Application granted granted Critical
Publication of TWI669620B publication Critical patent/TWI669620B/en

Links

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

Abstract

資料庫的切換方法、伺服器、存儲介質、電子設備及產品,獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;向主要伺服器發送該每個資料庫的資訊,該每個資料庫的資訊用於使該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊。 The data library switching method, the server, the storage medium, the electronic device and the product, obtain state information of each database in each group of at least two groups of databases; wherein each group of the database includes a main database And at least one standby database corresponding 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 abnormality Status; sending information of each database to the primary server, the information of each database is used to enable the primary server to determine the database with the same group identifier of the database according to the status information of each database Whether to switch; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database.

Description

資料庫的切換方法、伺服器、存儲介質、電子設備及產品 Database switching method, server, storage medium, electronic device and product

本發明實施例屬於通信領域,尤其是關於資料庫的切換方法、伺服器、存儲介質、電子設備及產品。 The embodiments of the present invention belong to the field of communications, and in particular, to a method for switching a database, a server, a storage medium, an electronic device, and a product.

隨著資訊化技術的快速發展,資料呈現爆炸式增長,隨之用於管理資料的資料庫就越來越重要了。當資料庫出現異常時,需要維護資料導致資料停止工作,甚至由於資料庫異常導致資料庫中資料丟失,如此可能會給企業和用戶帶來難以估計的經濟損失。因此,採取適當的措施來確保資料庫群組的高可用性是非常必要的,這裡高可用性是指通過減少因日常維護操作或突發異常導致資料庫異常的現象,以提高系統的高可用性。例如,當某一資料庫發生異常時,可以將與該資料庫相關的請求轉移到其他可以處於正常狀態的資料庫上,這樣可以保證公司和企業的核心業務系統安全、高效的運行。 With the rapid development of information technology, data is exploding, and the database for managing data is becoming more and more important. When the database is abnormal, the maintenance data needs to stop the work, and even the data in the database is lost due to the abnormal database, which may bring difficult economic losses to the enterprise and users. Therefore, it is necessary to take appropriate measures to ensure the high availability of the database group. Here, high availability refers to improving the high availability of the system by reducing the abnormality of the database caused by routine maintenance operations or sudden abnormalities. For example, when an exception occurs in a database, the request related to the database can be transferred to other databases that can be in a normal state, thus ensuring 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 nodes of the main server in the database group, or to select multiple major server boundary nodes in the same data and service processing, but if the database abnormality is due to high frequency transactions or a large number of Data processing causes the database to be abnormal after switching to the normal working database. Therefore, it is necessary to continuously switch the database, and it is necessary to continuously maintain an abnormal database, which seriously affects the system. Operational efficiency Rate and security.

本發明實施例提供資料庫的切換方法、伺服器、存儲介質、電子設備及產品,用於通過簡單的配置實現資料庫組之間的獨立監控與切換,有助於系統的高可用性。 Embodiments of the present invention provide a method for switching a database, a server, a storage medium, an electronic device, and a product, which are used for independent monitoring and switching between database groups through simple configuration, thereby contributing to high availability of the system.

第一方面,本發明實施例提供一種資料庫的切換方法,包括:從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;該從屬伺服器向主要伺服器發送該每個資料庫的資訊,該每個資料庫的資訊用於使該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊。 In a first aspect, an embodiment of the present invention provides a method for switching a database, including: a slave server acquiring state information of each database in each group of at least two groups of databases; wherein each group includes a primary database and at least one standby database, each of which 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 state and an abnormal state; the slave server sends the information of each database to the primary server, and the information of each database is used to enable the primary server to determine the database according to the status information of each database. Whether the group identifiers are switched between the same database; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database.

由於本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;根據資料庫的功能類型分為至少兩個資料庫組,形成相互獨立的至少兩組資料庫,各每組之間的資料相互獨立;將至少兩組資料庫中的每個組資料庫中的每個資料庫的資訊發送到主服務,主要伺服器根據每個資料庫的狀態資訊確定在同一組中的資料庫之間是否進行切換;如此,相同組標識之間的資料才能進行切換,通過簡單的配置實現資料庫組之間的獨立監控與切換,進而有助於系統的的高可用性。 In the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group includes a primary database and at least one standby database. Each group of data library 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; according to the function of the database The types are divided into at least two database groups, and at least two sets of databases are formed independently of each other, and the data between each group is independent of each other; at least each of the two sets of databases in each of the two sets of databases is The information 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 identification can be switched, and the data is realized through simple configuration. Independent monitoring and switching between library groups helps the system's high availability.

可選地,該查詢功能對應至少一組資料庫;該至少一組資料庫中的每組資料庫分別對應至少一種業務類型。 Optionally, the query function corresponds to at least one group of databases; each of the at least one group of databases corresponds to at least one type of service.

可選地,該至少一組資料庫中的每組資料庫分別對應至少一種業務類型,包括:交易頻率大於頻率閾值的業務類型對應一組資料庫;和/或;交易數量大於數量閾值的業務類型對應一組資料庫。 Optionally, each group of the at least one group of databases corresponds to at least one type of service, respectively, and the service type whose transaction frequency is greater than the frequency threshold corresponds to a group of databases; and/or; the service whose transaction quantity is greater than the quantity threshold The type corresponds to a set of databases.

可選地,該從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊之前,還包括:該從屬伺服器週期性探測該至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;該從屬伺服器根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作;該從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊,包括:該從屬伺服器獲取更新後的每個資料庫的狀態資訊,該跟新後的每個資料庫的狀態資訊是該從屬伺服器根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作得到的。 Optionally, before the slave server obtains status information of each database in each group of the at least two groups of databases, the method further includes: the slave server periodically detecting each group of the at least two groups of data Status information of each database in the library; the slave server updates the history status information of the database according to the status information of each database; the slave server obtains each group of data in at least two groups of databases Status information of each database in the library, including: the slave server obtains updated status information of each database, and the status information of each new database is the slave server according to each The status information of the database is obtained by updating the historical status information of the database.

可選地,該從屬伺服器週期性探測該至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊,包括:該從屬伺服器若確定上一次更新操作的總時長不大於第一預設時長,則從上一次更新操作起始,經過該第一預設時長後開始探測該至少兩組資料庫的每個資料庫的狀態資訊;該從屬伺服器若確定上一次更新操作的總時長大於第一預設時長,則從上一 次更新操作結束後開始探測該至少兩組資料庫的每個資料庫的狀態資訊。 Optionally, the slave server periodically detects status information of each database in each of the at least two groups of databases, including: the slave server determines that the total duration of the last update operation is not greater than The first preset duration starts from the last update operation, and after the first preset duration, starts to detect status information of each database of the at least two groups of databases; if the slave server determines the last update The total duration of the operation is greater than the first preset duration, and the status information of each database of the at least two groups of databases is detected after the last update operation ends.

第二方面,本發明實施例提供一種資料庫的切換方法,包括:主要伺服器接收從屬伺服器發送的至少兩組資料庫中每組資料庫中的每個資料庫的資訊;該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換。 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 of the at least two groups of data streams sent by the slave server; each of the data The information of the library includes the identifier of the database, the group identifier of the database, and the status information of the database; the main server determines whether the database with the same group identifier of the database is switched according to the status information of each 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 determines the same group identifier of the database. When there is at least one database in which the database state information is in a normal state, the database whose state information is in an abnormal state is switched to a database whose state is in a normal state.

可選地,該主要伺服器接收從屬伺服器發送的每個資料庫的資訊之後,包括:該主要伺服器在確定該傳輸每個資料庫的資訊的時長不大於第二預設時長時,該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;該主要伺服器在確定該傳輸每個資料庫的資訊的時長大於第二預設時長時,該主要伺服器向該從屬伺服器發送獲取每個資料庫的資訊的請求。 Optionally, after the primary server receives the information of each database sent by the slave server, the method includes: when the primary server determines that the time for transmitting the information of each database is not greater than the second preset duration And the primary server determines, according to the status information of each database, whether to switch between the same database with the same group identifier of the database; the primary server determines that the time for transmitting the information of each database is greater than the second When the preset duration is long, the primary server sends a request to the slave server to obtain information for each database.

第三方面,本發明實施例提供一種資料庫的切換的從屬伺服器,包括:獲取單元,用於獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種 功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;發送單元,用於向主要伺服器發送該每個資料庫的資訊,該每個資料庫的資訊用於使該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊。 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 at least two groups of data databases; Each group of databases includes a main database and at least one standby database, each of which corresponds to any one or more of four functional types; the four functional types include adding functions, deleting functions, changing functions, and query functions. The status information includes a normal status and an abnormal status; the sending unit is configured to send information of each database to the primary server, and the information of each database is used to make the primary server according to each database The status information determines whether the database with the same group identifier of the database is switched; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database.

由於本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;根據資料庫的功能類型分為至少兩個資料庫組,形成相互獨立的至少兩組資料庫,各每組之間的資料相互獨立;將至少兩組資料庫中的每個組資料庫中的每個資料庫的資訊發送到主服務,主要伺服器根據每個資料庫的狀態資訊確定在同一組中的資料庫之間是否進行切換;如此,相同組標識之間的資料才能進行切換,通過簡單的配置實現資料庫組之間的獨立監控與切換,進而有助於系統的的高可用性。 In the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group includes a primary database and at least one standby database. Each group of data library 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; according to the function of the database The types are divided into at least two database groups, and at least two sets of databases are formed independently of each other, and the data between each group is independent of each other; at least each of the two sets of databases in each of the two sets of databases is The information 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 identification can be switched, and the data is realized through simple configuration. Independent monitoring and switching between library groups helps the system's high availability.

可選地,該查詢功能對應至少一組資料庫;該至少一組資料庫中的每組資料庫分別對應至少一種業務類型。 Optionally, the query function corresponds to at least one group of databases; each of the at least one group of databases corresponds to at least one type of service.

可選地,該至少一組資料庫中的每組資料庫分別對應至少一種業務類型,包括:交易頻率大於頻率閾值的業務類型對應一組資料庫;和/或;交易數量大於數量閾值的業務類型對應一組資料庫。 Optionally, each group of the at least one group of databases corresponds to at least one type of service, respectively, and the service type whose transaction frequency is greater than the frequency threshold corresponds to a group of databases; and/or; the service whose transaction quantity is greater than the quantity threshold The type corresponds to a set of databases.

可選地,還包括探測單元,用於:週期性探測該至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;還包括更新單元,用於:所根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作;該獲取單元,用於:所獲取更新後的每個資料庫的狀態資訊,該跟新後的每個資料庫的狀態資訊是該更新單元根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作得到的。 Optionally, the method further includes: a detecting unit, configured to: periodically detect status information of each database in each of the at least two groups of databases; and further include an updating unit, configured to: each of the data according to the data The status information of the database is updated by 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 unit obtains an update operation of the historical status information of the database according to the status 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 detecting after the first preset duration Status 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, then detecting the at least two groups from the end of the last update operation Status information for each database in the database.

第四方面,本發明實施例提供一種資料庫切換的主要伺服器,包括:接收單元,用於接收從屬伺服器發送的至少兩組資料庫中每組資料庫中的每個資料庫的資訊;該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;所決策單元,用於根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換。 In a fourth aspect, the embodiment of the present invention provides a main server for database switching, comprising: a receiving unit, configured to receive information about each database in each of the at least two groups of data databases sent by the slave server; The information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database; the decision unit is configured to determine the database with the same group identifier of the database according to the status information of each database. Whether to switch between.

可選地,該決策單元,用於:所在確定該資料庫的組標識相同的資料庫中存在至少一個資料庫狀態資訊為正常狀態的該資料庫時,則將資料庫狀態資訊為異常狀態的資料庫切換該資料庫狀態為正常狀態的資料庫。 Optionally, the determining unit is configured to: when the database in which the at least one database state information is in a normal state in the database having the same group identifier of the database is determined, the database state information is an abnormal state. The database switches the database whose status is normal.

可選地,該決策單元,用於:所在確定該傳輸每個資料庫的資訊的時長不大於第二預設時長時,該決策單元根據該每個資料庫的狀態 資訊確定資料庫的組標識相同的資料庫之間是否進行切換;該決策單元在確定該傳輸每個資料庫的資訊的時長大於第二預設時長時,該決策單元向該從屬伺服器發送獲取每個資料庫的資訊的請求。 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 the database according to the state information of each database Whether the group identifiers are switched between the same database; when the decision unit determines that the length of the information for transmitting each database is greater than the second preset duration, the decision unit sends and acquires each data to the slave server. A request for information from the library.

第五方面,本發明實施例中提供了一種電子設備,包括:處理器、記憶體、收發器和匯流排介面,其中,處理器、記憶體、收發器和匯流排介面之間通過匯流排連接;該處理器,用於讀取該記憶體中的程式,執行下列方法:獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;該記憶體,用於存儲一個或多個可執行程式,可以存儲該處理器在執行操作時所使用的資料;該收發器,用於在該處理器的控制下向主要伺服器發送該每個資料庫的資訊,該每個資料庫的資訊用於使該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊。 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 the processor, the memory, the transceiver, and the bus interface are connected by a bus bar. 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 includes one a primary database and at least one standby database, each of which corresponds to any one or more of 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 normal State and abnormal state; the memory for storing one or more executable programs, which can store data used by the processor when performing operations; the transceiver is configured to be driven to the main servo under the control of the processor Transmitting the information of each database, and the information of each database is used to make the main server confirm the status information of each database. Whether to switch between the same group identifier database repository; wherein each of the database information includes the group identifier and status information identifying database repository, the repository.

第六方面,本發明實施例中提供了另一種電子設備,包括:處理器、記憶體、收發器和匯流排介面,其中,處理器、記憶體、收發器和匯流排介面之間通過匯流排連接;該收發器,用於接收從屬伺服器發送的至少兩組資料庫中每組資料庫 中的每個資料庫的資訊;該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;該處理器,用於讀取該記憶體中的程式,執行下列方法:根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;該記憶體,用於存儲一個或多個可執行程式,可以存儲該處理器在執行操作時所使用的資料。 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 the processor, the memory, the transceiver, and the bus interface pass through the bus The transceiver is configured to receive information of each database in each of the at least two groups of data streams sent by the slave server; the information of each database includes the identifier of the database, the group of the database The identifier and the status information of the database; the processor is configured to read the program in the memory, and perform the following method: determining whether the database with the same group identifier of the database is performed according to the status information of each database Switching; the memory for storing one or more executable programs that can store data used by the processor when performing operations.

第七方面,本發明實施例提供一種非暫態電腦可讀存儲介質,電腦存儲介質中存儲有指令,當其在電腦上運行時,使得電腦執行第一方面或第一方面的任意可能的實現方式中的方法,或者使得電腦執行第二方面或第二方面的任意可能的實現方式中的方法。 According to a seventh aspect, an embodiment of the present invention 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 the first aspect or any possible implementation of the first aspect. The method of the method, or the method of causing the computer to perform the second aspect or any possible implementation of the second aspect.

第八方面,本發明實施例提供一種包含指令的電腦程式產品,當其在電腦上運行時,使得電腦執行第一方面或第一方面的任意可能的實現方式中的方法,或者使得電腦執行第二方面或第二方面的任意可能的實現方式中的方法。 In an eighth aspect, an embodiment of the present invention provides a computer program product including instructions, which when executed on a computer, causes the computer to perform the method in the first aspect or any possible implementation manner of the first aspect, or causes the computer to execute the first The method of any of the two aspects or any of the possible implementations of the second aspect.

由於本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;根據資料庫的功能類型分為至少兩個資料庫組,形成相互獨立的至少兩組資料庫,各每組之間的資料相互獨立;將至少兩組資料庫中的每個組資料庫中的每個資料庫的資訊發送到主服務,主要伺服器根據每個資料庫的狀態資訊確定在同一組中的 資料庫之間是否進行切換;如此,相同組標識之間的資料才能進行切換,通過簡單的配置實現資料庫組之間的獨立監控與切換,進而有助於系統的的高可用性。 In the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group includes a primary database and at least one standby database. Each group of data library 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; according to the function of the database The types are divided into at least two database groups, and at least two sets of databases are formed independently of each other, and the data between each group is independent of each other; at least each of the two sets of databases in each of the two sets of databases is The information 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 identification can be switched, and the data is realized through simple configuration. Independent monitoring and switching between library groups helps the system's high availability.

S201~S204‧‧‧步驟 S201~S204‧‧‧Steps

101‧‧‧資料庫群組 101‧‧‧Database group

102‧‧‧從屬伺服器 102‧‧‧Subordinate Server

103‧‧‧主要伺服器 103‧‧‧Main server

104、105‧‧‧資料庫組 104, 105‧‧‧ database group

104a、105a‧‧‧主要資料庫 104a, 105a‧‧‧ main database

104b、105b‧‧‧備用資料庫 104b, 105b‧‧‧Alternative database

106a~106d‧‧‧資料庫探測進程 106a~106d‧‧‧Database detection process

107a、107b‧‧‧資料庫組監控進程 107a, 107b‧‧‧ database group monitoring process

108‧‧‧資料庫的資訊發送進程 108‧‧‧Information transfer process

109‧‧‧接收進程 109‧‧‧ Receiving process

110‧‧‧決策進程 110‧‧‧Decision process

300‧‧‧從屬伺服器 300‧‧‧Subordinate server

301‧‧‧獲取單元 301‧‧‧Acquisition unit

302‧‧‧發送單元 302‧‧‧Send unit

303‧‧‧探測單元 303‧‧‧Detection unit

304‧‧‧更新單元 304‧‧‧Update Unit

400‧‧‧主要伺服器 400‧‧‧Main server

401‧‧‧接收單元 401‧‧‧ receiving unit

402‧‧‧決策單元 402‧‧‧Decision unit

501、601‧‧‧處理器 501, 601‧‧‧ processor

502、602‧‧‧記憶體 502, 602‧‧‧ memory

503、603‧‧‧收發機 503, 603‧‧‧ transceiver

504、604‧‧‧匯流排介面 504, 604‧‧ ‧ bus interface

505、605‧‧‧匯流排 505, 605‧‧ ‧ busbar

為了更清楚地說明本發明實施例中的技術方案,下面將對實施例描述中所需要使用的附圖作簡要介紹。 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為本發明實施例提供的一種通信系統架構示意圖;圖2為本發明實施例提供的一種資料庫的切換方法流程示意圖;圖3為本發明實施例提供的一種從屬伺服器的結構示意圖;圖4為本發明實施例提供的一種主要伺服器的結構示意圖;圖5為本發明實施例提供的一種電子設備的結構示意圖;圖6為本發明實施例提供的另一種電子設備的結構示意圖。 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 data base 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 invention; 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 invention; and FIG. 6 is a schematic structural diagram of another electronic device according to an embodiment of the present invention.

為了使本發明的目的、技術方案及有益效果更加清楚明白,以下結合附圖及實施例,對本發明進行進一步詳細說明。應當理解,此處所描述的具體實施例僅僅用以解釋本發明,並不用於限定本發明。 The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. 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: Global System of Mobile Communication (GSM) system, Code Division Multiple Access (CDMA) system, and broadband. 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 group 101, a slave server 102, and a primary server 103. The primary server and the slave server are connected by wireless connection or wired connection or other means, and the slave server and each database in the database group are connected by wireless connection or wired connection or other means.

資料庫群組101包括至少兩組資料庫,資料庫組104和資料庫組105,資料庫組104和105分別包括一個主要資料庫和至少一個備用資料庫,資料庫組104包括主要資料庫104a和備用資料庫104b,資料庫組105包括主要資料庫105a和備用資料庫105b。主要資料庫和備用資料庫之間採用PSY進行資料同步,確保主要資料庫和備用資料庫中資料的同步。每組資料庫對應四種功能類型中任一種或者任多種;四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;比如該資料庫群組包括兩組資料庫104和105,這兩組資料庫分別是:查詢功能對應一組資料庫104,增加功能、刪除功能、更改功能對應另一組資料庫105;其中,每種功能類型的資料庫對應至少一組資料,查詢功能對應至少一組資料庫;至少一組資料庫中的每組資料庫分別對應至少一種業務類型,其中業務類型包括:取現、 消費、查詢餘額等。 The database group 101 includes at least two sets 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, and the database group 104 includes a primary database 104a. And the standby database 104b, the database group 105 includes a primary database 105a and a backup database 105b. PSY is used to synchronize data between the primary database and the alternate database to ensure synchronization of data in the primary and backup databases. Each group of databases 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; for example, the database group includes two sets of databases 104 and 105, The group database is respectively: the query function corresponds to a group of databases 104, and the adding function, the deleting function, and the changing function correspond to another group database 105; wherein each type of function type database corresponds to at least one set of data, and the query function corresponds to at least A set of databases; each of the at least one set of databases corresponds to at least one type of service, wherein the types of services include: cash withdrawal, consumption, and check 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 on the slave 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 slave node. The status information of all the databases connected by the server, 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_DB106a is used to detect the database of the database 104a. Status information; 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 status information of the database 105a, and the HCS_DB 106d is used to detect the database status information of the database 105b; each group of databases starts a data The library group monitoring process HCS_MON_AGENT is used to obtain the information of the database of each group, that is, HCS_MON_AGENT107a is used to obtain the database information of the database group 104, and the HCS_MON_AGENT 107b is used to obtain the database information of the database group 105; the information sending process of the database is UDP_SEND108 Come to the main The server 103 sends the information of each group of databases obtained by the database group monitoring process HCS_MON_AGENT107a~HCS_MON_AGENT107b.

主要伺服器103上部署資料庫監控與切換master模組,資料庫監控與切換master模組包括接收進程Infcollection109和決策進程Infdecision110。接收進程Infcollection109用於接收從屬伺服器發送的資料庫的資訊;決策進程Infdecision110用於根據接收到的從屬伺服器發送的資料庫的資訊,確定資料庫是否需要切換。 The main server 103 deploys a database monitoring and switching master module, and 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 used to receive the information of the database sent by the slave server; the decision process Infdecision 110 is used to determine whether the database needs to be switched according to the information of the database sent by the received slave server.

基於圖1所示的系統架構,圖2示例性示出了本發明實施例 提供的一種資料庫的切換方法流程示意圖,如圖2所示,本發明實施例提供的資料庫切換方法,包括以下步驟:步驟S201,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,每組資料庫包括一個主要資料庫和至少一個備用資料庫,每組資料庫對應四種功能類型中任一種或者任多種;四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;狀態資訊包括正常狀態和異常狀態;步驟S202,從屬伺服器向主要伺服器發送每個資料庫的資訊,其中,每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;步驟S203,主要伺服器接收從屬伺服器發送的至少兩組資料庫中每組資料庫中的每個資料庫的資訊;步驟S204,主要伺服器根據每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換。 Based on the system architecture shown in FIG. 1 , FIG. 2 exemplarily shows a schematic flowchart of a method for switching a database according to an embodiment of the present invention. As shown in FIG. 2 , the data library switching method provided by the embodiment of the present invention includes the following Step: Step S201: The slave server obtains status information of each database in each group of at least two groups of databases; wherein each group includes a primary database and at least one standby database, each group of data The library 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 in step S202, the slave server sends the slave server to the main server. The information of each database, wherein the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database; in step S203, the primary server receives at least two groups of databases sent by the slave server. Information of each database in each group of databases; step S204, the main server is based on the shape of each database Information to determine whether to switch between the same group identity database repository.

由於本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,每組資料庫包括一個主要資料庫和至少一個備用資料庫,每組資料庫對應四種功能類型中任一種或者任多種;四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;狀態資訊包括正常狀態和異常狀態;根據資料庫的功能類型分為至少兩個資料庫組,形成相互獨立的至少兩組資料庫,各每組之間的資料相互獨立;將至少兩組資料庫中的每個組資料庫中的每個資料庫的資訊發送到主服務,主要伺服器根據每個資料庫的狀態資訊確定在同一組中的資料庫之間是否 進行切換;如此,相同組標識之間的資料才能進行切換,可以通過簡單的配置實現資料庫組之間的獨立監控與切換,進而有助於資料庫的高可用性。 In the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group 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 sets of independent databases, each of which is independent of each other; and information of each of the at least two sets of databases is sent to the main Service, 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 identification can be switched, and the database group can be realized through simple configuration. Independent monitoring and switching between them, which in turn helps the database to be highly available.

在本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊,每組資料庫對應四種功能類型中任一種或者任多種,四種功能包括增加功能、刪除功能、更改功能以及查詢功能;其中,資料庫的查詢功能的使用頻率較高。可選地,查詢功能對應至少一組資料庫;至少一組資料庫中的每組資料庫分別對應至少一種業務類型。 In the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases, and each group of databases corresponds to any one or more of the four types of functions, and four functions. This includes adding functions, deleting functions, changing functions, and query functions; among them, the query function of the database is used more 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 group of databases, and the adding function, the deleting function, and the changing function correspond to at least another group of databases; each group of databases corresponds to at least one type of service, and the types of services include cash withdrawal, transfer, consumption, Pre-authorization or account settlement; the database 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 groups according to the type of service; optionally, adding functions, The delete function and the change function correspond to a set of databases, and the set of databases may also correspond to a set of databases or groups of databases according to the type of business.

可選地,查詢功能對應至少一組資料庫,該至少一組資料庫中的每組資料庫分別對應至少一種業務類型,包括:交易頻率大於頻率閾值的業務類型對應一組資料庫;和/或;交易數量大於數量閾值的業務類型對應一組資料庫。 Optionally, the query function corresponds to at least one set of data bases, and each set of the at least one set of data bases respectively corresponds to at least one service type, including: a set of data bases corresponding to a service type whose transaction frequency is greater than a frequency threshold; and/ Or; a business type with a transaction 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 group of databases, and the group of databases includes a main 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 a frequency threshold corresponds to a group of databases, and a service type whose transaction frequency is not greater than a frequency threshold corresponds to another group of databases; Or in the group of databases corresponding to the query 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 the group corresponding to the query function In the database, the service type whose transaction frequency is greater than the frequency threshold and the transaction quantity is greater than the quantity threshold corresponds to one set of data bases, and the other corresponds to another set of data bases.

可選地,任一種或者任多種功能類型對應的一組資料庫,其中,每組資料庫對應至少一種業務類型,根據業務類型可以將任一種或者任多種功能類型對應的該組資料庫繼續分組,比如交易頻率大於頻率閾值的業務類型對應一組資料庫;和/或;交易數量大於數量閾值的業務類型對應一組資料庫。如此,在原通信系統的構建中,可以降低資料庫的壓力,特別是存在高頻交易導致資料庫崩潰時,通過分組的方式可以有效解決針對同類大量資料處理的壓力問題。 Optionally, any one or a plurality of function types corresponding to a 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 of the plurality of types of functions may be further grouped according to the type of the service. For example, 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 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 the same kind of data processing.

可選地,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊之前,還包括:從屬伺服器週期性探測至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;從屬伺服器根據每個資料庫的狀態資訊對資料庫的歷史狀態資訊進行更新操作;從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊,包括:從屬伺服器獲取更新後的每個資料庫的狀態資訊,跟新後的每個資料庫的狀態資訊是從屬伺服器根據每個資料庫的狀態資訊對資料庫的歷史狀態資訊進行更新操作得到的。 Optionally, before the slave server obtains 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 the database Status information of each database; the slave server updates the history status information of the database according to the status information of each database; the slave server obtains each database in each group of at least two groups of databases The status information includes: the slave server obtains the updated status information of each database, and the status information of each database after the new database is the historical status of the database according to the status information of each database. Information obtained by the update operation.

在本發明實施例中,從屬伺服器關聯有多個資料庫,從屬伺 服器上的資料庫探測進程HCS_DB用來週期性探測該從屬伺服器所關聯的每個資料的狀態資訊,假設資料庫探測進程HCS_DB探測資料庫的週期為T,資料庫探測進程HCS_DB每隔週期T對所關聯的資料庫進行一次探測,從屬伺服器根據每個資料庫的狀態資訊對資料庫的歷史狀態資訊進行更新操作。更新操作需要一定的時間來完成。根據更新操作過程的時間來確定下一次啟動資料庫探測進程HCS_DB的時間。 In the embodiment of the present invention, the slave server is associated with multiple databases, and the database detection process HCS_DB on the slave server is used to periodically detect the status information of each data associated with the slave server, assuming database detection. The period of the process HCS_DB detection database is T, and the database detection process HCS_DB performs a detection on the associated database every cycle T, and the slave server updates the history status information of the database according to the status 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 slave server periodically detects status information of each of the at least two groups of the database, including: the slave server determines that the total duration of the last update operation is not greater than the first pre- If the duration is set, the status information of each database of at least two groups of databases is detected after the first preset time period; the slave server determines that the total duration of the last update operation is greater than The first preset duration starts to detect status information of each database of at least two groups of databases from the end of the last update operation. In this way, it can ensure that the database detection process HCS_DB can detect the status 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 slave server performs the detection of the database, the historical state information of the database is updated according to the state information of each database; the database detection process HCS_DB will be the database. After the status information is updated, the slave 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 status 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 the determination is not greater than the third preset duration, the historical status information of the database in the database monitoring process HCS_MON_AGENT is updated according to each database status information acquired; after the update is completed, the next acquisition is performed at least two groups. The status information of each database in each database in the database; determining the database group identifier corresponding to each database according to the mapping relationship between the identifier of the preset database and the identifier of the database group. When the determination is greater than the third preset duration, the database group monitoring process HCS_MON_AGENT re-acquires the database status information after the database detection process HCS_DB is updated, until the database group monitoring process HCS_MON_AGENT determines to obtain the status information of the updated database. When the time is not longer than the third preset duration, the historical status information of the database in the database group monitoring process HCS_MON_AGENT is updated according to each database status information acquired, and after the sleep T duration, the next time at least two are acquired. Status information for each database in each group of databases in the group database.

本發明實施例中,資料庫探測進程HCS_DB在探測相應的資料狀態資訊,相應的待更新的資料庫狀態資訊處於保護區域,資料庫組監控進程HCS_MON_AGENT無法讀取該保護區域中的資料庫狀態資訊。通過確定獲取更新後的資料庫的狀態資訊的時間是否大於第三預設時長,可以及時獲取到資料庫的狀態資訊中的最近一次的狀態資訊。 In the embodiment of the present invention, the database detection process HCS_DB is detecting the corresponding data status information, and the corresponding database status information to be updated is in the protection area, and the database group monitoring process HCS_MON_AGENT cannot read the database status information in the protection area. . By determining whether the time of obtaining the status information of the updated database is greater than the third preset duration, the latest status information in the status information of the database can 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 slave server sends the information of each database in each of the at least two groups of the updated database in the database monitoring process HCS_MON_AGENT to the main database. On the server, the receiving process Infcollection on the main server receives the information of each database in each group of the updated at least two groups of databases.

可選地,主要伺服器接收從屬伺服器發送的每個資料庫的資 訊之後還包括:主要伺服器判斷從屬伺服器發送到主要伺服器接收過程的時長是否大於第二預設時長,主要伺服器在確定傳輸每個資料庫的資訊的時長不大於第二預設時長時,主要伺服器根據每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換。主要伺服器在確定每個資料庫的資訊的傳輸每個資料庫的資訊的時長大於第二預設時長時,主要伺服器向從屬伺服器發送獲取每個資料庫的資訊的請求。如此,可以防止主要伺服器和從屬伺服器之間因鏈路中斷造成主要伺服器獲得歷史資料庫的資訊。 Optionally, after the primary server receives the information of each database sent by the slave server, the method further includes: determining, by the primary server, whether the duration of the process sent by the slave server to the primary server is greater than a second preset duration, When the server determines that the time for transmitting the information of each database is not longer than the second preset duration, the main server determines whether to switch between the databases with the same group identifier of the database according to the status information of each database. . When the primary server determines that the information of each database is transmitted for each database for a longer period of time than the second preset duration, the primary server sends a request for obtaining information of each database to the slave server. In this way, it is possible to prevent the main server from obtaining the information of the historical database due to the link interruption between the primary server and the slave server.

本發明實施例中,主要伺服器接收到從屬伺服器發送的至少兩組資料庫中每組資料庫中的每個資料庫的資訊且傳輸的時間小於第二預設時長時,主要伺服器上的決策進程Infdecision每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換。本發明實施例中提供了一種可選地實現方式:主要伺服器在確定資料庫的組標識相同的資料庫中存在至少一個資料庫狀態資訊為正常狀態的資料庫時,則將資料庫狀態資訊為異常狀態的資料庫切換資料庫狀態為正常狀態的資料庫。本發明實施例中通過簡單的配置實現了多組資料庫的獨立監控與切換,並且保證了多組資料庫之間互不干擾。在確定資料庫狀態資訊異常時,可以自動切換到該組其他正常狀態的資料庫上。 In the embodiment of the present invention, the main server receives the information of each database in each of the at least two groups of data streams sent by the slave server, and the transmission time is less than the second preset duration, the main server The decision process in the Infdecision status information of each database determines whether the database with the same group identifier of the database is switched. In an embodiment of the present invention, an optional implementation manner is provided: 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 status information is obtained. A database that changes the state of the database to a normal state for the database of the abnormal state. In the embodiment of the present invention, independent monitoring and switching of multiple groups of databases is realized through 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 other normal state database of the group.

本發明實施例中,主要伺服器判斷資料庫的組標識相同的資料庫中是否存在資料庫狀態資訊為異常狀態的資料庫,若存在,則在判斷組標識相同的資料庫中是否存在資料庫狀態資訊為正常狀態的資料庫,若存在,則將該資料庫狀態資訊為異常的資料庫切換到資料庫狀態資訊為正 常狀態的資料上。若資料庫的組標識相同的資料庫中不存在異常資料庫則不處理;若資料庫的組標識相同的資料庫中均為異常資料庫則也不處理。即資料庫的切換只在組內進行,不同組之間不進行切換,如此,可以實現多組資料庫之間的獨立監控與切換,進而有助於系統的高可用性。 In the embodiment of the present invention, the main server determines whether there is a database in which the database state information is abnormal in the same database with the group identifier of the database, and if so, whether the database exists in the database with the same group identifier. The status information is a normal status database. If it exists, the database whose status information is abnormal is switched to the data whose status information is normal. If there is no abnormal database in the database with the same group identifier in the database, it will not be processed; if the database has the same database in the database with the same identifier, it 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. Thus, 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 main server. Suppose the main server receives the database information of the 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 database The identifiers are 1A and 1B respectively, 1A indicates the primary database, 1B indicates the standby database, the status information of the primary database 1A is normal, and the status information of the standby database 1B is abnormal; then the standby database 1B is switched to The main database 1A; group 2 includes two databases, the database identification is 2A and 2B, 2A indicates the main database, 2B indicates the standby database, the status information of the main database 2A is abnormal, and the standby database 2B The status is abnormal; no switching is performed. Even if the database in the normal state of the group 1 does not perform the switching operation, the database switching will not be carried out, so that the high-availability independent monitoring and switching of the multiple groups of databases can be ensured.

圖3示例性示出了本發明實施例提供的一種資料庫切換的從屬伺服器的結構示意圖。 FIG. 3 is a schematic structural diagram of a slave server that is switched by a database 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. The obtaining unit is configured to obtain status information of each database in each group of at least two groups of databases; wherein each group includes a primary database and at least one standby database, each database Corresponding 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 a sending unit is configured to send each to the main server The information of the database, the information of each database is used to enable the main server to determine whether the database with the same group identifier of the database is switched according to the status information of each database; wherein the information of each database includes The identity of the database, the group ID of the database, and the 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 type of service.

可選地,至少一組資料庫中的每組資料庫分別對應至少一種業務類型,包括:交易頻率大於頻率閾值的業務類型對應一組資料庫;和/或;交易數量大於數量閾值的業務類型對應一組資料庫。 Optionally, each group of the at least one group of the database corresponds to the at least one service type, respectively, and the service type corresponding to the transaction frequency is greater than the frequency threshold, and/or the service type whose transaction quantity is greater than the quantity threshold. Corresponding to a set of databases.

可選地,還包括探測單元,用於:週期性探測至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;還包括更新單元,用於:所根據每個資料庫的狀態資訊對資料庫的歷史狀態資訊進行更新操作;獲取單元,用於:所獲取更新後的每個資料庫的狀態資訊,跟新後的每個資料庫的狀態資訊是更新單元根據每個資料庫的狀態資訊對資料庫的歷史狀態資訊進行更新操作得到的。 Optionally, the method further includes: a detecting unit, configured to: periodically detect status information of each of the at least two groups of the data banks; and further include an updating unit, configured to: according to each database The status information updates the history status information of the database; the obtaining unit is configured to: obtain status information of each updated database, and update the status information of each database with the new one according to each data. The status information of the library is obtained by updating the historical status information of the 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 detecting at least two groups after the first preset duration Status information of each database of the database; if the slave server determines that the total duration of the last update operation is greater than the first preset duration, then detecting each of the at least two groups of databases from the end of the last update operation Status information for the database.

從上述內容可以看出:由於本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,每組資料庫包括一個主要資料庫和至少一個備用資料庫,每組資料庫對應四種功能類型中任一種或者任多種;四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;狀態資訊包括正常狀態和異常狀態;根據資料庫的功能類型分為至少兩個資料庫組,形成相互獨立的至少兩組資料庫,各每組之間的資料相互獨立;將至少兩組資料庫中的每個組資料庫中的每個資料庫的資訊發送到主服務,主要伺服器根據每個資料庫的狀態資訊確定在同一組中的資料庫之間是否進行切換;如此,相同組標識之間的資料才能進行切換,可以通過簡單的配置實現資料庫組之間的獨立監控與切換,進而有助於系統的的高可用性。 It can be seen from the above that, in the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group includes a main database and At least one standby database, each group corresponding to any one or more of the four functional types; the four functional types include adding functions, deleting functions, changing functions, and query functions; status information includes normal status and abnormal status; The function type of the library is divided into at least two database groups, forming at least two groups of databases independent of each other, and the data between each group is independent of each other; each of the at least two groups of databases The information of the 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 identification can be switched, which can be simple The configuration enables independent monitoring and switching between the database groups, which in turn contributes to 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. The receiving unit is configured to receive information of each database in each of the at least two groups of data streams sent by the slave server; the information of each database includes the identifier of the database, the group identifier of the database, and The status information of the database; the decision unit is configured to determine whether to switch between the databases with the same group identifier of the database according to the status information of each database.

可選地,決策單元,用於:所在確定資料庫的組標識相同的資料庫中存在至少一個資料庫狀態資訊為正常狀態的資料庫時,則將資料 庫狀態資訊為異常狀態的資料庫切換資料庫狀態為正常狀態的資料庫。 Optionally, the determining unit is configured to: when there is at least one database in which the database state information is in a normal state in the same database in which the group identifier of the determined database is located, the database in which the database state information is in an abnormal state is switched. A database with a normal state of the database.

可選地,決策單元,用於:所在確定傳輸每個資料庫的資訊的時長不大於第二預設時長時,決策單元根據每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;決策單元在確定傳輸每個資料庫的資訊的時長大於第二預設時長時,決策單元向從屬伺服器發送獲取每個資料庫的資訊的請求。 Optionally, the determining unit is configured to: when determining that the duration of transmitting the information of each database is not greater than the second preset duration, the determining unit determines, according to the state information of each database, that the group identifier of the database is the same Whether to switch between the data bases; when the decision unit determines that the time for transmitting the information of each database is greater than the second preset duration, the decision unit sends a request for obtaining the information of each database to the slave server.

從上述內容可以看出:由於本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,每組資料庫包括一個主要資料庫和至少一個備用資料庫,每組資料庫對應四種功能類型中任一種或者任多種;四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;狀態資訊包括正常狀態和異常狀態;根據資料庫的功能類型分為至少兩個資料庫組,形成相互獨立的至少兩組資料庫,各每組之間的資料相互獨立;將至少兩組資料庫中的每個組資料庫中的每個資料庫的資訊發送到主服務,主要伺服器根據每個資料庫的狀態資訊確定在同一組中的資料庫之間是否進行切換;如此,相同組標識之間的資料才能進行切換,可以通過簡單的配置實現資料庫組之間的獨立監控與切換,進而有助於系統的的高可用性。 It can be seen from the above that, in the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group includes a main database and At least one standby database, each group corresponding to any one or more of the four functional types; the four functional types include adding functions, deleting functions, changing functions, and query functions; status information includes normal status and abnormal status; The function type of the library is divided into at least two database groups, forming at least two groups of databases independent of each other, and the data between each group is independent of each other; each of the at least two groups of databases The information of the 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 identification can be switched, which can be simple The configuration enables independent monitoring and switching between the database groups, which in turn contributes to the high availability of the system.

基於相同構思,本發明提供一種電子設備,可用於執行上述從屬伺服器側的方法流程。圖5為本發明提供的一種電子設備的結構示意圖。該電子設備包括處理器501、記憶體502、收發器503和匯流排介面504;其中,處理器501、記憶體502、收發器503和匯流排介面504通過匯流排505相互連接。 Based on the same concept, the present invention provides an electronic device that can be used to execute the method flow of the slave server side described above. FIG. 5 is a schematic structural diagram of an electronic device according to the present invention. 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 each other through a bus bar 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 used to store a program; specifically, the program may include a code, and the code includes a computer operation instruction. 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, a hard disk drive (HDD) or a 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 their extended set: operational instructions: including various operational instructions for implementing various operations.

作業系統:包括各種系統程式,用於實現各種基礎業務以及處理基於硬體的任務。 Operating System: Includes a variety of system programs for implementing a variety of 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. Busbars can be divided into address busbars, data busbars, and control busbars. For ease of representation, only one thick line is shown in Figure 5, but it does not mean that there is only one bus bar or one type of bus bar.

匯流排介面504可以為有線通信接入口,無線匯流排介面或其組合,其中,有線匯流排介面例如可以為乙太網介面。乙太網介面可以是光介面,電介面或其組合。無線匯流排介面可以為WLAN介面。 The bus interface 504 can be a wired communication access port, a wireless bus interface, or a combination thereof. The wired bus interface can be, for example, an Ethernet interface. The Ethernet interface can be an optical interface, a dielectric 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 hard wafer. The above 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 thereof.

該處理器501,用於讀取該記憶體502中的程式,執行下列方法:獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;該記憶體502,用於存儲一個或多個可執行程式,可以存儲該處理器501在執行操作時所使用的資料;該收發器503,用於在該處理器501的控制下向主要伺服器發送該每個資料庫的資訊,該每個資料庫的資訊用於使該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊。 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 the database includes a primary database and at least one standby database, each of which 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 state and an 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 an operation; the transceiver 503 is configured at the processor 501 Controlling, sending, to the main server, the information of each database, the information of each database is used to enable the main server to determine the database with the same group identifier of the database according to the status information of each database Whether to switch; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database.

可選地,該查詢功能對應至少一組資料庫;該至少一組資料庫中的每組資料庫分別對應至少一種業務類型。 Optionally, the query function corresponds to at least one group of databases; each of the at least one group of databases corresponds to at least one type of service.

可選地,該至少一組資料庫中的每組資料庫分別對應至少一種業務類型,包括:交易頻率大於頻率閾值的業務類型對應一組資料庫; 和/或;交易數量大於數量閾值的業務類型對應一組資料庫。 Optionally, each group of the at least one group of databases corresponds to at least one type of service, respectively, and the service type whose transaction frequency is greater than the frequency threshold corresponds to a group of databases; and/or; the service whose transaction quantity is greater than the quantity threshold The type corresponds to a set of databases.

可選地,該處理器,用於:週期性探測該至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作;獲取更新後的每個資料庫的狀態資訊,該跟新後的每個資料庫的狀態資訊是該更新單元根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作得到的。 Optionally, the processor is configured to: periodically detect status information of each database in each of the at least two groups of databases; and record the history of the database according to status information of each database The status information is updated; the status information of each database after the update is obtained, and the status information of each new database is the historical status of the database according to the status information of each database. Information obtained by 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 detecting after the first preset duration Status 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, then detecting each of the at least two groups of databases from the end of the last update operation Status information for each database.

應理解,以上各個單元的劃分僅僅是一種邏輯功能的劃分,實際實現時可以全部或部分集成到一個物理實體上,也可以物理上分開。本發明實施例中,發送單元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 invention, 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, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group of data The library includes a main database and at least one standby database, each of which corresponds to any one or more of four functional types; the four functional types include an add function, a delete function, a change function, and a query function; The 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 in each group 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 same group identifier The data can be switched, and the independent monitoring and switching between the database groups can be realized through simple configuration, which helps the system. High availability.

基於相同構思,本發明提供另一種電子設備,可用於執行上述主要伺服器側的方法流程。圖6為本發明提供的另一種電子設備的結構示意圖。該電子設備包括處理器601、記憶體602、收發器603和匯流排介面604;其中,處理器601、記憶體602、收發器603和匯流排介面604通過匯流排605相互連接。 Based on the same concept, the present invention provides another electronic device that can be used to perform the method flow of the above-described main server side. FIG. 6 is a schematic structural diagram of another electronic device according to the present invention. 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 each other through a bus bar 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 used to store a program; specifically, the program may include a program code, and the code includes a computer operation instruction. 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, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 602 may also include a combination of the above types of memory.

記憶體602存儲了如下的元素,可執行模組或者資料結構,或者它們的子集,或者它們的擴展集:操作指令:包括各種操作指令,用於實現各種操作。 The memory 602 stores the following elements, executable modules or data structures, or a subset thereof, or their extended set: operational instructions: including various operational instructions for implementing various operations.

作業系統:包括各種系統程式,用於實現各種基礎業務以及 處理基於硬體的任務。 Operating System: Includes a variety of system programs for implementing 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. Busbars can be divided into address busbars, data busbars, and control busbars. For ease of representation, only one thick line is shown in Figure 6, but it does not mean that there is only one bus bar or one type of bus bar.

匯流排介面604可以為有線通信接入口,無線匯流排介面或其組合,其中,有線匯流排介面例如可以為乙太網介面。乙太網介面可以是光介面,電介面或其組合。無線匯流排介面可以為WLAN介面。 The bus interface 604 can be a wired communication access port, a wireless bus interface, or a combination thereof. The wired bus interface can be, for example, an Ethernet interface. The Ethernet interface can be an optical interface, a dielectric 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 hard wafer. The above 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 thereof.

該處理器601,用於讀取該記憶體602中的程式,執行下列方法:根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;該記憶體602,用於存儲一個或多個可執行程式,可以存儲該處理器601在執行操作時所使用的資料; 該收發器603,用於在該處理器601的控制下接收從屬伺服器發送的至少兩組資料庫中每組資料庫中的每個資料庫的資訊;該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊。 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 For storing one or more executable programs, may store data used by the processor 601 when performing operations; the transceiver 603 is configured to receive at least two sent by the slave server under the control of the processor 601. The information of each database in each group of the database in the group database; the information of each database includes the identifier of the database, the group identifier 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 the database having the same group identifier of the database, the database state information is in an abnormal state. The database switches the database whose status is normal.

可選地,該處理器601,用於在確定該傳輸每個資料庫的資訊的時長不大於第二預設時長時,根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;在確定該傳輸每個資料庫的資訊的時長大於第二預設時長時,向該從屬伺服器發送獲取每個資料庫的資訊的請求。 Optionally, the processor 601 is configured to determine, according to the status information of each database, that the group identifier of the database is the same when determining that the duration of the information for transmitting each database is not greater than the second preset duration Whether to switch between the databases; when determining that the time for transmitting the information of each database is greater than the second preset duration, a request for obtaining 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 invention, 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 at the time of shipment of the electronic device 600, and can also store a code or the like for execution of the processor 601.

從上述內容可以看出:本發明實施例中,由於本發明實施例中,從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包 括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;根據資料庫的功能類型分為至少兩個資料庫組,形成相互獨立的至少兩組資料庫,各每組之間的資料相互獨立;將至少兩組資料庫中的每個組資料庫中的每個資料庫的資訊發送到主服務,主要伺服器根據每個資料庫的狀態資訊確定在同一組中的資料庫之間是否進行切換;如此,相同組標識之間的資料才能進行切換,通過簡單的配置實現資料庫組之間的獨立監控與切換,進而有助於系統的的高可用性。 It can be seen from the foregoing that, in the embodiment of the present invention, in the embodiment of the present invention, the slave server obtains state information of each database in each group of at least two groups of databases; wherein each group of data The library includes a main database and at least one standby database, each of which corresponds to any one or more of four functional types; the four functional types include an add function, a delete function, a change function, and a query function; The 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 in each group 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 same group identifier The data can be switched, and the independent monitoring and switching between the database groups can be realized through simple configuration, which 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 take the form of a complete hardware embodiment, a full software embodiment, or an embodiment combining soft and hardware aspects. Moreover, embodiments of the present invention may employ computer program products implemented on one or more computer usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) including computer usable code. form.

本發明實施例是參照根據本發明實施例的方法、設備(系統)、和電腦程式產品的流程圖和/或方框圖來描述的。應理解可由電腦程式指令實現流程圖和/或方框圖中的每一流程和/或方框、以及流程圖和/或方框圖中的流程和/或方框的結合。可提供這些電腦程式指令到通用電腦、專用電腦、嵌入式處理機或其他可程式設計資料處理設備的處理器以產生一個機器,使得通過電腦或其他可程式設計資料處理設備的處理器執行的指令產生用於實現在流程圖一個流程或多個流程和/或方框圖一個方框或多個方框中指定的功能的裝置。 Embodiments of the invention are described with reference to flowchart illustrations and/or block diagrams of a method, a device (system), and a computer program product according to an embodiment 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, a special purpose computer, an embedded processor or other programmable data processing device to produce a machine for executing instructions by a processor of a computer or other programmable data processing device Means are provided for implementing the functions specified in one or more of the flow or in one or more blocks of the flow chart.

這些電腦程式指令也可存儲在能引導電腦或其他可程式設 計資料處理設備以特定方式工作的電腦可讀記憶體中,使得存儲在該電腦可讀記憶體中的指令產生包括指令裝置的製造品,該指令裝置實現在流程圖一個流程或多個流程和/或方框圖一個方框或多個方框中指定的功能。 The computer program instructions can also be stored in a computer readable memory that can boot a computer or other programmable data processing device to operate in a particular manner, such that instructions stored in the computer readable memory produce an article of manufacture including the instruction device. The instruction means implements the functions specified in one or more blocks of the flow or in a flow or block diagram of the flowchart.

這些電腦程式指令也可裝載到電腦或其他可程式設計資料處理設備上,使得在電腦或其他可程式設計設備上執行一系列操作步驟以產生電腦實現的處理,從而在電腦或其他可程式設計設備上執行的指令提供用於實現在流程圖一個流程或多個流程和/或方框圖一個方框或多個方框中指定的功能的步驟。 These computer program instructions can also be loaded onto a computer or other programmable data processing device to perform a series of operational steps on a computer or other programmable device to produce computer-implemented processing on a computer or other programmable device. The instructions executed above provide steps for implementing the functions specified in one or more blocks of the flowchart or in a block or blocks of the flowchart.

顯然,本領域的技術人員可以對本發明實施例進行各種改動和變型而不脫離本發明的精神和範圍。這樣,倘若本發明實施例的這些修改和變型屬於本發明申請專利範圍及其等同技術的範圍之內,則本發明也意圖包含這些改動和變型在內。 It is apparent that those skilled in the art can make various modifications and variations to the embodiments of the invention without departing from the spirit and scope of the invention. Thus, it is intended that the present invention cover the modifications and variations of the embodiments of the invention.

Claims (12)

一種資料庫的切換方法,其特徵在於,包括:從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;該從屬伺服器向主要伺服器發送該每個資料庫的資訊,該每個資料庫的資訊用於使該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;其中,該查詢功能對應至少一組資料庫;該至少一組資料庫中的每組資料庫分別對應至少一種業務類型,包括:交易頻率大於頻率閾值的業務類型對應一組資料庫;和/或;交易數量大於數量閾值的業務類型對應一組資料庫。 A method for switching a database, comprising: obtaining, by a slave server, status information of each database in each group of at least two groups of databases; wherein each group of databases includes a main database and At least one standby database, each of which corresponds to any one or more of 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 state and an abnormal state. The slave server sends the information of each database to the primary server, and the information of each database is used to enable the primary server to determine the same group identifier of the database according to the status information of each database. Whether the switching between the libraries is performed; wherein the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database; wherein the query function corresponds to at least one group of databases; the at least one group Each group of databases in the database corresponds to at least one type of service, including: a transaction whose transaction frequency is greater than a frequency threshold Corresponds to a set type database; and / or; Number greater than a threshold number of transaction service type corresponding to a set of database. 如請求項1所述的資料庫的切換方法,其中,該從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊之前,還包括:該從屬伺服器週期性探測該至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;該從屬伺服器根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作;該從屬伺服器獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊,包括:該從屬伺服器獲取更新後的每個資料庫的狀態資訊,該跟新後的每個資料庫的狀態資訊是該從屬伺服器根據該每個資料庫的狀態資訊對該資料 庫的歷史狀態資訊進行更新操作得到的。 The method for switching a database according to claim 1, wherein the slave server obtains status information of each of the at least two groups of the database, and further includes: the slave server periodically Detecting status information of each database in each of the at least two groups of databases; the slave server updates the historical status information of the database according to the status information of each database; the slave servo Obtaining status information of each database in each group of at least two groups of databases, including: the slave server obtains updated status information of each database, and each new database is Status information is the information of the slave server based on the status information of each database The history status information of the library is obtained by the update operation. 如請求項2所述的資料庫的切換方法,其中,該從屬伺服器週期性探測該至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊,包括:該從屬伺服器若確定上一次更新操作的總時長不大於第一預設時長,則從上一次更新操作起始,經過該第一預設時長後開始探測該至少兩組資料庫的每個資料庫的狀態資訊;該從屬伺服器若確定上一次更新操作的總時長大於第一預設時長,則從上一次更新操作結束後開始探測該至少兩組資料庫的每個資料庫的狀態資訊。 The method for switching a database according to claim 2, wherein the slave server periodically detects status information of each database in each of the at least two groups of databases, including: the slave server Determining 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 the status of each database of the at least two groups of databases after the first preset duration Information: 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. 一種資料庫的切換方法,其特徵在於,包括主要伺服器接收從屬伺服器發送的至少兩組資料庫中每組資料庫中的每個資料庫的資訊;該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該主要伺服器接收從屬伺服器發送的每個資料庫的資訊之後,包括:該主要伺服器在確定該傳輸每個資料庫的資訊的時長不大於第二預設時長時,該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;該主要伺服器在確定該傳輸每個資料庫的資訊的時長大於第二預設時長時,該主要伺服器向該從屬伺服器發送獲取每個資料庫的資訊的請求。 A method for switching a database, comprising: a main server receiving information of each database in each of the at least two groups of data streams sent by the slave server; the information of each database includes a database The identifier of the database, the group identifier of the database, and the status information of the database; the primary server determines, according to the status information of each database, whether to switch between the databases with the same group identifier of the database; wherein, the primary server After receiving the information of each database sent by the slave server, the method includes: when the primary server determines that the time for transmitting the information of each database is not greater than the second preset duration, the primary server is configured according to the The status information of the database determines whether the database of the same group identifier of the database is switched; when the main server determines that the time of transmitting the information of each database is greater than the second preset duration, the main The server sends a request to the slave server to obtain information for each database. 如請求項4所述的資料庫的切換方法,其中,該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換,包括:該主要伺服器在確定該資料庫的組標識相同的資料庫中存在至少一個資料庫狀態資訊為正常狀態的該資料庫時,則將資料庫狀態資訊為異常狀 態的資料庫切換該資料庫狀態為正常狀態的資料庫。 The method for switching the database according to claim 4, wherein the primary server determines, according to the status information of each database, whether to switch between the same database of the group identifier of the database, including: the primary server When it is determined that the database with the same group identifier of the database has at least one database whose status information is in a normal state, the database status information is abnormal. The database of the state switches the database whose state is normal. 一種電子設備,其特徵在於,包括處理器、記憶體、收發器、匯流排介面,其中處理器、記憶體與收發器之間通過匯流排連接;該處理器,用於讀取該記憶體中的程式,執行下列方法:用於獲取至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;其中,該每組資料庫包括一個主要資料庫和至少一個備用資料庫,該每組資料庫對應四種功能類型中任一種或者任多種;該四種功能類型包括增加功能、刪除功能、更改功能以及查詢功能;該狀態資訊包括正常狀態和異常狀態;該收發器,用於向主要伺服器發送該每個資料庫的資訊,該每個資料庫的資訊用於使該主要伺服器根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;該記憶體,用於存儲一個或多個可執行程式,可以存儲該處理器在執行操作時所使用的資料;其中,該查詢功能對應至少一組資料庫;該至少一組資料庫中的每組資料庫分別對應至少一種業務類型,包括:交易頻率大於頻率閾值的業務類型對應一組資料庫;和/或;交易數量大於數量閾值的業務類型對應一組資料庫。 An electronic device, comprising: a processor, a memory, a transceiver, and a bus interface, wherein the processor, the memory and the transceiver are connected by a bus bar; the processor is configured to read the memory The program performs the following methods: for obtaining 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 group of data library 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 transceiver is used for the transceiver Sending information of each database to the primary server, the information of each database is used to enable the primary server to determine whether the database with the same group identifier of the database is performed according to the status information of each database Switching; wherein, the information of each database includes the identifier of the database, the group identifier of the database, and the status information of the database; the memory And storing one or more executable programs, and storing data used by the processor when performing operations; wherein the query function corresponds to at least one set of databases; each set of the at least one set of databases Corresponding to at least one service type respectively, 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 of databases. 如請求項6所述的電子設備,其中,該處理器,用於:週期性探測該至少兩組資料庫中每組資料庫中的每個資料庫的狀態資訊;根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作;獲取更新後的每個資料庫的狀態資訊,該跟新後的每個資料庫的狀態資訊是該處理器根據該每個資料庫的狀態資訊對該資料庫的歷史狀態資訊進行更新操作得到的。 The electronic device of claim 6, wherein the processor is configured to periodically detect status information of each database in each of the at least two groups of databases; according to each database The status information updates the historical status information of the database; obtains the updated status information of each database, and the status information of each new database is the status of the database according to the database. The information is obtained by updating the historical status information of the database. 如請求項7所述的電子設備,其中,該處理器,用於:若確定上一次更新操作的總時長不大於第一預設時長,則從上一次更新 操作起始,經過該第一預設時長後開始探測該至少兩組資料庫的每個資料庫的狀態資訊;若確定上一次更新操作的總時長大於第一預設時長,則從上一次更新操作結束後開始探測該至少兩組資料庫的每個資料庫的狀態資訊。 The electronic device of claim 7, 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, the last update is The operation starts, after the first preset duration, the state information of each database of the at least two groups of databases is detected; if it is determined that the total duration of the last update operation is greater than the first preset duration, then After the end of an update operation, the status information of each database of the at least two groups of databases is detected. 一種電子設備,其特徵在於,包括:處理器、記憶體、收發器和匯流排介面,其中,處理器、記憶體、收發器和匯流排介面之間通過匯流排連接;該收發器,用於接收從屬伺服器發送的至少兩組資料庫中每組資料庫中的每個資料庫的資訊:該每個資料庫的資訊包括資料庫的標識、資料庫的組標識以及資料庫的狀態資訊;該處理器,用於根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;其中,該處理器,還用於:在確定該傳輸每個資料庫的資訊的時長不大於第二預設時長時,該決策單元根據該每個資料庫的狀態資訊確定資料庫的組標識相同的資料庫之間是否進行切換;在確定該傳輸每個資料庫的資訊的時長大於第二預設時長時,向該從屬伺服器發送獲取每個資料庫的資訊的請求。 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 bar; the transceiver is configured to: Receiving information of each of the at least two groups of databases sent by the slave 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 status information of each database, whether to switch between databases with the same group identifier of the database; wherein the processor is further configured to: determine, in the database, When the duration of the information is not greater than the second preset duration, the decision unit determines, according to the status information of each database, whether to switch between the databases with the same group identifier of the database; determining each database in the transmission When the duration of the information is greater than the second preset duration, a request to obtain information of each database is sent to the slave server. 如請求項9所述的電子設備,其中,該處理器,還用於:在確定該資料庫的組標識相同的資料庫中存在至少一個資料庫狀態資訊為正常狀態的該資料庫時,則將資料庫狀態資訊為異常狀態的資料庫切換該資料庫狀態為正常狀態的資料庫。 The electronic device of claim 9, wherein the processor is further configured to: when it is determined that the database with the at least one database state information is in a normal state in the database having the same group identifier of the database, The database whose database status information is abnormal status switches the database whose status is normal. 一種非暫態電腦可讀存儲介質,其特徵在於,該非暫態電腦可讀存儲介質存儲電腦指令,該電腦指令用於使該電腦執行請求項1至3中任一項所述的資料庫的切換方法,或者該電腦指令用於使該電腦執行請求項4至5中任一項所述的資料庫的切換方法。 A non-transitory computer readable storage medium storing computer instructions for causing the computer to execute the database of any one of claims 1 to 3. A switching method, or the computer instruction for causing the computer to execute the switching method of the database according to any one of claims 4 to 5. 一種電腦程式產品,其特徵在於,該電腦程式產品包括存儲在非暫態電腦可讀存儲介質上的計算程式,該電腦程式包括程式指令,當該程式指 令被電腦執行時,使該電腦執行請求項1至3中任一項所述的資料庫的切換方法;或者使該電腦執行請求項4至5中任一項所述的資料庫的切換方法。 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 When the computer is executed by the computer, the computer is caused to perform the switching method of the database according to any one of claims 1 to 3; or the computer is caused to perform the switching method of the database according to any one of claims 4 to 5. .
TW107108986A 2017-04-18 2018-03-16 Database switching method, server, storage medium, electronic device and product TWI669620B (en)

Applications Claiming Priority (2)

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

Publications (2)

Publication Number Publication Date
TW201839636A TW201839636A (en) 2018-11-01
TWI669620B true TWI669620B (en) 2019-08-21

Family

ID=59600554

Family Applications (1)

Application Number Title Priority Date Filing Date
TW107108986A TWI669620B (en) 2017-04-18 2018-03-16 Database switching method, server, storage medium, electronic device and product

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
EP2659370A1 (en) * 2010-12-30 2013-11-06 Verisign, Inc. Method and system for implementing business logic
CN103853634A (en) * 2014-02-26 2014-06-11 北京优炫软件股份有限公司 Disaster recovery system and disaster recovery method
CN106294795A (en) * 2016-08-15 2017-01-04 合肥华凌股份有限公司 A kind of data base's changing method and system
TWI578170B (en) * 2015-11-04 2017-04-11 廣達電腦股份有限公司 Seamless automatic recovery of switch device

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
CN102761528A (en) * 2011-04-28 2012-10-31 中兴通讯股份有限公司 System and method for data management
CN103795553B (en) * 2012-10-29 2017-06-06 中国银联股份有限公司 Active and standby server switching based on monitoring
CN103019875B (en) * 2012-12-19 2015-12-09 北京世纪家天下科技发展有限公司 The method of the two main transformation of a kind of fulfillment database and device
CN104486155A (en) * 2014-12-15 2015-04-01 北京趣拿软件科技有限公司 Database cluster monitoring method and system
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
CN107066354B (en) * 2017-04-18 2021-01-05 中国银联股份有限公司 Database switching method, master server and slave server

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2659370A1 (en) * 2010-12-30 2013-11-06 Verisign, Inc. Method and system for implementing business logic
CN103853634A (en) * 2014-02-26 2014-06-11 北京优炫软件股份有限公司 Disaster recovery system and disaster recovery method
TWI578170B (en) * 2015-11-04 2017-04-11 廣達電腦股份有限公司 Seamless automatic recovery of switch device
CN106294795A (en) * 2016-08-15 2017-01-04 合肥华凌股份有限公司 A kind of data base's changing method and system

Also Published As

Publication number Publication date
TW201839636A (en) 2018-11-01
CN107066354A (en) 2017-08-18
CN107066354B (en) 2021-01-05
WO2018192286A1 (en) 2018-10-25

Similar Documents

Publication Publication Date Title
TWI669620B (en) Database switching method, server, storage medium, electronic device and product
CN107911249B (en) Method, device and equipment for sending command line of network equipment
US11403227B2 (en) Data storage method and apparatus, 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
CN103458036A (en) Access device and method of cluster file system
US20220004334A1 (en) Data Storage Method, Apparatus and System, and Server, Control Node and Medium
CN111049928B (en) Data synchronization method, system, electronic device and computer readable storage medium
CN106777126B (en) Data online migration method supporting heterogeneous time sequence database
RU2653254C1 (en) Method, node and system for managing data for database cluster
CN110119304B (en) Interrupt processing method and device and server
WO2016070571A1 (en) M2m node management method and apparatus, and computer storage medium
CN107391033B (en) Data migration method and device, computing equipment and computer storage medium
WO2017020735A1 (en) Data processing method, backup server and storage system
CN105354110B (en) Cloud Server data back up method and device
CN114218193A (en) Data migration method and device, computer equipment and readable storage medium
CN110417567B (en) Configuration method and device of Internet of things equipment
CN112363838A (en) Data processing method and device, storage medium and electronic device
CN107451154B (en) Data table processing method, device and system
CN111552701A (en) Method for determining data consistency in distributed cluster and distributed data system
CN112711466B (en) Hanging affair inspection method and device, electronic equipment and storage medium
CN111314272B (en) Task processing method and device
CN107710165A (en) Method and apparatus for the request of memory node synchronous service
CN114666348B (en) Method for quickly constructing distributed system based on python language