1. 下载nacos-server安装包:
(https://nacos.io/download/nacos-server/)
2. 解压安装nacos:
解压文件:nacos-server-2.4.0.1.zip
解压后:
3. 配置:
3.1 配置连接数据库为MySQL:
3.1.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=nacos
db.password.0=xxxxxxxx
### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
3.1.2 新建数据库,并初始化SQL脚本:
新建数据库用户:nacos,设置密码并配置相应的读写权限
用新建用户nacos登录,初始化SQL脚本:即在MySQL客户端工具中执行安装包目录下nacos/conf/mysql-schema.sql
3.2 配置登录页面(默认不需要登录),重点蓝色配置项
### 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=xaswjw
nacos.core.auth.server.identity.value=123321123321
### 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=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=
说明:
nacos.core.auth.plugin.nacos.token.secret.key值为Base64后的值,可以自定义,参考:Base64 在线编码解码 | Base64 加密解密 - Base64.us
4. 启动:
启动命令: startup.cmd -m standalone
5. 登录:
首次登录需要初始化nacos登录密码。
如果出现密码认证失败,也可以直接在数据中插入一条数据:
insert into users(username, password, enabled) values('nacos', '$10$mEkBskc5Lxkvcb13Df6Li.l6rooYjLNQTprNpX.lQKOEJQQxilEu6', 1);
默认密位为:nacos
也可以通过在线Bcrypt密码生成工具-Bejson.com 工具自定义密码,然后修改密码:
update users set password = '$10$mEkBskc5Lxkvcb13Df6Li.l6rooYjLNQTprNpX.lQKOEJQQxilEu6' where username = 'nacos'
登录成功界面:
安装完毕!