Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Spring Cloud's highly available service registry

Shulou Source: shulou.com Published: 2022-06-01 23:35:13 09月20日 Update

This article focuses on "how to use Spring Cloud's highly available service 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 use Spring Cloud's highly available service registry.

I. preparatory work

Continue to use the previous project, there is a little interlude, because you do not intend to modify the hosts file to achieve a single server service cluster, do not understand it for a day, and finally come to a conclusion: a single server has to modify hosts, and multiple servers can be configured through ip.

Modify hosts: C:\ Windows\ System32\ drivers\ etc

Add a few lines at the end of the file:

2. Modify the project erurekaserver

1. Create a new application-one.yml

Server: port: 8761spring: application: name: eurekaserver profiles: oneeureka: instance: hostname: localhost1 client: register-with-eureka: true fetch-registry: true serviceUrl: defaultZone: http://localhost2:8861/eureka/ server: enableSelfPreservation: false

2. Create a new application-two.yml

Server: port: 8861spring: application: name: eurekaserver profiles: twoeureka: instance: hostname: localhost2 client: register-with-eureka: true fetch-registry: true serviceUrl: defaultZone: http://localhost1:8761/eureka/ server: enableSelfPreservation: false

3. Modify startup items

EurekaServerApplication.java right-> Run As-> Run Configruations.. Create two launch applications

4. Start one two respectively

When starting, there is always a background will report an error, and so on after the startup is complete. Visit http://localhost:8761/ and http://localhost:8861/ respectively, and the results are as follows:

Third, modify the config-server project

1. Modify application.properties, red box marking part

2. Start config-server

4. Modify the bootstrap.yml of eurekaclient1

Start the project

Modify the application.yml of service-ribbon

Start the project

6. Visit http://localhost:8761/ and http://localhost:8861/ again

7. Visit http://localhost:8764/hello

Can be accessed successfully.

At this point, I believe you have a deeper understanding of "how to use Spring Cloud's highly available service 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!

Tags: Service project server content file learning practical deeper success two interest again background multiple practical practical interlude simple operation method time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Redmi NVidia MySQL Docker