All Products
Search
Document Center

:Use a self-manage Nacos service registry

Last Updated:Sep 03, 2024

When you deploy a Spring Cloud application or a Dubbo application that is developed in your on-premises environment to SAE, you can use the SAE built-in service registry or a self-managed Nacos to register and discover services. This topic describes how to build a Nacos registry and deploy applications to SAE for hosting.

Note SAE applications do not support the microservices governance feature of Microservices Engine (MSE).

Prerequisites

  • YUM is installed.
  • The access port of your Nacos registry, such as port 8848, is added to your security group before you run your application. For more information, see Add a security group rule.

Background information

A startup company needs to deploy a microservices application on SAE for management but expects to use a self-managed registry instead of the built-in registry of SAE.

For information about how to deploy an application in cluster mode, see Cluster deployment instructions.

Note
If you have a large number of microservices applications, you can use one of the following types of service registries that are listed in descending order by recommendation level:
  • MSE Nacos registry
  • Self-managed service registry
  • SAE built-in service registry

Step 1: Configure Nacos

Nacos runs in a Java environment. If you build and run Nacos from code, you must configure a Maven environment for Nacos. After Nacos is installed and started, Nacos provides the service registration and discovery feature. You must specify the configured service registry on the application side. After you run your application, the system automatically registers and discovers services based on the specified service registry.

For more information, see Quick Start for Nacos.

Step 2: Deploy applications to SAE

Compile your on-premises provider application and consumer application into WAR packages, JAR packages, or images, deploy the applications to SAE, and then use one of the following methods to connect the applications to the Nacos registry. For more information, see the following topics:

Method 1: Configure service registration and discovery

SAE provides the automatic addressing capabilities of Nacos Server for Java microservices applications. You can use the service registration and discovery feature of SAE to configure a service registry. For more information, see Use the SAE built-in Nacos registry. bt_use_user_created_nacos_in_service_registration_and_discovery

Method 2: Configure startup parameters

If you configure startup parameters to connect to the Nacos registry, take note of the following items:
  • Make sure that the network of SAE and the network of the self-managed Nacos registry are interconnected.
  • To prevent the command from being invalid, make sure that you do not use the -D and -XX parameters at the same time. Sample code:
    • Original code:
      java -Dalicloud.deployment.mode=EDAS_MANAGED -XX:+UseContainerSupport -XX:InitialRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0 -XX:+UnlockExperimentalVMOptions -XX:+UseWisp2 -Dio.netty.transport.noNative=true -XX:+UseG1GC -Dspring.profiles.active=yace -Dnacos.use.endpoint.parsing.rule=false -Dnacos.use.cloud.namespace.parsing=false -jar /home/admin/app/xx-server.jar
    • Modified code:
      java -XX:+UseContainerSupport -XX:InitialRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0 -XX:+UnlockExperimentalVMOptions -XX:+UseWisp2 -Dio.netty.transport.noNative=true -XX:+UseG1GC -Dspring.profiles.active=yace -Dnacos.use.endpoint.parsing.rule=false -Dnacos.use.cloud.namespace.parsing=false -jar /home/admin/app/xx-server.jar
  • If you use a self-managed service registry, we recommend that you use an image or a JAR package to deploy an application, and configure the following startup parameters: -Dnacos.use.endpoint.parsing.rule=false and -Dnacos.use.cloud.namespace.parsing=false.
    Important To use a non-SAE built-in registry, you must add the required startup parameters before -jar.
    • If you use an image to deploy an application, add -Dnacos.use.endpoint.parsing.rule=false and -Dnacos.use.cloud.namespace.parsing=false to the startup command of the image file. For information about how to create a Docker image, see Create an image to deploy a Java application.

      Sample code:

      RUN echo 'eval exec java -Dnacos.use.endpoint.parsing.rule=false -Dnacos.use.cloud.namespace.parsing=false -jar $CATALINA_OPTS /home/admin/app/hello-edas-0.0.1-SNAPSHOT.jar'> /home/admin/start.sh && chmod +x /home/admin/start.sh
    • If you use a JAR package to deploy an application, go to the Startup Command Settings section in the SAE console. Then, enter -Dnacos.use.endpoint.parsing.rule=false -Dnacos.use.cloud.namespace.parsing=false in the options Settings field. The following figure shows the startup command that is configured to deploy a Java application in the Open JDK 8 runtime environment. For more information, see Configure a startup command. sc_configure_a_startup_command_for_nacos

References

If an application failed to be deployed, see the following topics to identify the failure cause: