1、下载安装包,下载路径:https://github.com/alibaba/nacos/releases;找到对应版本,此安装教程是最新的2.4版本
2、下载到本地,找一个目录存放,解压
3、在自己本地创建一个数据库nacos,存放需要的数据库表;数据库文件在conf文件夹下面
这个文件直接去运行就好了;
4、修改配置文件,配置文件在conf下面,跟springboot类似,找到application.properties文件
5、这里我们不使用默认的数据库,配置到自己的数据库,防止数据丢失
修改配置文件,找到spring.datasource.platform配置,修改对应的数据库连接,账号密码 数据库数量这里是1,必填,不然会报错启动不了
#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
spring.datasource.platform=mysql
spring.sql.init.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=root
db.password.0=123456
6、设置登录的账号密码
### The auth system to use, currently only 'nacos' and 'ldap' is supported:
nacos.core.auth.system.type=nacos
### If turn on auth system:
nacos.core.auth.enabled=true
### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=true
### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
nacos.core.auth.enable.userAgentAuthWhite=false
### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=nacos
nacos.core.auth.server.identity.value=nacos
### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.cache.enable=false
nacos.core.auth.plugin.nacos.token.expire.seconds=18000
### The default token (Base64 String):
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
需要注意的地方
nacos.core.auth.plugin.nacos.token.secret.key这个值在2.4版本里面是没有值的,需要填写,可以默认SecretKey012345678901234567890123456789012345678901234567890123456789,也可以自己去生成一个,开启账号密码登录之后这个值必填
nacos.core.auth.enabled=true
nacos.core.auth.server.identity.key=nacos
nacos.core.auth.server.identity.value=nacos
这三个是必填参数,开启登录 账号 密码 不然启动了登录不进去哦
7、启动
进入命令行页面执行
startup.cmd -m standalone
结果是这样就是启动成功了,要是没有启动成功,看下对应的报错信息,直接修改一下配置文件就ok了