CN111565228A - Data source switching method, device, equipment and medium - Google Patents

Data source switching method, device, equipment and medium Download PDF

Info

Publication number
CN111565228A
CN111565228A CN202010354965.6A CN202010354965A CN111565228A CN 111565228 A CN111565228 A CN 111565228A CN 202010354965 A CN202010354965 A CN 202010354965A CN 111565228 A CN111565228 A CN 111565228A
Authority
CN
China
Prior art keywords
data source
client
connection
instruction
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010354965.6A
Other languages
Chinese (zh)
Other versions
CN111565228B (en
Inventor
刘君楼
赵三妨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Tuya Information Technology Co Ltd
Original Assignee
Hangzhou Tuya Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Tuya Information Technology Co Ltd filed Critical Hangzhou Tuya Information Technology Co Ltd
Priority to CN202010354965.6A priority Critical patent/CN111565228B/en
Publication of CN111565228A publication Critical patent/CN111565228A/en
Application granted granted Critical
Publication of CN111565228B publication Critical patent/CN111565228B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/148Migration or transfer of sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions

Abstract

The application discloses a data source switching method, a device, equipment and a medium, wherein the method comprises the following steps: detecting a data source switching instruction sent by a background so as to switch a data source of a local first client according to the data source switching instruction, wherein the first client is used for providing a target service; establishing a second client locally according to the data source switching instruction; detecting a connection establishment instruction sent by the background; establishing connection between the second client and a target data source corresponding to a to-be-connected data source label in the data source switching instruction according to the connection establishing instruction so that the second client can access the target data source to provide the target service; and closing the connection between the first client and the original data source. Thus, the data source can be switched without stopping the service, and the application of the service is not influenced.

Description

Data source switching method, device, equipment and medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for switching data sources.
Background
In the development process of the application service, the data source of the service is required to be switched due to the configuration of a plurality of data source information and the change of the data source information in the operation process of the service, and the existing data source switching method mainly comprises the steps of stopping the service, then changing the configuration in the service, and restarting the service after the configuration change is completed so as to complete the switching of the data source. Therefore, when the data source is switched, the service needs to be stopped first, and the data source is restarted after the switching is completed, so that the application of the service is influenced, and the loss caused by the service stopping is caused.
Disclosure of Invention
In view of the above, an object of the present application is to provide a data source switching method, apparatus, device, and medium, which can switch data sources without stopping services and without affecting applications of the services.
The specific scheme is as follows:
in a first aspect, the present application discloses a data source switching method, which is applied to a computer providing a target service, and includes:
detecting a data source switching instruction sent by a background so as to switch a data source of a local first client according to the data source switching instruction, wherein the first client is used for providing the target service;
establishing a second client locally according to the data source switching instruction;
detecting a connection establishment instruction sent by the background;
establishing connection between the second client and a target data source corresponding to a to-be-connected data source label in the data source switching instruction according to the connection establishing instruction so that the second client can access the target data source to provide the target service;
and closing the connection between the first client and the original data source.
Optionally, after the connection between the second client and the target data source corresponding to the to-be-connected data source tag in the data source switching instruction is established according to the connection establishment instruction, the method further includes:
feeding back connection completion information to the background;
detecting a connection closing instruction sent by the background according to the connection completion information;
correspondingly, the closing the connection between the first client and the original data source includes:
and closing the connection between the first client and the original data source according to the connection closing instruction.
Optionally, the detecting a data source switching instruction sent by the background includes:
and detecting a data source switching instruction sent by a background through a preset third-party plug-in the first client.
Optionally, the detecting the connection establishment instruction sent by the background includes:
and detecting a connection establishment instruction sent by the background through a preset third-party plug-in the second client.
Optionally, in the process of establishing, according to the connection establishment instruction, a connection between the second client and a target data source corresponding to the to-be-connected data source tag in the data source switching instruction, the method further includes:
creating a target route from the second client to the target data source if the target route does not exist in the second client;
and establishing connection between the second client and the target data source according to the target route.
Optionally, after the connection between the second client and the target data source corresponding to the to-be-connected data source tag in the data source switching instruction is established according to the connection establishment instruction, the method further includes:
if the target data source is redis, storing a preset key rule to the target data source;
and if the target data source is mysql and incomplete data operation exists between the first client and the corresponding original data source, allowing the first client to perform corresponding access operation on the original data source so as to complete the data operation.
Optionally, the establishing, according to the connection establishment instruction, a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction includes:
comparing the data source label to be connected in the connection establishing instruction with the data source label stored in the second client;
and if the data source label to be connected in the connection establishing instruction is consistent with the data source label stored in the second client, establishing the connection between the second client and the target data source.
In a second aspect, the present application discloses a data source switching apparatus applied to a computer providing a target service, including:
the first instruction acquisition module is used for detecting a data source switching instruction sent by a background so as to switch the data source of a local first client according to the data source switching instruction, wherein the first client is used for providing the target service;
the client establishing module is used for locally establishing a second client according to the data source switching instruction;
the second instruction acquisition module is used for detecting a connection establishment instruction sent by the background;
a connection establishing module, configured to establish, according to the connection establishing instruction, a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction, so that the second client performs an access operation on the target data source to provide the target service;
and the connection closing module is used for closing the connection between the first client and the original data source.
In a third aspect, the present application discloses a data source switching device, including:
a memory and a processor;
wherein the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the data source switching method disclosed above.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the data source switching method disclosed in the foregoing.
It can be seen that, in the present application, a data source switching instruction sent by a background is detected first, so as to perform data source switching of a local first client according to the data source switching instruction, where the first client is configured to provide the target service, a second client is locally established according to the data source switching instruction, a connection establishment instruction sent by the background is detected, then a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction is established according to the connection establishment instruction, so that the second client performs an access operation on the target data source to provide the target service, and then the connection between the first client and an original data source is closed. Therefore, a second client replacing the first client can be established, the second client replaces the first client to provide services after the second client establishes connection with the switched data source, and the data source can be switched without stopping the services without influencing the application of the services.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flow chart of a data source switching method disclosed in the present application;
FIG. 2 is a flow chart of a specific data source switching method disclosed in the present application;
fig. 3 is a schematic structural diagram of a data source switching apparatus disclosed in the present application;
FIG. 4 is a block diagram of a data source switching device disclosed herein;
fig. 5 is a block diagram of an electronic device disclosed in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
At present, a data source switching method mainly stops a service, then changes a configuration in the service, and restarts the service after the configuration change is completed, so as to complete switching of a data source. Therefore, when the data source is switched, the service needs to be stopped first, and the data source is restarted after the switching is completed, so that the application of the service is influenced, and the loss caused by the service stopping is caused. In view of this, the present application provides a data source switching method, which can perform data source switching without stopping service, and does not affect application of the service.
Referring to fig. 1, an embodiment of the present application discloses a data source switching method, which is applied to a computer providing a target service, and the method includes:
step S11: and detecting a data source switching instruction sent by a background so as to switch the data source of a local first client according to the data source switching instruction, wherein the first client is used for providing the target service.
In a specific implementation process, a data source switching instruction of a background corresponding to a local client needs to be detected first, so that after the data source switching instruction is detected, data source switching of a local first client is performed according to the data source switching instruction, wherein the first client is used for improving the target service.
Step S12: and establishing a second client locally according to the data source switching instruction.
It is understood that after detecting the data source switching instruction, a second client needs to be established locally according to the data source switching instruction, wherein the second client can provide the target service instead of the first client.
Step S13: and detecting a connection establishment instruction sent by the background.
After the second client is locally established, the method further comprises detecting a connection instruction sent by the background so as to establish a connection between the second client and a corresponding data source. After the second client is established, the background needs to perform corresponding preparation work, for example, data is migrated to a data source to be connected to the second client. And after the background finishes the related preparation work, sending out a connection establishment instruction so as to establish the related connection after locally detecting the connection establishment instruction.
Step S14: and establishing connection between the second client and a target data source corresponding to the to-be-connected data source label in the data source switching instruction according to the connection establishing instruction so that the second client performs access operation on the target data source to provide the target service.
After the connection establishing instruction is detected, establishing connection between the second client and a target data source corresponding to a to-be-connected data source label in the data source switching instruction according to the connection establishing instruction, so that the second client performs access operation on the target data source to provide the target service. Specifically, the data source switching instruction includes a to-be-connected data source tag, and the to-be-connected data source corresponds to a unique to-be-connected data source. Therefore, after the connection establishment instruction is detected, the connection between the second client and the target data source is established according to the connection establishment instruction, wherein the target data source is a data source corresponding to the to-be-connected data source tag in the data source switching instruction.
Step S15: and closing the connection between the first client and the original data source.
After the connection between the second client and the target data source is established, the connection between the first client and the original data source needs to be closed, and the second client provides the target service. Specifically, after receiving the corresponding information or instruction sent by the background, the connection between the first client and the original data source may be closed according to the information or instruction.
It can be seen that, in the present application, a data source switching instruction sent by a background is detected first, so as to perform data source switching of a local first client according to the data source switching instruction, where the first client is configured to provide the target service, a second client is locally established according to the data source switching instruction, a connection establishment instruction sent by the background is detected, then a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction is established according to the connection establishment instruction, so that the second client performs an access operation on the target data source to provide the target service, and then the connection between the first client and an original data source is closed. Therefore, a second client replacing the first client can be established, the second client replaces the first client to provide services after the second client establishes connection with the switched data source, and the data source can be switched without stopping the services without influencing the application of the services.
Referring to fig. 2, an embodiment of the present application discloses a specific data source switching method, which is applied to a computer providing a target service, and the method includes:
step S21: and detecting a data source switching instruction sent by a background so as to switch the data source of a local first client according to the data source switching instruction, wherein the first client is used for providing the target service.
In a specific implementation process, a data source switching instruction sent by a background needs to be detected first, so as to perform data source switching of a local first client according to the data source switching, where the first client is used to provide the target service. Specifically, the detecting the data source switching instruction sent by the background includes: and detecting a data source switching instruction sent by a background through a preset third-party plug-in the first client. The method includes the steps that corresponding third-party plug-ins are preset in a client side providing services, addresses, account numbers and passwords, data source types, data source deployment modes, connection pool configuration conditions and the like of data source information are packaged and provided for the client side in a third-party plug-in mode, and the client side authenticates the data source information of a designated label through the third-party plug-ins and performs corresponding initialization work. The data source switching instruction comprises a data source label to be connected, and the label is used for marking a unique corresponding data source.
In a specific implementation process, when the target service is deployed at the beginning, the service can obtain specific data source information in the operation process through a data source label granted by operation and maintenance personnel, and the operation and maintenance personnel must perform security authentication in the operation process, so that the service is ensured to be authorized to obtain the data source information, and only the resource information granted by the operation and maintenance personnel can be obtained. Of course, operation and maintenance personnel can reasonably prepare and allocate resources for the service according to the requirement condition of the service on the data source scale, including the deployment mode, connection configuration and operation permission of the data source, wherein the deployment mode of the data source includes the conditions of single point, master-slave, cluster or library division and table division, the connection configuration includes the connection size, the keep-alive time frequency, the connection recovery condition and the like, and the operation permission includes the permission to allocate the operation data source according to the service requirement, namely reading, writing and deleting. Therefore, the data source is labeled, and the use safety of the data source can be ensured.
Step S22: and establishing a second client locally according to the data source switching instruction.
After the data source switching instruction is detected, a second client needs to be established locally according to the data source switching instruction, specifically, new data source information under a to-be-connected data source label in the data source switching instruction is initialized to obtain the second client to replace an original first client.
Step S23: and detecting a connection establishment instruction sent by the background.
And after the second client is established, detecting a connection instruction sent by the background. The detecting the connection establishment instruction sent by the background comprises: and detecting a connection establishment instruction sent by the background through a preset third-party plug-in the second client. That is, the connection establishment instruction sent by the background may be detected by a preset third-party plug-in the second client.
Step S24: and establishing connection between the second client and a target data source corresponding to the to-be-connected data source label in the data source switching instruction according to the connection establishing instruction so that the second client performs access operation on the target data source to provide the target service.
After the connection establishment instruction is detected, the connection between the second client and the target data source corresponding to the to-be-connected data source tag in the data source switching instruction needs to be established according to the connection establishment instruction, so that the second client performs access operation on the target data source to provide the target service. Establishing the connection between the second client and the target data source corresponding to the to-be-connected data source label in the data source switching instruction according to the connection establishing instruction, wherein the connection establishing instruction comprises the following steps: comparing the data source label to be connected in the connection establishing instruction with the data source label stored in the second client; and if the data source label to be connected in the connection establishing instruction is consistent with the data source label stored in the second client, establishing the connection between the second client and the target data source. Specifically, since the third-party plug-ins in all the clients corresponding to the background detect the connection establishment instruction sent by the background, after the connection establishment instruction is detected, the data source tag to be connected in the connection establishment instruction needs to be compared with the data source tag stored in the second client, and the connection between the second client and the target data source needs to be established again under the condition that the comparison result is consistent.
In a specific implementation process, in the process of establishing a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction according to the connection establishment instruction, the method further includes: creating a target route from the second client to the target data source if the target route does not exist in the second client; and establishing connection between the second client and the target data source according to the target route. Specifically, if there is no target route from the second client to the target data source in the second client, the target route is created first, and then the connection between the second client and the target data source is established according to the target route.
After the connection between the second client and the target data source corresponding to the data source label to be connected in the data source switching instruction is established according to the connection establishment instruction, the method further includes: if the target data source is redis, storing a preset key rule to the target data source; and if the target data source is mysql and incomplete data operation exists between the first client and the corresponding original data source, allowing the first client to perform corresponding access operation on the original data source so as to complete the data operation. Specifically, after the connection between the second client and the target data source is completed, different processing is performed for different data source types, wherein, the data source types include but are not limited to mysql, redis and the like, the mysql data source creates new connection and closes connection with service operation such as transaction and the like, for redis, the data source can be distributed according to the operation key rule, the data under the key rule can be subjected to specified routing and data migration, routing change and routing dynamic creation according to the key rule, when the data source reaches the bottleneck of the physical resource, the data of the specified key rule is migrated to the data source distributed by another operation and maintenance personnel, and the service is informed to change the route, the data is operated in the appointed data source, and the original client pointing to the master-slave mode can be switched to the cluster mode to carry out the data operation. The data migration comprises the steps of maintaining full-volume data migration and incremental partial data synchronization during data migration.
Step S25: and feeding back connection completion information to the background.
After the connection between the second client and the background is established, connection completion information needs to be fed back to the background, so that the background can determine that the connection is completed and determine whether the connection between the first client and the original data source needs to be disconnected in time.
Step S26: and detecting a connection closing instruction sent by the background according to the connection completion information.
After feeding back the connection completion information to the background, a connection closing instruction sent by the background according to the connection completion information needs to be detected, so as to determine whether the connection between the first client and the original data source needs to be closed according to the connection closing instruction. And after the data access operation between the first client and the original data source is completed, the background sends a connection close message so as to locally disconnect the connection between the first client and the original data source.
Step S27: and closing the connection between the first client and the original data source according to the connection closing instruction.
After the connection closing instruction is detected, the connection between the first client and the original data source can be closed according to the connection closing instruction.
By the data source switching method, the capacity expansion, the migration, the change of the deployment mode and the upgrade of the data storage mode can be carried out on the data source under the condition that a user does not perceive the data source. Based on the management of the data information, the data source can be upgraded under the existing label of the service, the client is only required to be informed of the change of the data source information after the upgrade is completed, and after the running service receives the instruction, the data source can be switched according to the received instruction.
Referring to fig. 3, an embodiment of the present application discloses a data source switching device, which is applied to a computer providing a target service, and includes:
a first instruction obtaining module 11, configured to detect a data source switching instruction sent by a background, so as to perform data source switching of a local first client according to the data source switching instruction, where the first client is used to provide the target service;
the client establishing module 12 is configured to locally establish a second client according to the data source switching instruction;
a second instruction obtaining module 13, configured to detect a connection establishment instruction sent by the background;
a connection establishing module 14, configured to establish, according to the connection establishing instruction, a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction, so that the second client performs an access operation on the target data source to provide the target service;
and the connection closing module 15 is configured to close the connection between the first client and the original data source.
It can be seen that, in the present application, a data source switching instruction sent by a background is detected first, so as to perform data source switching of a local first client according to the data source switching instruction, where the first client is configured to provide the target service, a second client is locally established according to the data source switching instruction, a connection establishment instruction sent by the background is detected, then a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction is established according to the connection establishment instruction, so that the second client performs an access operation on the target data source to provide the target service, and then the connection between the first client and an original data source is closed. Therefore, a second client replacing the first client can be established, the second client replaces the first client to provide services after the second client establishes connection with the switched data source, and the data source can be switched without stopping the services without influencing the application of the services.
Further, referring to fig. 4, an embodiment of the present application further discloses a data source switching device, including: a processor 21 and a memory 22.
Wherein the memory 22 is used for storing a computer program; the processor 21 is configured to execute the computer program to implement the data source switching method disclosed in the foregoing embodiment.
For the specific process of the data source switching method, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
Further, referring to fig. 5, a schematic structural diagram of an electronic device 20 provided in the embodiment of the present application is shown, where the electronic device 20 may specifically implement the data source switching method disclosed in the foregoing embodiment.
In general, the electronic device 20 in the present embodiment includes: a processor 21 and a memory 22.
The processor 21 may include one or more processing cores, such as a four-core processor, an eight-core processor, and so on. The processor 21 may be implemented by at least one hardware of a DSP (digital signal processing), an FPGA (field-programmable gate array), and a PLA (programmable logic array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (graphics processing unit) which is responsible for rendering and drawing images to be displayed on the display screen. In some embodiments, the processor 21 may include an AI (artificial intelligence) processor for processing a calculation operation related to machine learning.
Memory 22 may include one or more computer-readable storage media, which may be non-transitory. Memory 22 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the memory 22 is at least used for storing the following computer program 221, wherein after being loaded and executed by the processor 21, the steps of the data source switching method disclosed in any one of the foregoing embodiments can be implemented. In addition, the resources stored in the memory 22 may also include an operating system 222, data 223, and the like, and the storage manner may be a transient storage or a permanent storage. The operating system 222 may be Windows, Unix, Linux, or the like. Data 223 may include a wide variety of data.
In some embodiments, the electronic device 20 may further include a display 23, an input/output interface 24, a communication interface 25, a sensor 26, a power supply 27, and a communication bus 28.
Those skilled in the art will appreciate that the configuration shown in FIG. 5 is not limiting of electronic device 20 and may include more or fewer components than those shown.
Further, an embodiment of the present application also discloses a computer readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the following steps:
detecting a data source switching instruction sent by a background so as to switch a data source of a local first client according to the data source switching instruction, wherein the first client is used for providing the target service; establishing a second client locally according to the data source switching instruction; detecting a connection establishment instruction sent by the background; establishing connection between the second client and a target data source corresponding to a to-be-connected data source label in the data source switching instruction according to the connection establishing instruction so that the second client can access the target data source to provide the target service; and closing the connection between the first client and the original data source.
It can be seen that, in the present application, a data source switching instruction sent by a background is detected first, so as to perform data source switching of a local first client according to the data source switching instruction, where the first client is configured to provide the target service, a second client is locally established according to the data source switching instruction, a connection establishment instruction sent by the background is detected, then a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction is established according to the connection establishment instruction, so that the second client performs an access operation on the target data source to provide the target service, and then the connection between the first client and an original data source is closed. Therefore, a second client replacing the first client can be established, the second client replaces the first client to provide services after the second client establishes connection with the switched data source, and the data source can be switched without stopping the services without influencing the application of the services.
In this embodiment, when the computer subprogram stored in the computer-readable storage medium is executed by the processor, the following steps may be specifically implemented: feeding back connection completion information to the background; detecting a connection closing instruction sent by the background according to the connection completion information; correspondingly, the closing the connection between the first client and the original data source includes: and closing the connection between the first client and the original data source according to the connection closing instruction.
In this embodiment, when the computer subprogram stored in the computer-readable storage medium is executed by the processor, the following steps may be specifically implemented: and detecting a data source switching instruction sent by a background through a preset third-party plug-in the first client.
In this embodiment, when the computer subprogram stored in the computer-readable storage medium is executed by the processor, the following steps may be specifically implemented: and detecting a connection establishment instruction sent by the background through a preset third-party plug-in the second client.
In this embodiment, when the computer subprogram stored in the computer-readable storage medium is executed by the processor, the following steps may be specifically implemented: creating a target route from the second client to the target data source if the target route does not exist in the second client; and establishing connection between the second client and the target data source according to the target route.
In this embodiment, when the computer subprogram stored in the computer-readable storage medium is executed by the processor, the following steps may be specifically implemented: if the target data source is redis, storing a preset key rule to the target data source; and if the target data source is mysql and incomplete data operation exists between the first client and the corresponding original data source, allowing the first client to perform corresponding access operation on the original data source so as to complete the data operation.
In this embodiment, when the computer subprogram stored in the computer-readable storage medium is executed by the processor, the following steps may be specifically implemented: comparing the data source label to be connected in the connection establishing instruction with the data source label stored in the second client; and if the data source label to be connected in the connection establishing instruction is consistent with the data source label stored in the second client, establishing the connection between the second client and the target data source.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of other elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The data source switching method, apparatus, device, and medium provided by the present application are introduced in detail above, and a specific example is applied in the present application to explain the principle and the implementation of the present application, and the description of the above embodiment is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A data source switching method is applied to a computer for providing target services, and comprises the following steps:
detecting a data source switching instruction sent by a background so as to switch a data source of a local first client according to the data source switching instruction, wherein the first client is used for providing the target service;
establishing a second client locally according to the data source switching instruction;
detecting a connection establishment instruction sent by the background;
establishing connection between the second client and a target data source corresponding to a to-be-connected data source label in the data source switching instruction according to the connection establishing instruction so that the second client can access the target data source to provide the target service;
and closing the connection between the first client and the original data source.
2. The data source switching method according to claim 1, wherein after the establishing of the connection between the second client and the target data source corresponding to the to-be-connected data source tag in the data source switching instruction according to the connection establishment instruction, the method further comprises:
feeding back connection completion information to the background;
detecting a connection closing instruction sent by the background according to the connection completion information;
correspondingly, the closing the connection between the first client and the original data source includes:
and closing the connection between the first client and the original data source according to the connection closing instruction.
3. The data source switching method according to claim 1, wherein the detecting the data source switching instruction sent by the background comprises:
and detecting a data source switching instruction sent by a background through a preset third-party plug-in the first client.
4. The data source switching method according to claim 1, wherein the detecting the connection establishment instruction sent by the background comprises:
and detecting a connection establishment instruction sent by the background through a preset third-party plug-in the second client.
5. The data source switching method according to claim 1, wherein in the process of establishing the connection between the second client and the target data source corresponding to the to-be-connected data source tag in the data source switching instruction according to the connection establishment instruction, the method further includes:
creating a target route from the second client to the target data source if the target route does not exist in the second client;
and establishing connection between the second client and the target data source according to the target route.
6. The data source switching method according to claim 1, wherein after the establishing of the connection between the second client and the target data source corresponding to the to-be-connected data source tag in the data source switching instruction according to the connection establishment instruction, the method further comprises:
if the target data source is redis, storing a preset key rule to the target data source;
and if the target data source is mysql and incomplete data operation exists between the first client and the corresponding original data source, allowing the first client to perform corresponding access operation on the original data source so as to complete the data operation.
7. The data source switching method according to any one of claims 1 to 6, wherein the establishing, according to the connection establishment instruction, a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction includes:
comparing the data source label to be connected in the connection establishing instruction with the data source label stored in the second client;
and if the data source label to be connected in the connection establishing instruction is consistent with the data source label stored in the second client, establishing the connection between the second client and the target data source.
8. A data source switching device applied to a computer for providing a target service comprises:
the first instruction acquisition module is used for detecting a data source switching instruction sent by a background so as to switch the data source of a local first client according to the data source switching instruction, wherein the first client is used for providing the target service;
the client establishing module is used for locally establishing a second client according to the data source switching instruction;
the second instruction acquisition module is used for detecting a connection establishment instruction sent by the background;
a connection establishing module, configured to establish, according to the connection establishing instruction, a connection between the second client and a target data source corresponding to a to-be-connected data source tag in the data source switching instruction, so that the second client performs an access operation on the target data source to provide the target service;
and the connection closing module is used for closing the connection between the first client and the original data source.
9. A data source switching apparatus, comprising:
a memory and a processor;
wherein the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the data source switching method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program, wherein the computer program when executed by a processor implements the data source switching method of any one of claims 1 to 7.
CN202010354965.6A 2020-04-29 2020-04-29 Data source switching method, device, equipment and medium Active CN111565228B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010354965.6A CN111565228B (en) 2020-04-29 2020-04-29 Data source switching method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010354965.6A CN111565228B (en) 2020-04-29 2020-04-29 Data source switching method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN111565228A true CN111565228A (en) 2020-08-21
CN111565228B CN111565228B (en) 2023-05-23

Family

ID=72074472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010354965.6A Active CN111565228B (en) 2020-04-29 2020-04-29 Data source switching method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN111565228B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103023921A (en) * 2012-12-27 2013-04-03 中国建设银行股份有限公司 Authentication and access method and authentication system
CN104991824A (en) * 2015-08-03 2015-10-21 上海斐讯数据通信技术有限公司 Method and system for dynamically switching application program data sources
US20160162825A1 (en) * 2014-12-05 2016-06-09 International Business Machines Corporation Monitoring the impact of information quality on business application components through an impact map to data sources
CN107045509A (en) * 2016-02-05 2017-08-15 北京京东尚科信息技术有限公司 A kind of system, apparatus and method connected for switch data storehouse

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103023921A (en) * 2012-12-27 2013-04-03 中国建设银行股份有限公司 Authentication and access method and authentication system
US20160162825A1 (en) * 2014-12-05 2016-06-09 International Business Machines Corporation Monitoring the impact of information quality on business application components through an impact map to data sources
CN104991824A (en) * 2015-08-03 2015-10-21 上海斐讯数据通信技术有限公司 Method and system for dynamically switching application program data sources
CN107045509A (en) * 2016-02-05 2017-08-15 北京京东尚科信息技术有限公司 A kind of system, apparatus and method connected for switch data storehouse

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
百度经验: "微信如何进入淘宝连接", 《HTTPS://JINGYAN.BAIDU.COM/ARTICLE/3C48DD34C691CAE10BE3583C.HTML》 *

Also Published As

Publication number Publication date
CN111565228B (en) 2023-05-23

Similar Documents

Publication Publication Date Title
CN111506386A (en) Virtual machine online migration method, device, equipment and computer readable storage medium
CN102591716B (en) Data items manager
US9275238B2 (en) Method and apparatus for data security reading
CN104268229A (en) Resource obtaining method and device based on multi-process browser
US10855776B2 (en) Method and device for managing sessions
US10169027B2 (en) Upgrade of an operating system of a virtual machine
CN103164659A (en) Method for realizing data storage safety and electronic device
US9330266B2 (en) Safe data storage method and device
US20180203726A1 (en) Virtual machine migration method and apparatus
CN110086607B (en) Method and device for rapidly switching deployment key, computer equipment and storage medium
CN104517067A (en) Method, device and system for data access
CN109088914B (en) Block generation method, block chain ecosystem and computer readable storage medium
US9535713B2 (en) Manipulating rules for adding new devices
CN111381850B (en) BIOS firmware upgrading method, device, equipment and medium
WO2023147744A1 (en) Key state inspection method and apparatus, and device and medium
US9886298B2 (en) Detecting an interrupted operation associated with a virtual machine
CN111565228A (en) Data source switching method, device, equipment and medium
CN115174596A (en) Equipment remote copying method, device and medium
CN115543393A (en) Upgrading method, electronic device and storage medium
WO2021233351A1 (en) Data transfer method and device, and terminal and computer-readable storage medium
CN114995958A (en) Virtualization platform information consistency control method, device and medium
WO2021077862A1 (en) File synchronization method and device
CN114884836A (en) High-availability method, device and medium for virtual machine
CN113741949A (en) Method, device and equipment for generating application program installation package and storage medium
CN111104363A (en) FPGA cloud platform using method, device, equipment and medium

Legal Events

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