nacos 二进制部署报错

发布时间 2023-10-07 11:05:43作者: 买定灬离手

nacos 报错:

Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

Error creating bean with name 'distroFilterRegistration' defined in class path resource [com/alibaba/nacos/naming/web/NamingConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.FilterRegistrationBean]: Factory method 'distroFilterRegistration' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'distroFilter': Unsatisfied dependency expressed through field 'distroMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'distroMapper' defined in URL [jar:file:/root/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-naming-2.2.3.jar!/com/alibaba/nacos/naming/core/DistroMapper.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverMemberManager' defined in URL [jar:file:/root/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-core-2.2.3.jar!/com/alibaba/nacos/core/cluster/ServerMemberManager.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.core.cluster.ServerMemberManager]: Constructor threw exception; nested exception is ErrCode:500, ErrMsg:jmenv.tbsite.net

 

解决办法一:单节点启动

修改 bin 目录下 startup.sh  这个文件

 把 export MODE="cluster" 改为 export MODE="standalone"

修改前:

 修改后

 然后执行  sh start.sh   再根据提示 查看日志 如下 则正常启动

 

 解决办法二:集群启动

在conf  目录下,原本是没有cluster.conf 文件的  默认是 cluster.conf.example  ,但是这个文件不生效,所以需要把他拷贝一份改名字为cluster.conf ,然后再修改这个集群配置文件即可

cp cluster.conf.example  cluster.conf

 修改cluster.conf 配置文件

 然后进入到bin 目录下,启动项目

如果修改过 bin 目录下 startup.sh  则把参数修改为集群启动,把 export MODE="standalone" 改为 export MODE="cluster"  (如果没修改过,则不需要修改,默认则为集群启动)