Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SpringCloud-Eureka self-protection mode and how to configure InstanceID

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What this article shares with you is about the self-protection mode of SpringCloud-Eureka and how to configure InstanceID. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Turn off self-protection

Protection mode is mainly used when there is a network partition scenario between a group of clients and the Eureka Server. Once in protected mode, Eureka Server will try to protect the information in the registry of its service and no longer delete the data in the registry of the service. When the network failure recovers, the Eureka Server node automatically exits the protected mode.

If you see what is shown in figure 1 in the Web console of Eureka, it proves that Eureka Server is in protected mode.

The self-protection mode can be turned off with the following configuration, which is in eureka-server:

Eureka.server.enableSelfPreservation=false Custom InstanceID for Eureka

When the client registers, the default value of the Instance ID for the service is in the following format:

${spring.cloud.client.hostname}: ${spring.application.name}: ${spring.application. Instance_id:$ {server.port}}

Translation means "hostname: service name: service port". When we view the service registration information in the Web console of Eureka, this is the format:

User-PC:eureka-client-user-service:8081

Many times we want to display IP in the above format, at this time, just replace the hostname with IP, or adjust the order. You can change it to the following and define it in the format of "service name: IP where the service is located: service port":

Eureka.instance.instance-id=$ {spring.application.name}: ${spring.cloud.client.ip-address}: ${server.port}

What we see after the definition is eureka-client-user-service:192.168.31.245:8081, and we can see which service it is, on which machine, and what the port is.

We can also click on the Instance ID of the service to jump, and the name displayed at this time becomes IP, but the link to the jump is still the host name.

So we need to add a configuration to make the jump link the way we want it to be, using IP to register, as shown in figure 2:

Custom instance jump link

Just now we have implemented the registration with IP through configuration. When you click Instance ID to jump, you can use IP to jump. The address of the jump is IP+Port/info by default. We can customize the address of this jump:

Eureka.instance.status-page-url=c.biancheng.net

The effect is shown in figure 3.

The above is the SpringCloud-Eureka self-protection mode and how to configure InstanceID. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report