2017-12-14 1 views
0

Spring Redis를 클라이언트에 연결하는 데 문제가 있습니다. 그래서 호스트 이름을 가진 프록시가 있고 3 개의 redis 노드가 있지만 하나만 사용할 수 있습니다. LettuceConnectionFactory를 사용하여 연결을 만듭니다. 응용 프로그램이 클라이언트에 연결을 시도 할 때 나는 예외 가지고 : 나는 레디 스 바탕 화면 관리자에서 연결하려고하면 작동 ... 대신스프링 데이터 redis가 Redis DNS 프록시에 연결할 수 없음

Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis on unavailableIP:13376; nested exception is com.lambdaworks.redis.RedisConnectionException: Unable to connect to /unavailableIP:13376 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis on unavailableIP:13376; nested exception is com.lambdaworks.redis.RedisConnectionException: Unable to connect to /unavailableIP:13376 
Caused by: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis on unavailableIP:13376; nested exception is com.lambdaworks.redis.RedisConnectionException: Unable to connect to /unavailableIP:13376 
Caused by: com.lambdaworks.redis.RedisConnectionException: Unable to connect to /unavailableIP:13376 
Caused by: java.net.ConnectException: Connection refused: no further information: /unavailableIP:13376"}} 

을 ..

는 적용 할 수있는 방법이 있나요 사용 가능한 IP를 얻으려면 "다시 시도"하시겠습니까?

답변

0

HA 용 Java와 함께 DNS 프록시를 사용하면 코드/런타임에 약간의 조정이 필요할 수 있습니다. Java는 DNS 응답을 일정 시간 동안 캐시합니다. 그러면 DNS가 업데이트 된 IP 주소로 응답하지만 Java 코드가 이전 IP 주소로 해석 될 수 있습니다. 또한 가용성 점검의 구현에 따라 백엔드는 데이터가 새로 고쳐질 때까지 약간의 시간이 걸리지 만 레터스의 끊어진 연결은 즉시 다시 시도됩니다.

나는 드롭/타임 아웃 연결에만 반응 할 수 있으므로 DNS 기반 밸런서를 사용하지 말 것을 제안합니다. 보다 적극적인 접근법 (Redis Sentinel과 같은)을 사용하는 것이 더 좋습니다.

연결/다시 연결할 때마다 주소를 확인하는 사용자 지정 DNS로 Lettuce의 DnsResolver을 구성하려고 할 수 있습니다.

은 참조 :

관련 문제