In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
one。 Why do you need clusters?
The previous article explained how to build a single node eureka, this article explains how to build an eureka cluster, where the cluster or local different ports execute three eureka, because the conditions are not allowed, there are no three computers, so we will deal with it. The purpose of the eureka cluster is to prevent one point failure, the whole service paralysis problem, become a single point failure, because one point of the problem, there is another point to top. Work instead of this point, so the cluster also achieves high availability and high performance
two。 The principle of cluster
Each registration point is equipped with a url of other points, which can synchronize data with other server points. When the service registers to one point, the store will synchronize the service to other registration points. When consumers need to consume, they will ask the registry for a specific service, and the registry will provide consumers with the specific access address of the service provider, and finally realize the service call.
three。 Create a cluster win environment configuration
It is convenient to soak all the services directly in the local win10 environment. Originally, the real simulation environment is to run on the virtual machine of linux. Everyone can run Baidu on their own. The principle is the same, but if you need to package and publish on linux, I will operate directly on win. First, configure multiple services locally, map the domain name, and add it to the hosts file under the path C:\ Windows\ System32\ drivers\ etc:
127.0.0.1 eureka3000.com
127.0.0.1 eureka3001.com
127.0.0.1 eureka3002.com
What needs to be reminded here is that you have permissions to modify hosts files. For more information on how to set permissions, please see win10 to modify configuration files.
four。 The first directory to create a cluster is as follows: creating eureka3000 was mentioned in the previous article (see Building an Eureka single node). The same is true for creating eureka3001 and eureka3001. Here, paste the pom file directly.
Pom file for eureka3000: 4.0.0 com.org.ldc eureka3000 0.0.1-SNAPSHOT eureka3000 Demo project for Spring Boot 1.8 com.org.ldc eureka-father 1.0.0.RELEASE org.springframework.cloud spring-cloud-starter-netflix-eureka-server Org.springframework.boot spring-boot-starter-web org.springframework.cloud spring-cloud-dependencies Finchley.SR2 pom import Org.springframework.boot spring-boot-maven-plugin eureka3000's applicatiion.yml file: server: port: 3000eureka: server: enable-self-preservation: false # turn off the self-protection mechanism eviction-interval-timer-in-ms: 4000 # set the cleanup interval (in milliseconds, default is 60: 1000) instance: hostname: eureka3000.com client: serviceUrl: DefaultZone: http://eureka3001.com:3001/eureka, Http://eureka3002.com:3002/eureka # registers itself as a service in another registry spring: application: name: eureka-server-cluster # sets the service name eureka3000 startup class as the original eureka3001 pom file: 4.0.0 com.org.ldc eureka3001 0.0.1-SNAPSHOT eureka3001 Demo project for Spring Boot 1.8 com.org.ldc Eureka-father 1.0.0.RELEASE org.springframework.cloud spring-cloud-starter-netflix-eureka-server org.springframework.boot spring-boot-starter-web org.springframework.cloud spring- Cloud-dependencies Finchley.SR2 pom import org.springframework.boot spring-boot-maven-plugin eureka3001's application file: server: port: 3001eureka: server: enable-self-preservation: false # closes since My protection mechanism eviction-interval-timer-in-ms: 4000 # sets the cleanup interval (in milliseconds, default is 60mm 1000) instance: hostname: eureka3001.com client: serviceUrl: defaultZone: http://eureka3000.com:3000/eureka, Http://eureka3002.com:3002/eureka # registers itself as a service in another registry spring: application: name: eureka-server-cluster # sets the service name
Startup is the same as above
Pom file for eureka3002:
4.0.0com.org.ldceureka30020.0.1-SNAPSHOTeureka3002Demo project for Spring Boot 1.8 com.org.ldceureka-father 1.0.0.RELEASE org.springframework.cloud spring-cloud-starter-netflix-eureka-server org.springframework.boot spring-boot-starter-web org.springframework.cloud spring-cloud-dependencies Finchley.SR2 pom import org.springframework.boot spring-boot-maven-plugin
-application file of eureka3002:
Server:
Port: 3002
Eureka:
Server:
Enable-self-preservation: false # turn off the self-protection mechanism
Eviction-interval-timer-in-ms: 4000 # sets the cleanup interval (in milliseconds, the default is 60 to 1000)
Instance:
Hostname: eureka3002.com
Client:
ServiceUrl:
DefaultZone: http://eureka3001.com:3001/eureka,http://eureka3000.com:3000/eureka # registers itself as a service to another registry
Spring:
Application:
Name: eureka-server-cluster # sets the service name
-finally, the pom file of the project is as follows:
SpringBoot-Eureka environment building multi-module construction example
4.0.0
Eureka-father
Pom
Com.org.ldceureka-father1.0.0.RELEASE org.springframework.boot spring-boot-starter-parent 2.0.2.RELEASE eureka3000 eureka3001 eureka3002 user5000 com.org.ldc eureka3000 0.0.1-SNAPSHOT com.org.ldc eureka3001 0.0.1-SNAPSHOT Com.org.ldc eureka3002 0.0.1-SNAPSHOT com.org.ldc user5000 0.0.1-SNAPSHOT
To explain here, the building tutorial here is based on maven aggregation project, and you need to be able to build maven aggregation project. By default, everyone will build it here, so you can go to Baidu on your own if you don't understand it. The final test is to start each registry, and then start the service to enter the access address of each registry in the browser, as shown in the following figure, indicating that the construction is successful! [insert picture description here] (https://img-blog.csdnimg.cn/20191215215951525.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMjU1MDE3,size_16,color_FFFFFF,t_70)> for more tutorials, please follow the non-class classes, work together, work hard, and the passing friends will give me a like. Thank you for sharing the resources of java, including a full set of videos from introduction to development of java. And the 26 projects of java, the resources are relatively large, the size is about 290g, the link is easy to fail, the way to get is to follow the official account: non-subject class, let the reply: java project can be obtained, I wish you all a happy study
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.