二、Nacos 2.2.3 生产级部署指南Windows版本(单机 + MySQL + 鉴权)

Nacos 作为阿里开源的动态服务发现、配置管理和服务管理平台,是微服务架构中不可或缺的核心组件。本文将以 Nacos 2.2.3 版本为例,详细讲解 Windows 系统下基于 MySQL8.4.0 持久化的单机版部署流程

1、windows必须先安装jdk8;

Nacos 基于 Java 开发,2.2.3 版本对 JDK8 兼容性最佳,高版本 JDK 可能出现兼容性问题,务必选择 JDK8。

2、安装MySQL840

Nacos 默认使用嵌入式数据库 Derby,重启后数据会丢失,生产 / 测试环境需改用 MySQL 持久化配置,本文选择 MySQL8.4.0 版本。

3、数据库(nacos_config)与表需要手动建立;

4、数据表建立语句

https://github.com/alibaba/nacos/blob/2.2.3/distribution/conf/mysql-schema.sql

部署过程中需要打开对应的版本git地址;

5、部署Nacos

打开bin目录下的startup.cmd 设置mode为standalone 单机模式

运行startup.cmd文件

6、application.properties 内容如下:

复制代码
# 基础单机配置(保留你的原有设置)
nacos.standalone=true
server.port=8848

# MySQL连接配置
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://172.16.22.40:3306/nacos_config?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
db.user.0=root
db.password.0=shhy123

# ========== 你的原有鉴权配置(完全保留,2.2.3适配,无需修改) ==========
nacos.core.auth.enabled=true
nacos.core.auth.plugin.enabled=true
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
nacos.core.auth.server.identity.key=custom-auth-key
nacos.core.auth.server.identity.value=custom-auth-value
nacos.core.auth.identity.key=custom-auth-key
nacos.core.auth.identity.value=custom-auth-value
nacos.core.auth.enable.userAgentAuthWhite=false
nacos.core.auth.plugin.nacos.token.empty.access=false

# 可选:解决Windows日志中文乱码(建议保留)
server.tomcat.uri-encoding=UTF-8
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
相关推荐
hef2881 天前
如何实现SQL字段值的计算输出:算术运算符与别名结合
jvm·数据库·python
2401_827499991 天前
python项目实战11-正则表达式基础
python·mysql·正则表达式
那个失眠的夜1 天前
Spring 的纯注解配置
xml·java·数据库·后端·spring·junit
XDHCOM1 天前
ORA-06722: TLI Driver连接失败,Oracle报错修复对比远程处理,选择最佳解决方案
数据库·oracle
小红的布丁1 天前
Redis 集群详解:主从哨兵和切片集群有什么区别
前端·数据库·redis
杰克尼1 天前
redis(day08-Redis原理篇)
数据库·redis·php
余佬学数据库1 天前
Oracle 19c RECOVER TABLE 恢复误删除数据
数据库·oracle
Dream of maid1 天前
Mysql(6)关联查询
数据库·mysql
lonelyhiker1 天前
cas学习笔记
数据库·笔记·学习
云淡风轻~窗明几净1 天前
ubuntu的lazarus的Tline/TeaLine组件的构思
linux·数据库·ubuntu