A method and device for deploying microservices, and electronic equipment

By obtaining the source code, script files and docker image package files of the microservice for compression processing, automated deployment under the Linux operating system is achieved, solving the problems of large deployment workload and high professional requirements in the existing technology, and improving deployment efficiency.

CN111352635BActive Publication Date: 2024-12-17SHENZHEN HONGHE INNOVATION INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910305767.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-16
Publication Date
2024-12-17
Estimated Expiration
2039-04-16

AI Technical Summary

Technical Problem

Under the microservice architecture, software installation packages under the Linux system need to be manually compiled, packaged and installed, resulting in large deployment workloads and high professional requirements, and lack of automated construction and deployment processes.

Method used

By compiling and generating jar packages by obtaining the source code of microservices, obtaining script files and docker image package files, performing compression processing to generate compressed packages, and decompressing and installing and configuring microservices under the Linux operating system to achieve an automated deployment process.

Benefits of technology

It greatly reduces the packaging, construction and deployment workload of development and maintenance personnel, reduces the professional requirements of operators, and realizes the automated construction and deployment of microservices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111352635B_ABST
    Figure CN111352635B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for deploying microservices, and an electronic device, including: obtaining the source code of the microservice, compiling the source code to generate a jar package; obtaining a script file corresponding to the microservice, the script file being used to install, configure, and manage the microservice; obtaining a docker image package file corresponding to the microservice; compressing the jar package, the script file, and the docker image package file to generate a compressed package of the microservice; transmitting the compressed package of the microservice to a host installed with a Linux operating system, and decompressing, installing, and configuring the microservice under the Linux operating system. The present invention can realize the automated construction and deployment of microservices, and reduce the workload and complexity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of operating system technology, and in particular to a method and device for deploying microservices, and an electronic device. Background Art

[0002] In the microservice architecture, there are a large number of microservices that need to be deployed. Packaging microservices into Docker images and implementing the functions of microservices by building, starting, and running Docker containers is a common deployment method.

[0003] At present, software installation packages under Linux systems generally need to be compiled, packaged, installed and run under Linux systems. Running Docker containers under Linux systems is generally achieved by executing commands to build Docker images and start Docker containers. The workload of packaging, building, installing and deploying is large and requires high professionalism. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a method and device for building an installation package, and an electronic device, which can realize the automatic construction and deployment process of microservices.

[0005] Based on the above objectives, the present invention provides a method for deploying microservices, including:

[0006] Obtain the source code of the microservice, and compile the source code to generate a jar package;

[0007] Obtain a script file corresponding to the microservice, where the script file is used to install, configure, and manage the microservice;

[0008] Get the Docker image package file corresponding to the microservice;

[0009] Compress the jar package, script file, and docker image package file to generate a compressed package of the microservice;

[0010] The compressed package of the microservice is transmitted to a host computer with a Linux operating system installed, and the compressed package of the microservice is decompressed, installed and configured under the Linux operating system.

[0011] Optionally, the method further includes: obtaining the source code of the front-end page, compiling the source code of the front-end page to generate an html file, compressing the jar package, html file, script file, and docker image package file to generate a compressed package of the microservice.

[0012] Optionally, under the Linux operating system, the compressed package of the microservice is decompressed and the script file is executed to install and configure the microservice.

[0013] Optionally, under the Linux operating system, the configuration file of the microservice is externally mounted on a corresponding docker container.

[0014] An embodiment of the present invention further provides a device for deploying microservices, including:

[0015] The first acquisition module is used to obtain the source code of the microservice and compile the source code to generate a jar package;

[0016] A second acquisition module is used to acquire a script file corresponding to the microservice, where the script file is used to install, configure, and manage the microservice;

[0017] The third acquisition module is used to obtain the Docker image package file corresponding to the microservice;

[0018] A compression module is used to compress the jar package, script file, and docker image package file to generate a compressed package of the microservice;

[0019] The sending module is used to transmit the compressed package of the microservice to a host installed with a Linux operating system, decompress the compressed package of the microservice under the Linux operating system, and install and configure the microservice.

[0020] Optionally, the device further comprises:

[0021] A fourth acquisition module, when the microservice includes a front-end page, is used to acquire the source code of the front-end page, and compile the source code of the front-end page to generate an HTML file;

[0022] The compression module is used to compress the jar package, html file, script file, and docker image package file to generate a compressed package of the microservice.

[0023] Optionally, under the Linux operating system, the compressed package of the microservice is decompressed and the script file is executed to install and configure the microservice.

[0024] Optionally, under the Linux operating system, the configuration file of the microservice is externally mounted on a corresponding docker container.

[0025] An embodiment of the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the method for deploying microservices is implemented when the processor executes the program.

[0026] From the above, it can be seen that the method, device and electronic device for deploying microservices provided by the present invention obtain the source code of the microservice, compile the source code to generate a jar package, obtain the script file corresponding to the microservice, obtain the docker image package file corresponding to the microservice, compress the jar package, the script file and the docker image package file to generate a compressed package of the microservice; then transmit the compressed package of the microservice to the host with the Linux operating system installed, decompress the compressed package of the microservice under the Linux operating system, install and configure the microservice. The present invention can automatically build an installation package of the microservice on the first host, and install and deploy the microservice based on the installation package under the Linux operating system, thereby greatly reducing the packaging, construction and deployment workload of developers and maintenance personnel, and reducing the professional requirements of operators. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0028] Figure 1 A schematic diagram of a method flow chart of an embodiment of the present invention;

[0029] Figure 2 is a schematic diagram of the structure of a device according to an embodiment of the present invention;

[0030] Figure 3 This is a schematic diagram of the structure of a docker container according to an embodiment of the present invention;

[0031] Figure 4 4 is a system architecture block diagram of an embodiment of the present invention. DETAILED DESCRIPTION

[0032] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.

[0033] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. The subsequent embodiments will not explain this one by one.

[0034] The method for deploying microservices provided by an embodiment of the present invention includes:

[0035] Get the source code of the microservice and compile it to generate a jar package;

[0036] Get the script file corresponding to the microservice;

[0037] Get the docker image package file corresponding to the microservice;

[0038] Compress the jar package, script file, and docker image package file to generate a compressed package of the microservice;

[0039] The compressed package of the microservice is transferred to a host computer with a Linux operating system installed, the compressed package of the microservice is decompressed under the Linux operating system, and the microservice is installed and configured.

[0040] The method for deploying microservices in an embodiment of the present invention can generate a compressed package of the microservice on a first host installed with a first operating system, transmit the compressed package of the microservice to a second host installed with a Linux operating system, and deploy the microservice on the second host using the compressed package of the microservice. The first operating system is different from the Linux operating system. The first host downloads the source code of the microservice from the source code version control system, compiles the source code to generate a jar package using a compilation tool, obtains the script file corresponding to the microservice, obtains the docker image package file corresponding to the microservice, compresses the jar package, the script file, and the docker image package file together to generate a compressed package of the microservice; the first host transmits the compressed package of the microservice to the second host, and performs decompression, installation, and startup operations under the Linux operating system to implement the deployment of the microservice.

[0041] Figure 1 is a schematic diagram of a method flow of an embodiment of the present invention, Figure 4 The system architecture block diagram of the embodiment of the present invention is shown in the figure. As shown in the figure, the method for deploying microservices provided by the embodiment of the present invention includes:

[0042] S10: Obtain the source code of the microservice and compile the source code to generate a jar package;

[0043] In the embodiment of the present invention, the first host on which the first operating system is installed downloads the source code corresponding to the microservice from the source code version control system (Subversion, SVN), and compiles the source code using a compilation tool to generate a jar package.

[0044] The first operating system is, for example, a Windows operating system, which is installed with an automated deployment system, which automatically downloads source code from SVN and compiles the source code to generate a jar package. For a microservice with a front-end page source code, the source code is compiled to generate an html file corresponding to the page.

[0045] Automated deployment systems include Jenkins, gradle, ant, maven, etc. It is beneficial to the automated deployment system to set a scheduled build task. When the build task time arrives, the source code is automatically obtained from SVN and the task is automatically built according to the source code.

[0046] S11: Get the script file corresponding to the microservice;

[0047] Download and obtain the script file corresponding to the microservice from SVN. The script file is used to install, configure and manage the corresponding microservice.

[0048] S12: Get the docker image package file corresponding to the microservice;

[0049] Download and obtain the docker image package file from SVN. The docker image package file is pre-generated under the Linux operating system and then uploaded to SVN.

[0050] S13: compress the jar package, script file, and docker image package file to generate a compressed package of the microservice;

[0051] The data files prepared by the above preprocessing, the jar package, script files, docker image package files of the microservice, and if there is a front-end page, the compiled html files are also compressed together to generate a compressed package of the microservice.

[0052] S14: The compressed package of the microservice is transferred to the Linux system, the compressed package of the microservice is decompressed in the Linux system, and the microservice is installed and configured.

[0053] After the first host generates a compressed package of the microservice, it transmits the compressed package of the microservice to the second host installed with the Linux operating system. There are many ways of data transmission, for example, the second host downloads the compressed package of the microservice from the first host through the ftp protocol or the http protocol.

[0054] The second host obtains the compressed package of the microservice, decompresses the compressed package, executes the script file, and installs and configures the microservice.

[0055] Figure 3It is a schematic diagram of the structure of the Docker container of the embodiment of the present invention. As shown in the figure, in the embodiment of the present invention, the configuration file of the microservice is externally mounted on the corresponding docker container. When the docker container is started and run, it is mounted and started by executing the command (docker run-v). With the plug-in method, when the microservice needs to be upgraded, the new version of the jar package and / or the html file of the front-end page can be directly packaged and compiled, and the new version of the jar package and / or html file can be replaced with the current version of the jar package and / or html file without packaging the docker container, which can achieve rapid upgrade; when the configuration file of the microservice needs to be modified, it can be modified directly outside the docker container without operating the docker container, reducing complexity.

[0056] Figure 2 is a schematic diagram of the device structure of an embodiment of the present invention, Figure 4 The system architecture block diagram of an embodiment of the present invention is shown in the figure. As shown in the figure, the device for deploying microservices provided by the embodiment of the present invention includes:

[0057] The first acquisition module is used to obtain the source code of the microservice and compile the source code to generate a jar package;

[0058] The second acquisition module is used to obtain the script file corresponding to the microservice;

[0059] The third acquisition module is used to obtain the Docker image package file corresponding to the microservice;

[0060] A compression module is used to compress the jar package, script file, and docker image package file to generate a compressed package of the microservice;

[0061] The sending module is used to transmit the compressed package of the microservice to a host installed with a Linux operating system, decompress the compressed package of the microservice under the Linux operating system, and install and configure the microservice.

[0062] The device for deploying microservices according to the embodiment of the present invention can generate a compressed package of the microservices on a first host installed with a first operating system, transmit the compressed package of the microservices to a second host installed with a Linux operating system, and deploy the microservices on the second host based on the compressed package of the microservices. The first operating system is different from the Linux operating system, the first acquisition module downloads and obtains the source code of the microservices from the source code version control system, uses the compilation tool to compile the source code to generate a jar package, the second acquisition module obtains the script file corresponding to the microservice, the third acquisition module obtains the docker image package file corresponding to the microservice, the compression module compresses the jar package, the script file, and the docker image package file together to generate a compressed package of the microservice; the sending module transmits the compressed package of the microservices to the second host, and performs decompression, installation, and startup operations based on the compressed package of the microservices under the Linux operating system to realize the deployment of the microservices.

[0063] In the embodiment of the present invention, the first acquisition module downloads the source code corresponding to the microservice from the source code version control system (Subversion, SVN), and uses a compilation tool to compile the source code to generate a jar package.

[0064] The first operating system is, for example, a Windows operating system, which is installed with an automated deployment system, which automatically downloads source code from SVN and compiles the source code to generate a jar package. For a microservice with a front-end page source code, the source code is compiled to generate an html file corresponding to the page.

[0065] Automated deployment systems include Jenkins, gradle, ant, maven, etc. It is beneficial to the automated deployment system to set a scheduled build task. When the build task time arrives, the source code is automatically obtained from SVN and the task is automatically built according to the source code.

[0066] The second acquisition module downloads and acquires a script file corresponding to the microservice from the SVN, where the script file is used to install, configure, and manage the corresponding microservice.

[0067] The third acquisition module downloads and acquires the docker image package file from SVN. The docker image package file is pre-generated under the Linux operating system and then uploaded to the SVN.

[0068] The compression module compresses the various data files prepared by the above preprocessing, the jar package, script files, docker image package files of the microservice, and if there is a front-end page, the compiled html file, etc., to generate a compressed package of the microservice.

[0069] The device for deploying microservices according to an embodiment of the present invention further includes:

[0070] A fourth acquisition module, when the microservice includes a front-end page, is used to acquire the source code of the front-end page, and compile the source code of the front-end page to generate an HTML file;

[0071] The compression module is used to compress the jar package, html file, script file, and docker image package file to generate a compressed package of the microservice.

[0072] The sending module transmits the compressed package of the microservice to the second host on which the Linux operating system is installed. There are many ways of data transmission, for example, the second host downloads the compressed package of the microservice from the first host via the ftp protocol or the http protocol.

[0073] The second host obtains the compressed package of the microservice, decompresses the compressed package, executes the script file, and installs and configures the microservice.

[0074] Figure 3 It is a schematic diagram of the structure of the docker container of the embodiment of the present invention. As shown in the figure, in the embodiment of the present invention, the configuration file of the microservice is externally mounted on the corresponding docker container. When the docker container is started and run, it is mounted and started by executing the command (docker run-v). With the plug-in method, when the microservice needs to be upgraded, the new version of the jar package and / or the html file of the front-end page can be directly packaged and compiled, and the new version of the jar package and / or html file can be replaced with the current version of the jar package and / or html file without packaging the docker container, which can achieve rapid upgrade; when the configuration file of the microservice needs to be modified, it can be modified directly outside the docker container without operating the docker container, reducing complexity.

[0075] Based on the above purpose, an embodiment of the present invention further proposes an embodiment of a device for executing the method for deploying microservices. The device includes:

[0076] One or more processors and memory.

[0077] The device for executing the method for deploying microservices may further include: an input device and an output device.

[0078] The processor, memory, input device and output device may be connected via a bus or other means.

[0079] As a non-volatile computer-readable storage medium, the memory can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the method for deploying microservices in the embodiment of the present invention. The processor executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory, that is, the method for deploying microservices in the above method embodiment is implemented.

[0080] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created according to the use of the device for executing the method for deploying microservices, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the member user behavior monitoring device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0081] The input device can receive input digital or character information, and generate key signal input related to user settings and function control of the device for executing the method for deploying microservices. The output device can include display devices such as display screens.

[0082] The one or more modules are stored in the memory, and when executed by the one or more processors, the method for deploying microservices in any of the above method embodiments is executed. The embodiment of the device for executing the method for deploying microservices has the same or similar technical effect as any of the above method embodiments.

[0083] The embodiment of the present invention further provides a non-transitory computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the processing method of the list item operation in any of the above method embodiments. The embodiment of the non-transitory computer storage medium has the same or similar technical effect as any of the above method embodiments.

[0084] Finally, it should be noted that a person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. The technical effect of the embodiment of the computer program is the same or similar to that of any of the above-mentioned method embodiments.

[0085] In addition, typically, the devices and equipment described in the present disclosure may be various electronic terminal devices, such as mobile phones, personal digital assistants (PDAs), tablet computers (PADs), smart TVs, etc., or large terminal devices, such as servers, etc. Therefore, the protection scope of the present disclosure should not be limited to a specific type of device or equipment. The client described in the present disclosure may be applied to any of the above electronic terminal devices in the form of electronic hardware, computer software, or a combination of the two.

[0086] In addition, the method according to the present disclosure may also be implemented as a computer program executed by a CPU, and the computer program may be stored in a computer-readable storage medium. When the computer program is executed by the CPU, the above functions defined in the method of the present disclosure are performed.

[0087] In addition, the above method steps and system units may also be implemented using a controller and a computer-readable storage medium for storing a computer program that enables the controller to implement the above steps or unit functions.

[0088] In addition, it should be understood that the computer-readable storage medium (e.g., memory) described herein can be a volatile memory or a non-volatile memory, or can include both a volatile memory and a non-volatile memory. As an example and not by way of limitation, a non-volatile memory can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), or a flash memory. A volatile memory can include a random access memory (RAM), which can act as an external cache memory. As an example and not by way of limitation, RAM can be obtained in a variety of forms, such as synchronous RAM (DRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to include, but are not limited to, these and other suitable types of memory.

[0089] The apparatus of the above-mentioned embodiment is used to implement the corresponding method in the above-mentioned embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0090] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples. Within the scope of the present invention, the above embodiments or technical features in different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity.

[0091] In addition, to simplify the description and discussion, and in order not to obscure the present invention, known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided figures. In addition, the devices may be shown in the form of block diagrams to avoid obscuring the present invention, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the present invention will be implemented (i.e., these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present invention, it will be apparent to those skilled in the art that the present invention may be implemented without these specific details or with variations in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0092] Although the invention has been described in conjunction with specific embodiments of the invention, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.

[0093] The embodiments of the present invention are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for deploying microservices, applied to a first host on which a first operating system is installed, characterized in that: include: Obtain the source code of the microservice from the version control system, and compile the source code to generate a jar package; Obtain a script file corresponding to the microservice from a version control system, where the script file is used to install, configure, and manage the microservice; Obtain the docker image package file corresponding to the microservice; wherein the docker image package file is pre-generated under the Linux operating system and uploaded to the version control system; Compress the jar package, script file, and docker image package file to generate a compressed package of the microservice; The compressed package of the microservice is transmitted to a host computer with a Linux operating system installed, and the compressed package of the microservice is decompressed, installed and configured under the Linux operating system; wherein the first operating system is different from the Linux operating system.

2. The method according to claim 1, characterized in that If the microservice includes a front-end page, the method further includes: obtaining the source code of the front-end page, compiling the source code of the front-end page to generate an html file, compressing the jar package, html file, script file, and docker image package file to generate a compressed package of the microservice.

3. The method according to claim 1, characterized in that Under the Linux operating system, the compressed package of the microservice is decompressed and the script file is executed to install and configure the microservice.

4. The method according to claim 1, characterized in that: Under the Linux operating system, the configuration file of the microservice is externally mounted on the corresponding Docker container.

5. A device for deploying microservices, applied to a first host on which a first operating system is installed, characterized in that: include: The first acquisition module is used to obtain the source code of the microservice from the version control system and compile the source code to generate a jar package; A second acquisition module is used to obtain a script file corresponding to the microservice from a version control system, where the script file is used to install, configure, and manage the microservice; A third acquisition module is used to obtain the docker image package file corresponding to the microservice; wherein the docker image package file is pre-generated under the Linux operating system and uploaded to the version control system; A compression module is used to compress the jar package, script file, and docker image package file to generate a compressed package of the microservice; A sending module is used to transmit the compressed package of the microservice to a host installed with a Linux operating system, decompress the compressed package of the microservice under the Linux operating system, and install and configure the microservice; wherein the first operating system is different from the Linux operating system.

6. The device according to claim 5, characterized in that Also includes: A fourth acquisition module, when the microservice includes a front-end page, is used to acquire the source code of the front-end page, and compile the source code of the front-end page to generate an HTML file; The compression module is used to compress the jar package, html file, script file, and docker image package file to generate a compressed package of the microservice.

7. The device according to claim 5, characterized in that Under the Linux operating system, the compressed package of the microservice is decompressed and the script file is executed to install and configure the microservice.

8. The device according to claim 5, characterized in that Under the Linux operating system, the configuration file of the microservice is externally mounted on the corresponding Docker container.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 4 is implemented.