In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to apply SpringCloud to integrate Eureka registry", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to apply SpringCloud to integrate Eureka registry.
Introduction
Eureka, the core component of SpringCloud, provides service registration and service discovery functions to manage various services in distributed systems, such as registration, discovery, circuit breaker, load balancing and so on.
Version Notes SpringCloud:Greenwich.RELEASESpringBoot: 2.1.2.RELEASE implementation steps
1. Introduce dependency
Parent project
Org.springframework.cloud spring-cloud-dependencies Greenwich.RELEASE pom import
Sub-project
Org.springframework.cloud spring-cloud-starter-netflix-eureka-server
two。 Add configuration application.properties
# Project port number server.port=6001 # Project name spring.application.name=service-registry # whether to register yourself as a service in another service registry, whether the default true eureka.client.register-with-eureka=false # synchronizes the service list from other service centers, and whether the default true eureka.client.fetch-registry=false # sets the address to interact with Eureka Server. Both query service and registration service depend on this address. Eureka.client.serviceUrl.defaultZone= http://localhost:${server.port}/eureka/
3. Startup class add startup registry
@ SpringBootApplication @ EnableEurekaServer / / enable the Eureka service public class Application {public static void main (String [] args) {SpringApplication.run (Application.class,args);}} Cluster Registry
In the distributed system, the registry is the most important basic part. In order to prevent the catastrophe caused by the failure of the registry, we must ensure the high availability of the registry. We can use the cluster approach.
1. Create a project
Create 3 projects as described above
Registry-1
Registry-2
Registry-3
two。 Modify the host file of the operating system
Windows system C:\ Windows\ System32\ drivers\ etc\ hosts
Linux system / etc/hosts
Add the following configuration:
127.0.0.1 service-registry1 127.0.0.1 service-registry2 127.0.0.1 service-registry3
3. Configuration file modification
# registry-1.application.properties # Project port number server.port=6001 # Project name spring.application.name=service-registry # Service registries must display settings register-with-eureka and fetch-registry with a value of true Otherwise, the service is unavailable # whether to register itself as a service with another service registry eureka.client.register-with-eureka=true # whether to synchronize the service list from other service centers eureka.client.fetch-registry=true # to set the address to interact with Eureka Server Both query and registration services rely on this address. Eureka.client.serviceUrl.defaultZone= http://service-registry2:6002/eureka/, Http://service-registry3:6003/eureka/ eureka.instance.appname=service-registry # Host name eureka.instance.hostname=service-registry1 # Service Registry address # registry-2.application.properties # Project Port number server.port=6002 # Project name spring.application.name=service-registry # Service Registry must display settings register-with-eureka and fetch-registry with values of true Otherwise, the service is unavailable # whether to register itself as a service with another service registry eureka.client.register-with-eureka=true # whether to synchronize the service list from other service centers eureka.client.fetch-registry=true # to set the address to interact with Eureka Server Both query and registration services rely on this address. Eureka.client.serviceUrl.defaultZone= http://service-registry1:6001/eureka/,http://service-registry3:6003/eureka/ eureka.instance.appname=service-registry # Host name eureka.instance.hostname=service-registry2 # registry-3.application.properties # Project Port number server.port=6003 # Project name spring.application.name=service-registry # Service Registry must display the settings register-with-eureka and fetch-registry with a value of true Otherwise, the service is unavailable # whether to register itself as a service with another service registry eureka.client.register-with-eureka=true # whether to synchronize the service list from other service centers eureka.client.fetch-registry=true # to set the address to interact with Eureka Server Both query and registration services rely on this address. Eureka.client.serviceUrl.defaultZone= http://service-registry1:6001/eureka/,http://service-registry2:6003/eureka/ eureka.instance.appname=service-registry # Host name eureka.instance.hostname=service-registry3 Note
1. Mutual registration of service registry clusters must be enabled.
Register-with-eureka: true fetch-registry: true
two。 The spring.application.name of the service registry cluster must be the same
3.eureka.client.serviceUrl.defaultZone: localhost cannot appear. Be sure to use host to specify the host name.
At this point, I believe you have a deeper understanding of "how to apply SpringCloud integrated Eureka registry". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.