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

How to build the client of Eureka Server

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

How to build the client of Eureka Server, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Eureka, as the name implies, the meaning of the word itself is, (glad to find the answer to something, especially the answer to a question) I found it, I found it

Eureka is an open source Netflix OSS component that is mainly used for service registration and discovery. Service discovery is one of the key principles based on micro-service architecture, and it will be very difficult and fragile to configure each client manually. With Eureka, we can deploy our applications as highly available applications. Eureka consists of two parts: the Eureka server and the Eureka client.

Note: to refer to this example, you may need to use the following development tools or environments, Intellij idea2017.3,maven,jdk1.7

1. Introduction of Eureka Server

Open idea,File- > New Project- > Spring Initializr, and select dependencies. The necessary dependencies that need to build config server are web, and Eureka Server.

two。 Turn on EurekaServer

Add a note @ EnableEurekaServer to Application

3.application.properties configuration related properties

# Service name

Spring.application.name=eureka-server

# Port

Server.port=8761

# ${} is a spring placeholder. If HOSTNAME is configured, the environment variable is read. Otherwise, use the localhost default

Eureka.instance.hostname=$ {HOSTNAME:localhost}

# whether it is necessary to register with the registry, because the project itself is a service registry, so it is false

Eureka.client.registerWithEureka=false

# whether you need to obtain a list of services from the registry for the same reason as false

Eureka.client.fetchRegistry=false

# self-protection mechanism of Eureka: on for true, off for false. Default is on #

Eureka.server.enable-self-preservation=false

The reference on Eureka's self-protection mechanism is quoted below, which comes from the official explanation of eureka's self-protection mechanism.

When the Eureka server starts, it attempts to get all instance registry information from neighboring nodes. If there is a problem getting information from the node, the server tries all peer nodes before abandoning. If the server can successfully get all the instances, it sets the update threshold that it should receive based on this information. If at any time the renewal is lower than the percentage configured for this value (less than 85% within 15 minutes), the server will stop the expired instance to protect the current instance registry information. The purpose of this is to prevent instances from eliminating normal applications because of temporary fluctuations in the network.

# cleanup interval (in milliseconds) to expel offline services. The interval is 10 seconds. The default is 60.

Eureka.server.evictionIntervalTimerInMs=5000

# maximum server cache time

Eureka.server.responseCacheUpdateIntervalMs=2000

Note: configuration parameters can allow diversification. The following four configurations have the same effect, but in different forms.

Eureka.server.responseCacheUpdateIntervalMs=2000

Eureka.server.response-cache-update-interval-ms=2000

Eureka.server.responseCacheUpdateIntervalMs:2000

Eureka.server.response-cache-update-interval-ms:2000

4. By starting the service, you can access the management interface of the eureka server by accessing http://localhost:8617, as follows:

Eureka management interface

At this point, our eureka server has been built.

5. We can also configure the following parameters in the application.properties configuration file to integrate spring security to provide login verification for our eureka server, and only through login verification can we see the management interface.

5.1 first you need to introduce

Add security dependency

5.2 configure verification information

# # enabling Verification

Security.basic.enabled=true

# # user name

Security.user.name=admin

# # password

Security.user.password=234567

After reading the above, have you mastered how to build the client of Eureka Server? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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

Internet Technology

Wechat

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

12
Report