<?xml version="1.0" encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.12.RELEASE</version><relativePath/><!-- lookup parent from repository --></parent><groupId>tech.foolfish</groupId><artifactId>discovery-server</artifactId><version>0.0.1-SNAPSHOT</version><name>microservice-discovery-server-eureka</name><description>Discovery Server</description><properties><java.version>11</java.version><spring-cloud.version>Hoxton.SR12</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jetty</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency><dependency><groupId>org.glassfish.jaxb</groupId><artifactId>jaxb-runtime</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
部署Eureka Server
打包并启动
xuej@dev-server:~/Documents/sts4/microservice-discovery-server-eureka$mvncleanpackage-DskipTests=truexuej@dev-server:~/Documents/sts4/microservice-discovery-server-eureka$java-jar-Dspring.profiles.active=peer1target/discovery-server-0.0.1-SNAPSHOT.jarxuej@dev-server:~/Documents/sts4/microservice-discovery-server-eureka$java-jar-Dspring.profiles.active=peer2target/discovery-server-0.0.1-SNAPSHOT.jarxuej@dev-server:~/Documents/sts4/microservice-discovery-server-eureka$java-jar-Dspring.profiles.active=peer3target/discovery-server-0.0.1-SNAPSHOT.jar._________/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_|'_| | '_\/_`|\\ \ \\\/ ___)||_)|||||||(_||) ) ) )' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.3.12.RELEASE)2022-07-26 00:36:27.349 INFO 26218 --- [ main] oserviceDiscoveryServerEurekaApplication : The following profiles are active: peer32022-07-26 00:36:29.040 WARN 26218 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.2022-07-26 00:36:29.478 INFO 26218 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=54ae4ea2-203e-35b5-83ec-c201cb7d44562022-07-26 00:36:29.840 INFO 26218 --- [ main] org.eclipse.jetty.util.log : Logging initialized @7146ms to org.eclipse.jetty.util.log.Slf4jLog2022-07-26 00:36:30.063 INFO 26218 --- [ main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 87642022-07-26 00:36:30.076 INFO 26218 --- [ main] org.eclipse.jetty.server.Server : jetty-9.4.42.v20210604; built: 2021-06-04T17:33:38.939Z; git: 5cd5e6d2375eeab146813b0de9f19eda6ab6e6cb; jvm 11.0.11+92022-07-26 00:36:30.185 INFO 26218 --- [ main] o.e.j.s.h.ContextHandler.application : Initializing Spring embedded WebApplicationContext2022-07-26 00:36:30.185 INFO 26218 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2789 ms2022-07-26 00:36:30.494 WARN 26218 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.2022-07-26 00:36:30.494 INFO 26218 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.2022-07-26 00:36:30.509 INFO 26218 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@eadb4752022-07-26 00:36:30.997 INFO 26218 --- [ main] org.eclipse.jetty.server.session : DefaultSessionIdManager workerName=node02022-07-26 00:36:30.998 INFO 26218 --- [ main] org.eclipse.jetty.server.session : No SessionScavenger set, using defaults2022-07-26 00:36:30.999 INFO 26218 --- [ main] org.eclipse.jetty.server.session : node0 Scavenging every 660000ms2022-07-26 00:36:31.024 INFO 26218 --- [ main] o.e.jetty.server.handler.ContextHandler : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@aa21042{application,/,[file:///tmp/jetty-docbase.8764.3389909432607769067/],AVAILABLE}2022-07-26 00:36:31.025 INFO 26218 --- [ main] org.eclipse.jetty.server.Server : Started @8332ms2022-07-26 00:36:31.057 WARN 26218 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.2022-07-26 00:36:31.058 INFO 26218 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.2022-07-26 00:36:31.627 INFO 26218 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'2022-07-26 00:36:32.447 INFO 26218 --- [ main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses Jersey2022-07-26 00:36:32.540 WARN 26218 --- [ main] ockingLoadBalancerClientRibbonWarnLogger : You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of `spring.cloud.loadbalancer.ribbon.enabled` to `false` or remove spring-cloud-starter-netflix-ribbon from your project.2022-07-26 00:36:33.145 INFO 26218 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING2022-07-26 00:36:33.443 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-12022-07-26 00:36:33.795 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson2022-07-26 00:36:33.796 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson2022-07-26 00:36:33.796 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml2022-07-26 00:36:33.796 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml2022-07-26 00:36:34.283 INFO 26218 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration2022-07-26 00:36:34.362 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false2022-07-26 00:36:34.366 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null2022-07-26 00:36:34.367 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false2022-07-26 00:36:34.367 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false2022-07-26 00:36:34.367 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true2022-07-26 00:36:34.367 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true2022-07-26 00:36:34.367 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server2022-07-26 00:36:34.574 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 2002022-07-26 00:36:34.577 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 302022-07-26 00:36:34.579 INFO 26218 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 42022-07-26 00:36:34.584 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1658766994583 with initial instances count: 02022-07-26 00:36:34.623 INFO 26218 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...2022-07-26 00:36:34.624 INFO 26218 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://eureka-peer2.com:8763/eureka/, http://eureka-peer1.com:8762/eureka/]2022-07-26 00:36:34.628 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson2022-07-26 00:36:34.628 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson2022-07-26 00:36:34.628 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml2022-07-26 00:36:34.628 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml2022-07-26 00:36:34.718 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson2022-07-26 00:36:34.719 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson2022-07-26 00:36:34.719 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml2022-07-26 00:36:34.719 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml2022-07-26 00:36:34.810 INFO 26218 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://eureka-peer2.com:8763/eureka/2022-07-26 00:36:34.810 INFO 26218 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://eureka-peer1.com:8762/eureka/2022-07-26 00:36:34.835 INFO 26218 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []2022-07-26 00:36:34.836 INFO 26218 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized2022-07-26 00:36:34.905 INFO 26218 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'2022-07-26 00:36:34.968 INFO 26218 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application MICROSERVICE-DISCOVERY-EUREKA-CLUSTER with eureka with status UP2022-07-26 00:36:34.969 INFO 26218 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1658766994969, current=UP, previous=STARTING]2022-07-26 00:36:34.988 INFO 26218 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8764: registering service...2022-07-26 00:36:34.992 INFO 26218 --- [ Thread-18] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..2022-07-26 00:36:35.008 INFO 26218 --- [ Thread-18] o.s.c.n.e.server.EurekaServerBootstrap : Eureka data center value eureka.datacenter is not set, defaulting to default2022-07-26 00:36:35.009 INFO 26218 --- [ Thread-18] o.s.c.n.e.server.EurekaServerBootstrap : Eureka environment value eureka.environment is not set, defaulting to test2022-07-26 00:36:35.081 INFO 26218 --- [ Thread-18] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false2022-07-26 00:36:35.081 INFO 26218 --- [ Thread-18] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context2022-07-26 00:36:35.154 INFO 26218 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8764 - registration status: 2042022-07-26 00:36:35.155 INFO 26218 --- [ main] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey:1.19.4 05/24/2017 03:20 PM'2022-07-26 00:36:35.217 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson2022-07-26 00:36:35.218 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson2022-07-26 00:36:35.218 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml2022-07-26 00:36:35.218 INFO 26218 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml2022-07-26 00:36:35.606 INFO 26218 --- [ main] o.e.j.s.h.ContextHandler.application : Initializing Spring DispatcherServlet 'dispatcherServlet'2022-07-26 00:36:35.606 INFO 26218 --- [ main] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'2022-07-26 00:36:35.611 INFO 26218 --- [ main] o.s.web.servlet.DispatcherServlet : Completed initialization in 5 ms2022-07-26 00:36:35.628 INFO 26218 --- [ main] o.e.jetty.server.AbstractConnector : Started ServerConnector@790174f2{HTTP/1.1, (http/1.1)}{0.0.0.0:8764}2022-07-26 00:36:35.629 INFO 26218 --- [ main] o.s.b.web.embedded.jetty.JettyWebServer : Jetty started on port(s) 8764 (http/1.1) with context path '/'2022-07-26 00:36:35.630 INFO 26218 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 87642022-07-26 00:36:35.678 INFO 26218 --- [ main] oserviceDiscoveryServerEurekaApplication : Started MicroserviceDiscoveryServerEurekaApplication in 11.682 seconds (JVM running for 12.985)2022-07-26 00:36:35.799 INFO 26218 --- [tp2129844134-21] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8763 with status UP (replication=true)2022-07-26 00:36:35.801 INFO 26218 --- [tp2129844134-21] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8764 with status UP (replication=true)2022-07-26 00:36:55.592 INFO 26218 --- [tp2129844134-19] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8762 with status UP (replication=true)2022-07-26 00:37:04.579 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Disable delta property : false2022-07-26 00:37:04.579 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null2022-07-26 00:37:04.579 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false2022-07-26 00:37:04.579 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application is null : false2022-07-26 00:37:04.579 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true2022-07-26 00:37:04.579 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Application version is -1: false2022-07-26 00:37:04.579 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server2022-07-26 00:37:04.597 INFO 26218 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 2002022-07-26 00:37:05.083 INFO 26218 --- [ Thread-18] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8762 with status UP (replication=true)2022-07-26 00:37:05.083 INFO 26218 --- [ Thread-18] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8763 with status UP (replication=true)2022-07-26 00:37:05.084 INFO 26218 --- [ Thread-18] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-DISCOVERY-EUREKA-CLUSTER/10.0.2.15:microservice-discovery-eureka-cluster:8764 with status UP (replication=true)2022-07-26 00:37:05.084 INFO 26218 --- [ Thread-18] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 3 instances from neighboring DS node2022-07-26 00:37:05.084 INFO 26218 --- [ Thread-18] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 52022-07-26 00:37:05.084 INFO 26218 --- [ Thread-18] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP2022-07-26 00:37:05.089 INFO 26218 --- [ Thread-18] e.s.EurekaServerInitializerConfiguration : Started Eureka Server2022-07-26 00:38:05.085 INFO 26218 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms2022-07-26 00:39:05.088 INFO 26218 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 3ms2022-07-26 00:39:50.612 INFO 26218 --- [tp2129844134-18] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-GATEWAY-ZUUL/10.0.2.15:microservice-gateway-zuul:8079 with status UP (replication=true)2022-07-26 00:40:05.089 INFO 26218 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms2022-07-26 00:40:54.486 INFO 26218 --- [tp2129844134-21] c.n.e.registry.AbstractInstanceRegistry : Registered instance MICROSERVICE-GATEWAY-ZUUL/10.0.2.15:microservice-gateway-zuul:8078 with status UP (replication=true)2022-07-26 00:41:05.089 INFO 26218 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms2022-07-26 00:41:34.371 INFO 26218 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration2022-07-26 00:42:05.090 INFO 26218 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms2022-07-26 00:43:05.091 INFO 26218 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 1ms