WO2020192311A1 - 主从服务器切换方法、装置、电子设备及存储介质 - Google Patents

主从服务器切换方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2020192311A1
WO2020192311A1 PCT/CN2020/075769 CN2020075769W WO2020192311A1 WO 2020192311 A1 WO2020192311 A1 WO 2020192311A1 CN 2020075769 W CN2020075769 W CN 2020075769W WO 2020192311 A1 WO2020192311 A1 WO 2020192311A1
Authority
WO
WIPO (PCT)
Prior art keywords
slave
server
master
memory database
switching
Prior art date
Application number
PCT/CN2020/075769
Other languages
English (en)
French (fr)
Inventor
申航
陈二奇
高宇
Original Assignee
北京达佳互联信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京达佳互联信息技术有限公司 filed Critical 北京达佳互联信息技术有限公司
Priority to EP20776845.8A priority Critical patent/EP3937426B1/en
Publication of WO2020192311A1 publication Critical patent/WO2020192311A1/zh
Priority to US17/481,602 priority patent/US11500744B2/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • G06F11/1451Management of the data involved in backup or backup restore by selection of backup contents
    • 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
    • G06F11/2028Failover techniques eliminating a faulty processor or activating a spare
    • 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/2038Error 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 with a single idle spare processing component
    • 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/2048Error 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 where the redundant components share neither address space nor persistent storage
    • 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/2097Error 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 maintaining the standby controller/processing unit updated
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/40Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass for recovering from a failure of a protocol instance or entity, e.g. service redundancy protocols, protocol state redundancy or protocol service redirection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/80Database-specific techniques
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/084Configuration by using pre-existing information, e.g. using templates or copying from other elements
    • H04L41/0846Configuration by using pre-existing information, e.g. using templates or copying from other elements based on copy from other elements

Definitions

  • This application relates to the field of data processing technology, and in particular to a method, device, electronic device, and storage medium for switching between master and slave servers.
  • a slave server In a distributed storage system, in order to ensure that the service can be quickly restored after a server failure, a slave server will be set up in the system. Once the main server fails, the slave server will be switched to the main server to continue to provide services.
  • a distributed storage system is usually provided with a master server 110, a slave server 120 and a control server 130.
  • Stateful service is a commonly used service method. After the server receives the client's request, it will determine how to respond to the client's request according to its current working status. In a distributed storage system with stateful services, the control server 130 monitors whether the main server 110 fails. If the main server 110 fails, the slave server 120 must be quickly restored to the state before the main server 110 failure to provide external services. . Therefore, the slave server 120 performs the same operation as the master server 110 in real time. Specifically, taking the operation of creating a file as an example, the master server 110 receives an operation request for creating a file, and after performing the operation of creating a file, saves the operation record of the operation in the log log; then, reads the log and sends it asynchronously to the slave server 120. The slave server 120 performs the same file creation operation to achieve the same state as the master server 110.
  • LRU Least Recently Used
  • the process of fetching operation records is time-consuming.
  • the master server 110 fails it may happen that the operation record is not sent to the slave server 120 in time, which causes the slave server 120 to fail to perform the same operation. After it is switched to the master server, it cannot keep the same as the original master server 110. The same state before the failure.
  • this application provides a method, device, electronic device, and storage medium for switching between master and slave servers.
  • a master-slave server switching method which is applied to a control server communicating with a master server and a slave server, and includes:
  • the master server is provided with a master memory database, the master memory database is used to save the status information of the master server after each operation performed in real time, and the status information is used for the status information set in the slave server Read and save from the memory database in real time;
  • a master-slave switching command is sent to the slave server.
  • the master-slave switching command is used to instruct the slave server to upgrade to a new master server based on the status information stored in the slave memory database.
  • a master-slave server switching device which is applied to a control server communicating with a master server and a slave server, and includes:
  • the monitoring module is configured to monitor whether the main server is faulty;
  • the main server is provided with a main memory database, and the main memory database is used to save real-time state information after each operation performed by the main server, and the state information is used for Read and save in real time from the memory database set in the slave server;
  • the server switching module is configured to send a master-slave switching command to the slave server if the master server fails.
  • the master-slave switching command is used to instruct the slave server to upgrade to a new master based on the status information stored in the slave memory database. server.
  • a control server communicates with a master server and a slave server, including:
  • a memory for storing processor executable instructions
  • the processor is configured to:
  • the master server is provided with a master memory database, the master memory database is used to save the status information of the master server after each operation performed in real time, and the status information is used for the status information set in the slave server Read and save from the memory database in real time;
  • a master-slave switching command is sent to the slave server.
  • the master-slave switching command is used to instruct the slave server to upgrade to a new master server based on the status information stored in the slave memory database.
  • a non-transitory computer-readable storage medium is provided.
  • the electronic device can implement the above-mentioned master-slave server switching method. A step of.
  • a computer program product which when the computer program product is executed by a processor of an electronic device, enables the electronic device to implement the steps of the above-mentioned master-slave server switching method.
  • the technical solution provided by the embodiments of the present application may include the following beneficial effects: monitoring whether the main server fails, wherein a main memory database is provided in the main server, and the main memory database is used to save the status information of the main server after each operation performed in real time.
  • the master-slave switching command is sent to the slave server, so that the slave server is upgraded to a new one based on the status information saved in the slave memory database.
  • the master server because the status information of the master server is written to the main memory database in real time, and the slave memory database in the slave server reads the status information from the main memory database in real time, so it can be used when the master server fails
  • the slave server quickly maintains the same state as the master server before the failure, effectively solving the problem that the master server takes a long time to read the operation record from the memory or hard disk.
  • Figure 1 is a schematic diagram of the structure of a distributed storage system in related technologies
  • Fig. 2 is a flow chart showing a method for switching between master and slave servers according to an exemplary embodiment
  • Fig. 3 is a schematic structural diagram showing a distributed storage system with state services according to an exemplary embodiment
  • Fig. 4 is a flowchart showing another master-slave server switching method according to an exemplary embodiment
  • Fig. 5 is a block diagram showing a device for switching between master and slave servers according to an exemplary embodiment
  • Fig. 6 is a block diagram showing a device for switching between master and slave servers according to an exemplary embodiment
  • Fig. 7 is a block diagram showing another device for switching between master and slave servers according to an exemplary embodiment
  • Fig. 8 is a block diagram showing a server for implementing a method for switching between master and slave servers according to an exemplary embodiment.
  • Fig. 2 is a flowchart showing a method for switching between master and slave servers according to an exemplary embodiment. As shown in Figure 2, the master-slave server switching method is applied to the control server communicating with the master server and the slave server, and includes the following steps:
  • step S201 monitor whether the master server fails; the master server is provided with a master memory database, which is used to save the status information of the master server after each operation performed in real time, and the status information is used for the slave servers set in the slave server.
  • the memory database is read and saved in real time.
  • the operations performed by the main server may be file editing operations such as file creation and deletion.
  • the status information is the result of each operation performed by the main server.
  • the failure of the main server may be caused by various reasons. The server crashed.
  • the control server 350 monitors the network connection status of the master server 310 in real time.
  • the master memory database 320 and the slave memory database 340 can be set in the master server 310 and the slave server 330, respectively.
  • the in-memory database may be a Redis in-memory database.
  • the Redis in-memory database is a key-value database.
  • the main Redis in-memory database has the function of writing data
  • the Redis in-memory database has the function of reading data.
  • the main server writes status information into the main Redis memory database in real time.
  • the key is the index node (inode) number of each file, and the value corresponding to the key stores each file.
  • the status information of the main server can be read from the Redis memory database in real time from the main Redis memory database and stored in the same key-value form.
  • step S202 if the master server fails, a master-slave switching command is sent to the slave server.
  • the master-slave switching command is used to instruct the slave server to upgrade to a new master server according to the status information stored in the slave memory database.
  • the slave server since the state information in the main memory database 320 is read and stored in real time from the in-memory database 340, when the slave server receives the master-slave switching command sent by the control server 350 after monitoring the failure of the master server 310, it can Modify its own role (role) from the original slave server (master server), that is, upgrade to a new master server according to the saved state information, and continue to provide services to the outside world.
  • master server master server
  • the technical solution provided by the embodiments of the present application may include the following beneficial effects: monitoring whether the main server fails, wherein a main memory database is provided in the main server, and the main memory database is used to save the status information of the main server after each operation performed in real time.
  • the master-slave switching command is sent to the slave server, so that the slave server is upgraded to a new one based on the status information saved in the slave memory database.
  • the master server because the status information of the master server is written to the main memory database in real time, and the slave memory database in the slave server reads the status information from the main memory database in real time, so it can be used when the master server fails
  • the slave server quickly maintains the same state as the master server before the failure, effectively solving the problem that the master server takes a long time to read the operation record from the memory or hard disk.
  • Fig. 4 is a flowchart showing another method for switching between master and slave servers according to an exemplary embodiment. As shown in the figure, the master-slave server switching method is applied to the control server communicating with the master server and the slave server, and includes the following steps:
  • step S401 every first preset time interval, a heartbeat packet is sent to the main server.
  • the first preset time for the control server to send the heartbeat packet can be set to be shorter, such as sending every 20 seconds A heartbeat packet is sent to the main server; on the contrary, if the real-time performance of the service is not high, or when the main server does not need to be monitored in real time, the first preset time can be set longer.
  • step S402 it is determined whether the response to the heartbeat packet is received within the second preset time. If it is received, it is determined that the main server is normal, and step S401 is returned; if it is not received, it is determined that the main server is faulty, and step S403 is executed. .
  • the second preset time in this step may also be set according to specific conditions. If the control server does not receive the response of the main server to the heartbeat packet within the second preset time, the main service is judged to be faulty.
  • the control server monitors the status of the main server by sending a heartbeat packet periodically, and can know whether the main server is faulty in time and judge its availability.
  • step S403 a master-slave switching command is sent to the slave server.
  • the master-slave switching command is used to instruct the slave server to upgrade to a new master server according to the status information stored in the slave memory database.
  • step S404 the slave memory database in the slave server is switched to the new main memory database.
  • each slave server contains a slave memory database that stores state information. Similar to step S201 in the embodiment shown in FIG. 2, the memory database in the master server saves the status information of the master server in real time, so that the slave memory databases in each slave server can be read and saved in real time.
  • the control server selects a slave server from multiple slave servers as the target slave server, and then sends a master-slave switching command to the target slave server, so that the target slave server is based on the state saved in the slave memory database
  • the information is upgraded to the new master server, and the target slave server is switched from the main memory database to the new main memory database.
  • the main memory database saves the status information of the main server after each operation performed in real time, so that it can be read and stored in real time by the slave memory database in the slave server, which can effectively solve the problem of the main server from the memory or hard disk. It takes a long time to read the operation record, which leads to the problem that the status of the slave server and the master server before the failure is not completely consistent, so that the slave server can take over the responsibility of the master server in a short time, and reduce the business caused by the switch between the master and slave servers Impact, maximize service availability and continuity.
  • Fig. 5 is a block diagram showing a device for switching between master and slave servers according to an exemplary embodiment. 5, the device includes a monitoring module 510 and a server switching module 520.
  • the monitoring module 510 is configured to monitor whether the main server fails;
  • the main server is provided with a main memory database, which is used to save the state information of the main server after each operation performed in real time, and the state information is used to set in the slave server Real-time read and save from the memory database;
  • the server switching module 520 is configured to send a master-slave switching command to the slave server if the master server fails.
  • the master-slave switching command is used to instruct the slave server to upgrade to a new master server according to the status information stored in the slave memory database.
  • the technical solution provided by the embodiments of the present application may include the following beneficial effects: monitoring whether the main server fails, wherein a main memory database is provided in the main server, and the main memory database is used to save the status information of the main server after each operation performed in real time.
  • the master-slave switching command is sent to the slave server, so that the slave server is upgraded to a new one based on the status information saved in the slave memory database.
  • the master server because the status information of the master server is written to the main memory database in real time, and the slave memory database in the slave server reads the status information from the main memory database in real time, so it can be used when the master server fails
  • the slave server quickly maintains the same state as the master server before the failure, effectively solving the problem that the master server takes a long time to read the operation record from the memory or hard disk.
  • the main memory database and the secondary memory database are Redis memory databases.
  • the master-slave server switching device further includes:
  • the database switching module 530 is configured to switch the slave memory database in the slave server to the new main memory database after the master-slave switching command is sent to the slave server after the server switching module executes if the master server fails.
  • each of the multiple slave servers includes a secondary memory database for storing the status information; the status information is generated by the multiple slave servers
  • the selection unit is configured to select a slave server from a plurality of slave servers as the target slave server;
  • the command sending unit is configured to send a master-slave switching command to the target slave server, and the master-slave switching command is used to instruct the target slave server to upgrade to a new master server according to the status information stored in the slave memory database.
  • the server switching module 520 further includes:
  • the switching unit is configured to switch the slave memory database in the target slave server to the new main memory database after the command sending unit executes and sends the master-slave switching command to the target slave server.
  • the monitoring module 510 may include:
  • the heartbeat sending unit is configured to send a heartbeat packet to the main server every first preset time interval
  • the judging unit is configured to judge whether a response to the heartbeat packet is received within the second preset time; if so, the main server has not failed; if not, the main server has failed.
  • Fig. 6 is a block diagram showing a device 600 for switching between master and slave servers according to an exemplary embodiment.
  • the device 600 may be a mobile phone, a computer, a digital broadcasting terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
  • the device 600 may include one or more of the following components: a processing component 602, a memory 604, a power supply component 606, a multimedia component 608, an audio component 610, an input/output (I/O) interface 612, a sensor component 614, And communication component 616.
  • the processing component 602 generally controls the overall operations of the device 600, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations.
  • the processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the foregoing method.
  • the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components.
  • the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
  • the memory 604 is configured to store various types of data to support the operation of the device 600. Examples of these data include instructions for any application or method operating on the device 600, contact data, phone book data, messages, pictures, videos, etc.
  • the memory 604 can be implemented by any type of volatile or nonvolatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable and Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic Disk or Optical Disk.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read-only memory
  • EPROM erasable and Programmable Read Only Memory
  • PROM Programmable Read Only Memory
  • ROM Read Only Memory
  • Magnetic Memory Flash Memory
  • Magnetic Disk Magnetic Disk or Optical Disk.
  • the power supply component 606 provides power to various components of the device 600.
  • the power supply component 606 may include a power management system, one or more power supplies, and other components associated with the generation, management, and distribution of power for the device 600.
  • the multimedia component 608 includes a screen that provides an output interface between the device 600 and the user.
  • the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user.
  • the touch panel includes one or more touch sensors to sense touch, sliding, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure related to the touch or slide operation.
  • the multimedia component 608 includes a front camera and/or a rear camera. When the device 600 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capabilities.
  • the audio component 610 is configured to output and/or input audio signals.
  • the audio component 610 includes a microphone (MIC).
  • the microphone is configured to receive external audio signals.
  • the received audio signal can be further stored in the memory 604 or sent via the communication component 616.
  • the audio component 610 further includes a speaker for outputting audio signals.
  • the I/O interface 612 provides an interface between the processing component 602 and a peripheral interface module.
  • the above-mentioned peripheral interface module may be a keyboard, a click wheel, a button, and the like. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
  • the sensor component 614 includes one or more sensors for providing the device 600 with various aspects of status assessment.
  • the sensor component 614 can detect the on/off status of the device 600 and the relative positioning of components.
  • the component is the display and keypad of the device 600.
  • the sensor component 614 can also detect the position change of the device 600 or a component of the device 600. , The presence or absence of contact between the user and the device 600, the orientation or acceleration/deceleration of the device 800, and the temperature change of the device 600.
  • the sensor component 614 may include a proximity sensor configured to detect the presence of nearby objects when there is no physical contact.
  • the sensor component 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications.
  • the sensor component 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.
  • the communication component 616 is configured to facilitate wired or wireless communication between the apparatus 600 and other devices.
  • the device 600 can access a wireless network based on a communication standard, such as WiFi, an operator network (such as 2G, 3G, 4G, or 5G), or a combination thereof.
  • the communication component 616 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel.
  • the communication component 616 further includes a near field communication (NFC) module to facilitate short-range communication.
  • the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
  • RFID radio frequency identification
  • IrDA infrared data association
  • UWB ultra-wideband
  • Bluetooth Bluetooth
  • the apparatus 600 may be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing equipment (DSPD), programmable logic devices (PLD), field programmable Implemented by a gate array (FPGA), controller, microcontroller, microprocessor, or other electronic components, used to implement the above-mentioned master-slave server switching method.
  • ASIC application specific integrated circuits
  • DSP digital signal processors
  • DSPD digital signal processing equipment
  • PLD programmable logic devices
  • FPGA field programmable Implemented by a gate array (FPGA), controller, microcontroller, microprocessor, or other electronic components, used to implement the above-mentioned master-slave server switching method.
  • non-transitory computer-readable storage medium including instructions, such as the memory 604 including instructions, which can be executed by the processor 620 of the device 600 to complete the foregoing method.
  • the non-transitory computer-readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
  • Fig. 7 is a block diagram showing another device 700 for switching between master and slave servers according to an exemplary embodiment.
  • the apparatus 700 may be provided as a server.
  • the apparatus 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732, for storing instructions executable by the processing component 722, such as an application program.
  • the application program stored in the memory 732 may include one or more modules each corresponding to a set of instructions.
  • the processing component 722 is configured to execute instructions to execute any master-slave server switching method provided in the embodiments of the present application.
  • the device 700 may also include a power component 726 configured to perform power management of the device 700, a wired or wireless network interface 750 configured to connect the device 700 to a network, and an input output (I/O) interface 758.
  • the device 700 can operate based on an operating system stored in the memory 732, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM or the like.
  • a control server is also provided, and the control server is in communication connection with the master server and the slave server, including:
  • a memory 802 for storing processor executable instructions
  • processor 801 is configured to:
  • the master server is provided with a master memory database, the master memory database is used to save the status information of the master server after each operation performed in real time, and the status information is used for the status information set in the slave server Read and save from the memory database in real time;
  • a master-slave switching command is sent to the slave server.
  • the master-slave switching command is used to instruct the slave server to upgrade to a new master server according to the status information stored in the slave memory database.
  • the main memory database and the secondary memory database are Redis memory databases.
  • the processor 801 is further configured to:
  • the master server fails, after sending a master-slave switching command to the slave server, switch the slave memory database in the slave server to a new master memory database.
  • each of the multiple slave servers includes a secondary memory database for storing the status information; the status information is generated by the multiple slave servers
  • the slave memory database in each slave server is read in real time from the main memory database; the processor 801 is specifically configured to:
  • the processor 801 is further configured to:
  • the processor 801 is specifically configured to:

Abstract

本申请关于一种主从服务器切换方法、装置、电子设备及存储介质,该方法包括:监听主服务器是否发生故障,主服务器中设置有主内存数据库,主内存数据库用于实时保存主服务器每次执行操作后的状态信息,该状态信息用于从服务器中的从内存数据库实时读取并保存,若主服务器发生故障,则发送主从切换命令至从服务器,主从切换命令用于指示从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。由于主服务器的状态信息是实时写入主内存数据库的,从服务器中的从内存数据库是实时从主内存数据库中读取状态信息的,因此,可在主服务器故障时使从服务器快速地与主服务器故障前的状态保持一致。

Description

主从服务器切换方法、装置、电子设备及存储介质
本申请要求在2019年03月22日提交中国专利局、申请号为201910223583.7、申请名称为“主从服务器切换方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据处理技术领域,尤其涉及主从服务器切换方法、装置、电子设备及存储介质。
背景技术
分布式存储系统中,为了保障服务器故障后能够快速恢复服务,会在系统中设置从服务器。一旦主服务器出现故障,便将从服务器切换为主服务器以继续提供服务。具体的,如图1所示,为了实现主从服务器切换,分布式存储系统通常设置有主服务器110、从服务器120以及控制服务器130。
有状态服务是一种常用的服务方式。服务器接收到客户端的请求后,会根据自身当前的工作状态,确定如何响应客户端请求。在有状态服务的分布式存储系统中,由控制服务器130监听主服务器110是否故障,若主服务器110出现故障,则必须将从服务器120快速恢复到主服务器110故障前的状态,才能对外提供服务。因此,从服务器120会实时执行与主服务器110相同的操作。具体的,以创建文件的操作为例,主服务器110接收创建文件的操作请求,执行创建文件的操作后,将该操作的操作记录存入日志log;然后,读取log并异步发送至从服务器120,从服务器120执行相同的创建文件的操作,以达到与主服务器110相同的状态。
但是,发明人发现,受到内存容量的限制,主服务器110采用的虚拟页式存储管理服务的最近最少使用(Least Recently Used,LRU)算法会将某些log存入内存或硬盘,这导致从中读取操作记录的过程较为耗时。在主服务器110故障时,可能会出现操作记录未能及时发送给从服务器120的情况,这就导致从服务器120无法执行相同的操作,在其被切换为主服务器后,不能保持与原主服务器110故障前相同的状态。
发明内容
为克服相关技术中存在的问题,本申请提供一种主从服务器切换方法、装置、电子设 备及存储介质。
根据本申请实施例的第一方面,提供一种主从服务器切换方法,应用于与主服务器和从服务器通信连接的控制服务器,包括:
监听主服务器是否发生故障;所述主服务器中设置有主内存数据库,所述主内存数据库用于实时保存主服务器每次执行操作后的状态信息,所述状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
如果主服务器发生故障,则发送主从切换命令至从服务器,所述主从切换命令用于指示所述从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
根据本申请实施例的第二方面,提供一种主从服务器切换装置,应用于与主服务器和从服务器通信连接的控制服务器,包括:
监听模块,被配置为监听主服务器是否发生故障;所述主服务器中设置有主内存数据库,所述主内存数据库用于实时保存主服务器每次执行操作后的状态信息,所述状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
服务器切换模块,被配置如果主服务器发生故障,则发送主从切换命令至从服务器,所述主从切换命令用于指示所述从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
根据本申请实施例的第三方面,提供一种控制服务器,所述控制服务器与主服务器和从服务器通信连接,包括:
处理器;
用于存储处理器可执行指令的存储器;
其中,所述处理器被配置为:
监听主服务器是否发生故障;所述主服务器中设置有主内存数据库,所述主内存数据库用于实时保存主服务器每次执行操作后的状态信息,所述状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
如果主服务器发生故障,则发送主从切换命令至从服务器,所述主从切换命令用于指示所述从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
根据本申请实施例的第四方面,提供一种非临时性计算机可读存储介质,当所述存储介质中的指令由电子设备的处理器执行时,使得电子设备能够实现上述主从服务器切换方法的步骤。
根据本申请实施例的第五方面,提供一种计算机程序产品,当所述计算机程序产品由电子设备的处理器执行时,使得电子设备能够实现上述主从服务器切换方法的步骤。
本申请实施例提供的技术方案可以包括以下有益效果:监听主服务器是否发生故障,其中,主服务器中设置有主内存数据库,主内存数据库用于实时保存主服务器每次执行操 作后的状态信息,以供设置在从服务器中的从内存数据库实时读取并保存,如果确定主服务器发生故障,则发送主从切换命令至从服务器,以使从服务器根据从内存数据库中保存的状态信息升级为新的主服务器,由于主服务器的状态信息是实时写入主内存数据库的,并且,从服务器中的从内存数据库是实时从主内存数据库中读取状态信息的,因此,可在主服务器故障时使从服务器快速地与主服务器故障前的状态保持一致,有效解决主服务器从内存或硬盘中读取操作记录耗时较长的问题。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。
图1是相关技术中分布式存储系统的结构示意图;
图2是根据一示例性实施例示出的一种主从服务器切换方法的流程图;
图3是根据一示例性实施例示出的一种有状态服务的分布式存储系统的结构示意图;
图4是根据一示例性实施例示出的另一种主从服务器切换方法的流程图;
图5是根据一示例性实施例示出的一种主从服务器切换装置的框图;
图6是根据一示例性实施例示出的一种用于主从服务器切换的装置的框图;
图7是根据一示例性实施例示出的另一种用于主从服务器切换的装置的框图;
图8是根据一示例性实施例示出的一种用于实现主从服务器切换方法的服务器的框图。
具体实施方式
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。
图2是根据一示例性实施例示出的一种主从服务器切换方法的流程图。如图2所示,主从服务器切换方法应用于与主服务器和从服务器通信连接的控制服务器,包括以下步骤:
在步骤S201中,监听主服务器是否发生故障;主服务器中设置有主内存数据库,主内存数据库用于实时保存主服务器每次执行操作后的状态信息,状态信息用于设置在从服务器中的从内存数据库实时读取并保存。
本申请实施例中,主服务器所执行的操作可以为创建文件、删除文件等文件编辑操作,状态信息为主服务器执行每个操作后的操作结果,主服务器的故障可以为各种原因导致的主服务器死机。
具体的,如图3所示,控制服务器350实时监听主服务器310的网络连接状态,主内存数据库320和从内存数据库340可以分别设置在主服务器310和从服务器330之中,主内存数据库以及从内存数据库可以为Redis内存数据库,其中,Redis内存数据库是一种键-值(key-value)数据库,主Redis内存数据库具有写入数据的功能,从Redis内存数据库具有读取数据的功能。在本申请实施例中,主服务器将状态信息实时写入主Redis内存数据库,在主Redis内存数据库中,key为各个文件的索引节点(index node,inode)号,key对应的value存储着各个文件的状态信息,从Redis内存数据库可以从主Redis内存数据库中实时读取主服务器的状态信息并以相同的key-value形式保存。
在步骤S202中,如果主服务器发生故障,则发送主从切换命令至从服务器,主从切换命令用于指示从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
具体的,由于从内存数据库340实时读取并保存主内存数据库320中的状态信息,因此,当从服务器接收到控制服务器350在监听到主服务器310发生故障后发送的主从切换命令时,可将自身的角色(role)从原本的从服务器(slave server)修改为主服务器(master server),即,根据已保存的状态信息升级为新的主服务器,并继续对外提供服务。
本申请实施例提供的技术方案可以包括以下有益效果:监听主服务器是否发生故障,其中,主服务器中设置有主内存数据库,主内存数据库用于实时保存主服务器每次执行操作后的状态信息,以供设置在从服务器中的从内存数据库实时读取并保存,如果确定主服务器发生故障,则发送主从切换命令至从服务器,以使从服务器根据从内存数据库中保存的状态信息升级为新的主服务器,由于主服务器的状态信息是实时写入主内存数据库的,并且,从服务器中的从内存数据库是实时从主内存数据库中读取状态信息的,因此,可在主服务器故障时使从服务器快速地与主服务器故障前的状态保持一致,有效解决主服务器从内存或硬盘中读取操作记录耗时较长的问题。
图4是根据一示例性实施例示出的另一种主从服务器切换方法的流程图。如图所示,主从服务器切换方法应用于与主服务器和从服务器通信连接的控制服务器,包括以下步骤:
在步骤S401中,每间隔第一预设时间,发送一次心跳包至主服务器。
本申请实施例中,当所处理的业务对实时性要求较高或者要尽可能地实时监听主服务器时,控制服务器发送心跳包的第一预设时间就可以设置的短一些,如每20秒发送一次心跳包至主服务器;相反地,如果业务的实时性不高,或者不需要实时监听主服务器时,就可以将第一预设时间设置的长一些。
在步骤S402中,判断在第二预设时间内是否接收到对心跳包的响应,如果收到,则确 定主服务器正常,返回步骤S401;如果未收到,则确定主服务器故障,执行步骤S403。
具体的,本步骤中的第二预设时间也可以根据具体情况而设置,若控制服务器在第二预设时间内未接收到主服务器对心跳包的响应,则主服务被判断为故障。
可以理解的是,服务器故障会导致服务中断,进而给用户的使用造成巨大影响。本申请实施例中,控制服务器以定时发送心跳包的方式监听主服务器的状态,可以及时获知主服务器是否故障,判断其可用性。
在步骤S403中,发送主从切换命令至从服务器,主从切换命令用于指示从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
在步骤S404中,将从服务器中的从内存数据库切换为新的主内存数据库。
本申请实施例中,从服务器可以为一个,也可以为多个。当有多个从服务器时,每个从服务器中都包含存储有状态信息的从内存数据库。与图2所示实施例中步骤S201相同,主服务器中的内存数据库实时保存主服务器的状态信息,以使各个从服务器中的从内存数据库实时读取并保存。当主服务器发生故障时,控制服务器从多个从服务器中选取一个从服务器作为目标从服务器,然后,向该目标从服务器发送主从切换命令,以使该目标从服务器根据从内存数据库中保存的状态信息升级为新的主服务器,并将该目标从服务器中的从内存数据库切换为新的主内存数据库。
由图4所示实施例可见,主内存数据库实时保存主服务器每次执行操作后的状态信息,以供从服务器中的从内存数据库实时读取并保存,可有效解决主服务器从内存或硬盘中读取操作记录耗时较长,导致从服务器与主服务器故障前的状态不完全一致的问题,使从服务器能够在短时间内接管主服务器的职责,降低了主从服务器切换时对业务造成的影响,最大限度提高服务的可用性和连续性。
图5是根据一示例性实施例示出的一种主从服务器切换装置的框图。参照图5,该装置包括监听模块510,服务器切换模块520。
该监听模块510被配置为监听主服务器是否发生故障;主服务器中设置有主内存数据库,主内存数据库用于实时保存主服务器每次执行操作后的状态信息,状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
该服务器切换模块520被配置为如果主服务器发生故障,则发送主从切换命令至从服务器,主从切换命令用于指示从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
本申请实施例提供的技术方案可以包括以下有益效果:监听主服务器是否发生故障,其中,主服务器中设置有主内存数据库,主内存数据库用于实时保存主服务器每次执行操作后的状态信息,以供设置在从服务器中的从内存数据库实时读取并保存,如果确定主服务器发生故障,则发送主从切换命令至从服务器,以使从服务器根据从内存数据库中保存 的状态信息升级为新的主服务器,由于主服务器的状态信息是实时写入主内存数据库的,并且,从服务器中的从内存数据库是实时从主内存数据库中读取状态信息的,因此,可在主服务器故障时使从服务器快速地与主服务器故障前的状态保持一致,有效解决主服务器从内存或硬盘中读取操作记录耗时较长的问题。
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。
可选的,在本申请实施例中,所述主内存数据库和所述从内存数据库为Redis内存数据库。
可选的,在本申请实施例中,主从服务器切换装置,还包括:
数据库切换模块530,被配置为在服务器切换模块执行如果主服务器发生故障,则发送主从切换命令至从服务器之后,将从服务器中的从内存数据库切换为新的主内存数据库。
可选的,当有多个从服务器时,所述多个从服务器中的每个从服务器中包含有用于存储所述状态信息的从内存数据库;所述状态信息由所述多个从服务器中每个从服务器中的从内存数据库从所述主内存数据库中实时读取;服务器切换模块520,可以包括:
选取单元,被配置为从多个从服务器中选取一个从服务器作为目标从服务器;
命令发送单元,被配置为发送主从切换命令至目标从服务器,主从切换命令用于指示目标从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
可选的,在本申请实施例中,服务器切换模块520,还包括:
切换单元,被配置为在命令发送单元执行发送主从切换命令至目标从服务器之后,将目标从服务器中的从内存数据库切换为新的主内存数据库。
可选的,在本申请实施例中,监听模块510,可以包括:
心跳发送单元,被配置为每间隔第一预设时间,发送一次心跳包至主服务器;
判断单元,被配置为判断在第二预设时间内是否接收到对心跳包的响应;如果是,则主服务器未发生故障;如果否,则主服务器发生故障。
图6是根据一示例性实施例示出的一种用于主从服务器切换的装置600的框图。例如,装置600可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。
参照图6,装置600可以包括以下一个或多个组件:处理组件602,存储器604,电源组件606,多媒体组件608,音频组件610,输入/输出(I/O)的接口612,传感器组件614,以及通信组件616。
处理组件602通常控制装置600的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件602可以包括一个或多个处理器620来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件602可以包括一个或多个模块,便 于处理组件602和其他组件之间的交互。例如,处理组件602可以包括多媒体模块,以方便多媒体组件608和处理组件602之间的交互。
存储器604被配置为存储各种类型的数据以支持在设备600的操作。这些数据的示例包括用于在装置600上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器604可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
电源组件606为装置600的各种组件提供电力。电源组件606可以包括电源管理系统,一个或多个电源,及其他与为装置600生成、管理和分配电力相关联的组件。
多媒体组件608包括在所述装置600和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件608包括一个前置摄像头和/或后置摄像头。当设备600处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。
音频组件610被配置为输出和/或输入音频信号。例如,音频组件610包括一个麦克风(MIC),当装置600处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器604或经由通信组件616发送。在一些实施例中,音频组件610还包括一个扬声器,用于输出音频信号。
I/O接口612为处理组件602和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。
传感器组件614包括一个或多个传感器,用于为装置600提供各个方面的状态评估。例如,传感器组件614可以检测到设备600的打开/关闭状态,组件的相对定位,例如所述组件为装置600的显示器和小键盘,传感器组件614还可以检测装置600或装置600一个组件的位置改变,用户与装置600接触的存在或不存在,装置800方位或加速/减速和装置600的温度变化。传感器组件614可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件614还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件614还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。
通信组件616被配置为便于装置600和其他设备之间有线或无线方式的通信。装置600可以接入基于通信标准的无线网络,如WiFi,运营商网络(如2G、3G、4G或5G),或它们的组合。在一个示例性实施例中,通信组件616经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件616还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。
在示例性实施例中,装置600可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述主从服务器切换方法。
在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器604,上述指令可由装置600的处理器620执行以完成上述方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
图7是根据一示例性实施例示出的另一种用于主从服务器切换的装置700的框图。例如,装置700可以被提供为一服务器。参照图7,装置700包括处理组件722,其进一步包括一个或多个处理器,以及由存储器732所代表的存储器资源,用于存储可由处理组件722的执行的指令,例如应用程序。存储器732中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件722被配置为执行指令,以执行本申请实施例所提供的任一主从服务器切换方法。
装置700还可以包括一个电源组件726被配置为执行装置700的电源管理,一个有线或无线网络接口750被配置为将装置700连接到网络,和一个输入输出(I/O)接口758。装置700可以操作基于存储在存储器732的操作系统,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM或类似。
如图8所示,在示例性实施例中,还提供了一种控制服务器,所述控制服务器与主服务器和从服务器通信连接,包括:
处理器801;
用于存储处理器可执行指令的存储器802;
其中,所述处理器801被配置为:
监听主服务器是否发生故障;所述主服务器中设置有主内存数据库,所述主内存数据库用于实时保存主服务器每次执行操作后的状态信息,所述状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
如果主服务器发生故障,则发送主从切换命令至从服务器,所述主从切换命令用于指 示所述从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
可选的,所述主内存数据库和所述从内存数据库为Redis内存数据库。
可选的,所述处理器801还被配置为:
在如果主服务器发生故障,则发送主从切换命令至从服务器之后,将所述从服务器中的从内存数据库切换为新的主内存数据库。
可选的,当有多个从服务器时,所述多个从服务器中的每个从服务器中包含有用于存储所述状态信息的从内存数据库;所述状态信息由所述多个从服务器中每个从服务器中的从内存数据库从所述主内存数据库中实时读取;所述处理器801具体被配置为:
从多个从服务器中选取一个从服务器作为目标从服务器;
发送主从切换命令至所述目标从服务器,所述主从切换命令用于指示所述目标从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
可选的,所述处理器801还被配置为:
当有多个从服务器时,在发送主从切换命令至所述目标从服务器之后,将所述目标从服务器中的从内存数据库切换为新的主内存数据库。
可选的,所述处理器801具体被配置为:
每间隔第一预设时间,发送一次心跳包至主服务器;
判断在第二预设时间内是否接收到对所述心跳包的响应;如果是,则所述主服务器未发生故障;如果否,则所述主服务器发生故障。
本领域技术人员在考虑说明书及实践这里公开的内容后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本申请的真正范围和精神由下面的权利要求指出。
应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求来限制。

Claims (19)

  1. 一种主从服务器切换方法,应用于与主服务器和从服务器通信连接的控制服务器,包括:
    监听主服务器是否发生故障;所述主服务器中设置有主内存数据库,所述主内存数据库用于实时保存主服务器每次执行操作后的状态信息,所述状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
    如果主服务器发生故障,则发送主从切换命令至从服务器,所述主从切换命令用于指示所述从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
  2. 根据权利要求1所述的主从服务器切换方法,所述主内存数据库和所述从内存数据库为Redis内存数据库。
  3. 根据权利要求2所述的主从服务器切换方法,在如果主服务器发生故障,则发送主从切换命令至从服务器之后,还包括:
    将所述从服务器中的从内存数据库切换为新的主内存数据库。
  4. 根据权利要求2所述的主从服务器切换方法,当有多个从服务器时,所述多个从服务器中的每个从服务器中包含有用于存储所述状态信息的从内存数据库;所述状态信息由所述多个从服务器中每个从服务器中的从内存数据库从所述主内存数据库中实时读取;
    如果主服务器发生故障,则发送主从切换命令至从服务器,包括:
    从多个从服务器中选取一个从服务器作为目标从服务器;
    发送主从切换命令至所述目标从服务器,所述主从切换命令用于指示所述目标从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
  5. 根据权利要求4所述的主从服务器切换方法,当有多个从服务器时,在发送主从切换命令至所述目标从服务器之后,还包括:
    将所述目标从服务器中的从内存数据库切换为新的主内存数据库。
  6. 根据权利要求1所述的主从服务器切换方法,监听主服务器是否发生故障,包括:
    每间隔第一预设时间,发送一次心跳包至主服务器;
    判断在第二预设时间内是否接收到对所述心跳包的响应;如果是,则所述主服务器未发生故障;如果否,则所述主服务器发生故障。
  7. 一种主从服务器切换装置,应用于与主服务器和从服务器通信连接的控制服务器,包括:
    监听模块,被配置为监听主服务器是否发生故障;所述主服务器中设置有主内存数据库,所述主内存数据库用于实时保存主服务器每次执行操作后的状态信息,所述状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
    服务器切换模块,被配置为如果主服务器发生故障,则发送主从切换命令至从服务器, 所述主从切换命令用于指示所述从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
  8. 根据权利要求7所述的主从服务器切换装置,所述主内存数据库和所述从内存数据库为Redis内存数据库。
  9. 根据权利要求8所述的主从服务器切换装置,所述装置还包括:
    数据库切换模块,被配置为在所述服务器切换模块执行如果主服务器发生故障,则发送主从切换命令至从服务器之后,将所述从服务器中的从内存数据库切换为新的主内存数据库。
  10. 根据权利要求8所述的主从服务器切换装置,当有多个从服务器时,所述多个从服务器中的每个从服务器中包含有用于存储所述状态信息的从内存数据库;所述状态信息由所述多个从服务器中每个从服务器中的从内存数据库从所述主内存数据库中实时读取;
    所述服务器切换模块,包括:
    选取单元,被配置为从多个从服务器中选取一个从服务器作为目标从服务器;
    命令发送单元,被配置为发送主从切换命令至所述目标从服务器,所述主从切换命令用于指示所述目标从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
  11. 根据权利要求10所述的主从服务器切换装置,所述服务器切换模块,还包括:
    切换单元,被配置为在所述命令发送单元执行发送主从切换命令至所述目标从服务器之后,将所述目标从服务器中的从内存数据库切换为新的主内存数据库。
  12. 根据权利要求7所述的主从服务器切换装置,所述监听模块,包括:
    心跳发送单元,被配置为每间隔第一预设时间,发送一次心跳包至主服务器;
    判断单元,被配置为判断在第二预设时间内是否接收到对所述心跳包的响应;如果是,则所述主服务器未发生故障;如果否,则所述主服务器发生故障。
  13. 一种控制服务器,所述控制服务器与主服务器和从服务器通信连接,包括:
    处理器;
    用于存储处理器可执行指令的存储器;
    其中,所述处理器被配置为:
    监听主服务器是否发生故障;所述主服务器中设置有主内存数据库,所述主内存数据库用于实时保存主服务器每次执行操作后的状态信息,所述状态信息用于设置在从服务器中的从内存数据库实时读取并保存;
    如果主服务器发生故障,则发送主从切换命令至从服务器,所述主从切换命令用于指示所述从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
  14. 根据权利要求13所述的控制服务器,所述主内存数据库和所述从内存数据库为Redis内存数据库。
  15. 根据权利要求14所述的控制服务器,所述处理器还被配置为:
    在如果主服务器发生故障,则发送主从切换命令至从服务器之后,将所述从服务器中的从内存数据库切换为新的主内存数据库。
  16. 根据权利要求14所述的控制服务器,当有多个从服务器时,所述多个从服务器中的每个从服务器中包含有用于存储所述状态信息的从内存数据库;所述状态信息由所述多个从服务器中每个从服务器中的从内存数据库从所述主内存数据库中实时读取;所述处理器具体被配置为:
    从多个从服务器中选取一个从服务器作为目标从服务器;
    发送主从切换命令至所述目标从服务器,所述主从切换命令用于指示所述目标从服务器根据从内存数据库中保存的状态信息,升级为新的主服务器。
  17. 根据权利要求16所述的控制服务器,所述处理器还被配置为:
    当有多个从服务器时,在发送主从切换命令至所述目标从服务器之后,将所述目标从服务器中的从内存数据库切换为新的主内存数据库。
  18. 根据权利要求13所述的控制服务器,所述处理器具体被配置为:
    每间隔第一预设时间,发送一次心跳包至主服务器;
    判断在第二预设时间内是否接收到对所述心跳包的响应;如果是,则所述主服务器未发生故障;如果否,则所述主服务器发生故障。
  19. 一种非临时性计算机可读存储介质,当所述存储介质中的指令由电子设备的处理器执行时,使得电子设备能够实现权利要求1-6任一所述的方法步骤。
PCT/CN2020/075769 2019-03-22 2020-02-18 主从服务器切换方法、装置、电子设备及存储介质 WO2020192311A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP20776845.8A EP3937426B1 (en) 2019-03-22 2020-02-18 Master-slave server switching method, apparatus and storage medium
US17/481,602 US11500744B2 (en) 2019-03-22 2021-09-22 Method for primary-backup server switching, and control server

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910223583.7 2019-03-22
CN201910223583.7A CN109936481B (zh) 2019-03-22 2019-03-22 主从服务器切换方法、装置、电子设备及存储介质

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/481,602 Continuation US11500744B2 (en) 2019-03-22 2021-09-22 Method for primary-backup server switching, and control server

Publications (1)

Publication Number Publication Date
WO2020192311A1 true WO2020192311A1 (zh) 2020-10-01

Family

ID=66988135

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/075769 WO2020192311A1 (zh) 2019-03-22 2020-02-18 主从服务器切换方法、装置、电子设备及存储介质

Country Status (4)

Country Link
US (1) US11500744B2 (zh)
EP (1) EP3937426B1 (zh)
CN (1) CN109936481B (zh)
WO (1) WO2020192311A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114564340A (zh) * 2022-01-19 2022-05-31 中国电子科技集团公司第十研究所 航天地面系统分布式软件高可用方法
CN114978871A (zh) * 2022-04-08 2022-08-30 北京航天飞行控制中心 业务系统的节点切换方法及节点切换装置、电子设备
TWI832078B (zh) 2021-05-14 2024-02-11 新加坡商聯發科技(新加坡)私人有限公司 語音設備及其語音互動方法,以及電腦可讀記錄媒體

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109936481B (zh) * 2019-03-22 2021-06-18 北京达佳互联信息技术有限公司 主从服务器切换方法、装置、电子设备及存储介质
CN110765179A (zh) * 2019-10-18 2020-02-07 京东数字科技控股有限公司 分布式对账处理方法、装置、设备及存储介质
CN111258823A (zh) * 2020-01-17 2020-06-09 青梧桐有限责任公司 一种主从服务器的切换方法及系统
CN111258665A (zh) * 2020-01-21 2020-06-09 上海米哈游天命科技有限公司 一种服务器启动方法、装置、服务器和介质
CN111338905A (zh) * 2020-03-03 2020-06-26 中国工商银行股份有限公司 应用节点数据处理方法及装置
CN113391759B (zh) * 2020-03-13 2024-04-09 华为云计算技术有限公司 一种通信方法和设备
CN113254536A (zh) * 2021-06-09 2021-08-13 蚂蚁金服(杭州)网络技术有限公司 数据库事务处理方法、系统、电子设备及存储介质
CN114138732A (zh) * 2021-09-29 2022-03-04 聚好看科技股份有限公司 一种数据处理方法及装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030120669A1 (en) * 2001-12-26 2003-06-26 Han Mi Kyoung Duplex structure of main-memory DBMS using log information in diskless environment and method for controlling consistency of data of main-memory DBMS
KR100439857B1 (ko) * 2001-12-24 2004-07-12 엘지전자 주식회사 주기억 데이터베이스의 이중화 처리기의 구성 및 방법그리고 주기억 데이터 베이스 내의 동기화 방법
CN1808394A (zh) * 2006-02-20 2006-07-26 南京联创科技股份有限公司 基于内存数据库的软双机方法
CN102043686A (zh) * 2009-10-20 2011-05-04 华为技术有限公司 一种内存数据库的容灾方法、备用服务器及系统
CN103530200A (zh) * 2012-07-04 2014-01-22 腾讯科技(深圳)有限公司 一种服务器热备份系统和方法
CN109936481A (zh) * 2019-03-22 2019-06-25 北京达佳互联信息技术有限公司 主从服务器切换方法、装置、电子设备及存储介质

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6782496B2 (en) * 2001-04-13 2004-08-24 Hewlett-Packard Development Company, L.P. Adaptive heartbeats
US7383264B2 (en) * 2003-03-27 2008-06-03 Hitachi, Ltd. Data control method for duplicating data between computer systems
JP5602311B2 (ja) * 2011-04-15 2014-10-08 株式会社日立製作所 ファイル共有システム及びファイル共有方法
CN103207841B (zh) * 2013-03-06 2016-01-20 青岛海信传媒网络技术有限公司 基于键值对缓存的数据读写方法及装置
WO2015029139A1 (ja) * 2013-08-27 2015-03-05 株式会社東芝 データベースシステム、プログラムおよびデータ処理方法
US9842033B2 (en) * 2014-11-12 2017-12-12 Netapp, Inc. Storage cluster failure detection
CN106940699B (zh) * 2016-01-05 2021-02-05 创新先进技术有限公司 一种内存数据的同步处理方法、装置、服务器及系统
CN106980625B (zh) * 2016-01-18 2020-08-04 阿里巴巴集团控股有限公司 一种数据同步方法、装置及系统
CN106254236A (zh) * 2016-08-05 2016-12-21 成都广达新网科技股份有限公司 一种基于tcp事件的多服务器主从机工作方法
CN109376197B (zh) * 2018-09-28 2020-01-17 掌阅科技股份有限公司 一种数据同步方法、服务器及计算机存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100439857B1 (ko) * 2001-12-24 2004-07-12 엘지전자 주식회사 주기억 데이터베이스의 이중화 처리기의 구성 및 방법그리고 주기억 데이터 베이스 내의 동기화 방법
US20030120669A1 (en) * 2001-12-26 2003-06-26 Han Mi Kyoung Duplex structure of main-memory DBMS using log information in diskless environment and method for controlling consistency of data of main-memory DBMS
CN1808394A (zh) * 2006-02-20 2006-07-26 南京联创科技股份有限公司 基于内存数据库的软双机方法
CN102043686A (zh) * 2009-10-20 2011-05-04 华为技术有限公司 一种内存数据库的容灾方法、备用服务器及系统
CN103530200A (zh) * 2012-07-04 2014-01-22 腾讯科技(深圳)有限公司 一种服务器热备份系统和方法
CN109936481A (zh) * 2019-03-22 2019-06-25 北京达佳互联信息技术有限公司 主从服务器切换方法、装置、电子设备及存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3937426A4 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI832078B (zh) 2021-05-14 2024-02-11 新加坡商聯發科技(新加坡)私人有限公司 語音設備及其語音互動方法,以及電腦可讀記錄媒體
CN114564340A (zh) * 2022-01-19 2022-05-31 中国电子科技集团公司第十研究所 航天地面系统分布式软件高可用方法
CN114978871A (zh) * 2022-04-08 2022-08-30 北京航天飞行控制中心 业务系统的节点切换方法及节点切换装置、电子设备
CN114978871B (zh) * 2022-04-08 2023-10-24 北京航天飞行控制中心 业务系统的节点切换方法及节点切换装置、电子设备

Also Published As

Publication number Publication date
EP3937426A4 (en) 2022-04-20
US20220004469A1 (en) 2022-01-06
EP3937426A1 (en) 2022-01-12
CN109936481A (zh) 2019-06-25
EP3937426B1 (en) 2023-04-12
US11500744B2 (en) 2022-11-15
CN109936481B (zh) 2021-06-18

Similar Documents

Publication Publication Date Title
WO2020192311A1 (zh) 主从服务器切换方法、装置、电子设备及存储介质
US11416061B2 (en) Terminal control method and apparatus, and terminal
JP6348989B2 (ja) ファームウェアの復元方法、装置、端末、プログラム及び記録媒体
CN107357704B (zh) 一种应用程序检测方法、终端及计算机可读存储介质
EP3499786B1 (en) Data synchronization method, apparatus, storage medium and electronic device
JP6420916B2 (ja) システムパーティションファイルを監視する方法及び装置
CN109684406A (zh) 跨机房的redis集群备份数据的方法、装置、设备及存储介质
US20240086360A1 (en) File saving method and electronic device
CN111274205B (zh) 数据块访问方法及装置、存储介质
CN114020615A (zh) 异地多活金融系统的测试方法、装置、设备及存储介质
CN113609107A (zh) 数据库管理方法、装置、电子设备及存储介质
US9928134B2 (en) Method and apparatus for repairing dynamic link library file
CN111290882B (zh) 数据文件备份方法、数据文件备份装置及电子设备
US20220330108A1 (en) Method for processing link failure information and electronic device
CN108923988B (zh) 设备分组方法及装置
CN112632184A (zh) 数据处理方法、装置、电子设备及存储介质
CN111274210B (zh) 元数据处理方法、装置及电子设备
US20230274036A1 (en) Data reading method, storage medium, and mobile terminal
CN112416697A (zh) 一种信息处理、装置、终端及存储介质
CN116996584A (zh) 任务处理方法、装置和设备
CN111857800A (zh) 组件动态配置方法、装置、电子设备及存储介质

Legal Events

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

Ref document number: 20776845

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2020776845

Country of ref document: EP

Effective date: 20211005