Service switching method, device and electronic equipment

By starting the first server and the backup server in the distributed file system to perform dual log write operations, the problem of service downtime during distributed service switching is solved, efficient service switching without service downtime is achieved, and system performance is improved.

CN110275802BActive Publication Date: 2025-10-03BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910568257.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-27
Publication Date
2025-10-03
Estimated Expiration
2039-06-27

AI Technical Summary

Technical Problem

During the distributed service switching process, existing technologies have downtime, which causes the service to be unable to respond to requests and affects performance.

Method used

When the original main server of the distributed file system is in working state, start the first server and write logs to the distributed file system and local disk through the first server. At the same time, start at least one backup server to write logs to its local disk. After ensuring log synchronization, stop the original main server and use the backup server to complete the log writing task.

Benefits of technology

This ensures zero downtime during service switching, ensures log integrity, improves service performance, and reduces the risk of switching failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110275802B_ABST
    Figure CN110275802B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer technology, and provides a service switching method, device, and electronic device to solve the problem of being unable to respond to requests during downtime during the switching process, thereby affecting service performance. The method includes: when the original main server corresponding to the distributed file system is in a working state, starting a first server; controlling the original main server to stop working and writing logs to the distributed file system and the local disk of the first server through the first server; starting at least one first backup server and writing logs to the first local disk through the first server; when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of at least one first backup server, controlling the first server to stop working and writing logs to the local disk of at least one first backup server through a first backup server. This ensures that there is no downtime and improves service performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a service switching method, device, electronic device, and computer-readable storage medium. Background Art

[0002] Ensuring high availability is a key design goal for distributed services. Most stateful distributed services achieve high availability by building redundant multi-node services. Distributed consistency replication protocols are a common approach for achieving state consistency across multiple nodes. Currently, there are a variety of distributed consistency replication protocols, and as consistency protocols evolve, the specific implementation methods for these protocols are constantly evolving. It's often unavoidable that a distributed system initially adopts a certain consistency implementation method as a high-availability solution. However, as the system scales and other factors increase, the old solution becomes inadequate, necessitating a switch to a new consistency solution.

[0003] However, currently, during the switch process, services based on the old consistency solution generally stop recording logs, where logs can also be called operation logs. The service is in a downtime state from this point in time. The service based on the new consistency solution starts and loads the logs recorded on the old consistency solution. After loading is complete, the service records logs on the new consistency solution and the service resumes its updated state. Alternatively, the service based on the old consistency solution stops recording logs and is in a downtime state from this point in time. The service based on the new consistency solution starts and begins loading the logs recorded on the old consistency solution. After loading is complete, the service takes a snapshot of the new consistency solution. After the snapshot is complete, the service records logs on the new consistency solution and the service resumes its updated state. In other words, to ensure that the service consistency solution does not lose logs during the switch process, there is a downtime period. This time window ensures that the service based on the new consistency solution can fully trace back the logs recorded in the old consistency solution to the metadata collection without omission. However, due to the existence of this time window, the service will experience a downtime period during which it cannot respond to any update requests, affecting service performance. Summary of the Invention

[0004] Embodiments of the present invention provide a service switching method, device, electronic device, and computer-readable storage medium to solve the problem in the prior art of failing to respond to requests during downtime during a switching process, thereby affecting service performance.

[0005] In a first aspect, an embodiment of the present invention provides a service switching method, the method comprising:

[0006] When the original primary server corresponding to the distributed file system is in a working state, starting the first server;

[0007] Controlling the original master server to stop working, and writing logs to the distributed file system and the local disk of the first server through the first server;

[0008] Starting at least one first standby server, and writing a log to a first local disk through the first server, where the first local disk is a local disk of the at least one first standby server;

[0009] When the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of the at least one first standby server, the first server is controlled to stop working, and the log is written to the local disk of the at least one first standby server through one of the at least one first standby servers.

[0010] Optionally, after controlling the first server to stop working, the method further includes:

[0011] At least one second standby server is started, and a log is written to a second local disk through the second standby server, wherein the second local disk is a local disk of the second standby server.

[0012] Optionally, when the original primary server corresponding to the distributed file system is in a working state, starting the first server includes:

[0013] When the original primary server corresponding to the distributed file system is in a working state and the original backup server corresponding to the distributed file system stops working, the first server is started.

[0014] Optionally, after controlling the original primary server to stop working and before starting at least one first backup server, the method further includes:

[0015] The original standby server is started, and logs of the distributed file system are read through the original standby server.

[0016] Optionally, before controlling the first server to stop working, the method further includes:

[0017] Control the original standby server to stop working.

[0018] Optionally, after controlling the original primary server to stop working and before starting at least one first backup server, the method further includes:

[0019] The second server is started, and a snapshot of the log in the distributed file system is obtained through the second server to obtain log snapshot information, and the log snapshot information is transmitted to the first server, and the log snapshot information is written to the local disk of the first server through the first server.

[0020] Optionally, after starting at least one first standby server, the method further includes:

[0021] The log snapshot information is written into the local disk of the at least one first standby server through the first server.

[0022] In a second aspect, an embodiment of the present invention further provides a service switching device, the device comprising:

[0023] A first starting module, configured to start the first server when the original primary server corresponding to the distributed file system is in a working state;

[0024] A first control module is configured to control the original master server to stop working, and to write logs to the distributed file system and a local disk of the first server through the first server;

[0025] A second startup module is configured to start at least one first standby server and write a log to a first local disk through the first server, where the first local disk is a local disk of the at least one first standby server;

[0026] The second control module is used to control the first server to stop working and write the log to the local disk of the at least one first standby server through one of the at least one first standby servers when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of the at least one first standby server.

[0027] Optionally, the second startup module is also used to start at least one second backup server after the second control module controls the first server to stop working, and write logs to the second local disk through the second backup server, wherein the second local disk is the local disk of the second backup server.

[0028] Optionally, the first starting module is configured to start the first server when an original primary server corresponding to the distributed file system is in working state and an original backup server corresponding to the distributed file system stops working.

[0029] Optionally, the second startup module is used to start the original backup server after the first control module controls the original main server to stop working and before the second startup module starts the at least one first backup server, and read the log of the distributed file system through the original backup server.

[0030] Optionally, the first control module is configured to control the original standby server to stop working before controlling the first server to stop working.

[0031] Optionally, the device further includes:

[0032] The third startup module is used to start the second server after the first control module controls the original main server to stop working and before the second startup module starts at least one first backup server, to snapshot the log in the distributed file system through the second server to obtain log snapshot information, and to transmit the log snapshot information to the first server, and to write the log snapshot information to the local disk of the first server through the first server.

[0033] Optionally, after the second startup module starts at least one first standby server, the second startup module writes the log snapshot information into a local disk of the at least one first standby server through the first server.

[0034] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the service switching method described above when executing the computer program.

[0035] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the service switching method described above are implemented.

[0036] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the service switching method provided in each embodiment of the present application.

[0037] In the service switching method of the embodiment of the present application, since during the switching process, the first server is started when the original main server corresponding to the distributed file system is in a working state, and when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of at least one first backup server, the first server is controlled to stop working, and a log is written to the local disk of at least one first backup server through one of the at least one first backup servers. In this way, even if the original main server stops working, the first server has been started, and the log can be written to the distributed file system and the local disk of the first server through the first server, ensuring the integrity of the log during the switching process without a service downtime, thereby improving the service performance during the switching process. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in describing the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0039] Figure 1 This is one of the flow charts of the service switching method provided by an embodiment of the present invention;

[0040] Figure 2 This is the second flow chart of the service switching method provided by an embodiment of the present invention;

[0041] Figure 3 This is a schematic diagram of the consistency solution based on the distributed file system;

[0042] Figure 4 This is one of the principle diagrams of the service switching method provided by an embodiment of the present invention;

[0043] Figure 5 This is the second principle diagram of the service switching method provided by an embodiment of the present invention;

[0044] Figure 6 This is the third principle diagram of the service switching method provided by an embodiment of the present invention;

[0045] Figure 7 This is the fourth principle diagram of the service switching method provided by an embodiment of the present invention;

[0046] Figure 8 This is the fifth principle diagram of the service switching method provided by an embodiment of the present invention;

[0047] Figure 9 This is the sixth principle diagram of the service switching method provided by an embodiment of the present invention;

[0048] Figure 10 This is the seventh principle diagram of the service switching method provided by an embodiment of the present invention;

[0049] Figure 11 This is the eighth principle diagram of the service switching method provided by an embodiment of the present invention;

[0050] Figure 12 This is the ninth principle diagram of the service switching method provided by an embodiment of the present invention;

[0051] Figure 13 is a schematic diagram of a server switching device provided by an embodiment of the present invention;

[0052] Figure 14 It is a schematic diagram of the hardware structure of the electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0053] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0054] like Figure 1 As shown, in one embodiment, a service switching method is provided, which can be applied to a control platform. The method includes:

[0055] Step 101: When the original primary server corresponding to the distributed file system is in a working state, start the first server.

[0056] In the process of achieving consistency through a distributed file system, the original primary server (i.e., the primary server corresponding to the distributed file system, used here to distinguish the primary server after switching) is involved. The original primary server can write logs to the distributed file system, that is, write logs to the distributed file system and update the logs in the distributed file system. The distributed file system can also involve the original backup server (i.e., the backup server corresponding to the distributed file system, used here to distinguish the backup server during and after the switching process). The original backup server can read logs from the distributed file system, that is, the original backup server can read the logs of the distributed file system. When the primary server updates the logs in the distributed file, the original backup server can read the updated logs, thereby achieving log synchronization through the distributed file system, that is, achieving log consistency.

[0057] During the switching service process of this embodiment, if the control platform receives a switching instruction, it sends a startup instruction to the first server to start the first server, that is, the first server starts working after receiving the startup instruction. At this time, the distributed file system can be read through the first server, that is, the log of the distributed file system can be read.

[0058] Step 102: Control the original main server to stop working, and write logs to the distributed file system and the local disk of the first server through the first server.

[0059] After starting the first server, the original master server can be controlled to stop working. For example, the control platform can send a stop command to the original master server to stop the original master server. The original master server stops working after receiving the stop command. At the same time, the first server can be determined as the new master server. In this way, the first server can be used to write logs to the distributed file system and the local disk of the first server. That is, the first server is a dual-write version server, which can write logs to the distributed file system and the local disk of the first server at the same time.

[0060] Step 103: Start at least one first standby server, and write logs to the first local disk through the first server.

[0061] Among them, the first local disk is the local disk of at least one first backup server. After controlling the original main server to stop working and determining the first server as the new main server, at least one first backup server can be started. In this way, since the first server is the new main server, the first server can write logs to the first local disk, that is, the first server can write logs to the local disk of each first backup server in the above-mentioned at least one first backup server. At the same time, at least one first backup server can read logs from the first local disk, that is, it can read logs from its own local disk through the first backup server. In this way, even if the first server writes logs to the first local disk and updates the logs of the first local disk, the first backup server can also read the updated logs corresponding to its own local disk, thereby realizing log synchronization between the first server and the first backup server.

[0062] In one example, an even number (e.g., two) of second standby servers can be started. Thus, the even number of second standby servers and the first server constitute an odd number of servers, facilitating voting during the master election process. The first server can write logs to the local disks of the even number of second standby servers, and can read logs from its own local disks through the even number of second standby servers. It is understood that at this time, a master election mechanism is not provided for at least the first standby server, that is, at least one standby server does not participate in the master election.

[0063] Step 104: When the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of at least one first standby server, the first server is controlled to stop working, and the log is written to the local disk of at least one first standby server through one of the at least one first standby servers.

[0064] Before the switch, the distributed file system already has old logs. The old logs and the new logs generated by the distributed file system during the switch need to be synchronized to the local disk of the first server and the local disk of at least one backup server. In this way, log omissions can be avoided during the switch and log synchronization can be ensured. When the logs of the distributed file system are synchronized with the logs of the local disk of the first server and the logs of the local disk of at least one first backup server, the first server can be controlled to stop working, that is, the new main server stops working, and at least one backup server can participate in the master election (that is, the new main server can be determined from at least one backup server through the master election process), and one of the at least one first backup servers can be used as the new main server, and the log can be written through the local disk of the above-mentioned new server. In this way, the server in working state is at least one first backup server, one of the first backup servers is the new main server, and the local disk of each first backup server can be written through the new main server. The other first backup servers (that is, the first backup servers in at least one backup first server except the above-mentioned first backup server) can read the logs from their own local disks respectively, that is, read the logs from their own local disks respectively through other first backup servers to achieve log synchronization, that is, achieve log consistency. In this way, the service switching is completed, which can also be understood as the consistency scheme switching is completed.

[0065] In the service switching method of the embodiment of the present application, since during the switching process, the first server is started when the original main server corresponding to the distributed file system is in a working state, and when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of at least one first backup server, the first server is controlled to stop working, and a log is written to the local disk of at least one first backup server through one of the at least one first backup servers. In this way, even if the original main server stops working, the first server has been started, and the log can be written to the distributed file system and the local disk of the first server through the first server, ensuring the integrity of the log during the switching process without a service downtime, thereby improving the service performance during the switching process.

[0066] In one embodiment, when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of at least one first backup server, after controlling the first server to stop working, the method further includes: updating a service address list to obtain an updated service address list. The updated service address list includes the address of the at least one first backup server.

[0067] The primary server has stopped working and is unable to provide external services. External services are provided through at least one primary backup server. For example, one of the at least one primary backup server that writes logs can provide write services, while the other primary backup servers can provide read services. This requires updating the service address list—that is, changing the address list of servers providing external services. This ensures that external services can continue to be provided through the primary backup servers even if the primary server stops working.

[0068] In one embodiment, after controlling the first server to stop working, the method further includes: starting at least one second standby server, and writing logs to a second local disk through the second standby server, wherein the second local disk is a local disk of the second standby server.

[0069] The sum of the number of second standby servers and the number of first standby servers is an odd number, which facilitates voting during the master election process. For example, if the number of first standby servers is an even number, then the number of second standby servers is an odd number, and an odd number of second standby servers can be started. Each second standby server writes a log to its own local disk. In addition, one of the at least one first standby servers can not only write a log to the local disk of the at least one first standby server, but also write a log to the local disk of the at least one second standby server, that is, after starting the at least one second standby server, one of the at least one first standby servers can write a log to the local disk of the at least one second standby server, so that after one of the at least one first standby servers updates the log of the local disk of the at least one second standby server, the at least one second standby server can read the updated log of its own local disk to achieve log synchronization.

[0070] In one embodiment, when the original primary server corresponding to the distributed file system is in working state, starting the first server includes: when the original primary server corresponding to the distributed file system is in working state and the original backup server corresponding to the distributed file system stops working, starting the first server.

[0071] The distributed file system involves not only the original primary server but also the original backup server. During a switchover, the original backup server can be shut down before starting the primary server. This stops the backup server from reading logs from the distributed file system, reducing resource waste. If the backup server is down but the original primary server is still functioning, the primary server can be started and then shut down. This means that by starting with the backup server, even if the newly started primary server experiences downtime and cannot provide services properly, the original primary server remains unaffected and can still write logs.

[0072] In one embodiment, after controlling the original main server to stop working and before starting at least one first backup server, the method further includes: starting the original backup server and reading logs of the distributed file system through the original backup server.

[0073] Because the original backup server is stopped before the primary server is started, it can be restored after the primary server stops working, allowing it to continue reading logs from the distributed file system. If a problem occurs with the primary server, the original backup server for the distributed file system can be quickly taken over as the primary server, enabling a quick rollback of services and ensuring that services can still be provided through the original backup server if a problem occurs during the switchover process.

[0074] In one embodiment, before controlling the first server to stop working, the method further includes: controlling the original standby server to stop working.

[0075] It can be understood that, in the case where the logs of the distributed file system are synchronized with the logs of the local disk of the first server and the logs of the local disk of at least one first standby server, before controlling the first server to stop working, the original standby server is controlled to stop working. In the case where the logs of the distributed file system are synchronized with the logs of the local disk of the first server and the logs of the local disk of at least one first standby server, before controlling the first server to stop working, since the logs of the distributed file system are synchronized with the logs of the local disk of the first server and the logs of the local disk of at least one first standby server, the original standby server can be controlled to stop working, thereby reducing waste of resources.

[0076] In one embodiment, after controlling the original main server to stop working and before starting at least one first backup server, it also includes: starting a second server, taking a snapshot of the log in the distributed file system through the second server to obtain log snapshot information, and transmitting the log snapshot information to the first server, and writing the log snapshot information to the local disk of the first server through the first server.

[0077] Since there are logs in the distributed file system before starting at least one first standby server, these logs need to be synchronized to the local disk of the first server where the logs can be written. In this embodiment, by starting the second server, the second server takes a snapshot of the logs in the distributed file system to obtain log snapshot information and transmits the log snapshot information to the first server. The first server writes the log snapshot information to the local disk of the first server, thereby achieving synchronization of the logs of the distributed file system before starting at least one first standby server to the local disk of the first server, ensuring the integrity of the logs of the distributed file system in the local disk of the first server.

[0078] In one embodiment, after starting at least one first standby server, the method further includes: writing the log snapshot information to a local disk of the at least one first standby server through the first server.

[0079] After starting at least one first standby server, the log snapshot information can also be written to the local disk of at least one first standby server through the first server, that is, the log snapshot information can be written not only to the local disk of the first server, but also to the local disk of at least one first standby server, so that the local disk of at least one first standby server can have the log of the distributed file system, ensuring the integrity of the log of the distributed file system in the local disk of at least one first standby server.

[0080] In one embodiment, after starting at least one first standby server, the method further includes: transmitting the log snapshot information to the at least one first standby server through the second server.

[0081] In this way, each first standby server has the log snapshot information corresponding to the log of the distributed system. After the first standby server becomes the primary server, if necessary, the log snapshot information can be written to the corresponding local disk to achieve log synchronization.

[0082] like Figure 2 As shown, the above service switching process is specifically described with a specific embodiment, specifically taking the switching from a distributed file system (DFS) to Raft (a consensus algorithm) as an example. The Network File System (NFS) is a type of distributed file system. The specific steps are as follows:

[0083] Step 201: Control the original standby server to stop working.

[0084] like Figure 3As shown, it is a principle diagram of the consistency solution based on the distributed file system. When the original main server receives the request from the client, if the original main server needs to update the file in the distributed file system according to the request, the original main server's memory will update the metadata, and the original main server will write the corresponding operation log to the distributed file system, and update the log of the distributed file system. For example, if the main server needs to create a file in the distributed file system according to the request, the main server will create a file and write it to the distributed file system, and will also write the operation log of creating the file to the distributed file system. The original backup server can read the log of the distributed file system, that is, after the operation log of creating the file mentioned above, the original backup server can read the operation log, and can know that the file in the distributed file system has been updated, and can read the newly created file.

[0085] In an example, the above log can be understood as an operation log. As long as the metadata in the memory of the original master server corresponding to the distributed file system is updated, the original master server can write the corresponding operation log in the distributed file system.

[0086] like Figure 4 As shown, during the service switching process, the first step is to stop the standby server of the distributed file system, that is, first control the original standby server to stop working, and the original main server to work normally, and then write logs to the distributed file system.

[0087] Step 202: Start the first server.

[0088] like Figure 5 As shown, when the original standby server stops working but the original main server is in working state, the first server is started, and the log of the distributed file system can be read through the first server.

[0089] Step 203: Control the original master server to stop working, and switch the first server to the new master server.

[0090] like Figure 6 As shown, the first server can write logs to the distributed file system and its own local disk at the same time. It can be understood that the first server can write logs to the distributed file system and the Raft log at the same time.

[0091] In one example, whenever the metadata in the new primary server's memory is updated, the new primary server can write the corresponding operation log to the distributed file system and the new server's own local disk. When the first backup server is subsequently started, the new server can also write the operation log to the first backup server's local disk.

[0092] Step 204: Start the original standby server.

[0093] like Figure 7 As shown, after the first server is switched to the new primary server, the original standby server can be started to read logs from the distributed file system through the original standby server.

[0094] Step 205: Start the second server, take a snapshot of the log in the distributed file system through the second server to obtain log snapshot information, transmit the log snapshot information to the first server, and write the log snapshot information to the local disk of the first server through the first server.

[0095] like Figure 8 As shown, Snapshot is a snapshot technology that performs snapshot processing on existing logs of the distributed file system to obtain log snapshot information, which is beneficial for synchronizing the logs in the distributed file system with the local disk of the first server.

[0096] Step 206: Start two first standby servers, and use the two first standby servers to read logs from their own local disks respectively.

[0097] like Figure 8 As shown, at this time, the first backup server is a read-only server, which reads logs from its own local disk, and the main service (write service) of Raft will be restricted (for example, it can be manually restricted) on the first server, that is, logs can only be written through the first server, and the main service will not be switched at present. It is equivalent to that Raft does not provide a master election mechanism at this time to ensure the normal progress of the entire service switching process.

[0098] Step 207: When the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of the two first standby servers, the original standby server is controlled to stop working, and the first server is controlled to stop working, and logs are written to the local disks of the two first standby servers through one of the two first standby servers.

[0099] like Figure 9 As shown, when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of the two first backup servers, a switch instruction (Switch) can be sent to the first server to control a server to stop working, such as Figure 10 As shown. You can also control the original backup server to stop working, such as Figure 10As shown. In addition, two first standby servers can be set to participate in the master election, that is, one of the two first standby servers is selected as the new master server through the master election process, that is, one of the two first standby servers is switched to the master server. The new master server writes logs to the local disks of the two first standby servers, and the second server can also read logs from the first standby servers other than the new master server, as shown. Figure 11 shown.

[0100] In an example, as long as the in-memory metadata of one of the two first standby servers is updated, the first standby server can write the corresponding operation log to its own local disk, and can write the operation log to the local disk of the other of the two first standby servers. After the second standby server is subsequently started, the first standby server can also write the operation log to the local disk of the first standby server.

[0101] Step 208: Start a second standby server and write logs to its own local disk through the second standby server.

[0102] like Figure 12 As shown, at this time, the new server (one of the two first backup servers), the other first backup server of the two first backup servers, and the second backup server are working. The new backup server is responsible for writing logs to its own local disk, the local disk of the other first backup server, and the local disk of the second backup server. The other first backup server reads logs from its own local disk, and the second backup server writes logs to its own local disk. That is, the entire server cluster returns to normal. Through the above services of the new server, the other first backup server, and the second backup server, log consistency can be achieved, thereby achieving the switching of the consistency solution.

[0103] Through the above-mentioned service switching method, the switching is performed by the double-writing log method of the first server (that is, the logs of the distributed file system and the local disk can be written at the same time), and the disadvantage of the existing switching method that the service must be stopped for lossy switching is that the first server is started before the original main server stops working, and the first server can write logs to the distributed file system and the local disk of the first server when the original main server stops working (that is, double-writing logs), ensuring that the logs are not missed during the switching process, and there is no downtime, thereby improving system performance. At the same time, the switching method of this embodiment also gives the new solution sufficient verification time, avoiding the unknown risks that may be brought about by the new solution after switching. Even if a problem occurs with the first server during the switching process, it can be rolled back to the original backup server without loss, which reduces the risk of switching failure.

[0104] like Figure 13 As shown, the present invention also provides a service switching device 1300 according to an embodiment, which can be applied to a control platform. The device includes:

[0105] A first starting module, configured to start the first server when the original primary server corresponding to the distributed file system is in a working state;

[0106] A first control module is used to control the original main server to stop working, and write logs to the distributed file system and the local disk of the first server through the first server;

[0107] A second startup module is configured to start at least one first standby server and write a log to a first local disk through the first server, where the first local disk is a local disk of the at least one first standby server;

[0108] The second control module is used to control the first server to stop working and write logs to the local disk of at least one first standby server through one of the at least one first standby servers when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of at least one first standby server.

[0109] In one embodiment, the apparatus further includes an update module configured to update the service address list after the second control module controls the first server to stop working when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of at least one first backup server, thereby obtaining an updated service address list. The updated service address list includes the address of the at least one first backup server.

[0110] In one embodiment, the second startup module is further used to start at least one second backup server after the second control module controls the first server to stop working, and write logs to the second local disk through the second backup server, wherein the second local disk is the local disk of the second backup server.

[0111] In one embodiment, the first startup module is configured to start the first server when the original primary server corresponding to the distributed file system is in working state and the original backup server corresponding to the distributed file system stops working.

[0112] In one embodiment, the second startup module is used to start the original backup server after the first control module controls the original main server to stop working and before the second startup module starts at least one first backup server, and read the log of the distributed file system through the original backup server.

[0113] In one embodiment, the first control module is configured to control the original standby server to stop working before controlling the first server to stop working.

[0114] In one embodiment, the above apparatus further includes:

[0115] The third startup module is used to start the second server after the first control module controls the original main server to stop working and before the second startup module starts at least one first backup server, to snapshot the log in the distributed file system through the second server to obtain log snapshot information, and to transmit the log snapshot information to the first server, and to write the log snapshot information to the local disk of the first server through the first server.

[0116] In one embodiment, after the second startup module starts the at least one first standby server, the second startup module writes the log snapshot information into the local disk of the at least one first standby server through the first server.

[0117] The technical features of the electronic device provided in the embodiment of the present invention correspond to the technical features of the above-mentioned service switching method. The various processes of the above-mentioned service switching method are implemented through the electronic device and the same effect can be obtained. To avoid repetition, they will not be described here.

[0118] like Figure 14 As shown, an embodiment of the present invention further provides an electronic device 1400, including a processor 1401 and a memory 1402, wherein the memory 1402 stores a computer program that can be run on the processor 1401. When the computer program is executed by the processor 1401, the various processes in the above-mentioned service switching method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0119] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned service switching method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0120] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or electronic device that includes a series of elements includes not only those elements but also other elements not explicitly listed, or also includes elements inherent to such process, method, article, or electronic device. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, article, or electronic device that includes the element.

[0121] In the embodiments of the present invention, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present invention should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0122] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling an electronic device (which can be a mobile phone, computer, electronic device, air conditioner, or network device, etc.) to execute the methods of various embodiments of the present invention.

[0123] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0124] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are protected by the present invention.

Claims

1. A service switching method, characterized in that: The method comprises: When the original primary server corresponding to the distributed file system is in working state, starting a first server, where the first server is a dual-write version server and can write logs to the distributed file system and the local disk of the first server at the same time; Controlling the original master server to stop working, and writing logs to the distributed file system and the local disk of the first server through the first server; Starting at least one first standby server, and writing a log to a first local disk through the first server, where the first local disk is a local disk of the at least one first standby server; When the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of the at least one first standby server, the first server is controlled to stop working, and the log is written to the local disk of the at least one first standby server through one of the at least one first standby servers.

2. The method according to claim 1, characterized in that After controlling the first server to stop working, the method further includes: At least one second standby server is started, and a log is written to a second local disk through the second standby server, wherein the second local disk is a local disk of the second standby server.

3. The method according to claim 1, characterized in that The step of starting the first server when the original primary server corresponding to the distributed file system is in a working state includes: When the original primary server corresponding to the distributed file system is in a working state and the original backup server corresponding to the distributed file system stops working, the first server is started.

4. The method according to claim 3, characterized in that After controlling the original main server to stop working and before starting at least one first backup server, the method further includes: The original standby server is started, and logs of the distributed file system are read through the original standby server.

5. The method according to claim 4, characterized in that Before controlling the first server to stop working, the method further includes: Control the original standby server to stop working.

6. The method according to claim 1, characterized in that After controlling the original main server to stop working and before starting at least one first backup server, the method further includes: The second server is started, and a snapshot of the log in the distributed file system is obtained through the second server to obtain log snapshot information, and the log snapshot information is transmitted to the first server, and the log snapshot information is written to the local disk of the first server through the first server.

7. The method according to claim 6, characterized in that After starting at least one first standby server, the method further includes: The log snapshot information is written into the local disk of the at least one first standby server through the first server.

8. A service switching device, characterized in that: The device comprises: A first startup module is configured to start a first server when the original primary server corresponding to the distributed file system is in a working state, wherein the first server is a dual-write version server capable of writing logs to the distributed file system and to a local disk of the first server at the same time; A first control module is configured to control the original master server to stop working, and to write logs to the distributed file system and a local disk of the first server through the first server; A second startup module is configured to start at least one first standby server and write a log to a first local disk through the first server, where the first local disk is a local disk of the at least one first standby server; The second control module is used to control the first server to stop working and write the log to the local disk of the at least one first standby server through one of the at least one first standby servers when the log of the distributed file system is synchronized with the log of the local disk of the first server and the log of the local disk of the at least one first standby server.

9. The device according to claim 8, characterized in that The second startup module is also used to start at least one second backup server after the second control module controls the first server to stop working, and write logs to the second local disk through the second backup server, wherein the second local disk is the local disk of the second backup server.

10. The device according to claim 8, characterized in that The first starting module is configured to start the first server when the original primary server corresponding to the distributed file system is in working state and the original backup server corresponding to the distributed file system stops working.

11. The device according to claim 10, characterized in that The second startup module is used to start the original backup server after the first control module controls the original main server to stop working and before the second startup module starts the at least one first backup server, and read the log of the distributed file system through the original backup server.

12. The device according to claim 11, characterized in that The first control module is configured to control the original standby server to stop working before controlling the first server to stop working.

13. The device according to claim 8, characterized in that Also includes: The third startup module is used to start the second server after the first control module controls the original main server to stop working and before the second startup module starts at least one first backup server, to snapshot the log in the distributed file system through the second server to obtain log snapshot information, and to transmit the log snapshot information to the first server, and to write the log snapshot information to the local disk of the first server through the first server.

14. The device according to claim 13, characterized in that After the second startup module starts at least one first standby server, the second startup module writes the log snapshot information into the local disk of the at least one first standby server through the first server.

15. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps in the service switching method according to any one of claims 1 to 7 are implemented.

16. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the service switching method according to any one of claims 1 to 7 are implemented.

17. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the service switching method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data processing method and device

    CN106899648A