Micro-Service Architecture: Eureka Cluster Construction

Source: Internet
Author: User

Copyright NOTICE: This article for Bo Master original article, reproduced please indicate the source, Welcome to exchange Study!

Service registration, Discovery is one of the key principles of microservices architecture, because the microservices architecture is a network of a series of fine-grained services with a single function, the service communicates through a light-weight mechanism, which inevitably introduces a service registration discovery problem, which means that the service provider wants to register the reporting service address, The service caller should be able to discover the target service. In our microservices architecture, we use Eureka to complete the registration and discovery of micro-services. The microservices are registered through Eureka and the service callers find the target service through Eureka. As service providers provide services in a clustered manner, Eureka also uses a clustered approach to provide registration and discovery of services, data synchronization between Eureka instances in the cluster, and service registration information in all Eureka instances in sync. So the question is, how do the instances in the Eureka cluster know the existence of other instances, and how do we find other instances? The usual practice is through DNS, so we need to build a DNS server. The following is an introduction to the Euraka cluster construction process.

First, build a DNS server (Linux environment)

1, install the DNS server components, here we use bind

Command: Yum install-y bind Bind-chroot bind-utils

2. Edit the configuration DNS master configuration file

Command: vi/etc/named.conf

3. Modify the Named.rfc1912.zones file

command: vi/etc/named.rfc1912.zones

Add the required zone

4. Add set DNS forward parsing

Modify zone configuration file, forward parsing

Command: cd/var/named/

CP Named.localhost Eureka.com.zone

VI Eureka.com.zone

Note: The zone file name defined in the main profile [/etc/named.rfc1912.zones] is identical

5. Start the DNS server

command:service named start

6, test the detection domain information is normal

look before you check . configuration file has no Read permission

command:ll/var/named

If you do not have Read permission, add it with the chmod +r/var/named/* command

7. Restart the DNS server

Command: Service named restart

8. DNS server address configuration

The first way: This method is to temporarily modify the DNS address, and when the network restarts, it is automatically purged.

Command: vi/etc/resolv.conf

The second way: This method is to permanently modify the DNS address, which is not purged after the network restarts.

Command: VI/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ENP0S25

Second, the Eureka DNS configuration is placed outside the jar package to start the microservices

Docker command :Docker run –e eurekaserverdnsname= domain name Mirror

Three, Eureka cluster configuration

Writing the Eureka configuration file (application.yml)

which The configuration of the Eureka is divided into client side and Server side:

Eureka Client configuration,Eurekaserverurlcontext:eureka represents the path to the Eureka registry, which defaults to http://x.x.x.x:x/eureka/, Add this configuration table to the Eureka configuration file

The Eureka is registered as a client to the registry, thus constituting the Eureka cluster.

in the Eureka server configuration,Enableselfpreservation:false indicates that the self-protection mode is turned off in this Eureka server, and the so-called self-protection mode refers to the presence network partition,Eureka lost in a short period of time

Multi-client, it goes into self-protection mode, that is, a service does not send a heartbeat for a long time, andEureka does not delete it. The default is true:

The self-protection mode is on by default, which involves the threshold factor, which is 0.85 by default, which can be seen on the Eureka main interface:

The threshold value cannot be greater than the minimum value, otherwise it will enter self-protected mode.

The above is the Eureka cluster construction process, in the process of building a lot of pits, but also a lot of harvest, Eureka related to some of the configuration items are not here to repeat, the content is more, if necessary, I will introduce this part separately.

Micro-Service Architecture: Eureka Cluster Construction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.