nacos安装教程

x33g5p2x  于2022-03-11 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(767)

nacos安装步骤

1.解压安装包

2.创建mysql数据库

3.编辑配置文件application.properties

编辑端口号:

解开数据库的注释

编辑数据库连接的地址

添加数据库连接池的配置

完整配置如下,已删掉多余的注释

4.进入bin目录启动nacos

安装成功

nacos安装步骤

本次教程是针对的nacos版本:2.0.1,不同的版本,可能略有不同。

官网下载地址:

https://github.com/alibaba/nacos/tags

我下载的是2.0.1版本

1.解压安装包

  1. tar -xvf nacos-server-2.0.1.tar.gz

2.创建mysql数据库

SQL文件在解压文件下的config文件夹下,nacos-mysql.sql

nacos的各种数据存储在mysql数据库中

在MySQL服务器上创建nacos-mysql数据库,将SQL文件导入其中

3.编辑配置文件application.properties

编辑端口号:

  1. ### Default web context path:
  2. server.servlet.contextPath=/nacos
  3. ### Default web server port:
  4. server.port=5555

解开数据库的注释

  1. ### If use MySQL as datasource:
  2. spring.datasource.platform=mysql
  3. ### Count of DB:
  4. db.num=1

编辑数据库连接的地址

  1. ### Connect URL of DB:
  2. db.url.0=jdbc:mysql://mysql.xxx.tech:3306/nacos_prod?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
  3. db.user.0=nacos
  4. db.password.0=nacos

添加数据库连接池的配置

  1. ### Connection pool configuration: hikariCP
  2. db.pool.config.connectionTimeout=30000
  3. db.pool.config.validationTimeout=10000
  4. db.pool.config.maximumPoolSize=20
  5. db.pool.config.minimumIdle=2

完整配置如下,已删掉多余的注释

  1. #*************** Spring Boot Related Configurations ***************#
  2. ### Default web context path:
  3. server.servlet.contextPath=/nacos
  4. ### Default web server port:
  5. server.port=5555
  6. #*************** Config Module Related Configurations ***************#
  7. ### If use MySQL as datasource:
  8. spring.datasource.platform=mysql
  9. ### Count of DB:
  10. db.num=1
  11. ### Connect URL of DB:
  12. db.url.0=jdbc:mysql://mysql.xxx.tech:3306/nacos_prod?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
  13. db.user.0=nacos
  14. db.password.0=nacos
  15. ### Connection pool configuration: hikariCP
  16. db.pool.config.connectionTimeout=30000
  17. db.pool.config.validationTimeout=10000
  18. db.pool.config.maximumPoolSize=20
  19. db.pool.config.minimumIdle=2
  20. # nacos.naming.expireInstance=true
  21. nacos.naming.empty-service.auto-clean=true
  22. nacos.naming.empty-service.clean.initial-delay-ms=50000
  23. nacos.naming.empty-service.clean.period-time-ms=30000
  24. ### Metrics for elastic search
  25. management.metrics.export.elastic.enabled=false
  26. #management.metrics.export.elastic.host=http://localhost:9200
  27. ### Metrics for influx
  28. management.metrics.export.influx.enabled=false
  29. #*************** Access Log Related Configurations ***************#
  30. ### If turn on the access log:
  31. server.tomcat.accesslog.enabled=false
  32. ### The access log pattern:
  33. server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
  34. ### The directory of access log:
  35. server.tomcat.basedir=
  36. #*************** Access Control Related Configurations ***************#
  37. ### The ignore urls of auth, is deprecated in 1.2.0:
  38. nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
  39. ### The auth system to use, currently only 'nacos' is supported:
  40. nacos.core.auth.system.type=nacos
  41. ### If turn on auth system:
  42. nacos.core.auth.enabled=false
  43. ### The token expiration in seconds:
  44. nacos.core.auth.default.token.expire.seconds=18000
  45. ### The default token:
  46. nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
  47. ### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
  48. nacos.core.auth.caching.enabled=true
  49. ### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
  50. nacos.core.auth.enable.userAgentAuthWhite=true
  51. ### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
  52. ### The two properties is the white list for auth and used by identity the request from other server.
  53. nacos.core.auth.server.identity.key=
  54. nacos.core.auth.server.identity.value=
  55. #*************** Istio Related Configurations ***************#
  56. ### If turn on the MCP server:
  57. nacos.istio.mcp.server.enabled=false

若是配置集群的话,需要修改cluster.conf.example

在里边添加其他节点的nacos的IP+端口号

4.进入bin目录启动nacos

  1. ./startup.sh

安装成功

SpringCloud项目集成nacos请看这篇文章

SpringBoot项目集成nacos,并启动报错Failed to configure a DataSource: ‘url‘ attribute is not speci_小小张自由—>张有博-CSDN博客_springboot整合nacos启动报错本文详细介绍了nacos,常用的nacos的名词。springboot项目集成nacos的全过程,并从多个角度解决启动报错 Failed to configure a DataSource: ‘url‘ attribute is not speci

https://blog.csdn.net/promsing/article/details/121123765

如果本篇博客对您有一定的帮助,大家记得留言+点赞+收藏哦。 

相关文章