tags: spring cloud
Refer to the Spring Cloud course of Shang Silicon Valley, have made some notes, complete code:https://github.com/yao09605/mscloud
The service call relationship between the micro service architecture is more complicated, so a service registration center is enabled, and the registration of the unified management service is enabled. You can achieve service call, service discovery, and registration.
Several machines are registered with each other, and there are registration forms of all services on each machine.
cloud-eureka-server7001 cloud-eureka-server7002
Two Module basically copy paste
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
server:
port: 7001 # Another file into 7002
eureka:
instance:
hostname: eureka7001.com # Another file into erbeka7002.com
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://eureka7002.com:7002/eureka/ # Another file into http://eureka7001.com:7001/Eureka/
127.0.0.1 eureka7001.com
127.0.0.1 eureka7002.com
package org.example.mscloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class EurekaMain7001 {
public static void main(String[] args) {
SpringApplication.run(EurekaMain7001.class, args);
}
}
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
spring:
application:
name: cloud-payment-service #Service Name
eureka:
client:
register-with-eureka: true
fetchRegistry: true
service-url: #eureka server address
defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka
instance:
instance-id: payment8001 #
prefer-ip-address: true # i i
@EnableEurekaClient
@SpringBootApplication
public class PaymentMain8001 {
public static void main(String[] args) {
SpringApplication.run(PaymentMain8001.class,args);
}
}
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
The caller is no longer directly toned, and the service name is used:
public static final String PAYMENT_URL="http://CLOUD-PAYMENT-SERVICE";

Start two cloud clusters mycloud,mycloud1 Pom.xml adds the following configuration <dependency> <groupId>org.springframework.cloud&l...
In the microservices architecture, the registry is an essential component The registration center we built earlier is only suitable for local development. In the production environment, a cluster must...
Spring Cloud Eureka Cluster Test Report 1: Foreword: Due to the limited level of younger brothers, the tests may not be perfect enough. All majors are welcome to criticize and correct. Test 1. Take up...
2019 Unicorn Enterprise Heavy Gold Recruitment Python Engineer Standard >>> Use docker deployment service in dcos, do not use docker compose. You need to register the host ip and external por...
1. Create springcloud-eureka maven project pom.xml 2. Start class EurekaServerApplication.java 3. Create application-peer1.properties registered with peer2 registry, the registry p...
Foreword Eureka Server as a service registry, set up the cluster is still quite necessary, Eureka Server to build a cluster fairly simple and requires only two machines were deployed, two Eureka Serve...
Cluster: Configure the same service on different machines to build a large computing whole Implement clusters New N Eureka Server modules Add the same dependencies as the single Eureka Server to the p...
Introduction Eureka is a service management module of Spring Cloud, which creates conditions for the cluster deployment of business components. Business components can be registered in the Eureka cont...
Recorded a few pits encountered during the deployment of the eureka cluster, especially the last pit. After searching on the Internet for a long time, no results were found, and I finally found myself...
On the basis of the previous article, the simple cluster configuration of Eureka is realized to meet the requirements of high availability. Eureka's cluster logic, the difference with Zookeeper, not t...