Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

同一台服务器, 启动nacos集群,出现端口占用问题,具体问题如下 (版本号 : 2.0.0-ALPHA.2) #4873

Closed
bravelionet opened this issue Feb 4, 2021 · 14 comments
Assignees

Comments

@bravelionet
Copy link

bravelionet commented Feb 4, 2021

  1. 同一台服务器在启动nacos多个实例时, conf/application.properties port 已经修改为不同端口,仍然出现, io.grpc.netty.shaded.io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use
  2. 在出现以上错误, 毫无头绪查找, 个人建议报错再详细点,比如加上哪个端口号被占用,比如port 8848 address already in use
@xuhui54
Copy link

xuhui54 commented Feb 4, 2021

遇到相同问题,
错误堆栈
2021-02-04 17:08:04,756 ERROR Startup errors : {}

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grpcSdkServer': Invocation of init method failed; nested exception is java.io.IOException: Failed to bind
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:139)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:413)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1761)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:319)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:866)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
at com.alibaba.nacos.Nacos.main(Nacos.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
Caused by: java.io.IOException: Failed to bind
at io.grpc.netty.shaded.io.grpc.netty.NettyServer.start(NettyServer.java:246)
at io.grpc.internal.ServerImpl.start(ServerImpl.java:184)
at io.grpc.internal.ServerImpl.start(ServerImpl.java:90)
at com.alibaba.nacos.core.remote.grpc.BaseGrpcServer.startServer(BaseGrpcServer.java:142)
at com.alibaba.nacos.core.remote.BaseRpcServer.start(BaseRpcServer.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
... 26 common frames omitted
Caused by: java.net.BindException: Address already in use: bind

@KomachiSion
Copy link
Collaborator

2.0需要4个端口

server.port(默认8848)

raft port: ${server.port} - 1000
grpc port: ${server.port} + 1000
grpc port for server: ${server.port} + 1001

@xuhui54
Copy link

xuhui54 commented Feb 5, 2021

重启电脑。 修改个节点application.properties的port。随意启动一台正常,当启动第二台后就会报Error creating bean with name 'grpcSdkServer': Invocation of init method failed; nested exception is java.io.IOException: Failed to bind

@bravelionet
Copy link
Author

您好,看到你所发的案例公式,server.port不同,后续三个端口也不会冲突吧,前提是服务器未启动任何程序的情况下仍然出现了该问题 @KomachiSion

@KomachiSion
Copy link
Collaborator

如果同一台机器, 启动2台以上服务端,那么必须确保4个port都不被占用。

比如第一个启动8848, 第二个启动9848, 那么9848会被第一个进程的grpc占用,导致无法启动。

Failed to bind 必然是端口被占用了,可能是你自己的程序占用的。只能自己排查环境。

@lucky2u
Copy link

lucky2u commented Apr 13, 2021

您好,看到你所发的案例公式,server.port不同,后续三个端口也不会冲突吧,前提是服务器未启动任何程序的情况下仍然出现了该问题 @KomachiSion

我还不行哎

@dashuaibi2018
Copy link

2.0需要4个端口

server.port(默认8848)

raft port: ${server.port} - 1000
grpc port: ${server.port} + 1000
grpc port for server: ${server.port} + 1001

感谢 端口连续了 导致冲突了

@dashuaibi2018
Copy link

您好,看到你所发的案例公式,server.port不同,后续三个端口也不会冲突吧,前提是服务器未启动任何程序的情况下仍然出现了该问题 @KomachiSion

我还不行哎

集群端口号不能是三个连续的

@woshishitou
Copy link

我今天也遇到了,结果发现是9849端口被某个服务跟redis的一个连接给占用了

@yuanweiGit
Copy link

2.0+之后的端口带有偏移量 尽量不要连续性 实测8843 8846 8849 这样是可以的

@Luxianshen
Copy link

2.0+之后的端口带有偏移量 尽量不要连续性 实测8843 8846 8849 这样是可以的

1.4.1 多启动个2.1.1 8849 不行

@mouday
Copy link

mouday commented Feb 24, 2023

1.4.2版本,以下配置也不行,端口占用

192.168.0.105:8845
192.168.0.105:8850
192.168.0.105:8855

@xinxinQ
Copy link

xinxinQ commented Nov 12, 2023

version 2.2.3 cluster 相同ip端口分別用 8149 8249 8349 亲测可用

@2623574740
Copy link

我自己做了nacos镜像,在同一个自定义的docker network里生成3个容器,端口号没有改(沿用8848,7848,9848,9849),报错
Caused by: java.io.IOException: Failed to bind to address 0.0.0.0/0.0.0.0:7848 at io.grpc.netty.shaded.io.grpc.netty.NettyServer.start(NettyServer.java:328) at io.grpc.internal.ServerImpl.start(ServerImpl.java:185) at io.grpc.internal.ServerImpl.start(ServerImpl.java:94) at com.alipay.sofa.jraft.rpc.impl.GrpcServer.init(GrpcServer.java:108) at com.alipay.sofa.jraft.rpc.impl.GrpcServer.init(GrpcServer.java:61) at com.alibaba.nacos.core.distributed.raft.JRaftServer.start(JRaftServer.java:205) ... 129 common frames omitted Caused by: io.grpc.netty.shaded.io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests