使用docker ps -a | grep nacos 命令查看nacos状态,发现nacos一直处于重启状态。命令结果如下
[root@slave1 ~]# docker ps -a | grep nacos
90fb3b7bc783 nacos/nacos-server:v2.2.0-slim "bin/docker-startup.…" 2 hours ago Restarting (1) Less than a second ago mall4cloud-nacos
使用vim /root/docker/nacos/logs/nacos.log查看日志发现,在nacos中存在以下错误Unknown column 'encrypted_data_key' in 'field list'.具体错误片段如下
2023-03-02 17:32:43,237 INFO
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-03-02 17:32:43,257 ERROR Application run failed
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.2.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 :
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'
ALTER TABLE config_info ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT '秘钥';
ALTER TABLE config_info_beta ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT '秘钥';
ALTER TABLE his_config_info ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT '秘钥';
环境
docker-compose.yaml
,部署运行了nacos
容器现象
http://192.168.1.46:8848/nacos
无法进入Nacos管理界面MySQL
、RocketMQ
等都正常启动。docker ps -a | grep nacos
命令查看nacos
状态,发现nacos
一直处于重启状态。命令结果如下vim /root/docker/nacos/logs/nacos.log
查看日志发现,在nacos
中存在以下错误Unknown column 'encrypted_data_key' in 'field list'
.具体错误片段如下原因
为保证用户敏感配置数据的安全,Nacos 提供了配置加密的新特性。降低了用户使用的风险,也不需要再对配置进行单独的加密处理。新版本的默认创建表的sql中已经添加该字段。
而
docker-compose.yml
执行时在导入MySQL
的mall4cloud_nacos
数据库与表结构并没有该字段。导致nacos
容器无法正常启动。解决
数据库表 config_info、config_info_beta、his_config_info中需要新增字段 encrypted_data_key ,用来存储每一个配置项加密使用的秘钥。在
mall4cloud_nacos
数据库下执行以下语句