WSL配置docker启动nacos容器load derby-schema.sql error.问题解决方案

问题再现

本来想要本地跑一下nacos,之前都是直接在Linux环境下面,现在就使用windows的wsl跑一下nacos,之前是需要先配置/conf文件下面的porperties文件以及构建对应的nacos-config数据库。所以我使用docker的时候就直接启动一个没有挂载的nacos容器,之后复制/conf文件以及/data文件到对应的挂载目录下面,之后直接docker rm -f 这个容器,之后挂载对应的容器,之后出现出现错误
重现错误

查看错误logs

2025-05-11 10:50:48,932 ERROR Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: 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:/home/nacos/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 3; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'nacosUserDetailsServiceImpl': Unsatisfied dependency expressed through field 'userPersistService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'embeddedUserPersistServiceImpl': Unsatisfied dependency expressed through field 'databaseOperate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'standaloneDatabaseOperateImpl': Invocation of init method failed; nested exception is java.lang.RuntimeException: com.alibaba.nacos.api.exception.runtime.NacosRuntimeException: errCode: 500, errMsg: load derby-schema.sql error.
我就复制了最前面的一段,后面的ERROR信息其实都是这个导致的,最后我们不难看出是SQL的初始化失败,同时注意这个数据库是Derby-schema.sql加载出现错误,所以应该是data这个文件错误

QWEN的解答

现在使用大模型当然是解决问题的第一优先级,我就直接将问题抛去给qwen3,看看它的建议
qwen3
就是derby数据库的缓存问题,就是说我们不能使用之前那个创建的nacos的数据库的sql来初始化后面的nacos

不挂载/data

直接将这个nacos容器删除先,之后只挂载/conf看看,同时将D:/Docker/nacos下面的文件删除干净
只挂载/conf文件
在这里插入图片描述

在这里插入图片描述

结论

只需要挂载/conf文件,使用原来的Derby数据库缓存会导致出现错误,还有其他的建议是直接删除Derby.loc和db.loc这些锁文件,但是我认为挑着文件删除太麻烦了,直接不复制/data就好,我这个单机的nacos暂时还不需要持久化,需要持久化使用的数据库应该是用mysql实现就好。其实只要配置nacos-logback.xml文件,直接复制到/conf文件下面就不需要其他的配置了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值