直接在机器上部署

下载

下载页面:https://github.com/alibaba/nacos/releases
下载链接:https://github.com/alibaba/nacos/releases/download/2.0.3/nacos-server-2.0.3.tar.gz
https://github.com/alibaba/nacos/releases/download/2.0.3/nacos-server-2.0.3.zip

解压

tar -zxvf nacos-server-2.0.3.tar.gz -C /usr/local/ && cd /usr/local/nacos/conf

配置cluster.conf

cp cluster.conf.example cluster.conf
vim cluster.conf

  1. #
  2. # Copyright 1999-2018 Alibaba Group Holding Ltd.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. #it is ip
  17. #example
  18. 192.168.2.20:8848
  19. 192.168.2.21:8848
  20. 192.168.2.22:8848

19-21行:配置集群信息

配置application.properties文件

vim /usr/local/nacos/conf/application.properties

  1. #
  2. # Copyright 1999-2021 Alibaba Group Holding Ltd.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. #*************** Spring Boot Related Configurations ***************#
  17. ### Default web context path:
  18. server.servlet.contextPath=/nacos
  19. ### Default web server port:
  20. server.port=8848
  21. #*************** Network Related Configurations ***************#
  22. ### If prefer hostname over ip for Nacos server addresses in cluster.conf:
  23. # nacos.inetutils.prefer-hostname-over-ip=false
  24. ### Specify local server's IP:
  25. # nacos.inetutils.ip-address=
  26. #*************** Config Module Related Configurations ***************#
  27. ### If use MySQL as datasource:
  28. # spring.datasource.platform=mysql
  29. spring.datasource.platform=mysql
  30. ### Count of DB:
  31. # db.num=1
  32. ### Connect URL of DB:
  33. db.url.0=jdbc:mysql://192.168.2.20:30569/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
  34. db.user.0=root
  35. db.password.0=root
  36. ### Connection pool configuration: hikariCP
  37. db.pool.config.connectionTimeout=30000
  38. db.pool.config.validationTimeout=10000
  39. db.pool.config.maximumPoolSize=20
  40. db.pool.config.minimumIdle=2
  41. #*************** Naming Module Related Configurations ***************#
  42. ### Data dispatch task execution period in milliseconds: Will removed on v2.1.X, replace with nacos.core.protocol.distro.data.sync.delayMs
  43. # nacos.naming.distro.taskDispatchPeriod=200
  44. ### Data count of batch sync task: Will removed on v2.1.X. Deprecated
  45. # nacos.naming.distro.batchSyncKeyCount=1000
  46. ### Retry delay in milliseconds if sync task failed: Will removed on v2.1.X, replace with nacos.core.protocol.distro.data.sync.retryDelayMs
  47. # nacos.naming.distro.syncRetryDelay=5000
  48. ### If enable data warmup. If set to false, the server would accept request without local data preparation:
  49. # nacos.naming.data.warmup=true
  50. ### If enable the instance auto expiration, kind like of health check of instance:
  51. # nacos.naming.expireInstance=true
  52. ### will be removed and replaced by `nacos.naming.clean` properties
  53. nacos.naming.empty-service.auto-clean=true
  54. nacos.naming.empty-service.clean.initial-delay-ms=50000
  55. nacos.naming.empty-service.clean.period-time-ms=30000
  56. ### Add in 2.0.0
  57. ### The interval to clean empty service, unit: milliseconds.
  58. # nacos.naming.clean.empty-service.interval=60000
  59. ### The expired time to clean empty service, unit: milliseconds.
  60. # nacos.naming.clean.empty-service.expired-time=60000
  61. ### The interval to clean expired metadata, unit: milliseconds.
  62. # nacos.naming.clean.expired-metadata.interval=5000
  63. ### The expired time to clean metadata, unit: milliseconds.
  64. # nacos.naming.clean.expired-metadata.expired-time=60000
  65. ### The delay time before push task to execute from service changed, unit: milliseconds.
  66. # nacos.naming.push.pushTaskDelay=500
  67. ### The timeout for push task execute, unit: milliseconds.
  68. # nacos.naming.push.pushTaskTimeout=5000
  69. ### The delay time for retrying failed push task, unit: milliseconds.
  70. # nacos.naming.push.pushTaskRetryDelay=1000
  71. ### Since 2.0.3
  72. ### The expired time for inactive client, unit: milliseconds.
  73. # nacos.naming.client.expired.time=180000
  74. #*************** CMDB Module Related Configurations ***************#
  75. ### The interval to dump external CMDB in seconds:
  76. # nacos.cmdb.dumpTaskInterval=3600
  77. ### The interval of polling data change event in seconds:
  78. # nacos.cmdb.eventTaskInterval=10
  79. ### The interval of loading labels in seconds:
  80. # nacos.cmdb.labelTaskInterval=300
  81. ### If turn on data loading task:
  82. # nacos.cmdb.loadDataAtStart=false
  83. #*************** Metrics Related Configurations ***************#
  84. ### Metrics for prometheus
  85. #management.endpoints.web.exposure.include=*
  86. ### Metrics for elastic search
  87. management.metrics.export.elastic.enabled=false
  88. #management.metrics.export.elastic.host=http://localhost:9200
  89. ### Metrics for influx
  90. management.metrics.export.influx.enabled=false
  91. #management.metrics.export.influx.db=springboot
  92. #management.metrics.export.influx.uri=http://localhost:8086
  93. #management.metrics.export.influx.auto-create-db=true
  94. #management.metrics.export.influx.consistency=one
  95. #management.metrics.export.influx.compressed=true
  96. #*************** Access Log Related Configurations ***************#
  97. ### If turn on the access log:
  98. server.tomcat.accesslog.enabled=true
  99. ### The access log pattern:
  100. server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
  101. ### The directory of access log:
  102. server.tomcat.basedir=
  103. #*************** Access Control Related Configurations ***************#
  104. ### If enable spring security, this option is deprecated in 1.2.0:
  105. #spring.security.enabled=false
  106. ### The ignore urls of auth, is deprecated in 1.2.0:
  107. nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
  108. ### The auth system to use, currently only 'nacos' and 'ldap' is supported:
  109. nacos.core.auth.system.type=nacos
  110. ### If turn on auth system:
  111. nacos.core.auth.enabled=false
  112. ### worked when nacos.core.auth.system.type=ldap,{0} is Placeholder,replace login username
  113. # nacos.core.auth.ldap.url=ldap://localhost:389
  114. # nacos.core.auth.ldap.userdn=cn={0},ou=user,dc=company,dc=com
  115. ### The token expiration in seconds:
  116. nacos.core.auth.default.token.expire.seconds=18000
  117. ### The default token:
  118. nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
  119. ### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
  120. nacos.core.auth.caching.enabled=true
  121. ### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
  122. nacos.core.auth.enable.userAgentAuthWhite=false
  123. ### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
  124. ### The two properties is the white list for auth and used by identity the request from other server.
  125. nacos.core.auth.server.identity.key=serverIdentity
  126. nacos.core.auth.server.identity.value=security
  127. #*************** Istio Related Configurations ***************#
  128. ### If turn on the MCP server:
  129. nacos.istio.mcp.server.enabled=false
  130. #*************** Core Related Configurations ***************#
  131. ### set the WorkerID manually
  132. # nacos.core.snowflake.worker-id=
  133. ### Member-MetaData
  134. # nacos.core.member.meta.site=
  135. # nacos.core.member.meta.adweight=
  136. # nacos.core.member.meta.weight=
  137. ### MemberLookup
  138. ### Addressing pattern category, If set, the priority is highest
  139. # nacos.core.member.lookup.type=[file,address-server]
  140. ## Set the cluster list with a configuration file or command-line argument
  141. # nacos.member.list=192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809
  142. ## for AddressServerMemberLookup
  143. # Maximum number of retries to query the address server upon initialization
  144. # nacos.core.address-server.retry=5
  145. ## Server domain name address of [address-server] mode
  146. # address.server.domain=jmenv.tbsite.net
  147. ## Server port of [address-server] mode
  148. # address.server.port=8080
  149. ## Request address of [address-server] mode
  150. # address.server.url=/nacos/serverlist
  151. #*************** JRaft Related Configurations ***************#
  152. ### Sets the Raft cluster election timeout, default value is 5 second
  153. # nacos.core.protocol.raft.data.election_timeout_ms=5000
  154. ### Sets the amount of time the Raft snapshot will execute periodically, default is 30 minute
  155. # nacos.core.protocol.raft.data.snapshot_interval_secs=30
  156. ### raft internal worker threads
  157. # nacos.core.protocol.raft.data.core_thread_num=8
  158. ### Number of threads required for raft business request processing
  159. # nacos.core.protocol.raft.data.cli_service_thread_num=4
  160. ### raft linear read strategy. Safe linear reads are used by default, that is, the Leader tenure is confirmed by heartbeat
  161. # nacos.core.protocol.raft.data.read_index_type=ReadOnlySafe
  162. ### rpc request timeout, default 5 seconds
  163. # nacos.core.protocol.raft.data.rpc_request_timeout_ms=5000
  164. #*************** Distro Related Configurations ***************#
  165. ### Distro data sync delay time, when sync task delayed, task will be merged for same data key. Default 1 second.
  166. # nacos.core.protocol.distro.data.sync.delayMs=1000
  167. ### Distro data sync timeout for one sync data, default 3 seconds.
  168. # nacos.core.protocol.distro.data.sync.timeoutMs=3000
  169. ### Distro data sync retry delay time when sync data failed or timeout, same behavior with delayMs, default 3 seconds.
  170. # nacos.core.protocol.distro.data.sync.retryDelayMs=3000
  171. ### Distro data verify interval time, verify synced data whether expired for a interval. Default 5 seconds.
  172. # nacos.core.protocol.distro.data.verify.intervalMs=5000
  173. ### Distro data verify timeout for one verify, default 3 seconds.
  174. # nacos.core.protocol.distro.data.verify.timeoutMs=3000
  175. ### Distro data load retry delay when load snapshot data failed, default 30 seconds.
  176. # nacos.core.protocol.distro.data.load.retryDelayMs=30000

配置34-42行:使用mysql做数据存储

配置jvm参数

vim /usr/local/nacos/bin/startup.sh
JAVA_OPT=”${JAVA_OPT} -server -Xms512M -Xmx2g -Xmn256M

分发安装包

  1. 拷贝整个目录到机器2(node1)、和机器3(node2)中
  2. scp -r /usr/local/nacos root@192.168.2.21:/usr/local/nacos

    启动集群

    1. sh /usr/local/nacos/bin/startup.sh && tail -f /usr/local/nacos/logs/start.out

    查看状态

    http://192.168.2.20:8848/nacos
    nacos/nacos

    停止集群

    1. sh /usr/local/nacos/bin/shutdown.sh
    至此,完成了nacos集群的安装和启停。

    使用docker部署

    ```shell docker run \ —name nacos -d \ -p 8848:8848 \ —privileged=true \ —restart=always \ -e JVM_XMS=256m \ -e JVM_XMX=256m \ -e MODE=standalone \ -e PREFER_HOST_MODE=hostname \ -v /home/nacos/logs:/home/nacos/logs \ -v /home/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \ nacos/nacos-server:v2.0.3
  1. <a name="tbV5W"></a>
  2. # 使用kubesphere部署
  3. <a name="KDuDE"></a>
  4. ## dockerhub
  5. nacos/nacos-server:v2.0.3
  6. <a name="afysl"></a>
  7. ## 资源分配
  8. ![图片.png](https://cdn.nlark.com/yuque/0/2022/png/22706049/1648882583864-4e871f92-2f15-46d7-9835-e85183eacb52.png#clientId=u41850453-3e7e-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=276&id=u05b1e0a2&margin=%5Bobject%20Object%5D&name=%E5%9B%BE%E7%89%87.png&originHeight=552&originWidth=1782&originalType=binary&ratio=1&rotation=0&showTitle=false&size=75896&status=done&style=none&taskId=ubca88ad4-50f5-4169-93f1-eaf140723c7&title=&width=891)
  9. <a name="Vvz0K"></a>
  10. ## 端口配置
  11. 8848<br />9848<br />9849<br />![image.png](https://cdn.nlark.com/yuque/0/2022/png/22706049/1649508361741-291e415f-332c-4c81-afef-001e6f01bdbb.png#clientId=ud87f7287-936a-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=274&id=u173d1315&margin=%5Bobject%20Object%5D&name=image.png&originHeight=548&originWidth=1765&originalType=binary&ratio=1&rotation=0&showTitle=false&size=67673&status=done&style=none&taskId=u08ec4737-5ad4-4292-b73f-c7ef37a2ce9&title=&width=882.5)
  12. <a name="LQqLV"></a>
  13. ## 环境变量
  14. ![image.png](https://cdn.nlark.com/yuque/0/2022/png/22706049/1649852902341-580f89f3-95e3-4155-90d8-72a0531d7709.png#clientId=udc0f2458-23d9-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=174&id=u051078be&margin=%5Bobject%20Object%5D&name=image.png&originHeight=347&originWidth=1859&originalType=binary&ratio=1&rotation=0&showTitle=false&size=41603&status=done&style=none&taskId=u33a34913-ce7c-4012-8127-17c104bd0e5&title=&width=929.5)
  15. <a name="oLquI"></a>
  16. ## 同步主机时区
  17. ![image.png](https://cdn.nlark.com/yuque/0/2022/png/22706049/1648807336453-2261a953-b3aa-4ee6-bee8-4836b99ad1ad.png#clientId=uad63ce43-ea4d-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=74&id=u313c3871&margin=%5Bobject%20Object%5D&name=image.png&originHeight=148&originWidth=1776&originalType=binary&ratio=1&rotation=0&showTitle=false&size=14988&status=done&style=none&taskId=u4298e127-b7d4-494f-8d77-9d62e6d28a9&title=&width=888)
  18. <a name="j5POk"></a>
  19. ## 配置文件子路径挂载
  20. (*** 默认使用路径挂载会覆盖容器内所有配置,所以如果只需要覆盖个别配置可以使用子路径)
  21. <a name="rWuEe"></a>
  22. ### /home/nacos/conf/application.properties
  23. ![图片.png](https://cdn.nlark.com/yuque/0/2022/png/22706049/1649063243156-db6cc76c-6729-4dcf-976b-cebd6c1fd266.png#clientId=uc0c26cf6-75aa-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=295&id=u364c8882&margin=%5Bobject%20Object%5D&name=%E5%9B%BE%E7%89%87.png&originHeight=589&originWidth=1816&originalType=binary&ratio=1&rotation=0&showTitle=false&size=117547&status=done&style=none&taskId=u5264db4f-0903-4a4b-9b4b-23a1d5b27e9&title=&width=908)
  24. <a name="iagoe"></a>
  25. ### /home/nacos/conf/cluster.conf![图片.png](https://cdn.nlark.com/yuque/0/2022/png/22706049/1649063263881-28804293-5fbd-4d08-91b0-ec8e28349938.png#clientId=uc0c26cf6-75aa-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=260&id=u72390ef5&margin=%5Bobject%20Object%5D&name=%E5%9B%BE%E7%89%87.png&originHeight=519&originWidth=1691&originalType=binary&ratio=1&rotation=0&showTitle=false&size=73653&status=done&style=none&taskId=ue7d5b274-887c-4654-aab8-4e72cb6f906&title=&width=845.5)
  26. <a name="pC9IB"></a>
  27. # 使用mysql作为持久化方式
  28. <a name="poEAY"></a>
  29. ## sql语句
  30. ```sql
  31. /*
  32. * Copyright 1999-2018 Alibaba Group Holding Ltd.
  33. *
  34. * Licensed under the Apache License, Version 2.0 (the "License");
  35. * you may not use this file except in compliance with the License.
  36. * You may obtain a copy of the License at
  37. *
  38. * http://www.apache.org/licenses/LICENSE-2.0
  39. *
  40. * Unless required by applicable law or agreed to in writing, software
  41. * distributed under the License is distributed on an "AS IS" BASIS,
  42. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  43. * See the License for the specific language governing permissions and
  44. * limitations under the License.
  45. */
  46. /******************************************/
  47. /* 数据库全名 = nacos_config */
  48. /* 表名称 = config_info */
  49. /******************************************/
  50. create database nacos;
  51. use nacos;
  52. CREATE TABLE `config_info` (
  53. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  54. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  55. `group_id` varchar(255) DEFAULT NULL,
  56. `content` longtext NOT NULL COMMENT 'content',
  57. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  58. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  59. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  60. `src_user` text COMMENT 'source user',
  61. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  62. `app_name` varchar(128) DEFAULT NULL,
  63. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  64. `c_desc` varchar(256) DEFAULT NULL,
  65. `c_use` varchar(64) DEFAULT NULL,
  66. `effect` varchar(64) DEFAULT NULL,
  67. `type` varchar(64) DEFAULT NULL,
  68. `c_schema` text,
  69. PRIMARY KEY (`id`),
  70. UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
  71. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
  72. /******************************************/
  73. /* 数据库全名 = nacos_config */
  74. /* 表名称 = config_info_aggr */
  75. /******************************************/
  76. CREATE TABLE `config_info_aggr` (
  77. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  78. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  79. `group_id` varchar(255) NOT NULL COMMENT 'group_id',
  80. `datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
  81. `content` longtext NOT NULL COMMENT '内容',
  82. `gmt_modified` datetime NOT NULL COMMENT '修改时间',
  83. `app_name` varchar(128) DEFAULT NULL,
  84. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  85. PRIMARY KEY (`id`),
  86. UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
  87. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
  88. /******************************************/
  89. /* 数据库全名 = nacos_config */
  90. /* 表名称 = config_info_beta */
  91. /******************************************/
  92. CREATE TABLE `config_info_beta` (
  93. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  94. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  95. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  96. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  97. `content` longtext NOT NULL COMMENT 'content',
  98. `beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
  99. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  100. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  101. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  102. `src_user` text COMMENT 'source user',
  103. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  104. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  105. PRIMARY KEY (`id`),
  106. UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
  107. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
  108. /******************************************/
  109. /* 数据库全名 = nacos_config */
  110. /* 表名称 = config_info_tag */
  111. /******************************************/
  112. CREATE TABLE `config_info_tag` (
  113. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  114. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  115. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  116. `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
  117. `tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
  118. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  119. `content` longtext NOT NULL COMMENT 'content',
  120. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  121. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  122. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  123. `src_user` text COMMENT 'source user',
  124. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  125. PRIMARY KEY (`id`),
  126. UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
  127. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
  128. /******************************************/
  129. /* 数据库全名 = nacos_config */
  130. /* 表名称 = config_tags_relation */
  131. /******************************************/
  132. CREATE TABLE `config_tags_relation` (
  133. `id` bigint(20) NOT NULL COMMENT 'id',
  134. `tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
  135. `tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
  136. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  137. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  138. `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
  139. `nid` bigint(20) NOT NULL AUTO_INCREMENT,
  140. PRIMARY KEY (`nid`),
  141. UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
  142. KEY `idx_tenant_id` (`tenant_id`)
  143. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
  144. /******************************************/
  145. /* 数据库全名 = nacos_config */
  146. /* 表名称 = group_capacity */
  147. /******************************************/
  148. CREATE TABLE `group_capacity` (
  149. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  150. `group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
  151. `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
  152. `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
  153. `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
  154. `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
  155. `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
  156. `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
  157. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  158. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  159. PRIMARY KEY (`id`),
  160. UNIQUE KEY `uk_group_id` (`group_id`)
  161. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
  162. /******************************************/
  163. /* 数据库全名 = nacos_config */
  164. /* 表名称 = his_config_info */
  165. /******************************************/
  166. CREATE TABLE `his_config_info` (
  167. `id` bigint(64) unsigned NOT NULL,
  168. `nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  169. `data_id` varchar(255) NOT NULL,
  170. `group_id` varchar(128) NOT NULL,
  171. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  172. `content` longtext NOT NULL,
  173. `md5` varchar(32) DEFAULT NULL,
  174. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  175. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  176. `src_user` text,
  177. `src_ip` varchar(50) DEFAULT NULL,
  178. `op_type` char(10) DEFAULT NULL,
  179. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  180. PRIMARY KEY (`nid`),
  181. KEY `idx_gmt_create` (`gmt_create`),
  182. KEY `idx_gmt_modified` (`gmt_modified`),
  183. KEY `idx_did` (`data_id`)
  184. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
  185. /******************************************/
  186. /* 数据库全名 = nacos_config */
  187. /* 表名称 = tenant_capacity */
  188. /******************************************/
  189. CREATE TABLE `tenant_capacity` (
  190. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  191. `tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
  192. `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
  193. `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
  194. `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
  195. `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
  196. `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
  197. `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
  198. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  199. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  200. PRIMARY KEY (`id`),
  201. UNIQUE KEY `uk_tenant_id` (`tenant_id`)
  202. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
  203. CREATE TABLE `tenant_info` (
  204. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  205. `kp` varchar(128) NOT NULL COMMENT 'kp',
  206. `tenant_id` varchar(128) default '' COMMENT 'tenant_id',
  207. `tenant_name` varchar(128) default '' COMMENT 'tenant_name',
  208. `tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
  209. `create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
  210. `gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
  211. `gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
  212. PRIMARY KEY (`id`),
  213. UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
  214. KEY `idx_tenant_id` (`tenant_id`)
  215. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
  216. CREATE TABLE `users` (
  217. `username` varchar(50) NOT NULL PRIMARY KEY,
  218. `password` varchar(500) NOT NULL,
  219. `enabled` boolean NOT NULL
  220. );
  221. CREATE TABLE `roles` (
  222. `username` varchar(50) NOT NULL,
  223. `role` varchar(50) NOT NULL,
  224. UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
  225. );
  226. CREATE TABLE `permissions` (
  227. `role` varchar(50) NOT NULL,
  228. `resource` varchar(255) NOT NULL,
  229. `action` varchar(8) NOT NULL,
  230. UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
  231. );
  232. INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
  233. INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');

configMap配置

application.properties

  1. # spring
  2. server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
  3. server.contextPath=/nacos
  4. server.port=${NACOS_APPLICATION_PORT:8848}
  5. spring.datasource.platform=${SPRING_DATASOURCE_PLATFORM:""}
  6. nacos.cmdb.dumpTaskInterval=3600
  7. nacos.cmdb.eventTaskInterval=10
  8. nacos.cmdb.labelTaskInterval=300
  9. nacos.cmdb.loadDataAtStart=false
  10. db.num=${MYSQL_DATABASE_NUM:1}
  11. db.url.0=jdbc:mysql://192.168.2.20:30569/nacos?${MYSQL_SERVICE_DB_PARAM:characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false}
  12. #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}
  13. db.user=root
  14. db.password=root
  15. ### The auth system to use, currently only 'nacos' is supported:
  16. nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}
  17. ### The token expiration in seconds:
  18. nacos.core.auth.default.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}
  19. ### The default token:
  20. nacos.core.auth.default.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey012345678901234567890123456789012345678901234567890123456789}
  21. ### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
  22. nacos.core.auth.caching.enabled=${NACOS_AUTH_CACHE_ENABLE:false}
  23. nacos.core.auth.enable.userAgentAuthWhite=${NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLE:false}
  24. nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:serverIdentity}
  25. nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:security}
  26. server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
  27. server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
  28. # default current work dir
  29. server.tomcat.basedir=
  30. ## spring security config
  31. ### turn off security
  32. 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/**}
  33. # metrics for elastic search
  34. management.metrics.export.elastic.enabled=false
  35. management.metrics.export.influx.enabled=false
  36. nacos.naming.distro.taskDispatchThreadCount=10
  37. nacos.naming.distro.taskDispatchPeriod=200
  38. nacos.naming.distro.batchSyncKeyCount=1000
  39. nacos.naming.distro.initDataRatio=0.9
  40. nacos.naming.distro.syncRetryDelay=5000
  41. nacos.naming.data.warmup=true

cluster.conf