WO2023246168A1 - 一种微服务迁移方法、装置及计算设备 - Google Patents

一种微服务迁移方法、装置及计算设备 Download PDF

Info

Publication number
WO2023246168A1
WO2023246168A1 PCT/CN2023/079205 CN2023079205W WO2023246168A1 WO 2023246168 A1 WO2023246168 A1 WO 2023246168A1 CN 2023079205 W CN2023079205 W CN 2023079205W WO 2023246168 A1 WO2023246168 A1 WO 2023246168A1
Authority
WO
WIPO (PCT)
Prior art keywords
microservice
configuration
center
configuration information
registration
Prior art date
Application number
PCT/CN2023/079205
Other languages
English (en)
French (fr)
Inventor
杨奕
周升升
罗健文
Original Assignee
华为云计算技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2023246168A1 publication Critical patent/WO2023246168A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • G06F9/4856Task life-cycle, e.g. stopping, restarting, resuming execution resumption being on a different machine, e.g. task migration, virtual machine migration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt

Definitions

  • This application relates to the technical field of information technology (IT), and in particular to a microservice migration method, device and computing equipment.
  • IT information technology
  • the service architecture has gradually evolved from the original monolithic architecture to the microservice architecture, and the microservice architecture is inseparable from the registration center and configuration center.
  • you can switch between different registration centers and you can also switch between different configuration centers.
  • the registration center and configuration center will be migrated at the same time.
  • the current migration process of the registration center or configuration center is relatively complicated and inconvenient to operate.
  • This application provides a microservice migration method, device, computing device, computing device cluster, computer storage medium and computer product, which can realize automatic migration of the configuration center and improve the efficiency of microservice migration.
  • this application provides a microservice migration method, which can be applied to cloud platforms.
  • the cloud platform can be used to manage instances that provide microservices.
  • the method may include: obtaining the stored first microservice configuration information of the target microservice from a first configuration center running in the first instance; and generating a second microservice configuration of the migrated target microservice based on the first microservice configuration information. Information; sending the second microservice configuration information to the second configuration center running on the second instance, and the second configuration center is used to store the configuration information of the migrated target microservice.
  • generating the second microservice configuration information of the migrated target microservice based on the first microservice configuration information includes: performing format conversion on the first microservice configuration information of the target microservice, and generating Second microservice configuration information corresponding to the microservice type of the second configuration center. From this, the microservice configuration information that adapts to the new configuration center is obtained through format conversion.
  • the method further includes: in response to the first offline instruction, offline the first configuration center.
  • the method before sending the second microservice configuration information to the second configuration center running on the second instance, the method further includes: obtaining the corresponding relationship between the second instance and the first configuration center; Based on the second microservice configuration information and the corresponding relationship, a second instance for running the second configuration center is created.
  • the method before sending the second microservice configuration information to the second configuration center running on the second instance, the method further includes: obtaining the corresponding relationship between the second instance and the first configuration center; Based on the second microservice configuration information and corresponding relationships, create and run the second configuration center on the pre-created second instance.
  • the second configuration center may also be created in advance, and run the second configuration center and the second instance corresponding to the first configuration center according to the corresponding relationship between the second instance and the first configuration center.
  • obtaining the corresponding relationship between the second instance and the first configuration center includes: obtaining the corresponding relationship between the identifier of the second instance and the first configuration center, where the identifier includes the Internet Protocol IP address and/or or instance ID.
  • the method further includes: providing a first configuration interface, the first configuration interface is used to receive a configuration center management policy set by the user, and the configuration center management policy is used to monitor the configuration of the target microservice by the first The configuration center switches to the second configuration center. This allows the cloud platform to obtain the configuration center association policy issued by the user through the new configuration center, so that the configuration monitoring of the target microservice can be adjusted according to the policy.
  • the service type of the first configuration center is different from the service type of the second configuration center.
  • the method before generating the second microservice configuration information of the migrated target microservice according to the first microservice configuration information of the target microservice stored in the first configuration center, the method further includes: providing the second microservice configuration information.
  • Configuration interface the second configuration interface is used to receive the service type of the second configuration center set by the user. This allows the cloud platform to obtain the service type of the second configuration center issued by the user through the new configuration center, so that the subscription mode of the target microservice can be adjusted according to the service type.
  • the method further includes: sending a first microservice registration request to a first registration center, where the first microservice registration request is used to request to register the migrated target microservice in the first registration center. , the target microservice has registered the microservice in the first registration center; sends a second microservice registration request to the second registration center running on the third instance, and the second microservice registration request is used to request the registration center in the second registration center. Register the migrated target microservice.
  • the method further includes: in response to the second offline instruction, offline the first registration center.
  • the first microservice configuration information includes one or more of the following: startup parameters of the target microservice, identification of the target microservice, number of threads related to the target microservice, number of threads related to the target microservice, Cache size, activity data, blacklist, whitelist.
  • this application provides a microservice migration device.
  • the device can be deployed on a cloud platform.
  • the cloud platform can be used to manage instances that provide microservices.
  • the device may include: a communication module and a processing module.
  • the communication module is used to obtain the stored first microservice configuration information of the target microservice from the first configuration center where the first instance runs.
  • the processing module is configured to generate second microservice configuration information of the migrated target microservice based on the first microservice configuration information.
  • the processing module is also used to send the second microservice configuration information to a second configuration center running on the second instance, and the second configuration center is used to store the configuration information of the migrated target microservice.
  • the processing module when the processing module generates the second microservice configuration information of the migrated target microservice based on the first microservice configuration information, it is specifically used to: configure the first microservice of the target microservice.
  • the information is format-converted to generate second microservice configuration information corresponding to the microservice type of the second configuration center.
  • the processing module is also configured to: respond to the first offline instruction, offline the first configuration center.
  • the processing module before sending the second microservice configuration information to the second configuration center running on the second instance, is also configured to: obtain the corresponding relationship between the second instance and the first configuration center. ; Based on the second microservice configuration information and corresponding relationship, create a second instance for running the second configuration center.
  • the processing module before sending the second microservice configuration information to the second configuration center running on the second instance, is also configured to: obtain the corresponding relationship between the second instance and the first configuration center. ;Based on the second microservice configuration Set the configuration information and corresponding relationships, and create and run the second configuration center on the pre-created second instance.
  • the second configuration center may also be created in advance, and run the second configuration center and the second instance corresponding to the first configuration center according to the corresponding relationship between the second instance and the first configuration center.
  • the processing module when obtaining the corresponding relationship between the second instance and the first configuration center, is specifically configured to: obtain the corresponding relationship between the identifier of the second instance and the first configuration center, where the identifier includes the Internet Protocol IP address and/or instance ID.
  • the processing module is also configured to: provide a first configuration interface, the first configuration interface is used to receive the configuration center management policy set by the user, and the configuration center management policy is used to monitor the configuration of the target microservice Switch from the first configuration center to the second configuration center.
  • the service type of the first configuration center is different from the service type of the second configuration center.
  • the processing module before generating the second microservice configuration information of the migrated target microservice based on the first microservice configuration information of the target microservice stored in the first configuration center, the processing module is also used to: A second configuration interface is provided, and the second configuration interface is used to receive the service type of the second configuration center set by the user.
  • the communication module is also used to send a first microservice registration request to the first registration center.
  • the first microservice registration request is used to request that the migrated target microservice be processed in the first registration center.
  • Registration the target microservice is registered in the first registration center;
  • the communication module is also used to send a second microservice registration request to the second registration center running on the third instance, and the second microservice registration request is used to Request to register the migrated target microservice in the second registration center.
  • the processing module is also configured to: respond to the second offline instruction, log out of the first registration center.
  • the first microservice configuration information includes one or more of the following: startup parameters of the target microservice, identification of the target microservice, number of threads related to the target microservice, number of threads related to the target microservice, Cache size, activity data, blacklist, whitelist.
  • the present application provides a computing device, including: at least one memory for storing a program; at least one processor for executing the program stored in the memory; wherein, when the program stored in the memory is executed, the processor is configured to Perform the method described in the first aspect or any possible implementation of the first aspect.
  • the present application provides a computing device cluster, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device,
  • the computing device cluster is configured to perform the method described in the first aspect or any possible implementation of the first aspect.
  • the application provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program When the computer program is run on a processor, it causes the processor to execute the first aspect or any one of the first aspects. Possible implementations of the methods described.
  • the present application provides a computer program product.
  • the computer program product When the computer program product is run on a processor, it causes the processor to execute the method described in the first aspect or any possible implementation of the first aspect.
  • Figure 1 is a schematic diagram of a registration center and configuration center migration process provided by an embodiment of the present application
  • Figure 2 is a schematic diagram of another registration center and configuration center migration process provided by an embodiment of the present application.
  • Figure 3 is a schematic flow chart of a microservice migration method provided by an embodiment of the present application.
  • Figure 4 is a schematic diagram of a scenario before microservice migration provided by the embodiment of this application.
  • Figure 5 is a schematic comparison diagram before and after interception enhancement provided by an embodiment of the present application.
  • Figure 6 is a schematic diagram of a process of migrating consumer services provided by an embodiment of the present application.
  • Figure 7 is a schematic diagram of a process of migrating provider services provided by an embodiment of the present application.
  • Figure 8 is a schematic diagram of a scenario after offline consumer services and provider services provided by the embodiment of this application.
  • Figure 9 is a schematic diagram of a scenario after microservice migration provided by the embodiment of this application.
  • Figure 10 is a schematic structural diagram of a microservice migration device provided by an embodiment of the present application.
  • Figure 11 is a schematic structural diagram of a computing device provided by an embodiment of the present application.
  • Figure 12 is a schematic structural diagram of a computing device cluster provided by an embodiment of the present application.
  • a and/or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. these three situations.
  • the symbol "/" in this article indicates that the associated object is or, for example, A/B means A or B.
  • first, second, etc. in the description and claims herein are used to distinguish different objects, rather than to describe a specific order of objects.
  • first response message and the second response message are used to distinguish different response messages, but are not used to describe a specific sequence of response messages.
  • multiple refers to two or more, for example, multiple processing units refers to two or more processing units, etc.; multiple Component refers to two or more components, etc.
  • Microservices are an architectural and organizational approach to developing software that can consist of small independent services that communicate through a clearly defined application programming interface (API). These services can be run by small independent teams.
  • microservices can be configured on an instance, which can be at least one of a computer, a server, a cloud computing platform (i.e., a "cloud platform”), or a virtual machine, a container, and the like.
  • the registration center is the "address book" in the microservice architecture. It records the mapping relationship between microservices and microservice addresses. It is a separate service in the entire microservice architecture. This service does not need to complete the business functions of the system. Instead, it is used to complete microservice registration and microservice discovery of the entire microservice system, as well as to monitor and manage the health status of microservices. management function.
  • the registration center can be configured on a node, which can be a computer, a server, a cloud computing platform (i.e., a "cloud platform"), or a virtual machine, etc.
  • the registration center can have the following functions: microservice registry, microservice registration and discovery, microservice inspection, etc.
  • the microservice registry is the core of the registration center. It is used to record the information of each microservice, such as the name of the microservice, Internet protocol (IP) address, port, etc.
  • the microservice registry provides query API and management API.
  • the query API is used to query available microservice instances, and the management API is used to register and cancel microservices.
  • Microservice registration refers to the process in which a microservice registers its own information to the registration center when it is started.
  • Microservice discovery refers to the mechanism for querying the list of available microservices and network addresses.
  • Microservice inspection means that the registration center uses a certain mechanism to regularly detect registered microservices. If an instance is found to be inaccessible for a long time, the instance will be removed from the microservice registry.
  • the registration center mainly involves three major roles: microservice provider, microservice consumer and registration center.
  • the relationship between these three roles is as follows:
  • each microservice starts, it registers its own network address and other information to the registration center, and the registration center stores this data.
  • the microservice consumer queries the microservice provider's address from the registration center and calls the microservice provider's interface through the address.
  • Each microservice communicates with the registration center using a certain mechanism (such as heartbeat). If the registration center cannot communicate with a certain microservice for a long time, the instance will be logged out.
  • the microservice network address changes such as instance addition or IP change, etc.
  • it will be re-registered to the registration center. In this way, microservice consumers do not need to manually modify the provider's network address.
  • the configuration center can be used to manage the configuration of microservice applications. Microservices connect to the configuration center and can obtain microservice configuration information and changes from the configuration center.
  • the configuration center is also the core component of other microservice management and control functions. For example, the issuance of microservice governance rules can also be implemented through the configuration center.
  • the configuration center can be configured on a node, which can be a computer, a server, a cloud computing platform (i.e., a "cloud platform"), or a virtual machine, etc.
  • the registration center and the configuration center may be configured on the same node or on different nodes, which is not limited here.
  • the configuration center can be kie or nacos.
  • different configuration centers have different service types. For example, when the configuration center is kie, the service type of the configuration center is kie; when the configuration center is nacos, the service type of the configuration center is nacos.
  • the registry is a mapping relationship table between microservices and their IP addresses.
  • Microservice subscribers can obtain the registry through the subscription registration center to discover downstream microservices. For example, for microservice subscribers and downstream microservices, when microservice A needs to call microservice B, microservice A is the microservice subscriber, and microservice B is the downstream microservice.
  • Dual registration means that a microservice is registered to two registration centers at the same time, so that microservice subscribers in both registration centers can discover and call the microservice.
  • Service subscription refers to a behavior of microservices to the registration center, which subscribes to one or more microservices.
  • the subscribing microservice will sense the instance change.
  • Double subscription means that a microservice subscriber subscribes to two registration centers at the same time.
  • the microservice subscriber can call the microservices registered in the two registration centers at the same time.
  • Configuration monitoring means that microservices sense configuration changes by paying attention to one or more configuration modifications. Microservices can pay attention to The behavior of configuration changes is called configuration listening.
  • Dynamic configuration means that microservices can sense configuration changes in real time (such as configuration changes in the configuration center) and perform relevant behaviors based on configuration changes.
  • Flow cutting refers to flow switching, which usually refers to the switching of flow from one system to another.
  • Rolling restart usually operates across multiple microservice instances, stopping and starting microservice instances in an incremental manner. The purpose is to ensure that the microservice is updated without interrupting the business.
  • Agent technology is a technology in the software field that can dynamically modify the bytecode or library functions of the host application when the host application starts without affecting the normal compilation of the host application.
  • java agent is a type of agent. It is a new feature introduced after JDK1.5. It supports the JVM to read the bytecode file into the memory. Before the JVM uses the corresponding byte stream to generate a Class object in the Java heap, the user can With the ability to modify its bytecode, the JVM uses the modified bytecode to create Class objects, thereby realizing non-code intrusive business logic modification and replacement of Java applications.
  • Figure 1 shows a process of migrating a registration center and a configuration center.
  • the old system includes the old registration center (that is, the old registration center), the old configuration center (that is, the old configuration center), microservice 1 and microservice 2. Both microservice 1 and microservice 2 can be registered to the old registration center, and microservice 1 can call microservice 2.
  • the old configuration center can deliver configurations to microservice 1 and microservice 2.
  • the old registration center and old configuration center need to be migrated, in order to enable microservice 1 and microservice 2 to adapt to the new registration center (i.e., new registration center) and new configuration center (i.e., new configuration center), you can modify the microservices 1 and microservice 2 undergo code transformation to obtain microservice 1' and microservice 2'.
  • both microservice 1' and microservice 2' can be registered in the new registration center, and microservice 1' can call microservice 2'. Then, you can manually export the relevant microservice configuration information of the old configuration center, parse and convert the relevant microservice configuration information to adapt to the new configuration center, and import it into the new configuration center. Afterwards, the new configuration center can issue configurations to microservice 1' and microservice 2'. At this point, the new system is ready for use. Finally, you can implement traffic cutting, gradually introduce all traffic to the new system, and remove the microservices in the old system.
  • the migration method shown in Figure 1 can realize the migration of the registration center and the configuration center, it requires the transformation of the microservice code, which has a greater impact, and the migration of the configuration center needs to be completed manually, which requires a large workload and inefficiency. Low. In addition, if it is necessary to ensure that the business is not interrupted, the old system and the new system need to be run at the same time, resulting in large resource consumption.
  • Figure 2 shows another registration center and configuration center migration process.
  • the old system includes the old registration center (that is, the old registration center), the old configuration center (that is, the old configuration center), microservice 1 and microservice 2. Both microservice 1 and microservice 2 can be registered to the old registration center, and microservice 1 can call microservice 2.
  • the old configuration center can deliver configurations to microservice 1 and microservice 2.
  • microservices also need to be Service 1 and microservice 2 undergo code transformation to obtain microservice 1' and microservice 2'.
  • both microservice 1' and microservice 2' can be registered in the new registration center, and microservice 1' can call microservice 2'. Then, you can pass Synchronize the registration tables in the new registration center and the old registration through the registration synchronizer, so that microservice 1' can discover microservice 2, microservice 1 can discover microservice 2', so that microservice 1' can call microservice 2.
  • Microservice 1 can call microservice 2'. Afterwards, you can manually export the relevant microservice configuration information of the old configuration center, parse and convert the relevant microservice configuration information to adapt to the new configuration center, and import it into the new configuration center. Then, the new configuration center can issue configurations to microservice 1' and microservice 2'. At this point, the new system is ready for use. Finally, after the new system is running stably, the microservices in the old system can be offline.
  • the migration method shown in Figure 2 can realize the migration of the registration center and the configuration center, it also requires the transformation of the microservice code, which has a greater impact, and the migration of the configuration center needs to be completed manually, which requires a large workload. low efficiency.
  • the old system and the new system need to be run at the same time for a period of time, resulting in large resource consumption.
  • it also needs to add the "registry synchronizer" component, which increases the migration cost.
  • embodiments of the present application provide a microservice migration method.
  • This method is mainly based on agent technology to enhance the configuration of microservices, so that when the microservices are migrated, the old configuration center used by the current microservices is used. Intercept and obtain the configuration content in a non-intrusive way, convert the configuration format and push it to the new configuration center, and automatically complete the configuration migration action. In this way, the automatic migration of the configuration center can be completed without modifying the code of the microservice.
  • this method can also enhance the registration of microservices, so that when the microservices are registered to the old registration center, they can be simultaneously registered to the new registration center, thus completing the dual registration of microservices.
  • corresponding policies can be issued through the new configuration center to shield the interaction between the microservices and the old registration center and old configuration center, thereby achieving the goal of taking the old registration center and old configuration center offline.
  • the purpose is to complete the final migration of microservices.
  • Figure 3 shows a microservice migration method. As shown in Figure 3, this microservice migration method can include the following steps:
  • the cloud platform obtains the startup parameters related to the target microservice uploaded by the user, and the configuration instructions issued by the user, where the configuration instructions include the identification of the new registration center and the identification of the new configuration center.
  • the cloud platform can provide a user interface (UI) to the user.
  • the user interface can be provided with an entrance for users to upload files.
  • users can upload startup parameters related to the target microservice through the user interface provided by the cloud platform.
  • the startup parameters may include bytecode enhancement packages and business application packages associated with the target microservice.
  • the bytecode enhancement package can at least be used to add configuration migration function and/or registration migration function to the original code without changing the logic of the original code related to the target microservice in the business application package.
  • This bytecode enhancement package can be implemented based on the aforementioned agent technology.
  • Business application packages are mainly used to configure target microservices in the cloud platform.
  • the cloud platform can be used to manage instances (such as containers, threads, etc.) that provide microservices.
  • the configuration instruction may include the identification of the new registration center and the identification of the new configuration center, so that the new registration center and the new configuration center can be found during the registration and configuration process.
  • the identification of the new registration center may be the Internet protocol (IP) address of the new registration center, the domain name of the new registration center, or the engine name of the new registration center, etc.
  • IP Internet protocol
  • the identifier of the new configuration center can be the IP address of the new configuration center, the domain name of the new configuration center, or the engine name of the new configuration center, etc.
  • the configuration instruction may also include the identification of the old registration center and the identification of the old configuration center. This allows the cloud platform to communicate with the old registration center and the old configuration center.
  • the configuration instruction including the identification of the old configuration center may be called a first instruction, and the configuration instruction including the identification of the old registration center may be called a second instruction.
  • the cloud platform can determine that there is a certain correspondence between the two identifiers.
  • the time for users to upload startup parameters and issue configuration instructions can be selected according to actual conditions, and is not limited here.
  • users can issue configuration instructions immediately after uploading startup parameters, or they can upload startup parameters and issue configuration instructions after a period of time (such as 1 hour, 1 day, 1 month, 1 year, etc.).
  • the user who uploads the startup parameters and the user who issues the configuration instructions can be the same user or different users, and there is no limit here.
  • the old registry can run in one instance.
  • the old registry can run on a physical machine, virtual machine, container, etc.
  • the old configuration center can also be run in a single instance.
  • the old configuration center can run on a physical machine, virtual machine, container, etc.
  • the target microservice has been registered as a microservice in the old registration center.
  • the microservice configuration information required by the target microservice is stored in the old configuration center.
  • the cloud platform starts the target microservice based on the startup parameters.
  • the cloud platform after the cloud platform obtains the startup parameters, it can configure the target microservice in the cloud platform based on the business application package and start the target microservice.
  • the instance corresponding to the target microservice may be, but is not limited to, a thread.
  • the cloud platform registers the target microservice to the old and new registration centers.
  • the cloud platform can send a message containing a microservice registration request to the old registration center to request the registered target microservice after migration in the old registration center.
  • the cloud platform can send a message containing a microservice registration request to the new registration center to request the registration of the migrated target microservice in the new registration center.
  • the old registration center obtains the request sent by the cloud platform, it can register the target microservice into it and return a successful registration message to the cloud platform.
  • the new registration center obtains the request sent by the cloud platform, it can register the target microservice into it and return a successful registration message to the cloud platform. In this way, dual registration of the target microservice is completed to realize the migration of the registration center.
  • the cloud platform may first create a new registration center on a certain instance (such as a virtual machine, container, etc.). For example, the cloud platform can send a request to create a new registration center to a virtual machine to create a new registration center on the virtual machine. Then, send a microservice registration request to the new registration center.
  • the new registration center can also be pre-created on other instances (such as physical machines, virtual machines, containers, etc.), and the details can be determined according to the actual situation.
  • the old registration center may be called the first registration center, and the new registration center may be called the second registration center.
  • the cloud platform sends a first message for querying the first microservice configuration information of the target microservice to the old configuration center.
  • the old configuration center sends the second message containing the first microservice configuration information to the cloud platform.
  • the old configuration center after the old configuration center obtains the first message sent by the cloud platform, it can send the user's relevant configuration of the target microservice to the cloud platform, that is, send the third message containing the first microservice configuration information to the cloud platform.
  • the first microservice configuration information may include one or more of the following: startup parameters of the target microservice, identification of the target microservice, number of threads related to the target microservice, number of threads related to the target microservice, Cache size, active data, blacklist or whitelist, etc.
  • S304 and S305 can be understood as steps in which the cloud platform obtains the microservice configuration information of the target microservice stored in the old configuration center from the old configuration center running in an instance.
  • the old configuration center may be called the first registration center.
  • the cloud platform performs format conversion on the first microservice configuration information to obtain the second microservice configuration information.
  • the formats of the microservice configuration information adapted to the two are also different. Therefore, after the cloud platform obtains the first microservice configuration information Finally, the format of the first microservice configuration information can be converted to obtain the second microservice configuration information adapted to the new configuration center.
  • the format of the first microservice configuration information may include any one of YAML, JSON, TEXT, Properties, INI, and XML.
  • the format of the second microservice configuration information may also include YAML, JSON, TEXT, Properties, Either INI or XML, and the format of the first microservice configuration information is different from the format of the second microservice configuration information.
  • S306 can be understood as a step in which the cloud platform generates the second microservice configuration information of the migrated target microservice based on the first microservice configuration information.
  • S306 is an optional step, that is, when the two configuration centers are of the same type, the format conversion of the first microservice configuration information may not be performed.
  • the cloud platform sends the third message containing the second microservice configuration information to the new configuration center.
  • the cloud platform can send the microservice configuration information to the new configuration center, that is, send the third message containing the second microservice configuration information to the new configuration center. This enables the migration of microservice configuration information in the old configuration center to the new configuration center.
  • the cloud platform may also first create an instance for running the new configuration center, such as one or more instances of virtual machines, containers, etc., so as to create an instance for storage in the instance.
  • a new configuration center for the second microservice configuration information For example, when the user performs the migration operation of the target microservice on the user interface provided by the cloud platform, the user can select the old configuration center and the identification of the instance used to run the new configuration center, such as the IP address and/or instance ID. In this way, the cloud platform can obtain the corresponding relationship between the identifiers of the old configuration center and the instance used to run the new configuration center, that is, the corresponding relationship between the old configuration center and the instance used to run the new configuration center. Then, the cloud platform can create an instance for running the new configuration center based on the corresponding relationship and the second microservice configuration information. When the cloud platform creates an instance for running the new configuration center, the second service configuration information can be configured in the new configuration center in the instance.
  • the new configuration center can also be pre-created on other instances (such as physical machines, virtual machines, containers, etc.), and the details can be determined according to the actual situation.
  • the new configuration center may be called the second registration center.
  • the new configuration center obtains the microservice subscription policy and configuration monitoring policy issued by the user.
  • the microservice subscription strategy is a strategy to switch the microservice subscription mode from dual registration centers to a single registration center. It can switch from subscribing to both the old and new registration centers to only subscribing to the new registration center, thereby shielding the target microservice from the old registration center. center of interaction.
  • the configuration monitoring strategy is to switch the configuration monitoring of the target microservice from the old configuration center to the new configuration center, thereby blocking the interaction between the target microservice and the old configuration center.
  • the new configuration center sends a message containing the microservice subscription policy and configuration monitoring policy to the cloud platform.
  • the new configuration center can send these policies to the cloud platform for execution by the cloud platform.
  • the message containing the microservice subscription strategy sent by the new configuration center can be used to instruct the cloud platform to switch the microservice subscription mode; the message sent by the new configuration center containing the configuration listening strategy can be used to instruct the cloud platform to switch to the target microservice. Configure monitoring to switch.
  • the cloud platform may provide two configuration interfaces.
  • One of the configuration interfaces can be used to receive the configuration center management policy set by the user.
  • This configuration center management policy can be used to switch the configuration monitoring of the target microservice from the old configuration center to the new configuration center.
  • the cloud platform can obtain the configuration center management policy sent by the new configuration center through the configuration interface and perform subsequent steps.
  • Another configuration interface can be used to receive the service type of the new configuration center set by the user.
  • the cloud platform can obtain the microservice subscription policy sent by the new configuration center through this configuration interface, thereby obtaining the service type of the new configuration center set by the user, and follow the next steps.
  • the new registration center is nacos and the microservice subscription policy is to subscribe to nacos only
  • the service type of the new configuration center is nacos.
  • the cloud platform changes the microservice subscription mode of the target microservice from simultaneously subscribing to both the old and new registration centers to only subscribing to the new registration center, and switches the configuration monitoring of the target microservice from the old configuration center to the new configuration center.
  • the cloud platform after the cloud platform obtains the microservice subscription policy and configuration monitoring policy sent by the new configuration center, it can change the microservice subscription mode of the target microservice from subscribing to both the old and new registration centers to only subscribing to the new registration center. , to block the interaction between the target microservice and the old registry. Also, the configuration monitoring of the target microservice can be switched from the old configuration center to the new configuration center to shield the interaction between the target microservice and the old configuration center. This enables the migration of the registration center and configuration center. For example, the new registration center is associated with the new configuration center, and the old registration center is associated with the old configuration center.
  • the old configuration center can be offline.
  • the new configuration center has been running for a certain period of time, or the cloud platform receives the offline instruction from the user
  • the old configuration center can be offline.
  • the cloud platform offline the old registration center and old configuration center, it can also offline the microservices adapted to the old registration center and old configuration center.
  • microservices are implemented through dual registration and intercepting the microservice configuration information of the old configuration center, converting the format of the microservice configuration information and sending it to the new configuration center.
  • Automatic migration improves migration efficiency.
  • the target microservice in the initial stage of migration, after uploading the bytecode enhancement package based on agent technology and the business application package related to the target microservice, the target microservice can be deployed in the cloud platform and subsequent operations can be implemented. In this process There is no need to modify the code of the target microservice, which reduces the difficulty of migration and improves the generalization ability of migration.
  • each step in the above embodiment does not mean the order of execution.
  • the execution order of each process should be determined by its function and internal logic, and should not constitute any influence on the implementation process of the embodiment of the present application. limited.
  • each step in the above embodiments may be selectively executed according to actual conditions, may be partially executed, or may be executed in full, which is not limited here.
  • all or part of any features in the above embodiments can be combined freely and in any way provided that there is no contradiction. The combined technical solutions are also within the scope of this application.
  • the initial scenario can be shown in Figure 4.
  • the two microservices are smoothly migrated to the Service Center registration center and Kie configuration center.
  • the migration of these two microservices can be implemented sequentially through rolling restart.
  • the following is an example of migrating the consumer microservice first and then migrating the provider microservice.
  • users can first start the Service Center registration center and Kie configuration center. Then, the user can add startup parameters in the user interface provided by the cloud platform, as well as add the respective identities of the Service Center registration center and the Kie configuration center.
  • the startup parameters added by the user can be: javaagent:agent.jar, spring-boot-demo-consumer.jar and spring-boot-demo-provider.jar.
  • agent.jar is a bytecode enhancement package, through which the interception and enhancement of registration and configuration can be implemented to implement the method described in the embodiment of this application.
  • interception enhancement as shown in Figure 5, interception enhancement is not executed in (A) of Figure 5. At this time, when the method is called, it is called directly; interception enhancement is executed in (B) of Figure 5. At this time, when the method is called, the method can be intercepted and enhanced through the agent. In this way, the premethod (premethod) and the postmethod (aftermethod) can be added before and after the method is called. That is, after the enhancement, the method can be added before and after the method is called. Additional processing logic, such as adding dual registration logic and configuration migration logic, etc.
  • spring-boot-demo-consumer.jar is a business application package associated with consumer microservices, through which consumer microservices can be configured in the cloud platform.
  • spring-boot-demo-provider.jar is the business application package associated with the provider microservice, through which the provider microservice can be configured in the cloud platform.
  • a user When a user needs to migrate multiple microservices, he or she can upload the business application packages associated with each of the multiple microservices at the same time, or in a time-sharing manner. For example, a business application package associated with a microservice can be uploaded at T1, and then uploaded at T1. Upload the business application package associated with another microservice at the T2 moment after the T1 moment.
  • the details may be determined according to the actual situation and are not limited here.
  • users can also add startup parameters to the cloud platform first, and add the respective identifiers of the Service Center registration center and Kie configuration center; then, start the Service Center registration center and Kie configuration center, and the details can be determined according to the actual situation. It depends, there is no limit here.
  • the cloud platform can carry the Java agent to start the consumer microservice.
  • the consumer microservice started by the cloud platform with Java agent is called "consumer microservice”.
  • the cloud platform can register the consumer microservice to the Nacos registration center and Service Center registration center at the same time.
  • the cloud platform can obtain the microservice configuration information of the consumer microservice adapted to the Nacos registration center and Nacos configuration center from the Nacos configuration center.
  • the cloud platform can perform type conversion on the obtained microservice configuration information to obtain microservice configuration information adapted to the Kie configuration center.
  • the cloud platform can send the converted microservice configuration information to the Kie configuration center. Later, when traffic comes in, the consumer microservice can discover the provider microservice and call the provider microservice. This completes the initial migration of consumer microservices.
  • the dotted lines in Figure 6 represent the interaction situation in the initial scene described in Figure 4.
  • the cloud platform can carry the Java agent to start the provider microservice.
  • the provider microservice started by the cloud platform with Java agent is called "provider microservice”.
  • the cloud platform can register the provider microservice to the Nacos registration center and Service Center registration center at the same time.
  • the cloud platform can obtain the appropriate configuration information from the Nacos configuration center and the Nacos registration center and Nacos configuration center.
  • Microservice configuration information of the configured provider microservice is obtained.
  • the cloud platform can perform format conversion on the obtained microservice configuration information to obtain microservice configuration information adapted to the Kie configuration center.
  • the cloud platform can send the converted microservice configuration information to the Kie configuration center.
  • the consumer ⁇ microservice can discover the provider ⁇ microservice and can call the provider ⁇ microservice. This completes the initial migration of the provider microservice.
  • the dotted lines in Figure 7 represent the interaction situation in the initial scene described in Figure 4.
  • the consumer ⁇ microservice can determine whether to call the provider microservice or the provider ⁇ microservice through load balancing.
  • the consumer microservices and provider microservices in the initial scenario can be offline.
  • the scene at this time can be shown in Figure 8.
  • users can deliver microservice subscription strategies and configure monitoring strategies to the cloud platform through the Kie configuration center.
  • the cloud platform can block the interaction between the consumer ⁇ microservice and the Nacos registration center and Nacos configuration center, and the interaction between the provider ⁇ microservice and the Nacos registration center and Nacos configuration center.
  • the migration of consumer microservices and provider microservices is finally completed.
  • the scene can be switched from the initial scene shown in Figure 4 to the scene shown in Figure 9.
  • microservice migration device provided by the embodiment of this application is introduced.
  • the microservice migration device is mainly proposed based on the microservice migration method described in Figure 3.
  • Figure 10 shows a microservice migration device.
  • the device can be deployed on a cloud platform.
  • the cloud platform can be used to manage instances that provide microservices.
  • the microservice migration device 1000 may include: a communication module 1001 and a processing module 1002.
  • the communication module 1001 is used to obtain the stored first microservice configuration information of the target microservice from the first configuration center where the first instance runs.
  • the processing module 1002 is configured to generate second microservice configuration information of the migrated target microservice based on the first microservice configuration information.
  • the processing module 1002 is also used to send the second microservice configuration information to a second configuration center running on the second instance.
  • the second configuration center is used to store the configuration information of the migrated target microservice.
  • the processing module 1002 when generating the second microservice configuration information of the migrated target microservice based on the first microservice configuration information, is specifically configured to: perform the following steps on the first microservice configuration information of the target microservice: Format conversion, generating second microservice configuration information corresponding to the microservice type of the second configuration center.
  • the processing module 1002 is also configured to: respond to the first offline instruction, offline the first configuration center.
  • the processing module 1002 before sending the second microservice configuration information to the second configuration center running on the second instance, is also configured to: obtain the corresponding relationship between the second instance and the first configuration center; based on The second microservice configuration information and corresponding relationship are used to create a second instance for running the second configuration center.
  • the processing module 1002 when obtaining the corresponding relationship between the second instance and the first configuration center, is specifically configured to: obtain the corresponding relationship between the identifier of the second instance and the first configuration center, where the identifier includes Internet Protocol IP Address and/or instance ID.
  • the processing module 1002 is also configured to: provide a first configuration interface, the first configuration interface is used to receive the configuration center management policy set by the user, and the configuration center management policy is used to monitor the configuration of the target microservice by the third The first configuration center switches to the second configuration center.
  • the service type of the first configuration center is different from the service type of the second configuration center.
  • the processing module 1002 before generating the second microservice configuration information of the migrated target microservice according to the first microservice configuration information of the target microservice stored in the first configuration center, the processing module 1002 is also configured to: provide the third microservice configuration information. Two configuration interfaces, the second configuration interface is used to receive the service type of the second configuration center set by the user.
  • the communication module 1001 is also used to send a first microservice registration request to the first registration center.
  • the first microservice registration request is used to request to register the migrated target microservice in the first registration center.
  • the target microservice is registered as a microservice in the first registration center.
  • the communication module 1001 is also used to send a second microservice registration request to the second registration center running on the third instance.
  • the second microservice registration request is used to request to register the migrated target microservice in the second registration center. .
  • the processing module 1002 is also configured to: respond to the second offline instruction, log out of the first registration center.
  • the first microservice configuration information includes one or more of the following: startup parameters of the target microservice, identification of the target microservice, number of threads related to the target microservice, cache size related to the target microservice , activity data, blacklist, whitelist.
  • both the communication module 1001 and the processing module 1002 can be implemented by software, or can be implemented by hardware.
  • the following takes the communication module 1001 as an example to introduce the implementation of the communication module 1001.
  • the implementation of the processing module 1002 may refer to the implementation of the communication module 1001.
  • the communication module 1001 may include code running on a computing instance.
  • the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container.
  • the above computing instance may be one or more.
  • communications module 1001 may include code running on multiple hosts/virtual machines/containers. It should be noted that multiple hosts/virtual machines/containers used to run the code can be distributed in the same region (region) or in different regions. Furthermore, multiple hosts/virtual machines/containers used to run the code can be distributed in the same availability zone (AZ) or in different AZs. Each AZ includes one data center or multiple AZs. geographically close data centers. Among them, usually a region can include multiple AZs.
  • the multiple hosts/VMs/containers used to run the code can be distributed in the same virtual private cloud (VPC), or across multiple VPCs.
  • VPC virtual private cloud
  • Cross-region communication between two VPCs in the same region and between VPCs in different regions requires a communication gateway in each VPC, and the interconnection between VPCs is realized through the communication gateway. .
  • the communication module 1001 may include at least one computing device, such as a server.
  • the communication module 1001 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD).
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • the above-mentioned PLD can be a complex programmable logical device (CPLD), a field-programmable gate array (field-programmable gate array, FPGA), a general array logic (generic array logic, GAL), or any combination thereof.
  • CPLD complex programmable logical device
  • FPGA field-programmable gate array
  • GAL general array logic
  • Multiple computing devices included in the communication module 1001 may be distributed in the same region or in different regions. Multiple computing devices included in the communication module 1001 may be distributed in the same AZ or in different AZs. Similarly, multiple computing devices included in the communication module 1001 may be distributed in the same VPC or in multiple VPCs.
  • the plurality of computing devices may be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
  • the communication module 1001 can be used to perform any steps in the microservice migration method described above, and the processing module 1002 can be used to perform any steps in the methods provided in the above embodiments. Communication The steps that the module 1001 and the processing module 1002 are responsible for can be specified as needed. The communication module 1001 and the processing module 1002 respectively implement different steps in the method provided by the above embodiment to realize all functions of the configuration migration device 1000.
  • computing device 1100 includes: bus 1102, processor 1104, memory 1106, and communication interface 1108.
  • the processor 1104, the memory 1106 and the communication interface 1108 communicate through a bus 1102.
  • Computing device 1100 may be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 1100.
  • the bus 1102 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus, etc. For ease of presentation, only one line is used in Figure 11, but it does not mean that there is only one bus or one type of bus.
  • Bus 1104 may include a path that carries information between various components of computing device 1100 (eg, memory 1106, processor 1104, communications interface 1108).
  • the processor 1104 may include a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP) or a digital signal processor (DSP). any one or more of them.
  • CPU central processing unit
  • GPU graphics processing unit
  • MP microprocessor
  • DSP digital signal processor
  • Memory 1106 may include volatile memory, such as random access memory (RAM).
  • RAM random access memory
  • the processor 104 may also include non-volatile memory (non-volatile memory), such as read-only memory (ROM), flash memory, mechanical hard disk drive (hard disk drive, HDD) or solid state drive (solid state drive). drive, SSD).
  • ROM read-only memory
  • HDD hard disk drive
  • SSD solid state drive
  • the memory 1106 stores executable program code, and the processor 1104 executes the executable program code to respectively implement the functions of the communication module 1001 and the processing module 1002, thereby implementing all or part of the steps of the method in the above embodiment. That is, the memory 1106 stores instructions for executing all or part of the steps in the methods of the above embodiments.
  • executable code is stored in the memory 1106, and the processor 1104 executes the executable code to respectively implement the functions of the microservice migration device 1000, thereby implementing all or part of the steps in the method of the above embodiment. That is, the memory 1106 stores instructions for executing all or part of the steps in the methods of the above embodiments.
  • the communication interface 1103 uses transceiver modules such as, but not limited to, network interface cards and transceivers to implement communication between the computing device 100 and other devices or communication networks.
  • An embodiment of the present application also provides a computing device cluster.
  • the computing device cluster includes at least one computing device.
  • the computing device may be a server, such as a central server, an edge server, or a local server in a local data center.
  • the computing device may also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
  • the computing device cluster includes at least one computing device 1100.
  • the memory 1106 of one or more computing devices 1100 in the computing device cluster may store the same instructions for executing all or part of the steps in the above embodiment method.
  • the memory 1106 of one or more computing devices 1100 in the computing device cluster may also store partial instructions for executing all or part of the steps in the methods of the above embodiments.
  • a combination of one or more computing devices 1100 may jointly execute instructions for performing all or part of the steps in the above embodiment methods.
  • the memories 1106 in different computing devices 1100 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the microservice migration device 1000. That is, the instructions stored in the memory 1106 in different computing devices 1100 can implement one or more modules in the communication module 1001 and the processing module 1002. Function.
  • one or more computing devices in a cluster of computing devices may be connected through a network.
  • the network may be a wide area network or a local area network, etc.
  • embodiments of the present application provide a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program When the computer program is run on a processor, it causes the processor to execute the steps in the above embodiments. Methods.
  • embodiments of the present application provide a computer program product, which when the computer program product is run on a processor, causes the processor to execute the methods in the above embodiments.
  • processors in the embodiments of the present application can be a central processing unit (CPU), or other general-purpose processor, digital signal processor (DSP), or application-specific integrated circuit (application specific integrated circuit, ASIC), field programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.
  • a general-purpose processor can be a microprocessor or any conventional processor.
  • the method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions.
  • Software instructions can be composed of corresponding software modules, and software modules can be stored in random access memory (random access memory, RAM), flash memory, read-only memory (read-only memory, ROM), programmable read-only memory (programmable rom) , PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically erasable programmable read-only memory (electrically EPROM, EEPROM), register, hard disk, mobile hard disk, CD-ROM or other well-known in the art any other form of storage media.
  • An exemplary storage medium is coupled to the processor such that the processor can read information from the storage medium and write information to the storage medium.
  • the storage medium can also be an integral part of the processor.
  • the processor and storage media may be located in an ASIC.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted over a computer-readable storage medium.
  • the computer instructions may be transmitted from one website, computer, server or data center to another website through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. , computer, server or data center for transmission.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more available media integrated therein.
  • the available media may be magnetic media (eg, floppy disk, hard disk, tape), optical media (eg, DVD), or semiconductor media (eg, solid state disk (SSD)), etc.

Abstract

一种微服务迁移方法,应用于用于管理提供微服务的实例的云平台,包括:从第一实例运行的第一配置中心获取存储的目标微服务的第一微服务配置信息;基于第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息;将第二微服务配置信息发送至运行在第二实例上的第二配置中心,第二配置中心用于存储迁移后的目标微微服务的配置信息。这样,在进行微服务迁移时,可以先从旧配置中心中获取到微服务配置信息,并由该微服务配置信息得到适配新配置中心的微服务配置信息,最后,再将适配新配置中心的微服务配置信息发送至新配置中心上,即实现对微服务的配置信息的自动迁移,提升了微服务迁移效率。

Description

一种微服务迁移方法、装置及计算设备
本申请要求于2022年6月23日提交中国国家知识产权局、申请号为202210718836.X、申请名称为“一种配置迁移方法、装置及设备”,以及于2022年10月25日提交中国国家知识产权局、申请号为202211311317.8、申请名称为“一种微服务迁移方法、装置及计算设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及信息技术(information technology,IT)技术领域,尤其涉及一种微服务迁移方法、装置及计算设备。
背景技术
随着技术的不断发展,服务架构逐步从原来的单体架构演进到微服务架构,而微服务的架构离不开注册中心和配置中心。其中,不同的注册中心之间可以切换,不同的配置中心之间也可以切换。例如,当某个服务需要配置到云服务上时,则会出现注册中心和配置中心同时迁移的情况。但目前注册中心或配置中心迁移的过程较为复杂,不便于操作。
发明内容
本申请提供了一种微服务迁移方法、装置、计算设备、计算设备集群、计算机存储介质及计算机产品,能够实现配置中心的自动迁移,提升了微服务迁移效率。
第一方面,本申请提供一种微服务迁移方法,该方法可以应用于云平台。该云平台可以用于管理提供微服务的实例。该方法可以包括:从第一实例运行的第一配置中心获取存储的目标微服务的第一微服务配置信息;基于第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息;将第二微服务配置信息发送至运行在第二实例上的第二配置中心,第二配置中心用于存储迁移后的目标微微服务的配置信息。
这样,在进行微服务迁移时,可以先从旧配置中心中获取到微服务配置信息,并由该微服务配置信息得到适配新配置中心的微服务配置信息,最后,再将适配新配置中心的微服务配置信息发送至新配置中心上,即实现对微服务的配置信息的自动迁移,提升了微服务迁移效率。
在一种可能的实现方式中,基于第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息,包括:对目标微服务的第一微服务配置信息进行格式转换,生成与第二配置中心的微服务类型对应的第二微服务配置信息。由此通过格式转换的方式即得到适配新配置中心的微服务配置信息。
在一种可能的实现方式中,方法还包括:响应于第一下线指令,下线第一配置中心。
在一种可能的实现方式中,在将第二微服务配置信息发送至运行在第二实例上的第二配置中心前,该方法还包括:获取第二实例与第一配置中心的对应关系;基于第二微服务配置信息和对应关系,创建用于运行第二配置中心的第二实例。
在一种可能的实现方式中,在将第二微服务配置信息发送至运行在第二实例上的第二配置中心前,该方法还包括:获取第二实例与第一配置中心的对应关系;基于第二微服务配置 信息和对应关系,在预先创建完成的第二实例上创建并运行第二配置中心。或者,第二配置中心也可以是预先创建好的,根据第二实例与第一配置中心的对应关系,运行与第一配置中心对应的第二配置中心及第二实例。
在一种可能的实现方式中,获取第二实例与第一配置中心的对应关系,包括:获取第二实例的标识与第一配置中心的对应关系,其中,标识包括互联网协议I P地址和/或实例I D。
在一种可能的实现方式中,方法还包括:提供第一配置接口,第一配置接口用于接收用户设置的配置中心管理策略,配置中心管理策略用于将目标微服务的配置监听由第一配置中心切换至第二配置中心。由此即使得云平台可以获取到用户通过新配置中心下发的配置中心关联策略,从而可以根据该策略调整目标微服务的配置监听。
在一种可能的实现方式中,第一配置中心的服务类型与第二配置中心的服务类型不同。
在一种可能的实现方式中,根据第一配置中心存储的目标微服务的第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息前,方法还包括:提供第二配置接口,第二配置接口用于接收用户设置的第二配置中心的服务类型。由此即使得云平台可以获取到用户通过新配置中心下发的第二配置中心的服务类型,从而可以根据服务类型调整目标微服务的订阅模式。
在一种可能的实现方式中,该方法还包括:向第一注册中心发送第一微服务注册请求,第一微服务注册请求用于请求在第一注册中心对迁移后的目标微服务进行注册,目标微服务在第一注册中心进行了微服务注册;向运行在第三实例上的第二注册中心发送第二微服务注册请求,第二微服务注册请求用于请求在第二注册中心对迁移后的目标微服务进行注册。
在一种可能的实现方式中,方法还包括:响应于第二下线指令,下线第一注册中心。
在一种可能的实现方式中,第一微服务配置信息包括以下一项或多项:目标微服务的启动参数、目标微服务的标识、与目标微服务相关的线程数、与目标微服务相关的缓存大小、活动数据、黑名单、白名单。
第二方面,本申请提供一种微服务迁移装置。该装置可以部署于云平台。该云平台可以用于管理提供微服务的实例。该装置可以包括:通信模块和处理模块。其中,通信模块用于从第一实例运行的第一配置中心获取存储的目标微服务的第一微服务配置信息。处理模块用于基于第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息。处理模块还用于将第二微服务配置信息发送至运行在第二实例上的第二配置中心,第二配置中心用于存储迁移后的目标微微服务的配置信息。
在一种可能的实现方式中,处理模块在基于第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息时,具体用于:对目标微服务的第一微服务配置信息进行格式转换,生成与第二配置中心的微服务类型对应的第二微服务配置信息。
在一种可能的实现方式中,处理模块,还用于:响应于第一下线指令,下线第一配置中心。
在一种可能的实现方式中,处理模块在将第二微服务配置信息发送至运行在第二实例上的第二配置中心前,还用于:获取第二实例与第一配置中心的对应关系;基于第二微服务配置信息和对应关系,创建用于运行第二配置中心的第二实例。
在一种可能的实现方式中,处理模块在将第二微服务配置信息发送至运行在第二实例上的第二配置中心前,还用于:获取第二实例与第一配置中心的对应关系;基于第二微服务配 置信息和对应关系,在预先创建完成的第二实例上创建并运行第二配置中心。或者,第二配置中心也可以是预先创建好的,根据第二实例与第一配置中心的对应关系,运行与第一配置中心对应的第二配置中心及第二实例。
在一种可能的实现方式中,处理模块在获取第二实例与第一配置中心的对应关系时,具体用于:获取第二实例的标识与第一配置中心的对应关系,其中,标识包括互联网协议IP地址和/或实例ID。
在一种可能的实现方式中,处理模块,还用于:提供第一配置接口,第一配置接口用于接收用户设置的配置中心管理策略,配置中心管理策略用于将目标微服务的配置监听由第一配置中心切换至第二配置中心。
在一种可能的实现方式中,第一配置中心的服务类型与第二配置中心的服务类型不同。
在一种可能的实现方式中,处理模块在根据第一配置中心存储的目标微服务的第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息前,还用于:提供第二配置接口,第二配置接口用于接收用户设置的第二配置中心的服务类型。
在一种可能的实现方式中,通信模块,还用于向第一注册中心发送第一微服务注册请求,第一微服务注册请求用于请求在第一注册中心对迁移后的目标微服务进行注册,目标微服务在第一注册中心进行了微服务注册;通信模块,还用于向运行在第三实例上的第二注册中心发送第二微服务注册请求,第二微服务注册请求用于请求在第二注册中心对迁移后的目标微服务进行注册。
在一种可能的实现方式中,处理模块,还用于:响应于第二下线指令,下线第一注册中心。
在一种可能的实现方式中,第一微服务配置信息包括以下一项或多项:目标微服务的启动参数、目标微服务的标识、与目标微服务相关的线程数、与目标微服务相关的缓存大小、活动数据、黑名单、白名单。
第三方面,本申请提供一种计算设备,包括:至少一个存储器,用于存储程序;至少一个处理器,用于执行存储器存储的程序;其中,当存储器存储的程序被执行时,处理器用于执行第一方面或第一方面的任一种可能的实现方式所描述的方法。
第四方面,本申请提供一种计算设备集群,包括至少一个计算设备,每个计算设备均包括处理器和存储器;至少一个计算设备的处理器用于执行至少一个计算设备的存储器中存储的指令,以使得计算设备集群执行第一方面或第一方面的任一种可能的实现方式所描述的方法。
第五方面,本申请提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,当计算机程序在处理器上运行时,使得处理器执行第一方面或第一方面的任一种可能的实现方式所描述的方法。
第六方面,本申请提供一种计算机程序产品,当计算机程序产品在处理器上运行时,使得处理器执行第一方面或第一方面的任一种可能的实现方式所描述的方法。
可以理解的是,上述第二方面至第六方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。
附图说明
下面对实施例或现有技术描述中所需使用的附图作简单地介绍。
图1是本申请实施例提供的一种注册中心和配置中心迁移的过程示意图;
图2是本申请实施例提供的另一种注册中心和配置中心迁移的过程示意图;
图3是本申请实施例提供的一种微服务迁移方法的流程示意图;
图4是本申请实施例提供的一种微服务迁移前的场景的示意图;
图5是本申请实施例提供的一种执行拦截增强前后的对比示意图;
图6是本申请实施例提供的一种迁移consumer服务的过程示意图;
图7是本申请实施例提供的一种迁移provider服务的过程示意图;
图8是本申请实施例提供的一种下线consumer服务和provider服务后的场景的示意图;
图9是本申请实施例提供的一种微服务迁移后的场景的示意图;
图10是本申请实施例提供的一种微服务迁移装置的结构示意图;
图11是本申请实施例提供的一种计算设备的结构示意图;
图12是本申请实施例提供的一种计算设备集群的结构示意图。
具体实施方式
本文中术语“和/或”,是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。本文中符号“/”表示关联对象是或者的关系,例如A/B表示A或者B。
本文中的说明书和权利要求书中的术语“第一”和“第二”等是用于区别不同的对象,而不是用于描述对象的特定顺序。例如,第一响应消息和第二响应消息等是用于区别不同的响应消息,而不是用于描述响应消息的特定顺序。
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。
在本申请实施例的描述中,除非另有说明,“多个”的含义是指两个或者两个以上,例如,多个处理单元是指两个或者两个以上的处理单元等;多个元件是指两个或者两个以上的元件等。
首先,对本申请中涉及的技术术语进行介绍。
(1)微服务
微服务(也可称之为“服务”)是一种开发软件的架构和组织方法,其可以由通过明确定义的应用程序编程接口(application programming interface,API)进行通信的小型独立服务组成。这些服务可以由各个小型独立团队负责。示例性的,微服务可以配置在实例上,该实例可以是计算机,服务器,云计算平台(即“云平台”),或者,虚拟机、容器等等中的至少一种。
(2)注册中心
注册中心是微服务架构中的”通讯录“,它记录了微服务和微服务地址的映射关系,其在整个的微服务架构中单独提出的一个服务,这个服务可以不用完成系统的业务功能,而是用来完成对整个微服务系统的微服务注册和微服务发现,以及对微服务健康状态的监控和管 理功能。示例性的,注册中心可以配置在节点上,该节点可以是计算机,服务器,云计算平台(即“云平台”),或者,虚拟机等等。示例性的,注册中心可以具备以下功能:微服务注册表、微服务注册与发现、微服务检查等。其中,微服务注册表是注册中心的核心,它用来记录各个微服务的信息,例如微服务的名称、互联网协议(internet protocol,IP)地址、端口等。微服务注册表提供查询API和管理API,查询API用于查询可用的微服务实例,管理API用于微服务的注册与注销。微服务注册是指微服务在启动时,将自己的信息注册到注册中心的过程。微服务发现是指查询可用的微服务列表及网络地址的机制。微服务检查是指注册中心使用一定的机制定时检测已注册的微服务,如发现某实例长时间无法访问,就会从微服务注册表移除该实例。
另外,注册中心主要涉及到三大角色:微服务提供者、微服务消费者和注册中心。这三个角色之间的关系如下:各个微服务在启动时,将自己的网络地址等信息注册到注册中心,注册中心存储这些数据。微服务消费者从注册中心查询微服务提供者的地址,并通过该地址调用微服务提供者的接口。各个微服务与注册中心使用一定机制(例如心跳)通信。如果注册中心与某微服务长时间无法通信,就会注销该实例。微服务网络地址发送变化(例如实例增加或IP变动等)时,会重新注册到注册中心,这样,微服务消费者就无需人工修改提供者的网络地址了。
(3)配置中心
配置中心可以用来管理微服务应用的配置。微服务连接配置中心,能够从配置中心获取微服务配置信息及其变化。配置中心还是其他微服务管控功能的核心部件,比如微服务治理规则的下发,也可以通过配置中心实现。示例性的,配置中心可以配置在节点上,该节点可以是计算机,服务器,云计算平台(即“云平台”),或者,虚拟机等等。在一些实施例中,注册中心和配置中心可以配置在同一节点上,也可以配置在不同的节点上,此处不做限定。示例性的,配置中心可以为kie,也可以为nacos。在一些实施例中,不同的配置中心的服务类型不同。例如,当配置中心为kie时,该配置中心的服务类型为kie;当配置中心为nacos时,该配置中心的服务类型为nacos。
(3)注册表
注册表是微服务与其IP地址的映射关系表。微服务订阅者可以通过订阅注册中心获取注册表来发现下游的微服务。示例性的,对于微服务订阅者和下游的微服务,当A微服务需要调用B微服务时,A微服务则为微服务订阅者,B微服务则为下游的微服务。
(4)双注册
双注册是指微服务同时注册到两个注册中心,使两个注册中心的微服务订阅者均可发现该微服务并调用。
(5)服务订阅
服务订阅是指微服务对注册中心的一种行为,其会对一个或者多个微服务进行订阅,当订阅的微服务的实例发生变化时,订阅微服务将会感知实例变化。
(6)双订阅
双订阅是指微服务订阅者同时订阅两个注册中心,该微服务订阅者可同时对两个注册中心注册的微服务进行调用。
(7)配置监听
配置监听是指微服务通过关注一个或多个配置修改来感知配置变化,可以把微服务关注 配置变化的行为称为配置监听。
(8)动态配置
动态配置是指微服务可实时感知配置变化(比如:配置中心的配置变动),并根据配置变化来执行相关行为。
(9)切流
切流即流量切换,通常指流量从一套系统切换到另一套系统。
(10)滚动重启
滚动重启通常是跨多个微服务实例上进行操作,以增量的方式停止和启动微服务实例,其目的是保证在该微服务不中断业务前提下对微服务进行更新。
(11)探针(agent)技术
agent技术是软件领域中,一种能够在不影响宿主应用正常编译的情况下,在宿主应用启动时动态修改宿主应用的字节码或库函数的技术。
(12)Java agent
java agent是agent的一种,在JDK1.5之后引入的新特性,它支持JVM将字节码文件读入内存之后,JVM使用对应的字节流在Java堆中生成一个Class对象之前,用户可以对其字节码进行修改的能力,JVM使用修改之后的字节码进行Class对象的创建,从而实现java应用的非代码侵入的业务逻辑修改和替换。
接下来,对本申请实施例提供的方案进行介绍。
示例性的,图1示出了一种注册中心和配置中心迁移的过程。如图1所示,在旧系统中包括旧注册中心(即旧的注册中心),旧配置中心(即旧的配置中心),微服务1和微服务2。微服务1和微服务2均可以注册至旧注册中心,且微服务1可以调用微服务2。旧配置中心可以向微服务1和微服务2下发配置。当需要迁移旧注册中心和旧配置中心时,为了使得微服务1和微服务2可以适配新注册中心(即新的注册中心)和新配置中心(即新的配置中心),可以对微服务1和微服务2进行代码改造,得到微服务1'和微服务2'。另外,微服务1'和微服务2'均可以注册至新注册中心,微服务1'可以调用微服务2'。接着,可以手动将旧配置中心的相关微服务配置信息导出,并对相关的微服务配置信息进行解析转换,以适配新配置中心,并导入至新配置中心中。之后,新配置中心可以向微服务1'和微服务2'下发配置。此时,新系统已经可以使用。最后,可以实行切流,将流量逐渐全部引入至新系统中,并下线旧系统中的微服务。
图1中所示的迁移方式,虽然可以实现注册中心和配置中心的迁移,但是其需要对微服务的代码进行改造,影响较大,且需要手动完成配置中心的迁移,工作量较大,效率低。另外,若需要保证业务不中断,则需旧系统和新系统同时运行,致使资源消耗较大。
示例性的,图2示出了另一种注册中心和配置中心迁移的过程。如图2所示,在旧系统中包括旧注册中心(即旧的注册中心),旧配置中心(即旧的配置中心),微服务1和微服务2。微服务1和微服务2均可以注册至旧注册中心,且微服务1可以调用微服务2。旧配置中心可以向微服务1和微服务2下发配置。当需要迁移旧注册中心和旧配置中心时,为了使得微服务1和微服务2可以适配新注册中心(即新的注册中心)和新配置中心(即新的配置中心),同样需要对微服务1和微服务2进行代码改造,得到微服务1'和微服务2'。另外,微服务1'和微服务2'均可以注册至新注册中心,微服务1'可以调用微服务2'。接着,可以通 过注册同步器对新注册中心和旧注册中的注册表进行同步,这样,微服务1'可以发现微服务2,微服务1可以发现微服务2',从而使得微服务1'可以调用微服务2,微服务1可以调用微服务2'。之后,可以手动将旧配置中心的相关微服务配置信息导出,并对相关的微服务配置信息进行解析转换,以适配新配置中心,并导入至新配置中心中。接着,新配置中心可以向微服务1'和微服务2'下发配置。此时,新系统已经可以使用。最后,待新系统运行稳定后,就可以下线旧系统中的微服务。
图2中所示的迁移方式,虽然可以实现注册中心和配置中心的迁移,但是其同样需要对微服务的代码进行改造,影响较大,且需要手动完成配置中心的迁移,工作量较大,效率低。另外,若需要保证业务不中断,则需旧系统和新系统同时运行一段时间,致使资源消耗较大。此外,其还需要增加“注册表同步器”这一组件,增加了迁移成本。
有鉴于此,本申请实施例提供了一种微服务迁移方法,该方法主要是基于agent技术对微服务的配置进行增强,从而实现在微服务迁移时,根据当前微服务使用的旧配置中心通过无侵入的方式拦截获取配置内容,进行配置格式转换并推送到新配置中心,自动完成配置迁移动作。由此以实现在不对微服务的代码进行改造的前提下完成配置中心的自动迁移。另外,该方法还可以实现对微服务的注册进行增强,使得当微服务注册至旧注册中心时,可以同步注册至新注册中心,从而完成微服务的双注册。进一步地,在完成微服务的初步迁移后,可以通过新配置中心下发相应的策略,以屏蔽微服务与旧注册中心和旧配置中心的交互,从而达到下线旧注册中心和旧配置中心的目的,以完成微服务的最终迁移。
示例性的,图3示出了一种微服务迁移的方法。如图3所示,该微服务迁移方法,可以包括以下步骤:
S301、云平台获取用户上传的与目标微服务相关的启动参数,以及,用户下发的配置指令,其中,配置指令中包括新注册中心的标识和新配置中心的标识。
本实施例中,云平台可以向用户提供用户界面(user interface,UI)。在该用户界面中可以设置有供用户上传文件的入口。进一步地,用户可以通过云平台提供的用户界面上传与目标微服务相关的启动参数。该启动参数可以包括字节码增强包和与目标微服务关联的业务应用包。其中,字节码增强包至少可以用于在不改变业务应用包中与目标微服务相关的原始代码的逻辑情况下,在原始代码中增加配置迁移功能和/或注册迁移功能。该字节码增强包可以基于前述的agent技术实现。业务应用包主要是用于在云平台中配置目标微服务。示例性的,该云平台可以用于管理提供微服务的实例(比如容器、线程等)。
另外,用户还可以通过云平台提供的UI下发一些配置指令。该配置指令中可以包括新注册中心的标识和新配置中心的标识,以便在注册和配置过程中,可以查找到新注册中心和新配置中心。在一些实施例中,新注册中心的标识可以是新注册中心的互联网协议(internet protocol,IP)地址,新注册中心的域名,或者,新注册中心的引擎名称等。新配置中心的标识可以是新配置中心的IP地址,新配置中心的域名,或者,新配置中心的引擎名称等。
在一些实施例中,配置指令中还可以包括旧注册中心的标识和旧配置中心的标识。由此以便于云平台可以与旧注册中心和旧配置中心通信。在一些实施例中,包括旧配置中心的标识的配置指令可以称之为第一指令,包括旧注册中心的标识的配置指令可以称之为第二指令。在一些实施例中,当配置指令中包含新配置中心的标识和旧配置中心的标识时,云平台可以确定出这两个标识间是具有一定的对应关系的。同时,可以确定出用于运行旧配置中心的实例(比如虚拟机或容器等)和新配置中心的标识间具有对应关系,或者,用于运行新配置中 心的实例和旧配置中心的标识间具有对应关系。
在一些实施例中,用户上传启动参数和下发配置指令的时间,可以根据实际情况进行选择,此处不做限定。例如,用户可以在上传启动参数后,立马就下发配置指令,也可以在上传启动参数,且经过一段时间(比如1小时、1天、1月、1年等)后,在下发配置指令。另外,上传启动参数的用户和下发配置指令的用户,可以是同一用户,也可以是不同的用户,此处不做限定。
在一些实施例中,旧注册中心可以运行于一个实例中。例如,旧注册中心可以运行在某个物理机、虚拟机、容器等中。同样的,旧配置中心也可以运行于一个实例中。例如,旧配置中心可以运行在某个物理机、虚拟机、容器等中。其中,在旧注册中心中已对目标微服务进行了微服务注册。在旧配置中心中存储有目标微服务所需的微服务配置信息。
S302、云平台基于启动参数,启动目标微服务。
本实施例中,云平台获取到启动参数后,可以基于业务应用包在其内配置目标微服务,启动目标微服务。示例性的,该目标微服务对应的实例可以但不限于为一个线程。
S303、云平台将目标微服务注册到新旧两个注册中心。
本实施例中,在目标微服务启动后,云平台可以向旧注册中心发送包含微服务注册请求的消息,以请求在旧注册中心中对迁移后的目标微服务进行注册。同时,云平台可以向新注册中心发送包含微服务注册请求的消息,以请求在新注册中心中对迁移后的目标微服务进行注册。当旧注册中心获取到云平台发送的请求后,可以将目标微服务注册至其内,并向云平台返回注册成功的消息。当新注册中心获取到云平台发送的请求后,可以将目标微服务注册至其内,并向云平台返回注册成功的消息。由此,以完成对目标微服务的双注册,以便实现对注册中心的迁移。
在一些实施例中,云平台可以先在某个实例(比如虚拟机、容器等)上创建新注册中心。例如,云平台可以向某个虚拟机发送创建新注册中心的请求,以在该虚拟机上创建新注册中心。然后,在向该新注册中心发送微服务注册请求。当然,该新注册中心也可以是预先创建在其他实例(比如物理机、虚拟机、容器等)上的,具体可根据实际情况而定。
在一些实施例中,旧注册中心可以称之为第一注册中心,新注册中心可以称之为第二注册中心。
S304、云平台向旧配置中心发送用于查询目标微服务的第一微服务配置信息的第一消息。
S305、旧配置中心向云平台发送包含第一微服务配置信息的第二消息。
本实施例中,旧配置中心获取到云平台发送的第一消息后,可以将其上用户对目标微服务的相关配置发送至云平台,即向云平台发送包含第一微服务配置信息的第二消息。在一些实施例中,第一微服务配置信息中可以包括以下一项或多项:目标微服务的启动参数,目标微服务的标识,与目标微服务相关的线程数,与目标微服务相关的缓存大小,活动数据,黑名单或白名单等。
在一些实施例中,S304和S305可以理解为是:云平台从某个实例中运行的旧配置中心获取该旧配置中心存储的目标微服务的微服务配置信息的步骤。
在一些实施例中,旧配置中心可以称之为第一注册中心。
S306、云平台对第一微服务配置信息进行格式转换,以得到第二微服务配置信息。
本实施例中,由于在进行微服务迁移时,新旧两个配置中心的类型往往是不同的,这使得与两者适配的微服务配置信息的格式也不同。因此,云平台在获取到第一微服务配置信息 后,可以对第一微服务配置信息进行格式转换,以得到与新配置中心适配的第二微服务配置信息。示例性的,第一微服务配置信息的格式可以包括YAML、JSON、TEXT、Properties、INI、XML中的任意一种,第二微服务配置信息的格式也可以包括YAML、JSON、TEXT、Properties、INI、XML中的任意一种,且第一微服务配置信息的格式与第二微服务配置信息的格式不同。
在一些实施例中,S306可以理解为是:云平台基于从第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息的步骤。
需要说明的是,S306为可选的步骤,也即,当两个配置中心的类型相同时,可以不对第一微服务配置信息进行格式转换。
S307、云平台向新配置中心发送包含第二微服务配置信息的第三消息。
本实施例中,云平台在得到第二微服务配置信息后,可以将该微服务配置信息发送至新配置中心,即向新配置中心发送包含第二微服务配置信息的第三消息。由此以实现旧配置中心中的微服务配置信息向新配置中心的迁移。
在一些实施例中,在S307之前,云平台还可以先创建用于运行新配置中心的实例,比如虚拟机、容器等实例中的一种或多种,以便在该实例中创建出用于存储第二微服务配置信息的新配置中心。示例性的,用户在云平台所提供的用户界面上进行目标微服务的迁移操作时,可以选择旧配置中心和用于运行新配置中心的实例的标识,比如IP地址和/或实例ID等。这样,云平台即可以获取到旧配置中心和用于运行新配置中心的实例的标识间的对应关系,也即获取到旧配置中心和用于运行新配置中心的实例间的对应关系。接着,云平台可以根据该对应关系和第二微服务配置信息,创建出用于运行新配置中心的实例。其中,云平台在创建用于运行新配置中心的实例过程中,可以将第二服务配置信息配置在该实例中的新配置中心中。
当然,该新配置中心也可以是预先创建在其他实例(比如物理机、虚拟机、容器等)上的,具体可根据实际情况而定。
在一些实施例中,新配置中心可以称之为第二注册中心。
S308、新配置中心获取用户下发的微服务订阅策略和配置监听策略。
本实施例中,用户可以在新配置中心中下发的微服务订阅策略和配置监听策略。微服务订阅策略是将微服务订阅模式由双注册中心切换为单注册中心的策略,其可以将同时订阅新旧两个注册中心切换为仅订阅新注册中心,由此以屏蔽目标微服务与旧注册中心的交互。配置监听策略是将目标微服务的配置监听从旧配置中心切换到新配置中心,由此以屏蔽目标微服务与旧配置中心的交互。
S309、新配置中心向云平台发送包含微服务订阅策略和配置监听策略的消息。
本实施例中,在用户下发微服务订阅策略和配置监听策略后,新配置中心可以将这些策略发送至云平台,以由云平台执行。此时,新配置中心发送的包含微服务订阅策略的消息,可以用来指示云平台切换微服务订阅模式;新配置中心发送的包含配置监听策略的消息,可以用来指示云平台对目标微服务的配置监听进行切换。
在一些实施例中,云平台可以提供两个配置接口。其中一个配置接口可以用来接收用户设置的配置中心管理策略。该配置中心管理策略可以用于将目标微服务的配置监听由旧配置中心切换至新配置中心。这样,当新配置中心获取到用户设置的配置中心管理策略(即配置监听策略)后,云平台通过该配置接口即可以获取到新配置中心发送的配置中心管理策略,并执行后续步骤。
另一个配置接口可以用来接收用户设置的新配置中心的服务类型。这样,当新配置中心获取到用户设置的微服务订阅策略,云平台通过该配置接口即可以获取到新配置中心发送的微服务订阅策略,从而获取到用户设置的新配置中心的服务类型,并执行后续步骤。示例性的,当新注册中心为nacos,且微服务订阅策略是仅订阅nacos,则新配置中心的服务类型为nacos。
S310、云平台将目标微服务的微服务订阅模式由同时订阅新旧两个注册中心换为仅订阅新注册中心,以及将目标微服务的配置监听由旧配置中心切换至新配置中心。
本实施例中,云平台在获取到新配置中心发送的微服务订阅策略和配置监听策略后,可以将目标微服务的微服务订阅模式由同时订阅新旧两个注册中心换为仅订阅新注册中心,以屏蔽目标微服务与旧注册中心的交互。以及,可以将目标微服务的配置监听由旧配置中心切换至新配置中心,以屏蔽目标微服务与旧配置中心的交互。由此以实现注册中心和配置中心的迁移。示例性的,新注册中心与新配置中心之间是关联的,旧注册中心与旧配置中心之间是关联的。
进一步地,当新注册中心运行一定时长,或者云平台接收到用户下发的下下线指令后,可以下线旧配置中心。当新配置中心运行一定时长,或者云平台接收到用户下发的下下线指令后,可以下线旧配置中心。此外,云平台在下线旧注册中心和旧配置中心后,可以同时可以下线与旧注册中心和旧配置中心适配的微服务。
由此,在进行微服务迁移时,通过双注册的方式,以及拦截旧配置中心的微服务配置信息,并将该微服务配置信息进行格式转换后发送至新配置中心的方式,实现了微服务的自动迁移,提升了迁移效率。另外,在迁移的初始阶段,上传基于agent技术的字节码增强包和与目标微服务相关的业务应用包后,即可以在云平台中部署目标微服务,且实现后续的操作,在该过程中并不需要对目标微服务的代码进行改造,降低了迁移难度,提升了迁移的泛化能力。
应理解的,将云平台替换为其他的组件或设备的方案仍在本申请的保护范围之内。另外,除了可以同时对注册中心和配置中心进行迁移外,还可以仅对配置中心进行迁移,亦可以仅对注册中心进行迁移。其中,对单一的某个中心进行迁移的流程,仍在本申请的保护范围之内,迁移流程可以参考图3中对其迁移的描述,此处不再赘述。此外,当同时对注册中心和配置中心进行迁移时,可以先迁移注册中心,在迁移配置中心,也可以先迁移配置中心,在迁移注册中心,亦可以两者同步进行迁移,此处不做限定。
可以理解的是,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。此外,在一些可能的实现方式中,上述实施例中的各步骤可以根据实际情况选择性执行,可以部分执行,也可以全部执行,此处不做限定。另外,上述实施例中的任意特征的全部或部分在不矛盾的前提下,可以自由地、任何地组合。组合后的技术方案也在本申请的范围之内。
为便于理解图3中所描述的过程,下面以Java agent技术且对两个微服务进行迁移为例演示本申请实施例提供的微服务迁移过程。应理解的是,当所需迁移的微服务的数量大于两个时,可以参考下文中的描述,此处不再赘述。
示例性的,初始场景可以如图4所示,在该场景下分别有一个provider微服务和一个consumer微服务,且两者均注册在Nacos注册中心。另外,可以通过Nacos配置中心向这两 个微服务下发配置。在该场景下还存在一个网关层(Gateway),其可以执行用户流量分发。
基于图4所示的场景将两个微服务平滑迁移到Service Center注册中心和Kie配置中心。其中,在迁移过程中,可以通过滚动重启的方式依次实现这两个微服务的迁移。为便于描述,下面以先迁移consumer微服务,再迁移provider微服务为例进行说明。
其中,在迁移之前,用户可以先启动Service Center注册中心和Kie配置中心。然后,用户可以在云平台提供的用户界面中添加启动参数,以及,添加Service Center注册中心和Kie配置中心这两者各自的标识。示例性的,用户添加的启动参数可以为:javaagent:agent.jar、spring-boot-demo-consumer.jar和spring-boot-demo-provider.jar。
其中,agent.jar为字节码增强包,通过其可以实现对注册和配置的拦截增强,以实现本申请实施例中所描述的方法。对于拦截增强,如图5所示,图5的(A)中未执行拦截增强,此时,在调用method这一方法时,是直接调用的;图5的(B)中执行了拦截增强,此时在调用method这一方法时,可以通过agent对方法拦截增强,这样可以在method调用前后各增加了前置方法(premethod)与后置方法(aftermethod),即通过增强后可在method前后增加额外的处理逻辑,比如增加双注册的逻辑和配置迁移的逻辑等。由此以实现基于agent开发,通过无侵入的方式执行注册中心与配置中心迁移,不依赖第三方组件,且不需要对微服务的原始代码进行改造,减少了迁移工作量。spring-boot-demo-consumer.jar为与consumer微服务关联的业务应用包,通过其可以在云平台中配置consumer微服务。spring-boot-demo-provider.jar为与provider微服务关联的业务应用包,通过其可以在云平台中配置provider微服务。在一些实施例中,当用户只需迁移一个微服务时,其可以只上传一个与该微服务关联的业务应用包。当用户需要迁移多个微服务时,其可以同时上传这多个微服务各自所关联的业务应用包,也可以分时上传,比如可以在T1时刻上传一个微服务所关联的业务应用包,在T1时刻之后的T2时刻上传另一个微服务所关联的业务应用包,具体可根据实际情况而定,此处不做限定。另外,用户也可以先在云平台中添加启动参数,以及,添加Service Center注册中心和Kie配置中心这两者各自的标识;然后,在启动Service Center注册中心和Kie配置中心,具体可根据实际情况而定,此处不做限定。
进一步地,用户在云平台上完成相应的配置后,可以下发用户触发微服务迁移的指令。如图6所示,云平台在获取到用户下发的指令后,可以携带Java agent启动consumer微服务。为便于描述,将云平台携带Java agent启动的consumer微服务称之为“consumer`微服务”。接着,云平台可以将consumer`微服务同时注册至Nacos注册中心和Service Center注册中心。然后,云平台可以从Nacos配置中心获取与Nacos注册中心和Nacos配置中心适配的consumer微服务的微服务配置信息。接着,云平台可以对其获取到微服务配置信息进行类型转换,以得到与Kie配置中心适配的微服务配置信息。接着,云平台可以将转换后的微服务配置信息发送至Kie配置中心。之后,当有流量进入时,consumer`微服务可以发现provider微服务,并可以调用provider微服务。这样就完成了对consumer微服务的初步迁移。其中,图6中的虚线线条代表的是图4中所描述的初始场景中的交互情况。
在完成consumer微服务的迁移后,如图7所示,云平台可以携带Java agent启动provider微服务。为便于描述,将云平台携带Java agent启动的provider微服务称之为“provider`微服务”。接着,云平台可以将provider`微服务同时注册至Nacos注册中心和Service Center注册中心。然后,云平台可以从Nacos配置中心获取与Nacos注册中心和Nacos配置中心适 配的provider微服务的微服务配置信息。接着,云平台可以对其获取到微服务配置信息进行格式转换,以得到与Kie配置中心适配的微服务配置信息。接着,云平台可以将转换后的微服务配置信息发送至Kie配置中心。之后,当有流量进入时,consumer`微服务可以发现provider`微服务,并可以调用provider`微服务。这样就完成了对provider微服务的初步迁移。其中,图7中的虚线线条代表的是图4中所描述的初始场景中的交互情况。
进一步地,在完成对consumer微服务和provider微服务的初步迁移之后,当有流量进入时,consumer`微服务可以通过负载均衡的方式确定其是调用provider微服务,还是调用provider`微服务。
当consumer`微服务和provider`微服务稳定运行一段时间后,可以下线初始场景中的consumer微服务和provider微服务。此时的场景可以如图8所示。当然,也可以继续保留初始场景中的consumer微服务和provider微服务,具体可根据实际情况而定,此处不做限定。
进一步地,用户可以通过Kie配置中心向云平台下发微服务订阅策略和配置监听策略。之后,云平台可以屏蔽consumer`微服务与Nacos注册中心和Nacos配置中心的交互,以及,屏蔽provider`微服务与Nacos注册中心和Nacos配置中心的交互。此时则最终完成对consumer微服务和provider微服务的迁移。这时的场景则由图4中所示的初始场景可以切换为图9中所示的场景。
接下来,对本申请实施例提供的一种微服务迁移装置进行介绍。该微服务迁移装置主要是基于前述图3中所描述的微服务迁移方法提出。
示例性的,图10示出了一种微服务迁移装置。该装置可以部署于云平台。该云平台可以用于管理提供微服务的实例。如图10所示,该微服务迁移装置1000可以包括:通信模块1001和处理模块1002。其中,通信模块1001用于从第一实例运行的第一配置中心获取存储的目标微服务的第一微服务配置信息。处理模块1002用于基于第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息。处理模块1002还用于将第二微服务配置信息发送至运行在第二实例上的第二配置中心,第二配置中心用于存储迁移后的目标微微服务的配置信息。
在一些实施例中,处理模块1002在基于第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息时,具体用于:对目标微服务的第一微服务配置信息进行格式转换,生成与第二配置中心的微服务类型对应的第二微服务配置信息。
在一些实施例中,处理模块1002,还用于:响应于第一下线指令,下线第一配置中心。
在一些实施例中,处理模块1002在将第二微服务配置信息发送至运行在第二实例上的第二配置中心前,还用于:获取第二实例与第一配置中心的对应关系;基于第二微服务配置信息和对应关系,创建用于运行第二配置中心的第二实例。
在一些实施例中,处理模块1002在获取第二实例与第一配置中心的对应关系时,具体用于:获取第二实例的标识与第一配置中心的对应关系,其中,标识包括互联网协议IP地址和/或实例ID。
在一些实施例中,处理模块1002,还用于:提供第一配置接口,第一配置接口用于接收用户设置的配置中心管理策略,配置中心管理策略用于将目标微服务的配置监听由第一配置中心切换至第二配置中心。
在一些实施例中,第一配置中心的服务类型与第二配置中心的服务类型不同。
在一些实施例中,处理模块1002在根据第一配置中心存储的目标微服务的第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息前,还用于:提供第二配置接口,第二配置接口用于接收用户设置的第二配置中心的服务类型。
在一些实施例中,通信模块1001,还用于向第一注册中心发送第一微服务注册请求,第一微服务注册请求用于请求在第一注册中心对迁移后的目标微服务进行注册,目标微服务在第一注册中心进行了微服务注册。通信模块1001,还用于向运行在第三实例上的第二注册中心发送第二微服务注册请求,第二微服务注册请求用于请求在第二注册中心对迁移后的目标微服务进行注册。
在一些实施例中,处理模块1002,还用于:响应于第二下线指令,下线第一注册中心。
在一些实施例中,第一微服务配置信息包括以下一项或多项:目标微服务的启动参数、目标微服务的标识、与目标微服务相关的线程数、与目标微服务相关的缓存大小、活动数据、黑名单、白名单。
在一些实施例中,其中,通信模块1001和处理模块1002均可以通过软件实现,或者可以通过硬件实现。示例性的,接下来以通信模块1001为例,介绍通信模块1001的实现方式。类似的,处理模块1002的实现方式可以参考通信模块1001的实现方式。
模块作为软件功能单元的一种举例,通信模块1001可以包括运行在计算实例上的代码。其中,计算实例可以包括物理主机(计算设备)、虚拟机、容器中的至少一种。进一步地,上述计算实例可以是一台或者多台。例如,通信模块1001可以包括运行在多个主机/虚拟机/容器上的代码。需要说明的是,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的区域(region)中,也可以分布在不同的region中。进一步地,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的可用区(availability zone,AZ)中,也可以分布在不同的AZ中,每个AZ包括一个数据中心或多个地理位置相近的数据中心。其中,通常一个region可以包括多个AZ。
同样,用于运行该代码的多个主机/虚拟机/容器可以分布在同一个虚拟私有云(virtual private cloud,VPC)中,也可以分布在多个VPC中。其中,通常一个VPC设置在一个region内,同一region内两个VPC之间,以及不同region的VPC之间跨区通信需在每个VPC内设置通信网关,经通信网关实现VPC之间的互连。
模块作为硬件功能单元的一种举例,通信模块1001可以包括至少一个计算设备,如服务器等。或者,通信模块1001也可以是利用专用集成电路(application-specific integrated circuit,ASIC)实现、或可编程逻辑器件(programmable logicdevice,PLD)实现的设备等。其中,上述PLD可以是复杂程序逻辑器件(complex programmable logical device,CPLD)、现场可编程门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合实现。
通信模块1001包括的多个计算设备可以分布在相同的region中,也可以分布在不同的region中。通信模块1001包括的多个计算设备可以分布在相同的AZ中,也可以分布在不同的AZ中。同样,通信模块1001包括的多个计算设备可以分布在同一个VPC中,也可以分布在多个VPC中。其中,所述多个计算设备可以是服务器、ASIC、PLD、CPLD、FPGA和GAL等计算设备的任意组合。
需要说明的是,在其他实施例中,通信模块1001可以用于执行前述所描述的微服务迁移方法中的任意步骤,处理模块1002可以用于执行上述实施例提供的方法中的任意步骤,通信 模块1001和处理模块1002负责实现的步骤可根据需要指定,通过通信模块1001和处理模块1002分别实现上述实施例提供的方法中不同的步骤来实现配置迁移装置1000的全部功能。
本申请还提供一种计算设备1100。如图11所示,计算设备1100包括:总线1102、处理器1104、存储器1106和通信接口1108。处理器1104、存储器1106和通信接口1108之间通过总线1102通信。计算设备1100可以是服务器或终端设备。应理解,本申请不限定计算设备1100中的处理器、存储器的个数。
总线1102可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图11中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。总线1104可包括在计算设备1100各个部件(例如,存储器1106、处理器1104、通信接口1108)之间传送信息的通路。
处理器1104可以包括中央处理器(central processing unit,CPU)、图形处理器(graphics processing unit,GPU)、微处理器(micro processor,MP)或者数字信号处理器(digital signal processor,DSP)等处理器中的任意一种或多种。
存储器1106可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。处理器104还可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器,机械硬盘(hard disk drive,HDD)或固态硬盘(solid state drive,SSD)。
存储器1106中存储有可执行的程序代码,处理器1104执行该可执行的程序代码以分别实现前述通信模块1001和处理模块1002的功能,从而实现上述实施例中方法的全部或部分步骤。也即,存储器1106上存有用于执行上述实施例方法中全部或部分步骤的指令。
或者,存储器1106中存储有可执行的代码,处理器1104执行该可执行的代码以分别实现前述微服务迁移装置1000的功能,从而实现上述实施例方法中全部或部分步骤。也即,存储器1106上存有用于执行上述实施例方法中全部或部分步骤的指令。
通信接口1103使用例如但不限于网络接口卡、收发器一类的收发模块,来实现计算设备100与其他设备或通信网络之间的通信。
本申请实施例还提供了一种计算设备集群。该计算设备集群包括至少一台计算设备。该计算设备可以是服务器,例如是中心服务器、边缘服务器,或者是本地数据中心中的本地服务器。在一些实施例中,计算设备也可以是台式机、笔记本电脑或者智能手机等终端设备。
如图12所示,所述计算设备集群包括至少一个计算设备1100。计算设备集群中的一个或多个计算设备1100中的存储器1106中可以存有相同的用于执行上述实施例方法中全部或部分步骤的指令。
在一些可能的实现方式中,该计算设备集群中的一个或多个计算设备1100的存储器1106中也可以分别存有用于执行上述实施例方法中全部或部分步骤的部分指令。换言之,一个或多个计算设备1100的组合可以共同执行用于执行上述实施例方法中全部或部分步骤的指令。
需要说明的是,计算设备集群中的不同的计算设备1100中的存储器1106可以存储不同的指令,分别用于执行微服务迁移装置1000的部分功能。也即,不同的计算设备1100中的存储器1106存储的指令可以实现前述通信模块1001和处理模块1002中的一个或多个模块的 功能。
在一些可能的实现方式中,计算设备集群中的一个或多个计算设备可以通过网络连接。其中,所述网络可以是广域网或局域网等等。
基于上述实施例中的方法,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,当计算机程序在处理器上运行时,使得处理器执行上述实施例中的方法。
基于上述实施例中的方法,本申请实施例提供了一种计算机程序产品,当计算机程序产品在处理器上运行时,使得处理器执行上述实施例中的方法。
可以理解的是,本申请的实施例中的处理器可以是中央处理单元(central processing unit,CPU),还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件,硬件部件或者其任意组合。通用处理器可以是微处理器,也可以是任何常规的处理器。
本申请的实施例中的方法步骤可以通过硬件的方式来实现,也可以由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于随机存取存储器(random access memory,RAM)、闪存、只读存储器(read-only memory,ROM)、可编程只读存储器(programmable rom,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)、寄存器、硬盘、移动硬盘、CD-ROM或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者通过所述计算机可读存储介质进行传输。所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。
可以理解的是,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。

Claims (26)

  1. 一种微服务迁移方法,其特征在于,所述方法应用于云平台,所述云平台用于管理提供微服务的实例,所述方法包括:
    从第一实例运行的第一配置中心获取存储的目标微服务的第一微服务配置信息;
    基于所述第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息;
    将所述第二微服务配置信息发送至运行在第二实例上的第二配置中心,所述第二配置中心用于存储迁移后的目标微微服务的配置信息。
  2. 根据权利要求1所述的方法,其特征在于,所述基于所述第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息,包括:
    对所述目标微服务的第一微服务配置信息进行格式转换,生成与所述第二配置中心的微服务类型对应的所述第二微服务配置信息。
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:
    响应于第一下线指令,下线所述第一配置中心。
  4. 根据权利要求1至3中任一所述的方法,其特征在于,所述将所述第二微服务配置信息发送至运行在第二实例上的第二配置中心前,所述方法还包括:
    获取所述第二实例与第一配置中心的对应关系;
    基于所述第二微服务配置信息和所述对应关系,创建所述第二实例。
  5. 根据权利要求4所述的方法,其特征在于,所述获取所述第二实例与第一配置中心的对应关系,包括:
    获取所述第二实例的标识与所述第一配置中心的对应关系,其中,所述标识包括互联网协议IP地址和/或实例ID。
  6. 根据权利要求1至5中任一所述的方法,其特征在于,所述方法还包括:
    提供第一配置接口,所述第一配置接口用于接收用户设置的配置中心管理策略,所述配置中心管理策略用于将所述目标微服务的配置监听由所述第一配置中心切换至所述第二配置中心。
  7. 根据权利要求1至6中任一所述的方法,其特征在于,所述第一配置中心的服务类型与所述第二配置中心的服务类型不同。
  8. 根据权利要求7中所述的方法,其特征在于,所述根据所述第一配置中心存储的目标微服务的第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息前,所述方法还包括:
    提供第二配置接口,所述第二配置接口用于接收所述用户设置的所述第二配置中心的服务类型。
  9. 根据权利要求1至7中任一所述的方法,其特征在于,所述方法还包括:
    向第一注册中心发送第一微服务注册请求,所述第一微服务注册请求用于请求在所述第一注册中心对所述迁移后的目标微服务进行注册,所述目标微服务在所述第一注册中心进行了微服务注册;
    向运行在第三实例上的第二注册中心发送第二微服务注册请求,所述第二微服务注册请求用于请求在所述第二注册中心对所述迁移后的目标微服务进行注册。
  10. 根据权利要求9所述的方法,其特征在于,所述方法还包括:
    响应于第二下线指令,下线所述第一注册中心。
  11. 根据权利要求1至10中任一所述的方法,其特征在于,所述第一微服务配置信息包括以下一项或多项:
    所述目标微服务的启动参数、所述目标微服务的标识、与所述目标微服务相关的线程数、与所述目标微服务相关的缓存大小、活动数据、黑名单、白名单。
  12. 一种微服务迁移装置,其特征在于,部署于云平台,所述云平台用于管理提供微服务的实例,所述装置包括:
    通信模块,用于从第一实例运行的第一配置中心获取存储的目标微服务的第一微服务配置信息;
    处理模块,用于基于所述第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息;
    所述处理模块,还用于将所述第二微服务配置信息发送至运行在第二实例上的第二配置中心,所述第二配置中心用于存储迁移后的目标微微服务的配置信息。
  13. 根据权利要求12所述的装置,其特征在于,所述处理模块在基于所述第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息时,具体用于:
    对所述目标微服务的第一微服务配置信息进行格式转换,生成与所述第二配置中心的微服务类型对应的所述第二微服务配置信息。
  14. 根据权利要求12或13所述的装置,其特征在于,所述处理模块,还用于:
    响应于第一下线指令,下线所述第一配置中心。
  15. 根据权利要求12至14中任一所述的装置,其特征在于,所述处理模块在将所述第二微服务配置信息发送至运行在第二实例上的第二配置中心前,还用于:
    获取所述第二实例与第一配置中心的对应关系;
    基于所述第二微服务配置信息和所述对应关系,创建用于运行第二配置中心的所述第二实例。
  16. 根据权利要求15所述的装置,其特征在于,所述处理模块在获取所述第二实例与第一配置中心的对应关系时,具体用于:
    获取所述第二实例的标识与所述第一配置中心的对应关系,其中,所述标识包括互联网协议IP地址和/或实例ID。
  17. 根据权利要求12至16中任一所述的装置,其特征在于,所述处理模块,还用于:
    提供第一配置接口,所述第一配置接口用于接收用户设置的配置中心管理策略,所述配置中心管理策略用于将所述目标微服务的配置监听由所述第一配置中心切换至所述第二配置中心。
  18. 根据权利要求12至17中任一所述的装置,其特征在于,所述第一配置中心的服务类型与所述第二配置中心的服务类型不同。
  19. 根据权利要求18中所述的装置,其特征在于,所述处理模块在根据所述第一配置中心存储的目标微服务的第一微服务配置信息,生成迁移后的目标微服务的第二微服务配置信息前,还用于:
    提供第二配置接口,所述第二配置接口用于接收所述用户设置的所述第二配置中心的服务类型。
  20. 根据权利要求12至19中任一所述的装置,其特征在于,
    所述通信模块,还用于向第一注册中心发送第一微服务注册请求,所述第一微服务注册请求用于请求在所述第一注册中心对所述迁移后的目标微服务进行注册,所述目标微服务在所述第一注册中心进行了微服务注册;
    所述通信模块,还用于向运行在第三实例上的第二注册中心发送第二微服务注册请求,所述第二微服务注册请求用于请求在所述第二注册中心对所述迁移后的目标微服务进行注册。
  21. 根据权利要求20所述的装置,其特征在于,所述处理模块,还用于:
    响应于第二下线指令,下线所述第一注册中心。
  22. 根据权利要求12至21中任一所述的装置,其特征在于,所述第一微服务配置信息包括以下一项或多项:
    所述目标微服务的启动参数、所述目标微服务的标识、与所述目标微服务相关的线程数、与所述目标微服务相关的缓存大小、活动数据、黑名单、白名单。
  23. 一种计算设备,其特征在于,包括:
    至少一个存储器,用于存储程序;
    至少一个处理器,用于执行所述存储器存储的程序;
    其中,当所述存储器存储的程序被执行时,所述处理器用于执行如权利要求1-11任一所述的方法。
  24. 一种计算设备集群,其特征在于,包括至少一个计算设备,每个计算设备均包括处理器和存储器;
    所述至少一个计算设备的处理器用于执行所述至少一个计算设备的存储器中存储的指令,以使得所述计算设备集群执行如权利要求1-11任一所述的方法。
  25. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,当所述计算机程序在处理器上运行时,使得所述处理器执行如权利要求1-11任一所述的方法。
  26. 一种计算机程序产品,其特征在于,当所述计算机程序产品在处理器上运行时,使得所述处理器执行如权利要求1-11任一所述的方法。
PCT/CN2023/079205 2022-06-23 2023-03-02 一种微服务迁移方法、装置及计算设备 WO2023246168A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202210718836 2022-06-23
CN202210718836.X 2022-06-23
CN202211311317.8A CN117311924A (zh) 2022-06-23 2022-10-25 一种微服务迁移方法、装置及计算设备
CN202211311317.8 2022-10-25

Publications (1)

Publication Number Publication Date
WO2023246168A1 true WO2023246168A1 (zh) 2023-12-28

Family

ID=89236089

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/079205 WO2023246168A1 (zh) 2022-06-23 2023-03-02 一种微服务迁移方法、装置及计算设备

Country Status (2)

Country Link
CN (1) CN117311924A (zh)
WO (1) WO2023246168A1 (zh)

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107294781A (zh) * 2017-06-30 2017-10-24 郑州云海信息技术有限公司 一种集群配置节点故障转移的方法及系统
CN107872525A (zh) * 2017-11-09 2018-04-03 杭州东方通信软件技术有限公司 一种微服务调用架构
CN108255574A (zh) * 2017-12-05 2018-07-06 顺丰科技有限公司 一种虚拟机迁移方法及装置
US20190171433A1 (en) * 2017-12-01 2019-06-06 Adp, Llc Methods for enabling a computer to migrate microservices and to perform microservice templating
CN110535947A (zh) * 2019-08-30 2019-12-03 苏州浪潮智能科技有限公司 一种存储设备集群配置节点切换方法、装置及设备
CN111913938A (zh) * 2020-08-11 2020-11-10 中国工商银行股份有限公司 数据迁移方法、系统、装置、电子设备和介质
CN112069129A (zh) * 2020-09-18 2020-12-11 浪潮云信息技术股份公司 基于国产cpu的配置文件格式转换方法、装置及介质
CN112765188A (zh) * 2020-12-31 2021-05-07 北京奇艺世纪科技有限公司 配置信息处理方法、配置管理系统、电子设备及存储介质
CN113626095A (zh) * 2021-06-29 2021-11-09 欧电云信息科技(江苏)有限公司 配置中心的切换方法、切换系统、电子设备及存储介质
CN113938520A (zh) * 2021-08-31 2022-01-14 阿里巴巴(中国)有限公司 一种服务注册方法、设备及存储介质
CN114047939A (zh) * 2021-11-10 2022-02-15 湖南快乐阳光互动娱乐传媒有限公司 一种数据处理方法及中间件
CN114138504A (zh) * 2021-11-15 2022-03-04 百果园技术(新加坡)有限公司 多注册中心的数据处理方法、装置、设备和存储介质
CN114640657A (zh) * 2020-12-16 2022-06-17 北京国双科技有限公司 多注册中心的融合方法、装置

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107294781A (zh) * 2017-06-30 2017-10-24 郑州云海信息技术有限公司 一种集群配置节点故障转移的方法及系统
CN107872525A (zh) * 2017-11-09 2018-04-03 杭州东方通信软件技术有限公司 一种微服务调用架构
US20190171433A1 (en) * 2017-12-01 2019-06-06 Adp, Llc Methods for enabling a computer to migrate microservices and to perform microservice templating
CN108255574A (zh) * 2017-12-05 2018-07-06 顺丰科技有限公司 一种虚拟机迁移方法及装置
CN110535947A (zh) * 2019-08-30 2019-12-03 苏州浪潮智能科技有限公司 一种存储设备集群配置节点切换方法、装置及设备
CN111913938A (zh) * 2020-08-11 2020-11-10 中国工商银行股份有限公司 数据迁移方法、系统、装置、电子设备和介质
CN112069129A (zh) * 2020-09-18 2020-12-11 浪潮云信息技术股份公司 基于国产cpu的配置文件格式转换方法、装置及介质
CN114640657A (zh) * 2020-12-16 2022-06-17 北京国双科技有限公司 多注册中心的融合方法、装置
CN112765188A (zh) * 2020-12-31 2021-05-07 北京奇艺世纪科技有限公司 配置信息处理方法、配置管理系统、电子设备及存储介质
CN113626095A (zh) * 2021-06-29 2021-11-09 欧电云信息科技(江苏)有限公司 配置中心的切换方法、切换系统、电子设备及存储介质
CN113938520A (zh) * 2021-08-31 2022-01-14 阿里巴巴(中国)有限公司 一种服务注册方法、设备及存储介质
CN114047939A (zh) * 2021-11-10 2022-02-15 湖南快乐阳光互动娱乐传媒有限公司 一种数据处理方法及中间件
CN114138504A (zh) * 2021-11-15 2022-03-04 百果园技术(新加坡)有限公司 多注册中心的数据处理方法、装置、设备和存储介质

Also Published As

Publication number Publication date
CN117311924A (zh) 2023-12-29

Similar Documents

Publication Publication Date Title
US11206451B2 (en) Information interception processing method, terminal, and computer storage medium
US11296960B2 (en) Monitoring distributed applications
WO2020186909A1 (zh) 虚拟网络业务处理方法、装置和系统,控制器,存储介质
JP5961718B2 (ja) ミドルボックスを備えるネットワークのアーキテクチャ
US20200366572A1 (en) Detect and enforce api slas using cloud access api broker
US11509522B2 (en) Synchronization of logical network state between global and local managers
JP2019528005A (ja) クラウドコンピューティングシステムにおいて仮想マシンが物理サーバにアクセスするための方法、装置、およびシステム
US11310345B2 (en) Displaying a service graph of microservices based on a ring of criticality
WO2017128710A1 (zh) 一种端口重定向的方法、服务器和系统
US11432137B2 (en) Service notification method for mobile edge host and apparatus
JP2014525204A (ja) 仮想ネットワーク内のパケットロスを最小化する仮想マシンマイグレーション
CN111585887B (zh) 基于多个网络的通信方法、装置、电子设备及存储介质
CN105359176B (zh) 更新先前递送的电子消息的接收者
CN106331065A (zh) 一种用于具有服务容器的主机系统的代理应用以及系统
US9591079B2 (en) Method and apparatus for managing sessions of different websites
WO2021068205A1 (zh) 访问控制方法、装置、服务器和计算机可读介质
US10204122B2 (en) Implementing an interface between tuple and message-driven control entities
US20240022629A1 (en) Kubernetes cluster load balance handling method and apparatus, and storage mediun
WO2021103657A1 (zh) 网络操作方法、装置、设备和存储介质
US20240015093A1 (en) Dynamic api gateway routing based on request metadata
WO2023246168A1 (zh) 一种微服务迁移方法、装置及计算设备
WO2024045646A1 (zh) 管理集群访问权限的方法、装置和系统
CN112491794A (zh) 一种端口转发方法、装置及相关设备
US20200366571A1 (en) Displaying a service graph of microservices based at least on a namespace
US20230077698A1 (en) Interspersed message batching in a database system

Legal Events

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

Ref document number: 23825826

Country of ref document: EP

Kind code of ref document: A1