我正在使用作为zuul代理(@EnableZuulProxy)的前端spring spring应用程序(微服务)将来自外部源的请求路由到使用spring cloud(spring boot)编写的其他内部微服务.
zuul服务器直接位于samples部分的应用程序中
@SpringBootApplication
@Controller
@EnableZuulProxy
@EnableDiscoveryClient
public class ZuulServerApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ZuulServerApplication.class).web(true).run(args);
}
}
Run Code Online (Sandbox Code Playgroud)
我在本地运行这组服务,它似乎工作正常但如果我在网络上运行它有一些负载或通过VPN然后我开始看到zuul转发错误,我在日志中看到客户端超时
有没有办法改变zuul前锋的超时,所以我可以从我的直接关注中消除这个问题.有什么可访问的参数设置.
我正处于发布阶段,这只是出现了:)
我看到的大多数示例都是一个服务的路由定义.
所以这样的事情:
zuul:
routes:
myserver:
path: /mypath/**
Run Code Online (Sandbox Code Playgroud)
让我们说我想将几条路由路由到一个服务,所以实际上它会是这样的:
zuul:
routes:
myserver:
path: /mypath/**, /anotherpath/**
Run Code Online (Sandbox Code Playgroud)
配置文件中不允许这样做,也不允许两次使用相同的路由名称.有没有真正的方法来做到这一点?
我的日志文件中偶尔会收到以下错误字符串。我正在使用 Spring Boot 运行 Spring Cloud 应用程序。我使用包含另一个配置文件的登录配置文件。Spring Boot版本为v1.2.3(Spring Cloud 1.0.1)。
%PARSER_ERROR[wex]2015-06-01 12:30:22.180 DEBUG 6833 --- [http-nio-9000-exec-1] ...日志消息的其余部分
我看到了这个条目(Spring Boot - logback PARSER_ERROR),但 ti 似乎不适用。
logback.xml 文件是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_FILE" value="logs/myservice.log"/>
<!-- the rollover settings with mean a max size per log of 100Mb and 7 days -->
<property name="MAX_HISTORY" value="7"/>
<property name="MAX_FILE_SIZE" value="100MB"/>
<!-- the specific loggers -->
<logger name="com.companyx" level="DEBUG"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.springframework.security.oauth2" level="INFO"/>
<logger name="org.springframework.integration" level="OFF"/>
<logger name="org.springframework.oxm" level="OFF"/>
<logger name="org.springframework.http" …Run Code Online (Sandbox Code Playgroud) 我想为我正在编写的spring cloud微服务编写一些自己的自定义zuul过滤器.一旦我编写了过滤器,我该如何集成它,以便底层的netflix zuul框架可以利用它.
我能够让eureka服务器以点对点模式运行.但我很好奇的一件事是如何让服务发现客户端注册到多个eureka服务器.
我的用例是这样的:
假设我有一个服务注册到其中一个eureka服务器(例如服务器A),并且注册被复制到其对等体.该服务实际上指向服务器A.如果服务器A出现故障,并且客户端希望与服务器A续订,则如果服务器A不再存在,更新如何工作.我是否需要注册两者,如果没有,那么如果客户端无法与服务器A通信,更新是如何发生的.它是否具有服务器B的一些知识(来自其初始和/或后续的通信A)并且故障转移要做它的注册续期?这在任何文档中都不清楚,我需要验证
所以根据答案,我将以下内容添加到我的application.yml中
eureka:
# these are settings for the client that gets services
client:
# enable these two settings if you want discovery to work
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8762/eureka/, http://localhost:8761/eureka/
Run Code Online (Sandbox Code Playgroud)
它只注册到逗号分隔列表中的第一个.如果我在eureka服务器之间切换注册翻转它们.
我可以看到它确实基于逗号分隔这些,但我的猜测是Eureka不使用它(来自EurekaClientConfigBean.java)
@Override
public List<String> getEurekaServerServiceUrls(String myZone) {
String serviceUrls = this.serviceUrl.get(myZone);
if (serviceUrls == null || serviceUrls.isEmpty()) {
serviceUrls = this.serviceUrl.get(DEFAULT_ZONE);
}
if (serviceUrls != null) {
return Arrays.asList(serviceUrls.split(","));
}
return new ArrayList<>();
}
Run Code Online (Sandbox Code Playgroud) 正如标题所说,是否有映射到 Redisson 框架的 spring 数据 redis ( http://redisson.org )
我有一组微服务,我们使用zuul从前端进行路由,作为使用spring cloud将uri上下文路径映射到特定微服务的一种方式.
在内部和外部,我们使用spring OAuth2,效果很好.
但是,对于一个特定服务,出现了对SAML的要求,这对该服务强加了粘性会话要求.
是否有人考虑过这个问题以及为zuul提供粘性会话支持的正确方法.
作为一个解决方法,直到我弄清楚这一点,我将一些请求从我们在前端的HAProxy直接路由到此服务.
我们正在使用点对点Eureka配置运行.请参阅下面的配置.
案例3对我来说意外.这是一个不正确的点对点Eureka配置的情况吗?
eureka配置如下:(我们在对等配置中将这两个实例相互指向)
spring:
profiles: api06-prod-int-discoveryserver # 10.202.10.95 eureka host
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://10.202.10.97:8761/eureka/
---
spring:
profiles: api05-prod-int-discoveryserver # 10.202.10.97 eureka host
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://10.202.10.95:8761/eureka/
Run Code Online (Sandbox Code Playgroud)
每个服务都配置为eureka设置如下:(我们指向xxx95为主要的两个实例)
eureka:
# these are settings for the client that gets services
client:
# enable these two settings if you want discovery to work
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://10.202.10.95:8761/eureka/,http://10.202.10.97:8761/eureka/
Run Code Online (Sandbox Code Playgroud) 我们有许多使用 spring boot (v1.2.3) 和 Spring Data Redis 的服务,它们使用 spring-boot-starter-redis 依赖项。
此外,我们正在使用 spring 会话及其相应的 redis 依赖项
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<version>1.0.0.RELEASE</version>
<type>pom</type>
</dependency>
Run Code Online (Sandbox Code Playgroud)
如果 redis 服务器未启动或无法访问,则该服务会发出失败并中止启动。
是否可以让服务在启动时不失败?我需要设置什么才能这样做?
注意:我跟踪了严重故障,它在 Spring Session 的 Redis 支持中。这里抛出的故障会导致服务失败。如果与 redis 的连接失败,是否可以回退到常规会话?
RedisHttpSessionConfiguration.java at line 156
public void afterPropertiesSet() throws Exception {
>>> RedisConnection connection = connectionFactory.getConnection();
Run Code Online (Sandbox Code Playgroud)
2015-06-02 17:20:00.214 WARN 67248 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name …Run Code Online (Sandbox Code Playgroud) 我正在使用spring数据redis运行spring boot服务,这是以下配置.
该服务似乎有效,但我在日志中看到了丢失的Sentinel消息流.从我运行服务的VM可以访问前哨节点.我能够直接从该VM远程登录到他们.知道为什么会这样吗?
spring:
profiles:
active: core-perf,swagger
default: core-perf,swagger
redis:
Pool: #Pool properties
# Max number of "idle" connections in the pool. Use a negative value to indicate
# an unlimited number of idle connections.
maxIdle: 8
# Target for the minimum number of idle connections to maintain in the pool.
# This setting only has an effect if it is positive.
minIdle: 0
# Max number of connections that can be allocated by the pool at a given time. …Run Code Online (Sandbox Code Playgroud)