2017-01-09 91 views
0

我在Linux機器上運行netflix oss堆棧。這個堆棧安裝了Eureka和一些微服務(hello services),所有這些都運行在單獨的docker容器中。將Zuul添加到Netflix OSS安裝

它使用Maven和Spring Boot安裝。

我的問題是:如何將Zuul添加到此堆棧中?我在網上找到了一些東西,但是他們也安裝了Eureka,如果我運行這個,我有條件重寫當前的Eureka。

回答

0

您需要的@EnableZuulProxy註釋添加到主類

@SpringBootApplication 
@EnableZuulProxy 
@EnableHystrixDashboard 
public class ZuulApp{ 
    public static void main(String[] args) { 
     SpringApplication.run(ZuulApp.class, args); 
    } 
} 

,並在application.yml文件,您的Eureka-微服務

zuul: 
    ignoredServices: '*' 
    routes: 
     microservice1: 
     path: /microservice1/** 
     stripPrefix: false 

     microservice2: 
     path: /microservice2/** 
     stripPrefix: false 

     ... 
     #If you have hystrix 
     hystrix: 
      threadpool: 
      default: 
       maxQueueSize: 100 
       queueSizeRejectionThreshold: 100 
      command:  
      default: 
      execution: 
       isolation: 
        thread: 
         timeoutInMilliseconds: 60000 
    #load balancing 
     ribbon: 
     MaxAutoRetries: 2 
     MaxAutoRetriesNextServer: 2   
     OkToRetryOnAllOperations: true 
     ServerListRefreshInterval: 2000 
     ConnectTimeout: 50000 
     ReadTimeout: 50000 

的名稱默認情況下zuul添加路由在端口8500上運行。

該maven依賴關係

0
  1. 此外,請確保您使用serviceid進行網址路由。 E.g:

    zuul: 
        routes: 
        httpbin: 
         path: /** 
         serviceId: httpbin 
    
  2. Zuul應該知道尤里卡能夠獲取正確的IP對它們運行的​​各種服務。

    ribbon: 
        eureka: 
        enabled: false 
    

上述配置保證您可以動態地添加對未來的特定服務更多的服務器,而無需修改zull路由服務器的配置,因爲這將能夠查詢和更新,其中特定服務是由運行的服務器查詢尤里卡