解决办法:
将startup.cmd中的set MODE="cluster"修改为set MODE="standalone"。
在Windows10下启动Nacos1.1.3正常,但是尝试启动Nacos1.3.2和1.4.0时,却总是失败!部分异常如下:
"nacos is starting with cluster"
,--.
,--.'|
,--,: : | Nacos 1.4.0
,`--.'`| ' : ,---. Running in cluster mode, All function modules
| : : | | ' ,'\ .--.--. Port: 8848
: | \ | : ,--.--. ,---. / / | / / ' Pid: 31804
| : ' '; | / \ / \. ; ,. :| : /`./ Console: http://192.168.0.100:8848/nacos/index.html
' ' ;. ;.--. .-. | / / '' | |: :| : ;_
| | | \ | \__\/: . .. ' / ' | .; : \ \ `. https://nacos.io
' : | ; .' ," .--.; |' ; :__| : | `----. \
| | '`--' / / ,. |' | '.'|\ \ / / /`--' /
' : | ; : .' \ : : `----' '--'. /
; |.' | , .-./\ \ / `--'---'
'---' `--`---' `----'
java.io.IOException: java.lang.IllegalArgumentException: db.num is null
at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceServiceImpl.reload(ExternalDataSourceServiceImpl.java:141)
at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceServiceImpl.init(ExternalDataSourceServiceImpl.java:115)
Caused by: java.lang.IllegalArgumentException: db.num is null
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:135)
at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceProperties.build(ExternalDataSourceProperties.java:96)
at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceServiceImpl.reload(ExternalDataSourceServiceImpl.java:130)
... 168 more
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authFilterRegistration' defined in class path resource [com/alibaba/nacos/core/auth/AuthConfig.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 'authFilterRegistration' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authFilter': Unsatisfied dependency expressed through field 'authManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthManager': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosUserDetailsServiceImpl': Unsatisfied dependency expressed through field 'userPersistService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'externalUserPersistServiceImpl': Unsatisfied dependency expressed through field 'persistService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalStoragePersistServiceImpl': Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error]load jdbc.properties error
Caused by: java.lang.RuntimeException: [db-load-error]load jdbc.properties error
2020-12-15 19:26:09,273 ERROR Nacos failed to start, please see D:\Soft-Dellvostro\Soft\Distributed\Tools\nacos-server-1.4.0\logs\nacos.log for more details.
查了好长时间,未发现有用的线索。无奈之下,只好从头开始分析日志。
开头的"nacos is starting with cluster",意为nacos以群集模式启动。于是,查了一下1.1.3到1.3.2再到1.4.0的相关差异,得知1.3.2和1.4.0的默认启动模式就是集群模式。而集群模式在没有进行集群配置的情况下,就会启动失败。
另外,application.properties的所有配置使用默认值即可。我之前尝试解决启动失败问题,曾将application.properties中# spring.datasource.platform=mysql的注释取消了。该注释取消之后,也会导致Nacos启动失败。
启动成功后,命令行界面显示如下:
2020-12-15 20:07:05,867 INFO Nacos started successfully in stand alone mode. use embedded storage