Get the App
SLTechnology News&Howtos  ›  Development  › 

Eureka self-protection mode and InstanceID configuration

Shulou Source: shulou.com Published: 2022-06-03 08:53:00 11月15日 Update

In this issue, Xiaobian will bring you the configuration of Eureka self-protection mode and InstanceID. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.

Turn off self-protection

Protected mode is primarily used when there is a network partitioning scenario between a set of clients and Eureka Server. Once in protected mode, Eureka Server attempts to protect information in its service registry and no longer deletes data from the service registry. When the network fails to recover, the Eureka Server node automatically exits protected mode.

If you see something like Figure 1 in Eureka's Web console, you're in protected mode.

Self-protection mode can be turned off by configuring eureka-server as follows:

eureka.server.enableSelfPreservation=false Custom InstanceID of Eureka

When the client registers, the default value of the Instance ID of the service has the following format:

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

Translated as "hostname: service name: service port." When we view service registration information in Eureka's Web console, it looks like this:

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

Many times we want to display IP in the above format, in this case, just replace the hostname with IP, or adjust the order. It can be changed to the following, defined 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}

After definition, we see eureka-client-user-service: 192.168.31.245: 8081, which service, on which machine, and on what port.

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

So you need to add a configuration to make the jump link look like we want, using IP to register, as shown in Figure 2:

Custom Instance Jump Links

Just now we have realized registration with IP through configuration. When clicking Instance ID to jump, you can jump with IP. The default address of jump is IP+Port/info. 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 configuration of Eureka self-protection mode and InstanceID shared by Xiaobian. If there is a similar doubt, please refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.

Tags: Services protection mode configuration that is time format host content name port link information address customer client console appearance registry network Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi NVidia Shulou Information Docker vpn