All Products
Search
Document Center

Microservices Engine:Connect microservice applications on ECS instances to Microservices Governance

Last Updated:Apr 09, 2024

You can connect microservice applications that are deployed in environments, such as Elastic Compute Service (ECS) instances and non-Alibaba Cloud virtual machines (VMs), to Microservices Governance of Microservices Engine (MSE). After the connection is established, you can use a series of microservices governance capabilities that are provided by MSE to govern the applications. This greatly improves the stability of online microservice applications and the development efficiency of microservice applications. This topic describes how to connect microservice applications that are deployed on ECS instances to Microservices Governance of MSE.

Prerequisites

  • An ECS instance is created. For more information, see Creation method overview.

  • Java Development Kit (JDK) is installed and environment variables are configured. For more information, see Java Downloads.

Procedure

To connect an application that is deployed on an ECS instance to Microservices Governance, perform the following steps:

Step 1: Download the MSE Java agent

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the top navigation bar, select a region.

  4. On the Instances page, find the instance that you want to connect and click Connect in the Actions column.

  5. In the Remote connection dialog box, select a connection method. For more information, see Connection methods.

  6. Download the MSE Java agent.

    URL for downloading the MSE Java agent from the Internet in each region:

    http://arms-apm-${regionId}.oss-${regionId}.aliyuncs.com/ms/AliyunJavaAgent.zip

    URL for downloading the MSE Java agent from a virtual private cloud (VPC) in each region:

    http://arms-apm-${regionId}.oss-${regionId}-internal.aliyuncs.com/ms/AliyunJavaAgent.zip

    Download the MSE Java agent by using shell scripts. The China (Hangzhou) region is used in this example.

    Note

    The content of the MSE Java agent varies with regions.

    • Command for downloading scripts from the Internet

      wget http://arms-apm-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/ms/AliyunJavaAgent.zip \
        -O AliyunJavaAgent.zip
    • Command for downloading scripts from a VPC: (used if the scripts cannot be downloaded from the Internet)

      wget http://arms-apm-cn-hangzhou.oss-cn-hangzhou-internal.aliyuncs.com/ms/AliyunJavaAgent.zip \
        -O AliyunJavaAgent.zip

Step 2: Install the MSE Java agent

Important

To install the MSE Java agent, you must make sure that at least 300 MB of memory space is reserved for the node on which you want to install the MSE Java agent.

Decompress and install the MSE Java agent package after it is downloaded.

  1. Decompress AliyunJavaAgent.zip to a random directory.

    unzip AliyunJavaAgent.zip -d /{user.workspace}/ 
    Note

    {user.workspace} specifies the directory used in this example. Replace {user.workspace} with the directory that you use.

  2. Add the mse.appName, mse.licenseKey, and profiler.micro.service.mse.version parameters to the application startup parameters.

    -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar
    -Dmse.licenseKey=<yourLicenseKey>    # <yourLicenseKey> specifies the license key that is automatically generated by the system. Do not disclose the license key. 
    -Dmse.appName=<yourAppName>          # <yourAppName> specifies the custom name of your application. 
    -Dprofiler.micro.service.mse.version=pro
    -Dmse.namespace=default
    -Dmse.enable=true

Sample code:

java -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar -Dmse.licenseKey=xxx -Dmse.appName=xxx Dprofiler.micro.service.mse.version=pro -Dmse.enable=true -jar application.jar

If your applications are connected to MSE and Application Real-Time Monitoring Service (ARMS) at the same time, the MSE Java agent is shared by MSE and ARMS. In this case, you need only to add the mse.licenseKey, mse.appName, and mse.enable parameters. You do not need to add the javaagent parameter.

Parameter

Description

mse.licenseKey

The license key that is automatically generated by the system. Do not disclose the license key to a third party.

The value of mse.licenseKey varies with regions.

mse.appName

The name of the application. Replace <yourAppName> with the name of your application.

profiler.micro.service.mse.version

The Microservices Governance edition in use. Valid values: base, pro, and ent. The value base indicates the Basic Edition, the value pro indicates the Professional Edition, and the value ent indicates the Enterprise Edition.

mse.namespace

The name of the namespace to which Microservices Governance belongs to.

Step 3: Verify the result

  1. Log on to the MSE console, and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance>Application governance ,check whether your application is connected to MSE.

What to do next

After you complete the preceding steps, Microservices Governance is enabled for your applications, such as the applications that are deployed on ECS instances and non-Alibaba Cloud VMs. You can log on to the MSE console, and use Microservices Governance of MSE to perform service governance for your Spring Cloud applications or Dubbo applications.