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

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

Info

Publication number
CN113407383B
CN113407383B CN202110736014.XA CN202110736014A CN113407383B CN 113407383 B CN113407383 B CN 113407383B CN 202110736014 A CN202110736014 A CN 202110736014A CN 113407383 B CN113407383 B CN 113407383B
Authority
CN
China
Prior art keywords
server
standby
web
main
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.)
Active
Application number
CN202110736014.XA
Other languages
Chinese (zh)
Other versions
CN113407383A (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

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 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; when the working state indicates that the Web system of the standby server completes the current starting, the address for providing the Web service is switched from the address of the main server to the address of the standby server, so that the standby server provides the Web service. In this way, in the primary-backup switching process, the primary server can timely detect whether the Web system of the backup server is started, so that the automatic switching of the primary-backup system can be timely realized, and a user does not need to manually detect whether the Web system of the backup server is started, thereby being beneficial to improving the efficiency of primary-backup switching and improving the user experience.

Description

Main and standby system switching method and device, server and main and standby system
Technical Field
The present invention relates to the field of data communications, and in particular, to a method and an apparatus for switching a primary system and a secondary system, a server, and a primary system and a secondary system.
Background
With rapid development of Web applications, conventional client applications have been gradually replaced by simple and easy-to-use Web systems, and the Web is abbreviated as World Wide Web (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 generally adopted to deploy the Web systems. The dual-computer 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 of the homologous policy of the browser and the security policy limitation of HTTPS (Hyper Text Transfer Protocol over SecureSocket Layer, hypertext transfer security protocol) (Web service contents which are different from the current address cannot be loaded in the current Web page), the starting state of the Web system of the backup server cannot be automatically queried in the Web page of the address of the main server, and thus the time for the Web system of the backup server to finish starting cannot be told to the user. At present, in a Web interface of a user terminal, a user continuously inputs a standby server address, and repeatedly refreshes a browser, until the standby server address can be accessed, the completion of starting a Web system of the standby server is indicated, and the mode has low efficiency and can not realize the switching of the main server and the standby server in time.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method, an apparatus, a server, and a primary and backup system for switching between a primary server and a backup server in a Web system, so as to improve switching efficiency.
In order to achieve the above object, embodiments of the present application are realized by:
in a first aspect, the present application provides a method for switching a primary system and a secondary 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; when the working state indicates that the Web system of the standby server completes the current starting, the address for providing the Web service is switched from the address of the main server to the address of the standby server, so that the standby server provides the Web service.
In the embodiment, in the primary-backup switching process, the primary server can timely detect whether the Web system of the backup server is started, so that the automatic switching of the primary-backup system can be timely realized, a user does not need to manually detect whether the Web system of the backup server is started, the primary-backup switching efficiency is improved, and the user experience is improved.
With reference to the first aspect, in some optional embodiments, a first Web service based on HTTP protocol is created in advance in the main server; the backup server is pre-established with a second Web service based on an HTTP protocol, and the access address of the second Web service is used for returning to the starting time of the Web system of the backup server when being accessed;
monitoring the working state of the Web system in the standby server according to a preset period, wherein the monitoring comprises the following steps:
and creating a preset tag according to 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 by the Web system of the standby server when the starting is completed.
In the embodiment, the preset label created each time is utilized, so that the time stamp of the starting time can be obtained when the Web system finishes starting, and the timely switching of the main system and the standby system is facilitated.
With reference to the first aspect, in some optional embodiments, 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 tag with the preset period through the first Web service in the main server, wherein the preset attribute of the preset tag 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 acquiring the primary-standby switching instruction, before the 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 includes:
a first Web service based on HTTP protocol is provided to a user terminal for displaying page information indicating that a mode switch is being performed on the user terminal.
In the embodiment, the first Web service may display the page information indicating that the mode is being switched on the user terminal during the mode switching period, so that the mode switching transition may be performed, and the user experience is improved.
With reference to the first aspect, in some optional embodiments, before switching an address for providing the Web service from an address of the primary server to an address of the backup server, the method further includes:
comparing a first time stamp with a second time stamp, wherein the first time stamp is a time stamp when the main and standby switching instructions are acquired, and the second time stamp is a time stamp when the Web system acquired from the standby server is started;
and when the second time stamp is after the first time stamp, determining that the Web system of the standby server completes the current startup.
In the embodiment, by comparing the first timestamp with the second timestamp, whether the Web system of the standby server is started or not can be detected, and the starting time can be conveniently detected.
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 active/standby switching instruction generated by clicking a 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 and standby switching instruction is acquired, sending a starting instruction to the standby server to trigger the Web system of the standby server to start starting.
In a second aspect, the present application further provides a primary and backup system switching device, 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 completes the current start-up, 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, which when executed by the processor, causes the server to perform the method described above.
In a fourth aspect, the present application further provides a primary and backup system, including a primary server and a backup server;
when the main server acquires the main-standby switching instruction, the main server is used for monitoring the working state of the Web system in the standby server according to a preset period;
when the working state indicates that the Web system of the standby server completes the current start, the main server is further used for switching an address for providing 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 a fifth aspect, the present application also provides a computer readable storage medium having a computer program stored therein, which when run on a computer causes the computer to perform the above-described method.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed 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 should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic circuit diagram of a server according to an embodiment of the present application.
Fig. 2 is a schematic diagram of a switching scenario of a primary and secondary system according to an embodiment of the present application.
Fig. 3 is a flow chart of a method for switching between a primary system and a standby system according to an embodiment of the present application.
Fig. 4 is a block diagram of a switching device of a primary and backup system according to an embodiment of the present application.
Icon: 10-a server; 11-a processing module; 12-a memory module; 13-a communication module; 20-a main and standby system; 30-a primary server; 40-preparing a server; 200-a main and standby system switching device; 210-a monitoring unit; 220-a 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 between descriptions and should not be construed as indicating or implying relative importance. The following embodiments and features of the embodiments may 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 Web services.
Web system: the Web application program or the system is provided through the Web service, a user accesses the Web service content through the terminal browser, and the user completes corresponding work or task through the interactive operation of the page in the terminal browser.
Web service: refers to a web service provided by the server 10 according to a transmission protocol for access by a terminal browser. The transport protocol may be hypertext transport protocol (Hypertext Transfer Protocol, HTTP) or hypertext transport security protocol (Hyper Text Transfer Protocol over SecureSocket Layer, HTTPs).
In this embodiment, the server 10 may include a processing module 11 and a storage module 12. The storage module 12 stores a computer program which, when executed by the processing module 11, enables the server 10 to perform the steps in 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 each other 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 and backup system 20, which may include a primary server 30 and a backup server 40, where the primary server 30 and the backup server 40 may be configured as the server 10 shown in fig. 1. Both the primary server 30 and the backup server 40 are deployed with a Web system as a HA (high availability) dual-computer cluster system.
In the primary and backup systems 20, web services can be provided through the primary server 30 or the backup server 40. The operation modes of the primary and secondary systems 20 may include a primary mode and a secondary mode.
When operating in the primary mode, the Web system of the primary server is running, and the backup server is typically in a standby state, i.e., the Web system of the backup server is in a shutdown state. When operating in the standby mode, the Web system of the standby server operates, and the main server is usually in a standby state, i.e., the Web system of the main server is in a shutdown state.
When the switching between the main mode and the standby mode is needed, the main server and the standby server can be matched with each other, and each step in the main and 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 may be implemented by mutually cooperating 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 a main server acquires a main-standby switching instruction, monitoring the working state of a Web system in a standby server according to a preset period;
and step S120, when the working state indicates that the Web system of the standby server completes the current start, 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 above embodiment, the first Web service in the main server may periodically monitor the working state of the Web system of the standby server, and then perform the main-standby switching when the Web system of the standby server completes the startup, and then the standby server provides the Web service. In this way, in the primary-backup switching process, the primary server can timely detect whether the Web system of the backup server is started, so that the automatic switching of the primary-backup system can be timely realized, and a user does not need to manually detect whether the Web system of the backup server is started, thereby being beneficial to improving the efficiency of primary-backup switching and improving the user experience.
The steps of the method will be described in detail below, as follows:
in step S110, the master-slave switching instruction is used by the master-slave system to switch the master server to the slave server, so that the slave server replaces the master server to execute the corresponding service. The mode of the main server obtaining the main and standby switching instructions can be flexibly determined according to actual conditions.
For example, the primary server may receive a primary-standby switching instruction sent by the external device. For example, the user sends the active/standby switching instruction to the active/standby service area through the browser of the user terminal, and at this time, the active/standby switching instruction sent by the user terminal can be obtained by the active/standby server.
For another example, the primary server may automatically generate the primary-standby switching instruction when the switching condition is satisfied, and at this time, the primary server may acquire the primary-standby switching instruction. The switching conditions can be flexibly set according to actual conditions. For example, when the main server needs to perform a software upgrade, or when there is an abnormality, it is determined that the switching condition is satisfied.
In the main server, a preset function is prestored through a JavaScript 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 functional preference, 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 master server acquires the master-slave switching instruction, the working state of the Web system in the slave server can be monitored through a preset function according to a preset period based on the JavaScript program, for example, the time stamp of the completion of starting of the Web system is monitored.
Understandably, the monitored operating state includes, but is not limited to, a timestamp of completion of start-up of the Web system in the backup server, a timestamp of shutdown or shutdown of the Web system. The preset period can be flexibly determined according to practical situations, 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 master server acquires the master-slave switching instruction.
In step S120, if the Web system completes the current startup, it means that the Web system in the backup server completes the startup after the primary server obtains the primary-backup switching instruction, and at this time, the address for providing the Web service is switched from the address of the primary server to the address of the backup server, so that the primary-backup switching can be implemented. The Web service is then provided by the backup server. The address of the standby server may 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 the HTTP protocol is pre-created 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. When the access address of the first Web service is accessed, page information may be returned. The page information may be a static page.
Understandably, the backup server can store time information of the Web system in the backup server when the start-up or stop operation is completed. For example, the backup server may store time information when the Web system completes startup in a designated file of the backup server, which may be flexibly determined or created, which is not particularly limited herein. The second Web service provided by the standby server may read the content in the specified file, so that when the access address of the second Web service is accessed, a timestamp of the time when the start-up of the Web system is completed may be returned to the accessing party (such as the main server).
Based on the first Web service and the second Web service, step S110 may include:
and creating a preset tag according to 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 by the Web system of the standby server when the starting is completed.
Wherein creating, by the preset function 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 tag with the preset period through the preset function in the main server, wherein the preset attribute of the preset tag 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. Where the Script tag is one of HTML (HyperText Markup Language ) tags, it can be used to embed a scripting language (e.g., javaScript) or to import an external scripting file (e.g., javaScript file). The Src attribute is one attribute in the Script tag, and can be used to import an external Script file (e.g., 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 by the Web system in the standby server when the start is completed can be returned, and therefore, the timestamp stored by the Web system when the start is completed can be accessed in the mode of HTTP request by loading the preset label on the Web page of the main server. In the access process, if the Web system is not started, the time stamp in the designated file is not read. At this time, the steps of creating the 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 are repeatedly performed in a preset period 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 alternative embodiment, before step S110, the method may further include:
and receiving the active/standby switching instruction generated by clicking a virtual button.
Understandably, in the Web service provided by the main server, the manager may create a virtual button in advance. The virtual button acts as a "push-to-switch" button as shown in fig. 2. When the active/standby mode is required to be switched, an administrator can access the Web service provided by the active server through the user terminal, and a one-button switching button as shown in fig. 2 can be presented on a display interface of a browser of the user terminal. The user may click the virtual button of "one-click switch" on the display interface of the user terminal, thereby generating a primary-standby switch instruction, and then the user terminal sends the primary-standby switch instruction to the primary server, so that the primary server responds to the primary-standby switch instruction, thereby executing the corresponding operations of step S110 and step S120.
In the embodiment, the virtual button is convenient for a user to perform operation of switching the active mode and the standby mode, so that the user experience is improved.
In this embodiment, before step S110, the method may further include:
and when the main and standby switching instruction is acquired, sending a starting instruction to the standby server to trigger the Web system of the standby server to start starting.
It is understood that in the primary and standby systems, when operating in the primary 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, a starting instruction is sent to the standby server. After receiving the start instruction, the standby server automatically triggers the Web system to start starting, which is not described herein.
As an alternative embodiment, after step S110, and before step S120, the method may further include:
a first Web service based on HTTP protocol is provided to a user terminal for displaying page information indicating that a mode switch is being performed on the user terminal.
Understandably, during the mode switching, the main server may provide the first Web service in order to facilitate the user's visual understanding that the mode switching is currently being performed. During the mode switching, when the user transmits a request for performing a Web service to the primary and secondary systems, feedback is performed by the primary server at this time. That is, the main server may return, based on the first Web service, a prompt message indicating that mode switching is being performed to the user. The prompt information can be flexibly set according to actual conditions, so that a user can conveniently know whether the mode switching is completed or not. Illustratively, the hint information may be "hint" as shown in FIG. 2: is being switched.
When the mode switching is completed, a request for providing the Web service may be directly transmitted from the backup server in response to the user terminal. Or the user terminal initiates the request again, and the standby server responds after receiving the request to provide the Web service.
As an alternative embodiment, before step S120, the method may further include:
comparing a first time stamp with a second time stamp, wherein the first time stamp is a time stamp when the main and standby switching instructions are acquired, and the second time stamp is a time stamp when the Web system acquired from the standby server is started;
and when the second time stamp is after the first time stamp, determining that the Web system of the standby server completes the current startup.
Understandably, after the main server obtains the working state of the Web system of the standby server, when analyzing the working state, the main server needs to ensure that the starting time in the working state has the following meaning: the Web system of the backup server is started after the primary server acquires the primary-backup switching instruction, and is not started before the primary server acquires the primary-backup switching instruction.
If the starting time indicates: the Web system of the backup server is started before the primary server obtains the primary-backup switching instruction, which means that the designated file of the backup server records the time stamp of the last start of the Web system, and the Web system may not be started in fact during the primary-backup switching.
When the start-up time indicates: the Web system of the standby server is started after the main server acquires the main-standby switching instruction, which means that the Web system is actually started during the main-standby switching period, 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 implementation flow of the method will be illustrated below in conjunction with fig. 2:
assume that in the primary/backup system 20, the access address of the primary server 30 is A1 (Https:// 1.1.1.1), and the access address of the backup server 40 is B1 (Https:// 2.2.2.2).
The administrator adds a Web service (i.e., a first Web service) based on HTTP protocol to the main server 30 in advance, and the access address of the service is A2 (HTTP:// 1.1.1/webming). During a mode switch, when the address of the service is accessed, an HTTP static page may be returned to alert that a reminder in the static page is being switched, illustratively as shown in fig. 2.
In addition, the administrator adds a Web service based on HTTP protocol (i.e., a second Web service) to the backup server 40 in advance, where the 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 a timestamp T2) when the Web system of the backup server 40 completes startup. The time stamp is generated after the Web system of the backup server 40 completes the startup, and is stored in a designated file of the backup server 40. That is, the Web service provided by the backup server 40 can read the content in the specified file and return the time stamp.
The addresses A1, A2, B1, and B2 are exemplary addresses, and may be different from the addresses of A1, A2, B1, and B2 in practical applications. That is, the addresses of the main/standby server and the Web service providing server may be flexibly set according to the actual situation, and are not particularly limited herein.
When the primary server 30 receives the primary/secondary switch command, the time is recorded as T1 (i.e. the first timestamp). In the page of the A2 address, the operation state of the Web system in the backup server 40 needs to be acquired through the B2 address. The B2 address cannot be queried directly through Ajax due to browser homology policies. In this embodiment, the query is performed by creating a Script tag to obtain the contents in the B2 address. The specific method is as follows:
and presetting a function in the page of A2 through the JavaScript program, then circularly creating a Script tag through the JavaScript program, and setting the Src attribute of the Script tag as the B2 address. Then, the Script tag is loaded into the Web page, the Script tag can automatically acquire the resource in the Src attribute (including the starting time stamp T2 of the Web system, namely, the second time stamp) after being loaded, and the acquired resource is operated as JavaScript code, and the functions are called when the code is operated. The start-up timestamp T2 of the Web system of the backup server 40 can be obtained when the function is running.
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, the standby server 40 is started after receiving the switching instruction, and then the standby server 40 automatically jumps to the B1 address of the standby server 40 through JavaScript. After the primary-backup switching is completed, the backup server 40 may delete the timestamp T2 stored in the specified 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 described above, so as to execute steps S110 to S120 until the mode switching is completed.
If T1 does not exist, this indicates that the backup server 40 has not been started. If T2 is earlier than T1, it indicates that the backup server 40 is the timestamp generated when the previous active-backup switch was performed, and it cannot indicate that the backup server 40 has been started in the current active-backup switch.
Based on the design, the problem of limitation of the browser homology strategy can be solved by creating the Script label; by adding HTTP protocol services to the main server 30 and the backup server 40, respectively, the problem of security restriction of the HTTPs protocol can be solved, so that the Web system start-up state of the backup server 40 can be obtained from the page provided by the 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 the one-key switching button in the Web page once, and the user can realize better transitional effect by waiting for the page to give a prompt before the standby server 40 is started and completed, so that the user experience is improved.
Referring to fig. 4, the embodiment of the present application further provides a primary-backup system switching device 200, which can be applied to the above-mentioned server, and is used for executing each step in the method. The active-standby System switching device 200 includes at least one software function module that may be stored in a memory module in the form of software or Firmware (Firmware) or cured in a server Operating System (OS). The processing module is configured to execute executable modules stored in the storage module, for example, 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 the following operations may be performed:
a monitoring unit 210, configured to monitor, when a main/standby switching instruction is acquired, a working state of the Web system in the standby server 40 according to a preset period;
and a switching unit 220, configured to switch, when the working state indicates that the Web system of the backup server 40 completes the current startup, an address for providing a Web service from an address of the main server 30 to an address of the backup server 40, so that the backup server 40 provides the Web service.
Wherein, a first Web service based on the HTTP protocol is pre-created in the main server 30, and the first Web service comprises the preset function; the backup server 40 has a second Web service created in advance based on the HTTP protocol, and an access address of the second Web service is used to return to the start time of the Web system of the backup server 40 when accessed. The monitoring unit 210 may also be configured to: a preset tag is created by 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 startup time stored by the Web system of the standby server 40 when the startup is completed.
Optionally, the monitoring unit 210 may be further configured to: creating a preset tag with the preset period by the preset function in the main server 30, wherein the preset attribute of the preset tag 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.
Optionally, the active/standby system switching apparatus 200 may further include a service providing unit. After step S110 is performed, and before step S120 is performed, the service providing unit is configured to provide a first Web service based on the HTTP protocol to the user terminal, for displaying page information indicating that mode switching is being performed on the user terminal.
Optionally, the monitoring unit 210 may be further configured to: comparing a first time stamp with a second time stamp, wherein the first time stamp is a time stamp when the master/slave switching instruction is acquired, and the second time stamp is a time stamp when the Web system acquired from the slave server 40 completes starting; when the second timestamp is after the first timestamp, it is determined that the Web system of the backup server 40 completes the current startup.
Optionally, the active/standby system switching apparatus 200 may further include a receiving unit for receiving the active/standby switching instruction generated by clicking the virtual button before performing step S110.
In this embodiment, the processing module may be an integrated circuit chip with signal processing capability. The processing module may be a general purpose processor. For example, the processor may be a central processing unit (Central Processing Unit, CPU), digital signal processor (Digital Signal Processing, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or may implement or perform the methods, steps, and logic blocks disclosed in embodiments of the present application.
The memory module may be, but is not limited to, random access memory, read only memory, programmable read only memory, erasable programmable read only memory, 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 for storing other programs or data, and the processing module executes the programs after receiving the execution instructions.
It will be appreciated that the architecture shown in fig. 1 is merely a schematic diagram of a server, and that a server may include many 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, for convenience and brevity of description, specific working processes of the server described above may refer to corresponding processes of each step in the foregoing method, and will not be described in detail herein.
Embodiments of the present application also provide 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 foregoing description of the embodiments, it will be apparent to those skilled in the art that the present application may be implemented in hardware, or by means of software plus a necessary general hardware platform, and based on this understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disc, a mobile hard disk, etc.), and includes several instructions to cause a computer device (may be a personal computer, a server, or a network device, etc.) to perform the methods described in the respective implementation scenarios of the present application.
In summary, the present application provides a method and apparatus for switching between a primary system and a secondary system, a server, and a primary system and a 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; when the working state indicates that the Web system of the standby server completes the current starting, the address for providing the Web service is switched from the address of the main server to the address of the standby server, so that the standby server provides the Web service. In this way, in the primary-backup switching process, the primary server can timely detect whether the Web system of the backup server is started, so that the automatic switching of the primary-backup system can be timely realized, and a user does not need to manually detect whether the Web system of the backup server is started, thereby being beneficial to improving the efficiency of primary-backup switching and improving the user experience.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus, system, and method may be implemented in other manners as well. The above-described apparatus, systems, and method embodiments are merely illustrative, for example, flow charts 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, the functional modules in the embodiments of the present application may be integrated together to form a single part, or each module may exist alone, or two or more modules may be integrated to form a single part.
The foregoing is merely exemplary embodiments of the present application and is not intended to limit the scope of the present application, and various modifications and variations may be suggested to one skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims (9)

1. The method for switching the active and standby systems is characterized by comprising the following steps:
when a main server acquires a main-standby switching instruction, monitoring the working state of a Web system in a standby server according to a preset period, creating a preset tag with a preset attribute of a second Web service in the preset period through a preset function in the main server, loading the preset tag into a Web page of the main service to acquire contents in the access address corresponding to the preset attribute, wherein the contents comprise starting time stored by the Web system of the standby server when the starting is completed, and the access address of the second Web service is used for returning to the starting time of the Web system of the standby server when the access is completed;
when the working state indicates that the Web system of the standby server completes the current start, the address for providing the Web service is switched from the address of the main server to the address of the standby server, so that the standby server provides the Web service.
2. The method according to claim 1, wherein a first Web service based on HTTP protocol is created in advance in the main server, the first Web service including the preset function; the second Web service based on the HTTP protocol is pre-established in the standby server;
monitoring the working state of the Web system in the standby server according to a preset period, wherein the monitoring comprises the following steps:
and creating the preset tag by the first Web service in the main server according to the preset period to acquire the content in the access address of the second Web service.
3. The method according to claim 1, wherein after the acquisition of the primary-standby switching instruction, before the address for providing the Web service is switched from the address of the primary server to the address of the standby server, the method further comprises:
a first Web service based on HTTP protocol is provided to a user terminal for displaying page information indicating that a mode switch is being performed on the user terminal.
4. The method of claim 1, wherein prior to switching the address providing the Web service from the address of the primary server to the address of the backup server, the method further comprises:
comparing a first time stamp with a second time stamp, wherein the first time stamp is a time stamp when the main and standby switching instructions are acquired, and the second time stamp is a time stamp when the Web system acquired from the standby server is started;
and when the second time stamp is after the first time stamp, determining that the Web system of the standby server completes the current startup.
5. The method of claim 1, wherein prior to monitoring the operational state of the Web system in the backup server according to a preset period, the method further comprises:
and receiving the active/standby switching instruction generated by clicking a virtual button.
6. A primary-backup system switching device, characterized in that the device comprises:
the monitoring unit is used for monitoring the working state of the Web system in the standby server according to a preset period when a main-standby switching instruction is acquired, creating a preset tag according to the preset period through a preset function in the main server, wherein the preset attribute of the preset tag is an access address of a second Web service, loading the preset tag into a Web page of the main service to acquire contents in the access address corresponding to the preset attribute, and the contents comprise the starting time stored when the Web system of the standby server is started, wherein the access address of the second Web service is used for returning to the starting time of the Web system of the standby server when the access address is accessed;
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 completes the current start-up, so that the standby server provides the Web service.
7. 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 of claims 1-5.
8. The main and standby system is characterized by comprising a main server and a standby server;
when the main server acquires a main-standby switching instruction, the main server is used for monitoring the working state of a Web system in a standby server according to a preset period, a preset tag is created according to the preset period through a preset function in the main server, the preset attribute of the preset tag is an access address of a second Web service, the preset tag is loaded into a Web page of the main service to acquire contents in the access address corresponding to the preset attribute, the contents comprise starting time stored when the Web system of the standby server is started, and the access address of the second Web service is used for returning to the starting time of the Web system of the standby server when the access address is accessed;
when the working state indicates that the Web system of the standby server completes the current start, the main server is further used for switching an address for providing 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.
9. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program which, when run on a computer, causes the computer to perform the method according to any of claims 1-5.
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 CN113407383A (en) 2021-09-17
CN113407383B true 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)

Families Citing this family (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
CN114553686B (en) * 2022-02-26 2023-09-08 苏州浪潮智能科技有限公司 Method, system, equipment and storage medium for switching main and standby flow
CN115134220B (en) * 2022-06-29 2023-11-10 北京飞讯数码科技有限公司 Master-slave server switching method and device, computing equipment and storage medium
CN115277375B (en) * 2022-09-27 2023-01-06 广州市保伦电子有限公司 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
杨晓芬 ; 王永会 ; 刘轶 ; .实时数据库系统双机热备机制设计与实现.计算机工程与应用.2012,第48卷(第29期),124-127+190. *
蔡钟鸣 ; .基于Web认证的用户无感知热备切换技术研究和实现.电脑知识与技术.2017,第13卷(第15期),225-227. *

Also Published As

Publication number Publication date
CN113407383A (en) 2021-09-17

Similar Documents

Publication Publication Date Title
CN113407383B (en) Main and standby system switching method and device, server and main and standby system
CN107181779B (en) Method, device and system for processing access request
CN107357890B (en) Webpage file processing method, device and system and storage equipment
CN111064626B (en) Configuration updating method, device, server and readable storage medium
CN112835782B (en) Interface access test method and system
CN112596951A (en) NAS data disaster tolerance method, device, equipment and storage medium
CN110647739A (en) Software installation detection method, device, terminal and storage medium
CN114168179A (en) Micro-service management method, device, computer equipment and storage medium
CN110881224B (en) Network long connection method, device, equipment and storage medium
CN114328097A (en) File monitoring method and device, electronic equipment and storage medium
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
CN110417601B (en) Information prompting method, device and system in client and readable storage medium
CN114721784B (en) Application running method and device, electronic equipment and readable medium
CN114610446A (en) Method, device and system for automatically injecting probe
CN104346228A (en) Application program sharing method and terminal
CN113885957A (en) Configuration file processing method, terminal device, server and storage medium
CN113765936A (en) Data transmission method, device, equipment and computer readable storage medium
CN113656378A (en) Server management method, device and medium
CN112416698A (en) Monitoring system expansion method and device, storage medium and electronic equipment
CN111475322A (en) Method and device for positioning stuck thread, computer equipment and readable storage medium
CN112464124A (en) Anomaly detection method, device and computer-readable storage medium
CN117033084B (en) Virtual machine backup method and device, electronic equipment and storage medium
CN114826886B (en) Disaster recovery method and device for application software and electronic equipment
US20200120183A1 (en) Method, device and program product for accessing backup server through office software

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