Nacos v2.0.4升级到v2.1.0报错解决方案:nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'encrypted_data_key' in 'field list'
一、Nacos v2.0.4升级到v2.1.0后启动报如下错误:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'memoryMonitor' defined in URL [jar:file:/home/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-config-2.1.0.jar!/com/alibaba/nacos/config/server/monitor/MemoryMonitor.class]:
Unsatisfied dependency expressed through constructor parameter 0; nested exception is 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 :
2022-05-31T06:58:30.314373334Z 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 ?,?]; nested exception is java.sql.SQLSyntaxErrorException:
Unknown column 'encrypted_data_key' in 'field list'
二、解决方案:
看提示是数据表缺少encrypted_data_key字段,那就手动为据表添加该字段
为保证用户敏感配置数据的安全,Nacos 提供了配置加密的新特性。降低了用户使用的风险,也不需要再对配置进行单独的加密处理。
数据库表 config_info、config_info_beta、his_config_info中需要新增字段 encrypted_data_key ,用来存储每一个配置项加密使用的秘钥。新版本的默认创建表的sql中已经添加该字段。
--对于目前已经搭建好的 Nacos 使用以下 sql 将字段添加到对应的表中:
ALTER TABLE table_name ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT '秘钥'
浙公网安备 33010602011771号