一、下载&解压
略
二、配置集群:conf\cluster.conf
因为是在单机上部署,所以集群是伪集群。
# 在一台机器时必须保证端口号不能是连续的,真实机器时建议保持端口号一致
127.0.0.1:7740
127.0.0.1:7744
127.0.0.1:7748
三、配置数据连接
- 初始化数据库脚本:conf\mysql-schema.sql
- 配置数据库连接
四、配置密钥
【ThisIsSongJianYongCustomSecretKey20130329】经过Base64 编码后的结果如下:
VGhpc0lzU29uZ0ppYW5Zb25nQ3VzdG9tU2VjcmV0S2V5MjAxMzAzMjk=
注意必须是大于32个字符编码后的值!如果不配置该项,则会报如下错误信息:
2023-04-26 20:13:43,837 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:/mnt/d/Tools/nacos-7740/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.1.jar!/com/alibaba/nacos/plugin/auth/impl/NacosAuthConfig.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tokenManagerDelegate': Unsatisfied dependency expressed through field 'jwtTokenManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenManager' defined in URL [jar:file:/mnt/d/Tools/nacos-7740/target/nacos-server.jar!/BOOT-INF/lib/nacos-plugin-default-impl-2.2.1.jar!/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.plugin.auth.impl.token.impl.JwtTokenManager]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: the length of secret key must great than or equal 32 bytes; And the secret key must be encoded by base64.Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.html
所有配置完成后,拷贝出2份,将端口【server.port=7740】分别改为【server.port=7744】、【server.port=7748】,其它配置无需修改!
五、启动nacos集群
启动|关闭命令
# 启动命令
bin/startup.sh
# 关闭命令
bin/shutdwon.sh
登录
http://localhost:7740/nacos 或 http://localhost:7744/nacos 或 http://localhost:7748/nacos
默认账号:nacos
默认密码:nacos
至此,安装完毕!