Nacos默认配置解读

发布于:2024-05-14 ⋅ 阅读:(144) ⋅ 点赞:(0)
# spring
server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
server.contextPath=/nacos
server.port=${NACOS_APPLICATION_PORT:8848}
spring.datasource.platform=${SPRING_DATASOURCE_PLATFORM:""}
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
db.num=${MYSQL_DATABASE_NUM:1}
db.url.0=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?${MYSQL_SERVICE_DB_PARAM:characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false}
db.url.1=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?${MYSQL_SERVICE_DB_PARAM:characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false}
db.user=${MYSQL_SERVICE_USER}
db.password=${MYSQL_SERVICE_PASSWORD}
### The auth system to use, currently only 'nacos' is supported:
nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}


### The token expiration in seconds:
nacos.core.auth.default.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}

### The default token:
nacos.core.auth.default.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey012345678901234567890123456789012345678901234567890123456789}

### 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=${NACOS_AUTH_CACHE_ENABLE:false}
nacos.core.auth.enable.userAgentAuthWhite=${NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLE:false}
nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:serverIdentity}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:security}
server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
# default current work dir
server.tomcat.basedir=
## spring security config
### turn off security
nacos.security.ignore.urls=${NACOS_SECURITY_IGNORE_URLS:/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**}
# metrics for elastic search
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false

nacos.naming.distro.taskDispatchThreadCount=10
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true

下面是详细解读

  1. 服务器配置:

    • server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}: 设置服务器的上下文路径,默认为/nacos
    • server.contextPath=/nacos: 另一种设置上下文路径的方式,也是/nacos
    • server.port=${NACOS_APPLICATION_PORT:8848}: 设置服务器运行的端口,默认为8848。
  2. 数据库配置:

    • db.num=${MYSQL_DATABASE_NUM:1}: 设置数据库数量,默认为1。
    • db.url.0db.url.1: 分别为两个数据库的连接信息,包括数据库地址、端口、数据库名称及其他连接参数。
    • db.user=${MYSQL_SERVICE_USER}: 数据库用户名。
    • db.password=${MYSQL_SERVICE_PASSWORD}: 数据库密码。
  3. Nacos配置:

    • nacos.cmdb.dumpTaskInterval=3600: CMDB的数据转储任务间隔,单位为秒。
    • nacos.cmdb.eventTaskInterval=10: CMDB的事件处理任务间隔,单位为秒。
    • nacos.cmdb.labelTaskInterval=300: CMDB的标签处理任务间隔,单位为秒。
    • nacos.cmdb.loadDataAtStart=false: 启动时是否加载CMDB数据,默认为不加载。
  4. 认证和安全配置:

    • nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}: 设置认证系统类型,默认为nacos
    • nacos.core.auth.default.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}: 默认令牌的过期时间,单位为秒。
    • nacos.core.auth.default.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey012345678901234567890123456789012345678901234567890123456789}: 用于生成认证令牌的秘钥。
    • nacos.core.auth.caching.enabled=${NACOS_AUTH_CACHE_ENABLE:false}: 是否开启认证信息的缓存。
  5. Tomcat和日志配置:

    • server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}: 是否启用Tomcat的访问日志。
    • server.tomcat.accesslog.pattern: 日志格式。
    • server.tomcat.basedir=: 设置Tomcat的基本工作目录。
  6. 安全性忽略URLs:

    • nacos.security.ignore.urls: 定义了不需要安全验证的URL模式。
  7. 性能监控:

    • management.metrics.export.elastic.enabled=false: 是否启用向Elasticsearch导出性能监控数据。
    • management.metrics.export.influx.enabled=false: 是否启用向InfluxDB导出性能监控数据。
  8. Nacos命名服务配置:

    • nacos.naming.distro.taskDispatchThreadCount=10: 分发任务的线程数。
    • nacos.naming.distro.taskDispatchPeriod=200: 分发任务的周期,单位为毫秒。
    • nacos.naming.distro.batchSyncKeyCount=1000: 批量同步的键值数。
    • nacos.naming.distro.initDataRatio=0.9: 初始数据比例。
    • nacos.naming.distro.syncRetryDelay=5000: 同步重试的延迟时间,单位为毫秒。
    • nacos.naming.data.warmup=true: 是否开启数据预热。

在这里插入图片描述


网站公告

今日签到

点亮在社区的每一天
去签到