首页 > 其他分享 >Nacos v2.1.2升级到v2.2.0后启动报如下错误

Nacos v2.1.2升级到v2.2.0后启动报如下错误

时间:2023-01-08 16:47:30浏览次数:46  
标签:info config v2.2 Nacos v2.1 nacos key encrypted data

今天更新了最新的nacos镜像后,发现升级到了v2.2.0版本,是2022年12月14日发布。更新后, Nacos启动出错:

1. 异常1:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'asyncNotifyService': Unsatisfied dependency expressed through field 'dumpService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :,
No DataSource set,
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)

解决办法:

1.1 检查数据库配置文件

### If use MySQL as datasource:
# spring.datasource.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

1.2 检查数据库的3306端口是否可以访问,尤其是在docker容器内。

1.3 数据库配置文件里的url ,参数部分修改为:characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai

2. 异常问题2

Caused by: com.alibaba.nacos.api.exception.NacosException: Nacos Server did not start because dumpservice bean construction failure :,
PreparedStatementCallback; bad SQL grammar [SELECT id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,type,encrypted_data_key FROM config_info WHERE id > ? ORDER BY id ASC LIMIT 0,1000]; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'encrypted_data_key' in 'field list',
    at com.alibaba.nacos.config.server.service.dump.DumpService.dumpOperate(DumpService.java:260),
    at 

看异常信息应该是nacos数据库表缺少encrypted_data_key字段。升级v2.2.0版后为保证用户敏感配置数据的安全,Nacos 提供了配置加密的新特性,降低了用户使用的风险,也不需要再对配置进行单独的加密处理。需要修改的表:

 config_info、config_info_beta、his_config_info.

增加encrypted_data_key字段:

ALTER TABLE config_info ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT 'secret key';
ALTER TABLE config_info_beta ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT 'secret key';
ALTER TABLE his_config_info ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT 'secret key';

新版应该数据库脚本字段应该添加,旧版本升级时需要添加这个字段。

标签:info,config,v2.2,Nacos,v2.1,nacos,key,encrypted,data
From: https://www.cnblogs.com/harbin1900/p/17034839.html

相关文章