Nacos2.2.3之MySQL8.X持久化详细配置过程

Nacos2.2.3之MySQL8.X持久化详细配置过程

文章目录

  • Nacos2.2.3之MySQL8.X持久化详细配置过程
  • 1. 官网与下载
    • 1. 官网
    • 2. Naocs是什么?
    • 3. 下载
  • 2. 安装与持久化配置
    • 1. 解压安装
    • 2. 创建数据库
      • 1. 连接数据库
      • 2. 创建nacos数据库
      • 3. 导入脚本
      • 4. 查看表
    • 3. 持久化配置
      • 1. application.properties修改前
      • 2. application.properties修改后
  • 3. 启动
    • 1. 启动
      • 1. 未配置MySQL8.X持久化前显示的是嵌入式存储
      • 2. 配置MySQL8.X持久化后显示使用的是外部存储
    • 2. 打开浏览器访问
      • 1. Naocs2.2.2版本前需要登录
      • 2. nacos2.2.2版本之后无需登录
    • 3. 关于Naocs鉴权
    • 1. 开启鉴权访问
    • 2. 鉴权配置不当常见错误

1. 官网与下载

1. 官网

官网:https://nacos.io/zh-cn/docs/quick-start.html

Nacos文档:https://nacos.io/zh-cn/docs/quick-start.html

GitHub: https://github.com/alibaba/nacos/releases

2. Naocs是什么?

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service的首字母简称,一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。

Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。

Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。 Nacos 是构建以“服务”为中心的现代应用架构 (例如微服务范式、云原生范式) 的服务基础设施。

3. 下载

您可以在Nacos的release notes及博客中找到每个版本支持的功能的介绍及下载,截止到2024-03-02 官方推荐的稳定版本为2.2.3。

在这里插入图片描述

Github中下载

在这里插入图片描述

github直接下载链接

Windows: https://github.com/alibaba/nacos/releases/download/2.2.3/nacos-server-2.2.3.zip

Linux: https://github.com/alibaba/nacos/releases/download/2.2.3/nacos-server-2.2.3.tar.gz

2. 安装与持久化配置

  1. Naocs默认使用的是嵌入式数据库derby

  2. 这里改为MySQL8作为持久化存储,Naocs也仅支持derbymysql的,其他数据库存储需要自行编译支持,可参考nacos github中提供的插件来支持其他数据库的持久化

  3. Nacos 从 2.2.0 版本开始,可通过 SPI 机制注入多数据源实现插件,并在引入对应数据源进行源码编译后,便可在 Nacos 启动时通过读取 application.properties 配置文件中 spring.datasource.platform 配置项选择加载对应多数据源插件;

  4. 多数据源支持github地址:https://github.com/alibaba/nacos/blob/feature_multiple_datasource_support/README.md;

  5. 下面以Windows版本为例配置Nacos2.2.3的持久化,Linux配置类似。

1. 解压安装

将下载后的nacos-server-2.2.3.zip解压到指定目录,如:H:\0002024CloudDeploy\nacos-2.2.3

2. 创建数据库

根据nacos-2.2.3/conf目录下的mysql-schema.sql创建数据库

在这里插入图片描述

1. 连接数据库

  1. 打开命令行创建并进入到H:\0002024CloudDeploy\nacos-2.2.3\conf目录下;
  2. 然后输入命令mysql -P 3307 -u root -p连接数据,注意这里使用 -P 3307指定连接MySQL的端口为3307,如果是默认的3306可以不写
H:\0002024CloudDeploy\nacos-2.2.3\conf>mysql -P 3307 -u root -p
Enter password: ******* # 这里输入密码回车,如下:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 421
Server version: 8.0.29 MySQL Community Server - GPLCopyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

2. 创建nacos数据库

mysql> create database nacos_config default character set utf8mb4 collate utf8mb4_general_ci;
Query OK, 1 row affected (0.01 sec)mysql>

3. 导入脚本

# 切换到 nacos_config数据库
mysql> use nacos_config;
Database changed
# 导入脚本
mysql> source mysql-schema.sql;
Query OK, 0 rows affected, 3 warnings (0.05 sec)Query OK, 0 rows affected, 3 warnings (0.04 sec)Query OK, 0 rows affected, 3 warnings (0.04 sec)Query OK, 0 rows affected, 3 warnings (0.04 sec)Query OK, 0 rows affected, 4 warnings (0.05 sec)Query OK, 0 rows affected, 9 warnings (0.04 sec)Query OK, 0 rows affected, 4 warnings (0.05 sec)Query OK, 0 rows affected, 9 warnings (0.04 sec)Query OK, 0 rows affected, 5 warnings (0.04 sec)Query OK, 0 rows affected (0.03 sec)Query OK, 0 rows affected (0.03 sec)Query OK, 0 rows affected (0.05 sec)Query OK, 1 row affected (0.01 sec)Query OK, 1 row affected (0.01 sec)mysql>

4. 查看表

nacos有12张表,如下

mysql> show tables;
+------------------------+
| Tables_in_nacos_config |
+------------------------+
| config_info            |
| config_info_aggr       |
| config_info_beta       |
| config_info_tag        |
| config_tags_relation   |
| group_capacity         |
| his_config_info        |
| permissions            |
| roles                  |
| tenant_capacity        |
| tenant_info            |
| users                  |
+------------------------+
12 rows in set (0.01 sec)mysql>

3. 持久化配置

  1. nacos本身也是一个SpringBoot应用,所以配置在application.properties

  2. nacos持久还配置在nacos-2.2.3/conf/application.properties中进行设置

在这里插入图片描述

1. application.properties修改前

application.properties中大概从33行开始,可以看到Config Module Related Configurations注释部分


#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
# spring.datasource.platform=mysql
# spring.sql.init.platform=mysql### Count of DB:
# db.num=1### Connect URL of DB:
# db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
# db.user.0=nacos
# db.password.0=nacos### Connection pool configuration: hikariCP

2. application.properties修改后

  1. db.开头的相关注释去掉;

  2. 注意spring.datasource.platform配置属性已弃用,建议使用spring.sql.init.platform替换。

#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
# spring.datasource.platform=mysql
spring.sql.init.platform=mysql### Count of DB:
# db.num=1
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3307/my_nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true
db.user.0=root
db.password.0=你的密码### Connection pool configuration: hikariCP

3. 启动

Nacos默认是以集群的方式启动的,如果需要单机启动,则在命令行中指定-m standalone参数来启动

1. 启动

  1. 打开命令行创口,进入nacos安装的bin目录下;
  2. 执行命令startup.cmd -m standalone启动

1. 未配置MySQL8.X持久化前显示的是嵌入式存储

在这里插入图片描述

2. 配置MySQL8.X持久化后显示使用的是外部存储

在这里插入图片描述

Microsoft Windows [版本 10.0.22631.3155]
(c) Microsoft Corporation。保留所有权利。H:\0002024CloudDeploy\nacos-2.2.3\bin>startup.cmd -m standalone
"nacos is starting with standalone",--.,--.'|,--,:  : |                                           Nacos 2.2.3
,`--.'`|  ' :                       ,---.               Running in stand alone mode, All function modules
|   :  :  | |                      '   ,'\   .--.--.    Port: 8848
:   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 27412
|   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://192.168.1.3:8848/nacos/index.html
'   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_
|   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io
'   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \
|   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /
'   : |     ;  :   .'   \   :    : `----'  '--'.     /
;   |.'     |  ,     .-./\   \  /            `--'---'
'---'        `--`---'     `----'2024-03-02 15:50:55,370 INFO Tomcat initialized with port(s): 8848 (http)2024-03-02 15:50:55,451 INFO Root WebApplicationContext: initialization completed in 2475 ms2024-03-02 15:50:58,970 INFO Adding welcome page: class path resource [static/index.html]2024-03-02 15:50:59,537 WARN You are asking Spring Security to ignore Ant [pattern='/**']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.2024-03-02 15:50:59,538 INFO Will not secure Ant [pattern='/**']2024-03-02 15:50:59,559 INFO Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@1133ec6e, org.springframework.security.web.context.SecurityContextPersistenceFilter@759fad4, org.springframework.security.web.header.HeaderWriterFilter@62417a16, org.springframework.security.web.csrf.CsrfFilter@22c86919, org.springframework.security.web.authentication.logout.LogoutFilter@5ae76500, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@53499d85, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@782a4fff, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@355e34c7, org.springframework.security.web.session.SessionManagementFilter@26be6ca7, org.springframework.security.web.access.ExceptionTranslationFilter@1b0a7baf]2024-03-02 15:50:59,581 INFO Exposing 1 endpoint(s) beneath base path '/actuator'2024-03-02 15:50:59,620 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'2024-03-02 15:50:59,643 INFO Nacos started successfully in stand alone mode. use external storage

2. 打开浏览器访问

特别注意

2.2.2版本之前的Nacos默认控制台,无论服务端是否开启鉴权,都会存在一个登录页;这导致很多用户被误导认为Nacos默认是存在鉴权的。在社区安全工程师的建议下,Nacos自2.2.2版本开始,在未开启鉴权时,默认控制台将不需要登录即可访问,同时在控制台中给予提示,提醒用户当前集群未开启鉴权。

在用户开启鉴权后,控制台才需要进行登录访问。 同时针对不同的鉴权插件,提供新的接口方法,用于提示控制台是否开启登录页;同时在2.2.3版本后,Nacos可支持关闭开源控制台,并引导到用户自定义的Nacos控制台,详情可查看Nacos鉴权插件-服务端插件及控制台手册-关闭登录功能

1. Naocs2.2.2版本前需要登录

访问: http://localhost:8848/nacos ,需要登录

  1. 输入用户名密码登录后如下:,默认用户名/密码:nacos/nacos
  2. 登录后才进入到默认的配置管理列表页面中

在这里插入图片描述

2. nacos2.2.2版本之后无需登录

访问: http://localhost:8848/nacos,直接进入到配置列表页面中,可看到提示没有开启鉴权

如需要开启鉴权,点击下图红色区域的文档连接查看与配置即可

在这里插入图片描述

3. 关于Naocs鉴权

  1. 关于nacos的鉴权,请查看官网 https://nacos.io/zh-cn/docs/v2/guide/user/auth.html
  2. 鉴权配置不当,nacos无法启动

1. 开启鉴权访问

application.properties中开启开启鉴权相关配置 ,如下

### If turn on auth system:
nacos.core.auth.system.type=nacos
# 1. 开启鉴权, 默认为 false 
nacos.core.auth.enabled=true ### ...
### 2. nacos.core.auth.server.identity.key与nacos.core.auth.server.identity.value默认为空,如果开启了nacos.core.auth.enabled=true 则必须配置这两项,否则启动报错
### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
### 自1.4.1起,在nacos.core.auth.enabled=true和nacos.core.auth.eenable.userAgentAuthWhite=false时起效
### 这两个属性是身份验证的白名单,用于标识来自其他服务器的请求,按需修改配置,如这里都配置为nacos
nacos.core.auth.server.identity.key=nacos
nacos.core.auth.server.identity.value=nacos### ....
### 3. 配置nacos.core.auth.plugin.nacos.token.secret.key,2.2.2起默认为空,必须否则启动时报错
### The default token (Base64 String): 自定义密钥时,推荐将配置项设置为Base64编码的字符串,且原始密钥长度不得低于32字符
nacos.core.auth.plugin.nacos.token.secret.key=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=

开启鉴权配置后,访问时会出现跟2.2.2版本以前一样的的登录界面

2. 鉴权配置不当常见错误

  1. 仅开启了鉴权nacos.core.auth.enabled=true ,而未设置nacos.core.auth.server.identity.keynacos.core.auth.server.identity.value
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authConfigs': Invocation of init method failed; nested exception is ErrCode:50002, ErrMsg:Empty identity, Please set `nacos.core.auth.server.identity.key` and `nacos.core.auth.server.identity.value`, detail: https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160)// ......
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)... 75 common frames omitted
Caused by: com.alibaba.nacos.api.exception.NacosException: Empty identity, Please set `nacos.core.auth.server.identity.key` and `nacos.core.auth.server.identity.value`, detail: https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat com.alibaba.nacos.auth.config.AuthConfigs.validate(AuthConfigs.java:102)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:389)at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333)at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157)... 88 common frames omitted
2024-03-02 16:24:08,308 WARN [ThreadPoolManager] Start destroying ThreadPool2024-03-02 16:24:08,308 WARN [ThreadPoolManager] Destruction of the end
  1. 未设置nacos.core.auth.plugin.nacos.token.secret.key
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2024-03-02 17:23:11,941 ERROR Application run failedorg.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcatat org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745)at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:423)at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)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:108)at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcatat org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142)at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104)at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:479)at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)... 16 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'basicAuthenticationFilter' defined in class path resource [com/alibaba/nacos/prometheus/filter/PrometheusAuthFilter.class]: Unsatisfied dependency expressed through method 'basicAuthenticationFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthConfig' defined in URL [jar:file:/H:/0002024CloudDeploy/nacos-2.2.3/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.3.jar!/com/alibaba/nacos/plugin/auth/impl/NacosAuthConfig.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tokenManagerDelegate': Unsatisfied dependency expressed through field 'jwtTokenManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenManager' defined in URL [jar:file:/H:/0002024CloudDeploy/nacos-2.2.3/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.3.jar!/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key  must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:212)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:203)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:97)at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:86)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:260)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234)at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53)at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5211)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)at java.util.concurrent.FutureTask.run(FutureTask.java:266)at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)at java.util.concurrent.FutureTask.run(FutureTask.java:266)at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486)at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123)... 21 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosAuthConfig' defined in URL [jar:file:/H:/0002024CloudDeploy/nacos-2.2.3/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.3.jar!/com/alibaba/nacos/plugin/auth/impl/NacosAuthConfig.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tokenManagerDelegate': Unsatisfied dependency expressed through field 'jwtTokenManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenManager' defined in URL [jar:file:/H:/0002024CloudDeploy/nacos-2.2.3/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.3.jar!/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key  must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:410)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)... 61 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tokenManagerDelegate': Unsatisfied dependency expressed through field 'jwtTokenManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenManager' defined in URL [jar:file:/H:/0002024CloudDeploy/nacos-2.2.3/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.3.jar!/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key  must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)... 84 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenManager' defined in URL [jar:file:/H:/0002024CloudDeploy/nacos-2.2.3/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.3.jar!/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key  must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315)at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:296)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)... 99 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key  must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:311)... 112 common frames omitted
Caused by: java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key  must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.htmlat com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager.processProperties(JwtTokenManager.java:81)at com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager.<init>(JwtTokenManager.java:67)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:423)at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)... 114 common frames omitted
Caused by: java.lang.IllegalArgumentException: The specified key byte array is 0 bits which is not secure enough for any JWT HMAC-SHA algorithm.  The JWT JWA Specification (RFC 7518, Section 3.2) states that keys used with HMAC-SHA algorithms MUST have a size >= 256 bits (the key size must be greater than or equal to the hash output size).  See https://tools.ietf.org/html/rfc7518#section-3.2 for more information.at com.alibaba.nacos.plugin.auth.impl.jwt.NacosJwtParser.<init>(NacosJwtParser.java:56)at com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager.processProperties(JwtTokenManager.java:77)... 120 common frames omitted
2024-03-02 17:23:11,947 WARN [ThreadPoolManager] Start destroying ThreadPool2024-03-02 17:23:11,947 WARN [ThreadPoolManager] Destruction of the endH:\0002024CloudDeploy\nacos-2.2.3\bin>

注意

  • Nacos是一个内部微服务组件,需要在可信的内部网络中运行,不可暴露在公网环境,防止带来安全风险。
  • Nacos提供简单的鉴权实现,为防止业务错用的弱鉴权体系,不是防止恶意攻击的强鉴权体系。
  • 如果运行在不可信的网络环境或者有强鉴权诉求,请参考官方简单实现做进行自定义插件开发。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/522237.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

特性螺旋面的刀具设计记录

最近和成型类刀具杠上了&#xff0c;这不最近有小伙伴提供了两个比较特殊的螺旋面工件&#xff0c;通常称作阴、阳转子。具体形状如下&#xff1a; 阴转子 阴转子端面齿形没看出有什么特殊的&#xff0c;但是在轴剖面齿形是内凹的&#xff0c;这个是比较特殊的形式。 阳转子…

使用再生龙(Clonezilla)备份和还原Linux系统

1. 再生龙(Clonezilla)介绍&#xff1a; Clonezilla是一款开源的磁盘克隆和备份工具&#xff0c;它可以帮助用户快速、高效地克隆和备份硬盘或分区。Clonezilla提供了两种不同的版本&#xff1a;Clonezilla Live和Clonezilla SE(Server Edition)。 Clonezilla Live&#xff1a;…

5. Java内存模型JMM

文章目录 计算机硬件存储体系基于计算机存储结构的 JMM Java 内存模型 JavaMemoryModelJMM规范下的三大特性原子性可见性有序性 多线程对变量的读写过程读取过程 多线程先行发生原则 happens-beforex,y 的 case 说明happens-before 原则说明happens-before 大原则happens-befor…

VBA_MF系列技术资料1-395

MF系列VBA技术资料1-395 为了让广大学员在VBA编程中有切实可行的思路及有效的提高自己的编程技巧&#xff0c;我参考大量的资料&#xff0c;并结合自己的经验总结了这份MF系列VBA技术综合资料&#xff0c;而且开放源码&#xff08;MF04除外&#xff09;&#xff0c;其中MF01-0…

Devc++调试窗口,一闪而过,调试闪退解决办法

今天使用Dev C调试&#xff0c;发现直接给我闪退了&#xff0c;恼火 解决办法&#xff1a; 安装图片所示框框&#xff0c;从上到下选择&#xff1a; 退出重启&#xff0c;OK

【粉丝福利】探秘内部审计数字化之道:精准解析转型方法与成功路径

&#x1f33c;前言 内部审计是一种独立的、客观的确认和咨询活动&#xff0c;包括鉴证、识别和分析问题以及提供管理建议和解决方案。狭义的数字化转型是指将企业经营管理和业务操作的各种行为、状态和结果用数字的形式来记录和存储&#xff0c;据此再对数据进行挖掘、分析和应…

循环链表的约瑟夫问题(牛客)——C语言解决

循环链表的约瑟夫问题描述 编号为 1 到 n 的 n 个人围成一圈。从编号为 1 的人开始报数&#xff0c;报到 m 的人离开。 下一个人继续从 1 开始报数。 n-1 轮结束以后&#xff0c;只剩下一个人&#xff0c;问最后留下的这个人编号是多少&#xff1f; 数据范围&#xff1a; 1 …

论文解读:Rectifying the Shortcut Learning of Background for Few-Shot Learning

文章汇总 问题&动机&解决方法 图像背景是一种有害知识的来源&#xff0c;这是少数镜头学习模型容易吸收的(问题) 通过在训练和评估中提取图像中的前景目标而不需要任何额外的监督来解决这个问题(动机) 在训练和评估时将模型的注意力吸引到图像前景上(方法) 摘要 …

OpenTenBase 开发环境搭建及Debug设置

最近有个 OpenTenBase开源核心贡献挑战赛 领导建议大家都去试试&#xff0c;我也去凑了下热闹&#xff0c;发现能力有限一时半会是搞不明白了&#xff0c;最多也就是能搞搞文档翻译&#xff0c;或者写点操作手册啥的。 不过不管怎么样&#xff0c;先把开发环境搭上&#xff0c;…

Zabbix(四)

Zabbix Proxy zabbix作为一个分布式监控系统(分布式监控解决方案)&#xff0c;支持通过代理(proxy)收集zabbix agent的监控数据&#xff0c;然后由zabbix proxy再把数据发送给zabbix server&#xff0c;也就是zabbix proxy 可以代替zabbix server收集监控数据&#xff0c;然后…

Chrome安装Axure插件

打开原型目录/resources/chrome&#xff0c;重命名axure-chrome-extension.crx&#xff0c;修改后缀为rar&#xff0c;axure-chrome-extension.rar 解压到axure-chrome-extension目录打开Chrome&#xff0c;更多工具->扩展程序&#xff0c;打开开发者模式&#xff0c;选择加…

用BIO实现tomcat

一、前言 本课程的难度较高&#xff0c;需要将Servlet原理和IO课程全部学完。 二、当前项目使用方式 (1).自定义servlet 自定义servlet需要实现WebServlet并且实现name和urlMapping 重启进行访问 http://localhost:8090/myServlet (2).自定义html 重启进行访问 http://loc…