linux 部署及负载均衡问题

Blade 已结 1 890
E-ER
E-ER 2021-09-06 20:50

一、该问题的重现步骤是什么?

  1. linux服务器部署之后gateway一直报错。程序能正常使用。登录,页面展示都是正常的。报错频率就是每次检查nacos在线服务时

  2. image.png


二、你期待的结果是什么?实际看到的又是什么?

虽然程序能正常使用,希望是不报错

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

bladex 2.8.2 linux 

四、请提供详细的错误堆栈信息,这很重要。


2021-09-06 20:39:32.605 ERROR 10173 --- [or-http-epoll-6] o.s.w.s.adapter.HttpWebHandlerAdapter    : [9303a09a-95] 500 Server Error for HTTP GET "/"


java.lang.NullPointerException: null

        at com.eer.gateway.handler.ErrorExceptionHandler.getHttpStatus(ErrorExceptionHandler.java:76) ~[classes!/:na]

        at org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler.renderErrorResponse(DefaultErrorWebExceptionHandler.java:146) ~[spring-boot-autoconfigure-2.3.12.RELEASE.jar!/:2.3.12.RELEASE]

        at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.lambda$handle$0(AbstractErrorWebExceptionHandler.java:304) ~[spring-boot-autoconfigure-2.3.12.RELEASE.jar!/:2.3.12.RELEASE]

        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:118) [reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2393) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2190) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2064) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:97) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:100) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators.error(Operators.java:196) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoError.subscribe(MonoError.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:97) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:251) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:251) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:165) [reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondError(MonoFlatMap.java:185) [reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoFlatMap$FlatMapInner.onError(MonoFlatMap.java:251) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:268) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:165) [reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onError(Operators.java:2059) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators.error(Operators.java:196) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoError.subscribe(MonoError.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onComplete(FluxSwitchIfEmpty.java:75) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators.complete(Operators.java:135) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:45) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:253) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150) [reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:76) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:274) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:851) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2393) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2190) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2064) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:441) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:211) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:161) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:86) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.subscribeNext(MonoIgnoreThen.java:253) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:51) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) ~[reactor-core-3.3.17.RELEASE.jar!/:3.3.17.RELEASE]

        at reactor.netty.http.server.HttpServerHandle.onStateChange(HttpServerHandle.java:65) ~[reactor-netty-0.9.20.RELEASE.jar!/:0.9.20.RELEASE]

        at reactor.netty.ReactorNetty$CompositeConnectionObserver.onStateChange(ReactorNetty.java:537) ~[reactor-netty-0.9.20.RELEASE.jar!/:0.9.20.RELEASE]

        at reactor.netty.tcp.TcpServerBind$ChildObserver.onStateChange(TcpServerBind.java:278) ~[reactor-netty-0.9.20.RELEASE.jar!/:0.9.20.RELEASE]

        at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:475) ~[reactor-netty-0.9.20.RELEASE.jar!/:0.9.20.RELEASE]

        at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:96) ~[reactor-netty-0.9.20.RELEASE.jar!/:0.9.20.RELEASE]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:191) ~[reactor-netty-0.9.20.RELEASE.jar!/:0.9.20.RELEASE]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) ~[netty-codec-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) ~[netty-codec-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) ~[netty-transport-native-epoll-4.1.65.Final-linux-x86_64.jar!/:4.1.65.Final]

        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) ~[netty-transport-native-epoll-4.1.65.Final-linux-x86_64.jar!/:4.1.65.Final]

        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) ~[netty-transport-native-epoll-4.1.65.Final-linux-x86_64.jar!/:4.1.65.Final]

        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.65.Final.jar!/:4.1.65.Final]

        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.65.Final.jar!/:4.1.65.Final]

        at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_191]

五、若有更多详细信息,请在下面提供。

还有个问题负载均衡咋做的,两台服务器,前台的请求会一直在一台服务器上跑,另一台一直没有接收到请求。
我在nacos指定了一台也不行,一直在3的服务器上跑。
image.pngimage.png


1条回答
  •  admin
    admin (楼主)
    2021-09-07 00:21

     500 Server Error for HTTP GET "/" 应该是nacos检查的时候调用了Gateway根目录的api地址,你手动用postman调用看看后端是否会有报错。或者你找到nacos检查时候调用的详细api地址,看看是否有报错,然后把这个api地址追加到帖子内。

    如果不配置ribbon的rule,他就是轮询的负载均衡策略,如果配置了还没有生效,你需要提供更多的信息,否则无法帮你判断。比如你在本地模拟3个ip,调用的时候看下是否也没有正确负载到。再检查一下相关服务是否引入了 blade-starter-ribbon。

    另外这个负载均衡自定义的逻辑可以见如下截图代码块

    image.png

    3 讨论(1)
提交回复