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.
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.
- 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
Method 1: Configure service registration and discovery
Method 2: Configure startup parameters
- 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
- Original code:
- 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.
- If you use an image to deploy an application, add