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.rhkb.cn/news/272568.html

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

相关文章

【Linux】编译器-gcc/g++使用

个人主页 &#xff1a; zxctscl 文章封面来自&#xff1a;艺术家–贤海林 如有转载请先通知 文章目录 1. 前言2. 初见gcc和g3. 程序的翻译过程3.1 预处理3.1.1 宏替换 去注释 头文件展开3.1.2 条件编译 3.2 编译3.3 汇编3.4 链接 4. 链接4.1 动态链接4.2 静态链接 1. 前言 在之…

OpenStack之keystone(用户认证)

Keystone&#xff08;认证&#xff09; Keystone 概述 1)管理用户及其权限 2)维护OpenStack Services 的 Endpoint 3)Authentication&#xff08;认证&#xff09;和 Authorization&#xff08;授权&#xff09; keystone的名词概念 1.User&#xff08;用户或服务&#xf…

C++内存管理篇

文章目录 1. C/C内存分布2. C中的内存管理方式3. operator new和operator delete函数4. new和delete的实现原理5. 定位new表达式(placement-new) 1. C/C内存分布 C语言中&#xff0c;为了方便管理内存空间&#xff0c;将内存分成了不同的区域&#xff0c;每个区域管理不同的数据…

代码随想录训练营第41天 | 动态规划:01背包理论基础、动态规划:01背包理论基础(滚动数组)、LeetCode 416.分割等和子集

动态规划&#xff1a;01背包理论基础 文章讲解&#xff1a;代码随想录(programmercarl.com) 视频讲解&#xff1a;带你学透0-1背包问题&#xff01;_哔哩哔哩_bilibili 动态规划&#xff1a;01背包理论基础&#xff08;滚动数组&#xff09; 文章讲解&#xff1a;代码随想录(…

支付宝开放平台证书验签生成签名接入方式的操作流程之公钥证书,密钥证书的生成

#小李子9479# 调用支付宝接口的安全验证方式均使用sign_type为RSA2的方式&#xff0c;有两种 1。密钥模式&#xff1a;应用公钥、应用私钥、平台公钥生成签名和验签方式 2。证书模式&#xff1a;支付宝根证书、支付宝公钥证书、应用公钥证书、应用私钥&#xff0c;采用RSA20…

Solidity Uniswap V2 价格预言机

预言机是连接区块链与链下服务的桥梁&#xff0c;这样就可以从智能合约中查询现实世界的数据。Chainlink 是最大的oracle网络之一&#xff0c;创建于 2017 年&#xff0c;如今已成为许多 DeFi 应用的重要组成部分。https://github.com/XuHugo/solidityproject Uniswap 虽然是链…

【❤️算法笔记❤️】-每日一刷-19、删除链表的倒数第 N个结点

文章目录 题目思路解答 题目 给你一个链表&#xff0c;删除链表的倒数第 n 个结点&#xff0c;并且返回链表的头结点。 输入&#xff1a;head [1,2,3,4,5], n 2 输出&#xff1a;[1,2,3,5]示例 2&#xff1a; 输入&#xff1a;head [1], n 1 输出&#xff1a;[]示例 3&…

迷不迷糊?前后端、三层架构和MVC傻傻分不清

现在的项目都讲究前后端分离&#xff0c;那到底什么是前后端&#xff0c;前后端和以前的MVC以及三层架构啥关系呢&#xff1f;今天就这个问题展开一下&#xff0c;方面后面的学习&#xff0c;因为前面讲的jsp、servlet和javabean根据实例&#xff0c;基本上有一个框架的理解了&…

Ubuntu下使用DAPLink(OpenOCD)

目录 1. 下载OpenOCD源代码 2. 编译代码 2.1 运行bootstrap 2.2 安装关联库 2.3 运行./configure 2.4 运行make 2.5 运行sudo make install 3. 烧录程序 3.1 挂起MCU 3.2 写入镜像 3.3 校验镜像 通过OpenOCD实现&#xff0c;在Ubuntu18 64bit下验证。 1. 下载OpenOC…

人力资源社会保障部教育部关于印发《关于深化中小学教师职称制度改革的指导意见》的通知

人力资源社会保障部、教育部印发 关于《深化中小学教师职称制度改革的指导意见》的通知 人社部发[2015]79号 各省、自治区、直辖市及新疆生产建设兵团人力资源社会保障厅&#xff08;局&#xff09;、教育部门&#xff08;教委、教育局&#xff09;&#xff1a; 为深化教育…

机器学习第29周周报 Beyond Dropout

文章目录 week29 Beyond Dropout摘要Abstract一、泛化理论二、文献阅读1. 题目2. abstract3. 网络架构3.1 特征图失真3.2 失真优化 4. 文献解读4.1 Introduction4.2 创新点4.3 实验过程4.3.1 全连接层实验4.3.2 卷积网络上的实验 4.4 结论 小结参考文献 week29 Beyond Dropout …

【C++专栏】C++入门 | 函数重载、引用、内联函数

博客主页&#xff1a;Duck Bro 博客主页系列专栏&#xff1a;C专栏关注博主&#xff0c;后期持续更新系列文章如果有错误感谢请大家批评指出&#xff0c;及时修改感谢大家点赞&#x1f44d;收藏⭐评论✍ C入门 | 函数重载、引用、内联函数 文章编号&#xff1a;C入门 / 02 文…

sizeof辨析——二维数组(超级详细)

二维数组加sizeof的知识如果基础不扎实&#xff0c;上面的代码恐怕很难区分&#xff0c;这篇文章就深度解析一下有关问题 我们在分析之前&#xff0c;要提及一些基础的前提知识 前提知识&#xff1a; 一&#xff1a; &数组名 和 sizeof&#xff08;数组名&#xff09;这…

【算法沉淀】最长回文子串

&#x1f389;&#x1f389;欢迎光临&#x1f389;&#x1f389; &#x1f3c5;我是苏泽&#xff0c;一位对技术充满热情的探索者和分享者。&#x1f680;&#x1f680; &#x1f31f;特别推荐给大家我的最新专栏《数据结构与算法&#xff1a;初学者入门指南》&#x1f4d8;&am…

每日OJ题_路径dp①_力扣62. 不同路径

目录 力扣62. 不同路径 解析代码 力扣62. 不同路径 62. 不同路径 难度 中等 一个机器人位于一个 m x n 网格的左上角 &#xff08;起始点在下图中标记为 “Start” &#xff09;。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角&#xff08;在下图中标…

视频可回溯系统技术方案vue3+ts+tegg+mysql+redis+oss

一、 项目背景 保险、基金、银行等众多行业在做技术平台时都会需要一种能够准确了解用户操作行为的方式方法。诸如通过埋点、平台监控、视频可回溯等&#xff0c;通过技术手段&#xff0c;保存用户操作轨迹&#xff0c;以此规范安全销售、平台健康检查、出现纠纷时可追溯、问题…

chrome插件开发的几种展现页面形式,3分钟看完

想要开发一个chrome浏览器插件&#xff0c;还是很有必要清楚插件都可以在哪些地方显示出来的&#xff0c;比如只想在pop页面弹出&#xff0c;还是添加右键菜单&#xff0c;还是提示桌面通知&#xff1f;还是在哪里展示&#xff1f;有哪些展示方式等 browserAction(浏览器右上角…

免费下载Corel Video Studio 2024-轻松创建令人惊叹的视频!

免费下载Corel Video Studio 2024-轻松创建令人惊叹的视频&#xff01; Corel Video Studio 2024免费下载Keygen 你厌倦了在视频编辑软件上花大钱吗&#xff1f;别再看了&#xff01;我们为您提供了完美的解决方案——Corel Video Studio 2024。最棒的部分是什么&#xff1f;…

分享MDN前端结构化技能、实践指南、学习资源

前言 MDN课程为成为一名成功的前端开发人员提供了一个结构化的基本技能和实践指南&#xff0c;以及推荐的学习资源。 先看下让人不得不服的书《宝宝的网页设计》&#xff08;套装共3册&#xff09; 宝宝的HTML、宝宝的CSS、宝宝的JavaScript 全球首套中英文宝宝编程启蒙书&a…

计算机网络 八股

计算机网络体系结构 OSI&#xff1a;物理层、数据链路层、网络层、运输层、会话层、表示层、应用层