Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Cloud Service Engine/ Best Practices/ Registry/Configuration Centers/ Connecting Spring Cloud Eureka Applications to Nacos Engines

Connecting Spring Cloud Eureka Applications to Nacos Engines

Updated on 2024-09-30 GMT+08:00

This section uses a demo to demonstrate how to connect Spring Cloud Eureka applications to Nacos engines.

Connect a provider service and a consumer service to a Nacos engine.

Prerequisites

  • You have created a Nacos engine. For details, see Creating a Registry/Configuration Center.
  • You have downloaded the demo source code from GitHub to the local host and decompressed it.
  • The Java JDK and Maven have been installed on the local host for compilation, building, and packaging, and the Maven central library can be accessed.

Restrictions

  • Nacos is compatible with Eureka APIs on the Eureka server side and saves and updates client instance information registered on the service side. Therefore, if you use only Eureka as the registry center, many features of Nacos, such as namespace and configuration management, cannot be used.
  • Eureka is used as the client and can be viewed only on the Service Management page of Nacos. Eureka services are displayed using the default attributes of Nacos.
    • Default namespace: public
    • Default group: DEFAULT_GROUP
  • The value of Protection Threshold for creating a service on the Service Management page of Nacos is a feature of Nacos and does not apply to the Eureka service.

Connecting Spring Cloud Eureka Applications to Nacos Engines

  1. Log in to CSE.
  2. Obtain the registry center address of a Nacos engine.

    1. In the left navigation pane, choose Registry/Configuration Center and click the Nacos engine instance.
    2. In the Connection Information area on the Basic Information page, obtain the service center address.

  3. Change the registry center address and microservice name in the demo.

    1. Configure the Nacos service center address and microservice name in the application.properties file.
      • Find the eureka-demo-master\eureka-consumer\src\main\resources\application.properties file in the demo source code directory downloaded to the local host and configure the consumer service.
        server.port=9001
        spring.application.name= eureka-client-consumer //Microservice name
        eureka.client.serviceUrl.defaultZone= XXX.nacos.cse.com:8848/nacos/eureka //Service center address of Nacos
        eureka.instance.lease-renewal-interval-in-seconds=15 //Service heartbeat update interval
        eureka.client.registry-fetch-interval-seconds=15 //Interval for pulling the registry center. It is recommended that the value be the same as the heartbeat interval.
      • Find the eureka-demo-master\eureka-provider\src\main\resources\application.properties file in the demo source code directory downloaded to the local host and configure the provider service.
        server.port=9000
        spring.application.name= eureka-client-provider //Microservice name
        eureka.client.serviceUrl.defaultZone= XXX.nacos.cse.com:8848/nacos/eureka //Service center address of Nacos
        eureka.instance.lease-renewal-interval-in-seconds=15 //Service heartbeat update interval
        eureka.client.registry-fetch-interval-seconds=15 //Interval for pulling the registry center. It is recommended that the value be the same as the heartbeat interval.

  4. Pack the demo source code into a JAR package.

    1. In the root directory of the demo source code, open the Command Prompt and run the mvn clean package command to package and compile the project.
    2. After the compilation is successful, two JAR packages are generated, as shown in Table 1.
      Table 1 Software packages

      Software Package Directory

      Software Package Name

      Description

      \eureka-consumer\target

      eureka-client-consumer-1.0.0-SNAPSHOT.jar

      Service consumer

      \eureka-provider\target

      eureka-client-provider-1.0.0-SNAPSHOT.jar

      Service provider

  5. Deploy Spring Cloud applications.

    Deploy provider and consumer on the ECS node in the VPC where the Nacos engine is located.
    1. Create an ECS node in the VPC where the engine instance is located and log in to the ECS node. For details, see Purchasing and Logging In to a Linux ECS.
    2. Install JRE to provide a running environment for services.
    3. Upload the JAR package generated in 4 to the ECS node.
    4. Run the java -jar {JAR package} command to run the generated JAR package.

  6. Confirm the deployment results.

    1. Optional: On the CSE console, choose Registry/Configuration Center and click the Nacos engine created in Prerequisites.
    2. Choose Service Management and check the number of instances of microservices eureka-client-consumer and eureka-client-provider.
      • If Instances is not 0, the demo has been connected to the Nacos engine.
      • If Instances is 0 or the eureka-client-consumer and eureka-client-provider services cannot be found, the demo fails to be connected to the Nacos engine.

Kami menggunakan cookie untuk meningkatkan kualitas situs kami dan pengalaman Anda. Dengan melanjutkan penelusuran di situs kami berarti Anda menerima kebijakan cookie kami. Cari tahu selengkapnya

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback