Microservices Engine (MSE) provides managed Nacos, ZooKeeper, and Eureka registries for Spring Cloud and Dubbo applications. This topic describes instance creation requirements, application configuration for each registry type, and troubleshooting steps.
Prerequisites
Before you begin, make sure that you have:
An Alibaba Cloud account with MSE activated
An Elastic Compute Service (ECS) instance where your application runs
The Virtual Private Cloud (VPC) and region information of your ECS instance
Create an instance
When you create an MSE instance, configure the following settings:
| Setting | Requirement |
|---|---|
| Network type: VPC | Select the same VPC as the ECS instance where your application runs. |
| Network type: Internet | Configure an IP address whitelist. Specify CIDR blocks in the <ECS public IP>/32 format. For more information, see Configure a public IP address whitelist. |
| Region | If you select VPC as the network type, select the same region as the ECS instance where your application runs. |
| Public bandwidth | To access the MSE instance over the Internet, set the public bandwidth to a value greater than 0. A public endpoint is generated only when the public bandwidth is non-zero. |
Connect to a Nacos registry
All configuration examples use the public endpoint of your MSE instance as the server address. Replace mse-XX-p.nacos-ans.mse.aliyuncs.com with your actual endpoint.
Spring Cloud
Add the following configuration to your application.properties file:
spring.application.name=service-provider
server.port=18081
# Replace with the public endpoint of your MSE Nacos instance
spring.cloud.nacos.discovery.server-addr=mse-XX-p.nacos-ans.mse.aliyuncs.com:8848To use a custom namespace, add:
spring.cloud.nacos.discovery.namespace=<your-namespace-id>Dubbo (XML)
<dubbo:application name="demo-provider"/>
<dubbo:protocol name="dubbo" port="28082" />
<dubbo:service interface="com.alibaba.dubbo.api.IHelloService" ref="helloService"/>
<bean id="helloService" class="com.alibaba.dubbo.service.impl.IHelloServiceImpl"/>
<!-- Replace with the public endpoint of your MSE Nacos instance -->
<dubbo:registry address="nacos://mse-XX-p.nacos-ans.mse.aliyuncs.com:8848"/>To use a custom namespace, update the registry address:
<dubbo:registry address="nacos://mse-XX-p.nacos-ans.mse.aliyuncs.com:8848?namespace=<your-namespace-id>"/>Dubbo (.properties)
dubbo.application.name=dubbo-consumer-demo
server.port=8080
# Replace with the public endpoint of your MSE Nacos instance
dubbo.registry.address=nacos://mse-XX-p.nacos-ans.mse.aliyuncs.com:8848To use a custom namespace, add:
dubbo.registry.parameters.namespace=<your-namespace-id>For more information about Nacos, see Nacos.
Connect to a ZooKeeper registry
Spring Cloud
Add the following configuration to your application.yml file:
spring:
application:
name: demo-provider
cloud:
zookeeper:
# Replace with the public endpoint of your MSE ZooKeeper instance
connect-string: mse-XX-p.nacos-ans.mse.aliyuncs.com:2181
discovery:
enabled: trueDubbo (XML)
<!-- Replace with the public endpoint of your MSE ZooKeeper instance -->
<dubbo:registry address="zookeeper://mse-XX-p.nacos-ans.mse.aliyuncs.com:2181" />Connect to a Eureka registry
Spring Cloud
Add the following configuration to your application.yml file:
server:
port: 8080
spring:
application:
name: demo-provider
eureka:
client:
serviceUrl:
# Replace with the public endpoint of your MSE Eureka instance
defaultZone: http://mse-XXX-p.eureka.mse.aliyuncs.com:8761/eureka
instance:
prefer-ip-address: trueConfigure a configuration center
For configuration center sample code, see the Nacos Java SDK documentation.
Troubleshoot issues in Nacos registries
If an issue occurs when you use an MSE Nacos registry, review the Nacos client logs in the naming.log file in the following directory:
${user.home}/logs/nacos/naming.log