CN113407383A - Main/standby system switching method and device, server and main/standby system - Google Patents

Main/standby system switching method and device, server and main/standby system Download PDF

Info

Publication number
CN113407383A
CN113407383A CN202110736014.XA CN202110736014A CN113407383A CN 113407383 A CN113407383 A CN 113407383A CN 202110736014 A CN202110736014 A CN 202110736014A CN 113407383 A CN113407383 A CN 113407383A
Authority
CN
China
Prior art keywords
server
standby
main
web
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110736014.XA
Other languages
Chinese (zh)
Other versions
CN113407383B (en
Inventor
刘凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Maipu Communication Technology Co Ltd
Original Assignee
Maipu Communication Technology Co Ltd
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 Maipu Communication Technology Co Ltd filed Critical Maipu Communication Technology Co Ltd
Priority to CN202110736014.XA priority Critical patent/CN113407383B/en
Publication of CN113407383A publication Critical patent/CN113407383A/en
Application granted granted Critical
Publication of CN113407383B publication Critical patent/CN113407383B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/202Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where processing functionality is redundant
    • G06F11/2023Failover techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Hardware Redundancy (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application provides a method and a device for switching a main system and a standby system, a server and the main system and the standby system. The method comprises the following steps: when the main server acquires the main/standby switching instruction, monitoring the working state of a Web system in the standby server according to a preset period; and when the working state indicates that the Web system of the standby server is started currently, switching the address for providing the Web service from the address of the main server to the address of the standby server so as to provide the Web service by the standby server. Therefore, in the process of switching the main server and the standby server, the main server can timely detect whether the Web system of the standby server is started or not, so that the automatic switching of the main system and the standby system can be timely realized, a user does not need to manually detect whether the Web system of the standby server is started or not, the efficiency of switching the main system and the standby system is favorably improved, and the user experience is improved.

Description

Main/standby system switching method and device, server and main/standby system
Technical Field
The present invention relates to the field of data communication, and in particular, to a method and an apparatus for switching a master/slave system, a server, and a master/slave system.
Background
With the rapid development of Web applications, various traditional client application programs have been gradually replaced by simple and easy-to-use Web systems, and Web is the abbreviation of World Wide Web. When various Web systems are deployed, in order to ensure continuous operation of the Web systems, a dual-computer cluster system is usually used to deploy the Web systems. The double-machine cluster system comprises a main server and a standby server, wherein in the Web system, the main server provides Web service, and when switching is needed, the Web service is switched to the standby server.
Because the homologous policy of the browser and the security policy of the HTTPS (Hyper Text Transfer Protocol over secure session Layer) (Web service content different from the current address cannot be loaded in the current Web page), the start state of the Web system of the standby server cannot be automatically queried in the Web page of the address of the main server, and therefore the time for completing the start of the Web system of the client standby server cannot be told. At present, usually, in a Web interface of a user terminal, a user continuously inputs an address of a standby server, and refreshes a browser repeatedly until the address of the standby server can be accessed, which means that a Web system of the standby server is started and completed.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method, an apparatus, a server, and a master/slave system for switching a master server and a slave server in a Web system, which can implement switching between the master server and the slave server in time, and improve switching efficiency.
In order to achieve the above object, embodiments of the present application are implemented as follows:
in a first aspect, the present application provides a method for switching between a master system and a standby system, where the method includes: when the main server acquires the main/standby switching instruction, monitoring the working state of a Web system in the standby server according to a preset period; and when the working state indicates that the Web system of the standby server is started currently, switching the address for providing the Web service from the address of the main server to the address of the standby server so as to provide the Web service by the standby server.
In the foregoing embodiment, in the active-standby switching process, the active server may detect in time whether the Web system of the standby server is started, so that automatic switching of the active-standby system may be realized in time, and a user does not need to manually detect whether the Web system of the standby server is started, which is beneficial to improving the active-standby switching efficiency and improving user experience.
With reference to the first aspect, in some optional embodiments, a first Web service based on an HTTP protocol is created in advance in the main server; a second Web service based on an HTTP protocol is pre-established in the standby server, and the access address of the second Web service is used for returning the starting time of the Web system of the standby server when the second Web service is accessed;
monitoring the working state of a Web system in a standby server according to a preset period, wherein the monitoring comprises the following steps:
and creating a preset label in the preset period through the first Web service in the main server to acquire the content in the access address of the second Web service, wherein the content comprises the starting time stored when the Web system of the standby server is started.
In the above embodiment, the preset tag created each time is used, so that the timestamp of the start-up can be obtained in time when the Web system is started up, thereby facilitating the timely switching between the main system and the standby system.
With reference to the first aspect, in some optional implementations, creating, by the first Web service in the main server, a preset tag at the preset period to obtain content in an access address of the second Web service includes:
creating a preset label in the preset period through the first Web service in the main server, wherein the preset attribute of the preset label is the access address of the second Web service;
and loading the preset tag into the Web page of the main service to acquire the content in the access address corresponding to the preset attribute.
With reference to the first aspect, in some optional implementations, after the obtaining the primary/secondary switching instruction, before the switching the address providing the Web service from the address of the primary server to the address of the secondary server, the method further includes:
providing a first Web service based on an HTTP protocol to a user terminal for displaying page information indicating that mode switching is in progress on the user terminal.
In the foregoing embodiment, the first Web service may display, during the mode switching, the page information indicating that the mode switching is being performed on the user terminal, so as to perform a transition of the mode switching, which is beneficial to improving user experience.
With reference to the first aspect, in some optional implementations, before switching the address providing the Web service from the address of the primary server to the address of the standby server, the method further includes:
comparing a first timestamp with a second timestamp, wherein the first timestamp is a timestamp when the main/standby switching instruction is acquired, and the second timestamp is a timestamp acquired from the standby server when the Web system is started;
and when the second timestamp is after the first timestamp, determining that the Web system of the standby server is started currently.
In the above embodiment, by comparing the first time stamp with the second time stamp, it can be ensured that whether the Web system of the standby server is started is detected, and the detection of the start time is facilitated.
With reference to the first aspect, in some optional embodiments, before monitoring the working state of the Web system in the standby server according to a preset period, the method further includes:
and receiving the main/standby switching instruction generated by clicking the virtual button.
With reference to the first aspect, in some optional embodiments, before monitoring the working state of the Web system in the standby server according to a preset period, the method further includes:
and when the main/standby switching instruction is acquired, sending a starting instruction to the standby server to trigger the Web system of the standby server to start.
In a second aspect, the present application further provides a device for switching between main and standby systems, where the device includes:
the monitoring unit is used for monitoring the working state of the Web system in the standby server according to a preset period when the main/standby switching instruction is acquired;
and the switching unit is used for switching the address for providing the Web service from the address of the main server to the address of the standby server when the working state indicates that the Web system of the standby server finishes the current start, so that the standby server provides the Web service.
In a third aspect, the present application further provides a server, including a processor and a memory coupled to each other, where the memory stores a computer program, and when the computer program is executed by the processor, the server is caused to perform the above method.
In a fourth aspect, the present application further provides a primary and standby system, including a primary server and a standby server;
the main server is used for monitoring the working state of a Web system in the standby server according to a preset period when the main/standby switching instruction is obtained;
when the working state indicates that the Web system of the standby server is started currently, the main server is further used for switching the address for providing the Web service from the address of the main server to the address of the standby server so that the standby server provides the Web service.
In a fifth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, which, when run on a computer, causes the computer to perform the above-mentioned method.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic circuit structure diagram of a server according to an embodiment of the present application.
Fig. 2 is a schematic view of a switching scenario of a primary/standby system according to an embodiment of the present application.
Fig. 3 is a flowchart illustrating a method for switching between active and standby systems according to an embodiment of the present application.
Fig. 4 is a block diagram of a main/standby system switching device according to an embodiment of the present application.
Icon: 10-a server; 11-a processing module; 12-a storage module; 13-a communication module; 20-a main standby system; 30-a primary server; 40-preparing a server; 200-main/standby system switching device; 210-a monitoring unit; 220-switching unit.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. It should be noted that the terms "first," "second," and the like are used merely to distinguish one description from another, and are not intended to indicate or imply relative importance. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, the present application provides a server 10, where the server 10 is deployed with a Web system, and may be used to provide a Web service.
A Web system: the Web application program or system is provided by Web service, a user accesses website service content through a terminal browser, and the user completes corresponding work or task through page interactive operation in the terminal browser.
Web service: refers to a web service provided by the server 10 according to a transport protocol for access by a terminal browser. The transmission Protocol may be a Hypertext Transfer Protocol (HTTP) or a Hypertext Transfer Protocol over secure session Layer (HTTPs).
In this embodiment, the server 10 may include a processing module 11 and a storage module 12. The storage module 12 stores therein a computer program, which, when executed by the processing module 11, enables the server 10 to execute the steps of the active/standby system switching method described below.
In this embodiment, the server 10 may further include other modules, for example, the server 10 may further include a communication module 13 for establishing a communication connection with other devices. For example, the server 10 may establish a communication connection with a user terminal or other server through the communication module 13. The user terminal may be, but is not limited to, a smart phone, a personal computer.
The processing module 11, the storage module 12 and the communication module 13 are electrically connected directly or indirectly to realize data transmission or interaction. For example, the modules may be electrically connected to each other via one or more communication buses or signal lines.
Referring to fig. 2, the present application further provides a primary/standby system 20, which may include a primary server 30 and a standby server 40, where the primary server 30 and the standby server 40 may be the server 10 shown in fig. 1. The main server 30 and the standby server 40 are both deployed with Web systems as HA (high availability) dual cluster systems.
In the active/standby system 20, a Web service may be provided through the active server 30 or the standby server 40. The operation modes of the active/standby system 20 may include a main mode and a standby mode.
When the standby server operates in the master mode, the Web system of the master server is operated, and the standby server is usually in a standby state, that is, the Web system of the standby server is in a closed state. When the standby mode is operated, the Web system of the standby server is operated, and the main server is usually in a standby state, that is, the Web system of the main server is in a closed state.
When the master mode and the standby mode need to be switched, the master server and the standby server can be matched with each other, and the steps in the following master-standby system switching method can be realized.
Referring to fig. 3, the present application further provides a method for switching between a primary system and a secondary system, which may be applied to the primary system and the secondary system, and the steps of the method may be implemented by matching a primary server and a secondary server in the primary system and the secondary system, where the method may include the following steps:
step S110, when the main server obtains the main/standby switching instruction, monitoring the working state of a Web system in the standby server according to a preset period;
step S120, when the operating status indicates that the Web system of the standby server is currently started, switching an address for providing the Web service from an address of a main server to an address of the standby server, so that the standby server provides the Web service.
In the foregoing embodiment, the first Web service in the primary server may periodically monitor the working state of the Web system of the standby server, and then perform primary/standby switching when the Web system of the standby server is started, and subsequently provide the Web service by the standby server. Therefore, in the process of switching the main server and the standby server, the main server can timely detect whether the Web system of the standby server is started or not, so that the automatic switching of the main system and the standby system can be timely realized, a user does not need to manually detect whether the Web system of the standby server is started or not, the efficiency of switching the main system and the standby system is favorably improved, and the user experience is improved.
The individual steps of the process are explained in detail below, as follows:
in step S110, the primary/secondary switching instruction is used for the primary/secondary system to switch the primary server to the secondary server, so that the secondary server replaces the primary server to execute a corresponding service. The mode of the main server for acquiring the main/standby switching instruction can be flexibly determined according to actual conditions.
For example, the master server may receive a master/slave switching instruction sent by the external device. For example, the user sends the primary/secondary switching instruction to the primary service area through a browser of the user terminal, and at this time, the primary server may obtain the primary/secondary switching instruction sent by the user terminal.
For another example, the main server may automatically generate the main/standby switching instruction when the switching condition is satisfied, and at this time, the main server may obtain the main/standby switching instruction. Wherein, the switching condition can be flexibly set according to the actual situation. For example, when the main server needs to perform software upgrade or there is an abnormality, it is determined that the switching condition is satisfied.
In the main server, a preset function is stored in advance through a JavaScript script program, and the preset function is used for acquiring the working state of the Web system in the standby server according to a preset period instead of acquiring the working state of the Web system in the standby server through Ajax.
JavaScript is a lightweight, interpreted, or just-in-time programming language with function priority, and its script program can run in a browser.
Ajax is a network messaging method applied to web pages, and is well known to those skilled in the art.
When the main server obtains the main/standby switching instruction, the working state of the Web system in the standby server may be monitored at a preset period through a preset function based on the JavaScript script program, for example, a timestamp for monitoring completion of startup of the Web system.
Understandably, the monitored working status includes, but is not limited to, a timestamp of completion of startup of the Web system in the standby server, and a timestamp of shutdown or shutdown of the Web system. The preset period can be flexibly determined according to actual conditions, and is not particularly limited herein.
After the main server obtains the working state of the Web system from the standby server, the working state can be analyzed to determine whether the Web system of the standby server is started currently. The current start refers to the start of the Web system after the main server obtains the main/standby switching instruction.
In step S120, if the Web system completes the current start, it indicates that the Web system in the standby server is started only after the main server obtains the main/standby switching instruction, and at this time, the address providing the Web service is switched from the address of the main server to the address of the standby server, so that the main/standby switching can be implemented. The standby server then provides the Web service. Wherein, the address of the standby server can be stored in the main server in advance.
In the present embodiment, in the main server, a first Web service based on the HTTP protocol is created in advance; and a second Web service based on an HTTP protocol is pre-established in the standby server, and the access address of the second Web service is used for returning the starting time of the Web system of the standby server when the second Web service is accessed. The page information may be returned when the access address of the first Web service is accessed. The page information may be a static page.
Understandably, the standby server can store and record the time information of the Web system in the standby server when the start or stop of the operation is completed. For example, the backup server may store the time information when the Web system is completely started in a specific file of the backup server, and the specific file may be flexibly determined or created, and is not particularly limited herein. The second Web service provided by the standby server can read the content in the specified file, so that the timestamp of the Web system when the start-up is completed can be returned to the accessing party (such as the main server) when the access address of the second Web service is accessed.
Based on the first Web service and the second Web service, step S110 may include:
and creating a preset label in the preset period through the preset function in the main server to acquire the content in the access address of the second Web service, wherein the content comprises the starting time stored when the Web system of the standby server is started.
Creating a preset tag to acquire content in an access address of the second Web service in the preset period through the preset function in the main server, including:
creating a preset label in the preset period through the preset function in the main server, wherein the preset attribute of the preset label is the access address of the second Web service;
and loading the preset tag into the Web page of the main service to acquire the content in the access address corresponding to the preset attribute.
In this embodiment, the preset tag may be a Script tag, and the preset attribute may be a Src attribute of the tag. The Script tag is a tag in HTML (HyperText Markup Language), and can be used to embed a Script Language (e.g., JavaScript) or introduce an external Script file (e.g., JavaScript file). The Src attribute is an attribute in the Script tag, and can be used to introduce an external Script file (e.g., a JavaScript Script file). The Src attribute may be used to set an address of an external script, such as an access address to add the second Web service in the present embodiment.
Because the access address of the second Web service is accessed, the timestamp stored when the Web system in the standby server is started can be returned, and therefore, the timestamp stored when the Web system is started can be accessed in an HTTP request mode by loading the preset tag on the Web page of the main server. In the access process, if the Web system is not started, the timestamp in the specified file cannot be read. At this time, the steps of "creating a preset tag and loading the preset tag into the Web page of the main service to obtain the content in the access address corresponding to the preset attribute" need to be repeatedly executed at a preset cycle until the Web system is started and the timestamp recorded in the specified file when the Web system is started can be read.
As an optional implementation manner, before step S110, the method may further include:
and receiving the main/standby switching instruction generated by clicking the virtual button.
Understandably, in the Web service provided by the main server, the administrator may create a virtual button in advance. The virtual button acts as a "one-touch-switch" button as shown in figure 2. When the active/standby mode needs to be switched, the administrator may enter the Web service provided by the main server through the user terminal, and a "one-key switching" button as shown in fig. 2 may be presented on the display interface of the browser of the user terminal. The user may click a "one-key switching" virtual button on a display interface of the user terminal, so as to generate a main/standby switching instruction, and then the user terminal sends the main/standby switching instruction to the main server, so that the main server responds to the main/standby switching instruction, thereby executing the corresponding operations in step S110 and step S120.
In the above embodiment, the virtual button facilitates the user to perform the operation of switching between the main mode and the standby mode, thereby facilitating the improvement of the user experience.
In this embodiment, before step S110, the method may further include:
and when the main/standby switching instruction is acquired, sending a starting instruction to the standby server to trigger the Web system of the standby server to start.
Understandably, in the active/standby system, when operating in the master mode, the standby server is in a standby state, and the Web system of the standby server is not started. When the main server receives the main/standby switching instruction, the main server sends a starting instruction to the standby server. After receiving the start instruction, the standby server will automatically trigger the Web system to start, which is not described herein again.
As an optional implementation manner, after step S110 and before step S120, the method may further include:
providing a first Web service based on an HTTP protocol to a user terminal for displaying page information indicating that mode switching is in progress on the user terminal.
Understandably, during mode switching, the primary server may provide the first Web service in order for the user to intuitively know that mode switching is currently being performed. During mode switching, when a user sends a request for Web service to the primary and secondary systems, the primary server performs feedback. That is, the main server can return prompt information indicating that mode switching is being performed to the user based on the first Web service. The prompt information can be flexibly set according to actual conditions, and a user can conveniently know whether the mode switching is finished. Illustratively, the hint information may be "hint: is in the process of switching.
When the mode switching is completed, the standby server may directly respond to a request for providing the Web service sent by the user terminal. Or the user terminal initiates the request again, and the standby server responds after receiving the request so as to provide the Web service.
As an optional implementation manner, before step S120, the method may further include:
comparing a first timestamp with a second timestamp, wherein the first timestamp is a timestamp when the main/standby switching instruction is acquired, and the second timestamp is a timestamp acquired from the standby server when the Web system is started;
and when the second timestamp is after the first timestamp, determining that the Web system of the standby server is started currently.
Understandably, after the main server obtains the working state of the Web system of the standby server, when analyzing the working state, the meaning of the starting time in the working state needs to be ensured as follows: the Web system of the standby server is started after the main server acquires the main/standby switching instruction, but not before the main server acquires the main/standby switching instruction.
If the start-up time indicates: the Web system of the standby server is started before the main server obtains the main/standby switching instruction, which means that the timestamp of the last start of the Web system is recorded in the specified file of the standby server, and the Web system may not be actually started during the current main/standby switching.
When the start-up time indicates: the Web system of the standby server is started after the main server obtains the main/standby switching instruction, which means that the Web system is actually started during the main/standby switching, and at this time, the address for providing the Web service can be switched from the address of the main server to the address of the standby server.
For ease of understanding, the following will illustrate the implementation flow of the method in conjunction with fig. 2:
assume that, in the active/standby system 20, the access address of the primary server 30 is A1(Https://1.1.1.1), and the access address of the standby server 40 is B1(Https:// 2.2.2.2.2).
The administrator adds a Web service based on the HTTP protocol (i.e., the first Web service) to the main server 30 in advance, and the access address of the service is a2(HTTP://1.1.1.1/webping. html). During a mode switch, when the address of the service is accessed, an HTTP static page may be returned to alert of the ongoing switch, illustratively the alert information in the static page as shown in fig. 2.
In addition, the administrator adds a Web service (i.e., a second Web service) based on the HTTP protocol to the standby server 40 in advance, where an access address of the service is assumed to be B2(HTTP://2.2.2.2/checkHealth), and the B2 address of the Web service may be used to obtain a timestamp (hereinafter referred to as timestamp T2) when the Web system of the standby server 40 is started. The timestamp is generated after the Web system of the standby server 40 is started, and is stored in a specified file of the standby server 40. That is, the Web service provided by the standby server 40 can read the contents in the specified file and return the time stamp.
Note that the addresses a1, a2, B1, and B2 are exemplary addresses, and may be different from the addresses a1, a2, B1, and B2 in practical applications. That is, both the main/standby server and the address providing the Web service can be flexibly set according to actual situations, and are not particularly limited herein.
When the primary server 30 receives the primary/secondary switching command, it records the time as T1 (i.e. the first timestamp). In the page of the a2 address, it is necessary to acquire the operating state of the Web system in the standby server 40 through the B2 address. Due to the browser isogeny policy, the B2 address cannot be directly queried by Ajax. In this embodiment, the query is performed by creating a Script tag to obtain the content at the address of B2. The specific mode is as follows:
a function is preset in a page of A2 through a JavaScript Script program, then a Script tag is circularly created through the JavaScript Script program, and the Src attribute of the Script tag is set to be the B2 address. Then, the Script tag is loaded into a Web page, after the Script tag is loaded, the resource (including the start timestamp T2 of the Web system, that is, the second timestamp) in the Src attribute can be automatically acquired, the acquired resource is operated as a JavaScript code, and when the code is operated, the function is called. When the function runs, the start time stamp T2 of the Web system of the standby server 40 may be obtained.
In this embodiment, the preset function may also be used to compare the time sequence relationship between T2 and T1, and the implementation manner may be:
if T2 is later than T1, it indicates that standby server 40 has finished booting after receiving the switch command, and then it automatically jumps to the B1 address of standby server 40 through JavaScript. When the active-standby switching is completed, the standby server 40 may delete the timestamp T2 stored in the designated file. During the operation of the Web system of the standby server, if a mode switching instruction is received, the identity of the standby server 40 is replaced with the identity of the main server 30 to perform steps S110 to S120 until the mode switching is completed.
If T1 does not exist, it indicates that standby server 40 has not yet been started. If T2 is earlier than T1, it indicates that the backup server 40 is the timestamp generated when the backup server was last switched between the primary and the backup, and it cannot indicate that the backup server 40 has been activated in the current primary and the backup.
Based on the design, the limitation problem of the browser homologous strategy can be solved by creating a Script tag; by adding HTTP protocol services to main server 30 and standby server 40, respectively, the problem of security restrictions of the HTTPs protocol can be solved, so that the Web system startup state of standby server 40 can be acquired in a page provided by main server 30. The user does not need to manually refresh the page to judge whether the standby server 40 can be accessed, the user can realize the function of automatically jumping to the address of the standby server 40 by clicking once through the one-key switching button in the Web page, and before the standby server 40 is started, the user also waits for the page to give a prompt, so that a better transition effect can be realized, and the user experience is improved.
Referring to fig. 4, an embodiment of the present application further provides a device 200 for switching between a master system and a standby system, which can be applied to the server described above and is used to execute each step in the method. The active/standby System switching device 200 includes at least one software function module which can be stored in a memory module in the form of software or Firmware (Firmware) or solidified in an Operating System (OS) of a server. The processing module is used for executing executable modules stored in the storage module, such as software function modules and computer programs included in the active/standby system switching device 200.
The active/standby system switching device 200 may include a monitoring unit 210 and a switching unit 220, and may perform the following operations:
a monitoring unit 210, configured to monitor a working state of the Web system in the standby server 40 according to a preset period when the main/standby switching instruction is obtained;
a switching unit 220, configured to switch, when the operating state indicates that the Web system of the standby server 40 is currently started, an address of the Web service to be provided from the address of the main server 30 to an address of the standby server 40, so that the standby server 40 provides the Web service.
A first Web service based on an HTTP protocol is created in the main server 30 in advance, and the first Web service includes the preset function; a second Web service based on the HTTP protocol is created in advance in the standby server 40, and an access address of the second Web service is used to return to the start time of the Web system of the standby server 40 when the second Web service is accessed. The monitoring unit 210 may also be configured to: creating a preset tag through the first Web service in the main server 30 at the preset period to obtain the content in the access address of the second Web service, where the content includes the start time stored when the Web system of the standby server 40 completes start.
Optionally, the monitoring unit 210 may be further configured to: creating a preset label in the preset period through the preset function in the main server 30, where a preset attribute of the preset label is an access address of the second Web service; and loading the preset tag into the Web page of the main service to acquire the content in the access address corresponding to the preset attribute.
Optionally, the active/standby system switching device 200 may further include a service providing unit. After performing step S110 and before performing step S120, the service providing unit is configured to provide the first Web service based on the HTTP protocol to the user terminal for displaying page information indicating that mode switching is in progress on the user terminal.
Optionally, the monitoring unit 210 may be further configured to: comparing a first timestamp with a second timestamp, where the first timestamp is a timestamp when the main/standby switching instruction is obtained, and the second timestamp is a timestamp obtained from the standby server 40 when the Web system is started; and when the second timestamp is later than the first timestamp, determining that the Web system of the standby server 40 is currently started.
Optionally, the active/standby system switching device 200 may further include a receiving unit, configured to receive the active/standby switching instruction generated by clicking a virtual button before executing step S110.
In this embodiment, the processing module may be an integrated circuit chip having signal processing capability. The processing module may be a general purpose processor. For example, the processor may be a Central Processing Unit (CPU), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, and may implement or execute the methods, steps, and logic blocks disclosed in the embodiments of the present Application.
The memory module may be, but is not limited to, a random access memory, a read only memory, a programmable read only memory, an erasable programmable read only memory, an electrically erasable programmable read only memory, and the like. In this embodiment, the storage module may be configured to store a JavaScript script program, a preset period, and the like. Of course, the storage module may also be used to store other programs or data, and the processing module executes the programs after receiving the execution instruction.
It is understood that the configuration shown in fig. 1 is only a schematic configuration of a server, and the server may further include more components than those shown in fig. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
It should be noted that, as will be clearly understood by those skilled in the art, for convenience and brevity of description, the specific working process of the server described above may refer to the corresponding process of each step in the foregoing method, and will not be described in detail herein.
The embodiment of the application also provides a computer readable storage medium. The computer-readable storage medium has stored therein a computer program which, when run on a computer, causes the computer to execute the active/standby system switching method as described in the above embodiments.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by hardware, or by software plus a necessary general hardware platform, and based on such understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the method described in the embodiments of the present application.
In summary, the present application provides a method and an apparatus for switching a primary/secondary system, a server, and a primary/secondary system. The method comprises the following steps: when the main server acquires the main/standby switching instruction, monitoring the working state of a Web system in the standby server according to a preset period; and when the working state indicates that the Web system of the standby server is started currently, switching the address for providing the Web service from the address of the main server to the address of the standby server so as to provide the Web service by the standby server. Therefore, in the process of switching the main server and the standby server, the main server can timely detect whether the Web system of the standby server is started or not, so that the automatic switching of the main system and the standby system can be timely realized, a user does not need to manually detect whether the Web system of the standby server is started or not, the efficiency of switching the main system and the standby system is favorably improved, and the user experience is improved.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus, system, and method may be implemented in other ways. The apparatus, system, and method embodiments described above are illustrative only, as the flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. A method for switching between a main system and a standby system is characterized by comprising the following steps:
when the main server acquires the main/standby switching instruction, monitoring the working state of a Web system in the standby server according to a preset period;
and when the working state indicates that the Web system of the standby server is started currently, switching the address for providing the Web service from the address of the main server to the address of the standby server so as to provide the Web service by the standby server.
2. The method according to claim 1, wherein a first Web service based on HTTP protocol is created in advance in the main server; a second Web service based on an HTTP protocol is pre-established in the standby server, and the access address of the second Web service is used for returning the starting time of the Web system of the standby server when the second Web service is accessed;
monitoring the working state of a Web system in a standby server according to a preset period, wherein the monitoring comprises the following steps:
and creating a preset label in the preset period through the first Web service in the main server to acquire the content in the access address of the second Web service, wherein the content comprises the starting time stored when the Web system of the standby server is started.
3. The method of claim 2, wherein creating, by the first Web service in the host server, a preset tag for obtaining the content in the access address of the second Web service at the preset period comprises:
creating a preset label in the preset period through the first Web service in the main server, wherein the preset attribute of the preset label is the access address of the second Web service;
and loading the preset tag into the Web page of the main service to acquire the content in the access address corresponding to the preset attribute.
4. The method according to claim 1, wherein after the obtaining of the active-standby switching instruction and before the address providing the Web service is switched from an address of a primary server to an address of the standby server, the method further comprises:
providing a first Web service based on an HTTP protocol to a user terminal for displaying page information indicating that mode switching is in progress on the user terminal.
5. The method of claim 1, wherein before switching the address for providing the Web service from the address of the primary server to the address of the standby server, the method further comprises:
comparing a first timestamp with a second timestamp, wherein the first timestamp is a timestamp when the main/standby switching instruction is acquired, and the second timestamp is a timestamp acquired from the standby server when the Web system is started;
and when the second timestamp is after the first timestamp, determining that the Web system of the standby server is started currently.
6. The method according to claim 1, wherein before monitoring the working state of the Web system in the standby server according to a preset period, the method further comprises:
and receiving the main/standby switching instruction generated by clicking the virtual button.
7. A device for switching between a main system and a standby system, the device comprising:
the monitoring unit is used for monitoring the working state of the Web system in the standby server according to a preset period when the main/standby switching instruction is acquired;
and the switching unit is used for switching the address for providing the Web service from the address of the main server to the address of the standby server when the working state indicates that the Web system of the standby server finishes the current start, so that the standby server provides the Web service.
8. A server, comprising a processor and a memory coupled to each other, the memory storing a computer program which, when executed by the processor, causes the server to perform the method of any one of claims 1-6.
9. A master-standby system is characterized by comprising a master server and a standby server;
the main server is used for monitoring the working state of a Web system in the standby server according to a preset period when the main/standby switching instruction is obtained;
when the working state indicates that the Web system of the standby server is started currently, the main server is further used for switching the address for providing the Web service from the address of the main server to the address of the standby server so that the standby server provides the Web service.
10. A computer-readable storage medium, in which a computer program is stored which, when run on a computer, causes the computer to carry out the method according to any one of claims 1-6.
CN202110736014.XA 2021-06-30 2021-06-30 Main and standby system switching method and device, server and main and standby system Active CN113407383B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110736014.XA CN113407383B (en) 2021-06-30 2021-06-30 Main and standby system switching method and device, server and main and standby system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110736014.XA CN113407383B (en) 2021-06-30 2021-06-30 Main and standby system switching method and device, server and main and standby system

Publications (2)

Publication Number Publication Date
CN113407383A true CN113407383A (en) 2021-09-17
CN113407383B CN113407383B (en) 2024-02-09

Family

ID=77680486

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110736014.XA Active CN113407383B (en) 2021-06-30 2021-06-30 Main and standby system switching method and device, server and main and standby system

Country Status (1)

Country Link
CN (1) CN113407383B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114510312A (en) * 2022-02-23 2022-05-17 光大科技有限公司 Visual implementation method and device for cluster master-slave node switching
CN114553686A (en) * 2022-02-26 2022-05-27 苏州浪潮智能科技有限公司 Method, system, equipment and storage medium for switching main and standby flow
CN115134220A (en) * 2022-06-29 2022-09-30 北京飞讯数码科技有限公司 Main/standby server switching method and device, computing equipment and storage medium
CN115277375A (en) * 2022-09-27 2022-11-01 广州市保伦电子有限公司 Method, system, equipment and storage medium for switching master server and standby server

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102629932A (en) * 2012-02-22 2012-08-08 张洋 Method for controlling embedded equipment through WEB application program
CN103023790A (en) * 2012-12-31 2013-04-03 北京京东世纪贸易有限公司 Method and system used for realizing cross-domain interactive access
CN104486447A (en) * 2014-12-30 2015-04-01 成都因纳伟盛科技股份有限公司 Large platform cluster system based on Big-Cluster
CN106059795A (en) * 2016-05-16 2016-10-26 乐视控股(北京)有限公司 Web system service monitoring and switching method and apparatus
CN109257229A (en) * 2018-10-25 2019-01-22 网宿科技股份有限公司 A kind of main/standby switching method and device
CN111106983A (en) * 2019-12-27 2020-05-05 杭州迪普科技股份有限公司 Method and device for detecting network connectivity
CN111666514A (en) * 2020-04-28 2020-09-15 平安科技(深圳)有限公司 Data processing method and device for realizing cross-domain request at webpage end and related equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102629932A (en) * 2012-02-22 2012-08-08 张洋 Method for controlling embedded equipment through WEB application program
CN103023790A (en) * 2012-12-31 2013-04-03 北京京东世纪贸易有限公司 Method and system used for realizing cross-domain interactive access
CN104486447A (en) * 2014-12-30 2015-04-01 成都因纳伟盛科技股份有限公司 Large platform cluster system based on Big-Cluster
CN106059795A (en) * 2016-05-16 2016-10-26 乐视控股(北京)有限公司 Web system service monitoring and switching method and apparatus
CN109257229A (en) * 2018-10-25 2019-01-22 网宿科技股份有限公司 A kind of main/standby switching method and device
CN111106983A (en) * 2019-12-27 2020-05-05 杭州迪普科技股份有限公司 Method and device for detecting network connectivity
CN111666514A (en) * 2020-04-28 2020-09-15 平安科技(深圳)有限公司 Data processing method and device for realizing cross-domain request at webpage end and related equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
杨晓芬;王永会;刘轶;: "实时数据库系统双机热备机制设计与实现", 计算机工程与应用, vol. 48, no. 29, pages 124 - 127 *
蔡钟鸣;: "基于Web认证的用户无感知热备切换技术研究和实现", 电脑知识与技术, vol. 13, no. 15, pages 225 - 227 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114510312A (en) * 2022-02-23 2022-05-17 光大科技有限公司 Visual implementation method and device for cluster master-slave node switching
CN114553686A (en) * 2022-02-26 2022-05-27 苏州浪潮智能科技有限公司 Method, system, equipment and storage medium for switching main and standby flow
CN114553686B (en) * 2022-02-26 2023-09-08 苏州浪潮智能科技有限公司 Method, system, equipment and storage medium for switching main and standby flow
CN115134220A (en) * 2022-06-29 2022-09-30 北京飞讯数码科技有限公司 Main/standby server switching method and device, computing equipment and storage medium
CN115134220B (en) * 2022-06-29 2023-11-10 北京飞讯数码科技有限公司 Master-slave server switching method and device, computing equipment and storage medium
CN115277375A (en) * 2022-09-27 2022-11-01 广州市保伦电子有限公司 Method, system, equipment and storage medium for switching master server and standby server

Also Published As

Publication number Publication date
CN113407383B (en) 2024-02-09

Similar Documents

Publication Publication Date Title
CN113407383B (en) Main and standby system switching method and device, server and main and standby system
CN109542744B (en) Method, device, storage medium and terminal for detecting abnormal starting problem of terminal
CN109597677B (en) Method and apparatus for processing information
US8694831B2 (en) Automatic bug reporting tool
CN110413432B (en) Information processing method, electronic equipment and storage medium
CN112769652B (en) Node service monitoring method, device, equipment and medium
US9727394B2 (en) Establishing causality order of computer trace records
CN111124761B (en) Equipment restarting method, device, equipment and medium
CN112486592A (en) Distributed data processing method, device, server and readable storage medium
US20150220517A1 (en) Efficient conflict resolution among stateless processes
CN110881224B (en) Network long connection method, device, equipment and storage medium
CN110908837A (en) Application program exception handling method and device, electronic equipment and storage medium
CN113220403B (en) Method and device for h5 intercepting Android return event and electronic equipment
CN109634782B (en) Method and device for detecting system robustness, storage medium and terminal
CN110231921B (en) Log printing method, device, equipment and computer readable storage medium
CN109257235B (en) Network anomaly recovery method, device, equipment and computer readable storage medium
WO2020117222A1 (en) Comparisons of application programming interface interactions to determine compatibilities
CN113656378A (en) Server management method, device and medium
CN112416698B (en) Expansion method and device of monitoring system, storage medium and electronic equipment
CN112464124A (en) Anomaly detection method, device and computer-readable storage medium
CN113157306A (en) Resource packaging management method, device, equipment and storage medium
CN114826886B (en) Disaster recovery method and device for application software and electronic equipment
CN117033084B (en) Virtual machine backup method and device, electronic equipment and storage medium
CN114780195B (en) Operation visualization method, device, equipment and storage medium
CN114443452A (en) Host operating system crash detection method, host and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant