Spring Cloud学习笔记:Eureka集群搭建样例
    		       		warning:
    		            这篇文章距离上次修改已过421天,其中的内容可能已经有所变动。
    		        
        		                
                
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
 
@SpringBootApplication
@EnableEurekaServer
public class EurekaClusterApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaClusterApplication.class, args);
    }
}
 
application.yml配置样例:
 
server:
  port:
 
eureka:
  instance:
    hostname: eureka1.com
    appname: eureka1
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://eureka2.com:8762/eureka/
 
Spring Cloud版本: Greenwich.SR1这个代码实例展示了如何使用Spring Cloud Eureka搭建一个基本的Eureka集群。在这个例子中,我们有两个Eureka服务器,分别称为eureka1.com和eureka2.com,运行在不同的机器上(或者虚拟机)。eureka1配置为注册到eureka2,而eureka2配置为不注册自己,只从eureka1获取服务信息。这样,两个Eureka服务器就可以互相注册和同步服务信息,形成一个集群。
评论已关闭