Compare commits

...

16 Commits

Author SHA1 Message Date
cxhello 26cc6b6056
refactor: Compatible with Nacos multiple versions (#464) 2025-07-24 19:40:33 +08:00
cxhello a3795ac461
feat: add Dockerfile 9848&8080 expose (#461)
* feat: add Dockerfile 9848-9849 expose

* feat: add Dockerfile 9848-9849 expose

* add Dockerfile 9848&8080 expose
2025-07-03 09:40:58 +08:00
杨翊 SionYang 9c93392805
Upgrade to 3.0.2 (#460) 2025-06-25 15:45:53 +08:00
杨翊 SionYang bcc778c832
Merge pull request #457 from nacos-group/3.x
Update readme
2025-05-22 18:11:01 +08:00
杨翊 SionYang baffa99131
Merge pull request #456 from nacos-group/3.x
3.x
2025-05-22 18:06:26 +08:00
xiweng.yy 9e80494a69 Upgrade to 3.0.1 2025-05-22 18:05:50 +08:00
xiweng.yy 74df95080f Merge branch 'refs/heads/master' into 3.x
# Conflicts:
#	build/Dockerfile
#	build/Dockerfile.Slim
#	build/bin/docker-startup.sh
#	build/conf/application.properties
#	example/.env
2025-05-22 18:04:38 +08:00
Ben e76c828582
支持通过 NACOS_CONSOLE_CONTEXTPATH 环境变量配置控制台上下文路径,默认为空 (#454)
* 支持通过 NACOS_CONSOLE_CONTEXTPATH 环境变量配置控制台上下文路径,默认 /nacos

* 支持通过 NACOS_CONSOLE_CONTEXTPATH 环境变量配置控制台上下文路径,默认为空
2025-05-22 17:58:31 +08:00
杨翊 SionYang c82efd39fd
Upgrade to 3.0.0 (#455) 2025-05-22 17:57:15 +08:00
paderlol e4f35a54c5
add libstdc++ to Dockerfile dependencies (#452) 2025-04-27 15:14:14 +08:00
杨翊 SionYang eff0d35f5b
Merge pull request #451 from nacos-group/3.x
Upgrade to 3.0.0
2025-04-27 13:58:01 +08:00
xiweng.yy a24b728c75 Upgrade to 3.0.0 2025-04-27 13:56:06 +08:00
杨翊 SionYang 6a611cbd58
Merge pull request #447 from nacos-group/master-2.5.1
Upgrade to 2.5.1
2025-03-11 14:19:31 +08:00
xiweng.yy d11f709704 Upgrade to 2.5.1 2025-03-11 14:19:03 +08:00
paderlol a61632e219
Merge pull request #445 from nacos-group/fix_embedded_start_failed
fix embedded start failed
2025-02-18 10:44:12 +08:00
pader aa991698ea
support arm platform for mysql 2025-02-18 10:42:01 +08:00
21 changed files with 458 additions and 115 deletions

View File

@ -40,13 +40,16 @@ docker run --name nacos-quick -e MODE=standalone -p 8848:8848 -p 9848:9848 -d na
## Advanced Usage
* Tips: You can change [the version of the Nacos image](https://hub.docker.com/r/nacos/nacos-server/tags) in the compose file from the following configuration.
* Tips: You can change [the version of the Nacos image](https://hub.docker.com/r/nacos/nacos-server/tags) in the compose
file from the following configuration.
`example/.env`
```dotenv
NACOS_VERSION=v2.3.1
```
For Mac user with Arm Chip (like M1/M2/M3 series) , you need to add `-slim` after version which support `arm` arch.
For Mac user with Arm Chip (like M1/M2/M3 series) , you need to add `-slim` after version which support `arm` arch.
```dotenv
NACOS_VERSION=v2.3.1-slim
```
@ -69,11 +72,8 @@ Run the following command
* Standalone Mysql
```powershell
# Using mysql 5.7
docker-compose -f example/standalone-mysql-5.7.yaml up
# Using mysql 8
docker-compose -f example/standalone-mysql-8.yaml up
cd example
./mysql-init.sh && docker-compose -f standalone-mysql.yaml up
```
* Standalone Nacos Cluster
@ -151,8 +151,13 @@ Run the following command
| NACOS_SECURITY_IGNORE_URLS | nacos.security.ignore.urls | default : `/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**` |
| NACOS_CONSOLE_UI_ENABLED | nacos.console.ui.enabled | default : `true` |
| NACOS_CORE_PARAM_CHECK_ENABLED | nacos.core.param.check.enabled | default : `true` |
| DB_POOL_CONNECTION_TIMEOUT | Database connection pool timeout in milliseconds | default : **30000** |
| DB_POOL_CONNECTION_TIMEOUT | Database connection pool timeout in milliseconds | default : **30000** |
| NACOS_CONSOLE_UI_ENABLED | nacos.console.ui.enabled | default : `true` |
| NACOS_CORE_PARAM_CHECK_ENABLED | nacos.core.param.check.enabled | default : `true` |
| NACOS_AUTH_ADMIN_ENABLE | nacos.core.auth.admin.enable | default : `true` |
| NACOS_AUTH_CONSOLE_ENABLE | nacos.core.auth.console.enable | default : `true` | |
| NACOS_CONSOLE_PORT | nacos.console.port | default : `8080` |
| NACOS_CONSOLE_CONTEXTPATH | nacos.console.contextPath | default : `` |
## Advanced configuration

View File

@ -50,11 +50,8 @@
* Standalone Mysql
```powershell
# Using mysql 5.7
docker-compose -f example/standalone-mysql-5.7.yaml up
# Using mysql 8
docker-compose -f example/standalone-mysql-8.yaml up
cd example
./mysql-init.sh && docker-compose -f standalone-mysql.yaml up
```
* docker单节点部署集群模式
@ -171,10 +168,12 @@
| NACOS_AUTH_IDENTITY_VALUE | nacos.core.auth.server.identity.value | `注意该环境变量在Nacos 2.2.1版本中已移除` |
| NACOS_SECURITY_IGNORE_URLS | nacos.security.ignore.urls | default : `/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**` |
| DB_POOL_CONNECTION_TIMEOUT | 数据库连接池超时时间,单位为毫秒 | 默认 : **30000** |
| NACOS_CONSOLE_UI_ENABLED | nacos.console.ui.enabled | default : `true` |
| NACOS_CORE_PARAM_CHECK_ENABLED | nacos.core.param.check.enabled | default : `true` |
| NACOS_AUTH_ADMIN_ENABLE | nacos.core.auth.admin.enable | default : `true` |
| NACOS_AUTH_CONSOLE_ENABLE | nacos.core.auth.console.enable | default : `true` | |
| NACOS_CONSOLE_PORT | nacos.console.port | default : `8080` |
| NACOS_CONSOLE_CONTEXTPATH | nacos.console.contextPath | default : `` |
## 高级配置

View File

@ -2,7 +2,7 @@ FROM alpine:latest
LABEL maintainer="pader <huangmnlove@163.com>"
# 安装依赖
RUN apk add --no-cache openjdk8-jre-base curl iputils ncurses vim libcurl bash
RUN apk add --no-cache openjdk17-jre curl iputils ncurses vim libcurl bash libstdc++
# 设置环境变量
ENV MODE="cluster" \
@ -11,9 +11,9 @@ ENV MODE="cluster" \
CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \
CLUSTER_CONF="/home/nacos/conf/cluster.conf" \
FUNCTION_MODE="all" \
JAVA_HOME="/usr/lib/jvm/java-1.8-openjdk" \
JAVA_HOME="/usr/lib/jvm/java-17-openjdk" \
NACOS_USER="nacos" \
JAVA="/usr/lib/jvm/java-1.8-openjdk/bin/java" \
JAVA="/usr/lib/jvm/java-17-openjdk/bin/java" \
JVM_XMS="1g" \
JVM_XMX="1g" \
JVM_XMN="512m" \
@ -23,7 +23,7 @@ ENV MODE="cluster" \
TOMCAT_ACCESSLOG_ENABLED="false" \
TIME_ZONE="Asia/Shanghai"
ARG NACOS_VERSION=2.5.0
ARG NACOS_VERSION=3.0.2
ARG HOT_FIX_FLAG=""
WORKDIR $BASE_DIR
@ -46,4 +46,5 @@ RUN mkdir -p logs \
&& chmod +x bin/docker-startup.sh
EXPOSE 8848
EXPOSE 9848 8080
ENTRYPOINT ["sh","bin/docker-startup.sh"]

View File

@ -1,6 +1,6 @@
FROM amd64/buildpack-deps:buster-curl as installer
ARG NACOS_VERSION=2.5.0
ARG NACOS_VERSION=3.0.2
ARG HOT_FIX_FLAG=""
RUN set -x \
@ -8,7 +8,7 @@ RUN set -x \
&& tar -xzvf /var/tmp/nacos-server.tar.gz -C /home \
&& rm -rf /var/tmp/nacos-server.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql
FROM adoptopenjdk/openjdk8:jre8u372-b07
FROM eclipse-temurin:17.0.15_6-jre
# set environment
ENV MODE="cluster" \
@ -45,4 +45,5 @@ RUN mkdir -p logs \
RUN chmod +x bin/docker-startup.sh
EXPOSE 8848
EXPOSE 9848 8080
ENTRYPOINT ["bin/docker-startup.sh"]

View File

@ -45,7 +45,6 @@ Xmn=$(join_if_exist "-Xmn" ${JVM_XMN})
XX_MS=$(join_if_exist "-XX:MetaspaceSize=" ${JVM_MS})
XX_MMS=$(join_if_exist "-XX:MaxMetaspaceSize=" ${JVM_MMS})
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 "
if [[ "${MODE}" == "standalone" ]]; then
JAVA_OPT="${JAVA_OPT} $Xms $Xmx $Xmn"
JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true"
@ -93,15 +92,43 @@ if [[ ! -z "${NACOS_AUTH_ENABLE}" ]]; then
JAVA_OPT="${JAVA_OPT} -Dnacos.core.auth.enabled=${NACOS_AUTH_ENABLE}"
fi
if [[ ! -z "${NACOS_AUTH_ADMIN_ENABLE}" ]]; then
JAVA_OPT="${JAVA_OPT} -Dnacos.core.auth.admin.enabled=${NACOS_AUTH_ADMIN_ENABLE}"
fi
if [[ ! -z "${NACOS_AUTH_CONSOLE_ENABLE}" ]]; then
JAVA_OPT="${JAVA_OPT} -Dnacos.core.auth.console.enabled=${NACOS_AUTH_CONSOLE_ENABLE}"
fi
if [[ -z "${NACOS_AUTH_TOKEN}" ]]; then
echo "env NACOS_AUTH_TOKEN must be set with Base64 String."
exit 255
fi
if [[ -z "${NACOS_AUTH_IDENTITY_KEY}" ]]; then
echo "env NACOS_AUTH_IDENTITY_KEY must be set."
exit 255
fi
if [[ -z "${NACOS_AUTH_IDENTITY_VALUE}" ]]; then
echo "env NACOS_AUTH_IDENTITY_VALUE must be set."
exit 255
fi
if [[ "${PREFER_HOST_MODE}" == "hostname" ]]; then
JAVA_OPT="${JAVA_OPT} -Dnacos.preferHostnameOverIp=true"
fi
JAVA_OPT="${JAVA_OPT} -Dnacos.member.list=${MEMBER_LIST}"
if [[ ! -z "${NACOS_DEPLOYMENT_TYPE}" ]]; then
JAVA_OPT="${JAVA_OPT} -Dnacos.deployment.type=${NACOS_DEPLOYMENT_TYPE}"
fi
JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p')
if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]]; then
JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASE_DIR}/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400"
else
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 "
JAVA_OPT_EXT_FIX="-Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"
JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
fi

View File

@ -1,55 +1,305 @@
# spring
server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
server.contextPath=/nacos
server.port=${NACOS_APPLICATION_PORT:8848}
server.tomcat.accesslog.max-days=30
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
server.error.include-message=ALWAYS
# default current work dir
server.tomcat.basedir=file:.
#*************** Config Module Related Configurations ***************#
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
#spring.datasource.platform=${SPRING_DATASOURCE_PLATFORM:}
#
# Copyright 1999-2025 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#--------------- Nacos Common Configurations ---------------#
#*************** Nacos port Related Configurations ***************#
### Nacos Server Main port
nacos.server.main.port=${NACOS_APPLICATION_PORT:8848}
#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ip=false
### Specify local server's IP:
# nacos.inetutils.ip-address=
#*************** Datasource Related Configurations ***************#
### nacos.plugin.datasource.log.enabled=true
spring.sql.init.platform=${SPRING_DATASOURCE_PLATFORM:}
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
### Count of DB:
# db.num=1
### Connect URL of DB:
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.user.0=${MYSQL_SERVICE_USER}
db.password.0=${MYSQL_SERVICE_PASSWORD}
## DB connection pool settings
db.pool.config.connectionTimeout=${DB_POOL_CONNECTION_TIMEOUT:30000}
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
### The auth system to use, currently only 'nacos' and 'ldap' is supported:
#*************** Metrics Related Configurations ***************#
### Metrics for prometheus
management.endpoints.web.exposure.include=prometheus
### Metrics for elastic search
management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200
### Metrics for influx
management.metrics.export.influx.enabled=false
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true
#*************** Core Related Configurations ***************#
### set the WorkerID manually
# nacos.core.snowflake.worker-id=
### Member-MetaData
# nacos.core.member.meta.site=
# nacos.core.member.meta.adweight=
# nacos.core.member.meta.weight=
### MemberLookup
### Addressing pattern category, If set, the priority is highest
# nacos.core.member.lookup.type=[file,address-server]
## Set the cluster list with a configuration file or command-line argument
# 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
## for AddressServerMemberLookup
# Maximum number of retries to query the address server upon initialization
# nacos.core.address-server.retry=5
## Server domain name address of [address-server] mode
# address.server.domain=jmenv.tbsite.net
## Server port of [address-server] mode
# address.server.port=8080
## Request address of [address-server] mode
# address.server.url=/nacos/serverlist
#*************** JRaft Related Configurations ***************#
### Sets the Raft cluster election timeout, default value is 5 second
# nacos.core.protocol.raft.data.election_timeout_ms=5000
### Sets the amount of time the Raft snapshot will execute periodically, default is 30 minute
# nacos.core.protocol.raft.data.snapshot_interval_secs=30
### raft internal worker threads
# nacos.core.protocol.raft.data.core_thread_num=8
### Number of threads required for raft business request processing
# nacos.core.protocol.raft.data.cli_service_thread_num=4
### raft linear read strategy. Safe linear reads are used by default, that is, the Leader tenure is confirmed by heartbeat
# nacos.core.protocol.raft.data.read_index_type=ReadOnlySafe
### rpc request timeout, default 5 seconds
# nacos.core.protocol.raft.data.rpc_request_timeout_ms=5000
### enable to support prometheus service discovery
#nacos.prometheus.metrics.enabled=true
#*************** Distro Related Configurations ***************#
### Distro data sync delay time, when sync task delayed, task will be merged for same data key. Default 1 second.
# nacos.core.protocol.distro.data.sync.delayMs=1000
### Distro data sync timeout for one sync data, default 3 seconds.
# nacos.core.protocol.distro.data.sync.timeoutMs=3000
### Distro data sync retry delay time when sync data failed or timeout, same behavior with delayMs, default 3 seconds.
# nacos.core.protocol.distro.data.sync.retryDelayMs=3000
### Distro data verify interval time, verify synced data whether expired for a interval. Default 5 seconds.
# nacos.core.protocol.distro.data.verify.intervalMs=5000
### Distro data verify timeout for one verify, default 3 seconds.
# nacos.core.protocol.distro.data.verify.timeoutMs=3000
### Distro data load retry delay when load snapshot data failed, default 30 seconds.
# nacos.core.protocol.distro.data.load.retryDelayMs=30000
### enable to support prometheus service discovery
#nacos.prometheus.metrics.enabled=true
#*************** Grpc Configurations ***************#
### Sets the maximum message size allowed to be received on the server.
#nacos.remote.server.grpc.sdk.max-inbound-message-size=10485760
### Sets the time(milliseconds) without read activity before sending a keepalive ping. The typical default is two hours.
#nacos.remote.server.grpc.sdk.keep-alive-time=7200000
### Sets a time(milliseconds) waiting for read activity after sending a keepalive ping. Defaults to 20 seconds.
#nacos.remote.server.grpc.sdk.keep-alive-timeout=20000
### Sets a time(milliseconds) that specify the most aggressive keep-alive time clients are permitted to configure. The typical default is 5 minutes
#nacos.remote.server.grpc.sdk.permit-keep-alive-time=300000
### cluster grpc(inside the nacos server) configuration
#nacos.remote.server.grpc.cluster.max-inbound-message-size=10485760
### Sets the time(milliseconds) without read activity before sending a keepalive ping. The typical default is two hours.
#nacos.remote.server.grpc.cluster.keep-alive-time=7200000
### Sets a time(milliseconds) waiting for read activity after sending a keepalive ping. Defaults to 20 seconds.
#nacos.remote.server.grpc.cluster.keep-alive-timeout=20000
### Sets a time(milliseconds) that specify the most aggressive keep-alive time clients are permitted to configure. The typical default is 5 minutes
#nacos.remote.server.grpc.cluster.permit-keep-alive-time=300000
#*************** Config Module Related Configurations ***************#
### the maximum retry times for push
nacos.config.push.maxRetryTime=50
#*************** Naming Module Related Configurations ***************#
### Data dispatch task execution period in milliseconds:
### If enable data warmup. If set to false, the server would accept request without local data preparation:
nacos.naming.data.warmup=true
### If enable the instance auto expiration, kind like of health check of instance:
# nacos.naming.expireInstance=true
nacos.naming.empty-service.auto-clean=true
nacos.naming.empty-service.clean.initial-delay-ms=50000
nacos.naming.empty-service.clean.period-time-ms=30000
#--------------- Nacos Web Server Configurations ---------------#
#*************** Nacos Web Server Related Configurations ***************#
### Nacos Server Web context path:
nacos.server.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
#*************** Access Log Related Configurations ***************#
### If turn on the access log:
server.tomcat.accesslog.enabled=true
### accesslog automatic cleaning time
server.tomcat.accesslog.max-days=30
### The access log pattern:
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
### The directory of access log:
server.tomcat.basedir=file:.
#*************** API Related Configurations ***************#
### Include message field
server.error.include-message=ALWAYS
### Enabled for open API compatibility
# nacos.core.api.compatibility.client.enabled=true
### Enabled for admin API compatibility
# nacos.core.api.compatibility.admin.enabled=false
### Enabled for console API compatibility
# nacos.core.api.compatibility.console.enabled=false
#--------------- Nacos Console Configurations ---------------#
#*************** Nacos Console Related Configurations ***************#
### Nacos Console Main port
nacos.console.port=${NACOS_CONSOLE_PORT:8080}
### Nacos Server Web context path:
nacos.console.contextPath=${NACOS_CONSOLE_CONTEXTPATH:}
### Nacos Server context path, which link to nacos server `nacos.server.contextPath`, works when deployment type is `console`
nacos.console.remote.server.context-path=${SERVER_SERVLET_CONTEXTPATH:/nacos}
#************** Console UI Configuration ***************#
### Turn on/off the nacos console ui.
nacos.console.ui.enabled=true
#--------------- Nacos Plugin Configurations ---------------#
#*************** CMDB Plugin Related Configurations ***************#
### The interval to dump external CMDB in seconds:
# nacos.cmdb.dumpTaskInterval=3600
### The interval of polling data change event in seconds:
# nacos.cmdb.eventTaskInterval=10
### The interval of loading labels in seconds:
# nacos.cmdb.labelTaskInterval=300
### If turn on data loading task:
# nacos.cmdb.loadDataAtStart=false
#*************** Auth Plugin Related Configurations ***************#
### The ignore urls of auth, will be deprecated in the future:
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/**}
### The auth system to use, default 'nacos' and 'ldap' is supported, other type should be implemented by yourself:
nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}
### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}
### The default token:
nacos.core.auth.plugin.nacos.token.secret.key=${NACOS_AUTH_TOKEN:}
### If turn on auth system:
# Whether open nacos server API auth system
nacos.core.auth.enabled=false
# Whether open nacos admin API auth system
nacos.core.auth.admin.enabled=true
# Whether open nacos console API auth system
nacos.core.auth.console.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=${NACOS_AUTH_CACHE_ENABLE:false}
nacos.core.auth.enable.userAgentAuthWhite=${NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLE:false}
### worked when nacos.core.auth.enabled=true
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:}
## 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
nacos.console.ui.enabled=true
nacos.core.param.check.enabled=true
### worked when nacos.core.auth.system.type=nacos or nacos.core.auth.console.enabled=true
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.cache.enable=false
nacos.core.auth.plugin.nacos.token.expire.seconds=${NACOS_AUTH_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=${NACOS_AUTH_TOKEN:}
### worked when nacos.core.auth.system.type=ldap?{0} is Placeholder,replace login username
#nacos.core.auth.ldap.url=ldap://localhost:389
#nacos.core.auth.ldap.basedc=dc=example,dc=org
#nacos.core.auth.ldap.userDn=cn=admin,${nacos.core.auth.ldap.basedc}
#nacos.core.auth.ldap.password=admin
#nacos.core.auth.ldap.userdn=cn={0},dc=example,dc=org
#nacos.core.auth.ldap.filter.prefix=uid
#nacos.core.auth.ldap.case.sensitive=true
#nacos.core.auth.ldap.ignore.partial.result.exception=false
#*************** Control Plugin Related Configurations ***************#
# plugin type
#nacos.plugin.control.manager.type=nacos
# local control rule storage dir, default ${nacos.home}/data/connection and ${nacos.home}/data/tps
#nacos.plugin.control.rule.local.basedir=${nacos.home}
# external control rule storage type, if exist
#nacos.plugin.control.rule.external.storage=
#*************** Config Change Plugin Related Configurations ***************#
# webhook
#nacos.core.config.plugin.webhook.enabled=false
# It is recommended to use EB https://help.aliyun.com/document_detail/413974.html
#nacos.core.config.plugin.webhook.url=http://localhost:8080/webhook/send?token=***
# The content push max capacity ,byte
#nacos.core.config.plugin.webhook.contentMaxCapacity=102400
# whitelist
#nacos.core.config.plugin.whitelist.enabled=false
# The import file suffixs
#nacos.core.config.plugin.whitelist.suffixs=xml,text,properties,yaml,html
# fileformatcheck,which validate the import file of type and content
#nacos.core.config.plugin.fileformatcheck.enabled=false
#*************** Istio Plugin Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabled=false
#--------------- Nacos Experimental Features Configurations ---------------#
#*************** K8s Related Configurations ***************#
### If turn on the K8s sync:
nacos.k8s.sync.enabled=false
### If use the Java API from an application outside a kubernetes cluster
#nacos.k8s.sync.outsideCluster=false
#nacos.k8s.sync.kubeConfig=/.kube/config
#*************** Deployment Type Configuration ***************#
### Sets the deployment type: 'merged' for joint deployment, 'server' for separate deployment server only, 'console' for separate deployment console only.
nacos.deployment.type=merged

View File

@ -0,0 +1,55 @@
# spring
server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
server.contextPath=/nacos
server.port=${NACOS_APPLICATION_PORT:8848}
server.tomcat.accesslog.max-days=30
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
server.error.include-message=ALWAYS
# default current work dir
server.tomcat.basedir=file:.
#*************** Config Module Related Configurations ***************#
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
#spring.datasource.platform=${SPRING_DATASOURCE_PLATFORM:}
spring.sql.init.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.user.0=${MYSQL_SERVICE_USER}
db.password.0=${MYSQL_SERVICE_PASSWORD}
## DB connection pool settings
db.pool.config.connectionTimeout=${DB_POOL_CONNECTION_TIMEOUT:30000}
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
### The auth system to use, currently only 'nacos' and 'ldap' is supported:
nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}
### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}
### The default token:
nacos.core.auth.plugin.nacos.token.secret.key=${NACOS_AUTH_TOKEN:}
### 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:}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:}
## 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
nacos.console.ui.enabled=true
nacos.core.param.check.enabled=true

View File

@ -3,4 +3,4 @@ MODE=standalone
SPRING_DATASOURCE_PLATFORM=mysql
NACOS_AUTH_IDENTITY_KEY=2222
NACOS_AUTH_IDENTITY_VALUE=2xxx
NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=

View File

@ -1,12 +1,7 @@
#nacos dev env
PREFER_HOST_MODE=hostname
EMBEDDED_STORAGE=embedded
NACOS_SERVERS=nacos1:8848 nacos2:8849 nacos3:8850
SPRING_DATASOURCE_PLATFORM=mysql
MYSQL_SERVICE_DB_NAME=nacos_devtest
MYSQL_SERVICE_PORT=3306
MYSQL_SERVICE_USER=nacos
MYSQL_SERVICE_PASSWORD=nacos
NACOS_SERVERS=nacos1:8848 nacos2:8848 nacos3:8848
NACOS_AUTH_IDENTITY_KEY=2222
NACOS_AUTH_IDENTITY_VALUE=2xxx
NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=

View File

@ -9,4 +9,4 @@ MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
NACOS_AUTH_IDENTITY_KEY=2222
NACOS_AUTH_IDENTITY_VALUE=2xxx
NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=

2
env/nacos-ip.env vendored
View File

@ -9,4 +9,4 @@ MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
NACOS_AUTH_IDENTITY_KEY=2222
NACOS_AUTH_IDENTITY_VALUE=2xxx
NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=

View File

@ -9,4 +9,4 @@ MYSQL_SERVICE_PASSWORD=nacos
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
NACOS_AUTH_IDENTITY_KEY=2222
NACOS_AUTH_IDENTITY_VALUE=2xxx
NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=

View File

@ -1 +1 @@
NACOS_VERSION=v2.5.0
NACOS_VERSION=v3.0.2

View File

@ -8,6 +8,7 @@ services:
- ./cluster-logs/nacos1:/home/nacos/logs
ports:
- "7848:7848"
- "8080:8080"
- "8848:8848"
- "9868:9848"
- "9850:9849"
@ -23,6 +24,7 @@ services:
- ./cluster-logs/nacos2:/home/nacos/logs
ports:
- "7849:7848"
- "8080:8080"
- "8849:8848"
- "9869:9848"
- "9851:9849"
@ -37,6 +39,7 @@ services:
- ./cluster-logs/nacos3:/home/nacos/logs
ports:
- "7850:7848"
- "8080:8080"
- "8850:8848"
- "9870:9848"
- "9852:9849"

View File

@ -8,6 +8,7 @@ services:
- ./cluster-logs/nacos1:/home/nacos/logs
ports:
- "7848:7848"
- "8080:8080"
- "8848:8848"
- "9868:9848"
- "9850:9849"
@ -26,6 +27,7 @@ services:
- ./cluster-logs/nacos2:/home/nacos/logs
ports:
- "7849:7848"
- "8080:8080"
- "8849:8848"
- "9869:9848"
- "9851:9849"
@ -43,6 +45,7 @@ services:
- ./cluster-logs/nacos3:/home/nacos/logs
ports:
- "7850:7848"
- "8080:8080"
- "8850:8848"
- "9870:9848"
- "9852:9849"

View File

@ -9,6 +9,7 @@ services:
volumes:
- ./cluster-logs/nacos1:/home/nacos/logs
ports:
- "8080:8080"
- "8848:8848"
- "9848:9848"
env_file:
@ -27,6 +28,7 @@ services:
volumes:
- ./cluster-logs/nacos2:/home/nacos/logs
ports:
- "8080:8080"
- "8849:8848"
- "9849:9848"
env_file:
@ -44,6 +46,7 @@ services:
volumes:
- ./cluster-logs/nacos3:/home/nacos/logs
ports:
- "8080:8080"
- "8850:8848"
- "9850:9848"
env_file:

View File

@ -8,6 +8,7 @@ services:
volumes:
- ./standalone-logs/:/home/nacos/logs
ports:
- "8080:8080"
- "8848:8848"
- "9848:9848"
- "9849:9849"

33
example/mysql-init.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e
# 加载 NACOS_VERSION
source .env
CLEAN_VERSION=${NACOS_VERSION#v}
SCHEMA_URL="https://raw.githubusercontent.com/alibaba/nacos/${CLEAN_VERSION}/distribution/conf/mysql-schema.sql"
TARGET_DIR="./mysql-init"
VERSIONED_FILE="${TARGET_DIR}/${NACOS_VERSION}-mysql-schema.sql"
FINAL_FILE="${TARGET_DIR}/mysql-schema.sql"
# 创建目录
mkdir -p "${TARGET_DIR}"
# 下载 schema 文件
echo "⬇️ Downloading MySQL schema for Nacos ${CLEAN_VERSION}..."
curl -sSL "$SCHEMA_URL" -o "${VERSIONED_FILE}"
# 校验下载
if [ ! -s "${VERSIONED_FILE}" ]; then
echo "❌ Failed to download schema file from $SCHEMA_URL"
exit 1
fi
# 拷贝为标准文件名供 MySQL 初始化使用
cp "${VERSIONED_FILE}" "${FINAL_FILE}"
# 删除原始版本号文件
rm -f "${VERSIONED_FILE}"
echo "✅ Downloaded and prepared: ${FINAL_FILE}"

View File

@ -8,10 +8,11 @@ services:
- MODE=standalone
- NACOS_AUTH_IDENTITY_KEY=serverIdentity
- NACOS_AUTH_IDENTITY_VALUE=security
- NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
- NACOS_AUTH_TOKEN=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=
volumes:
- ./standalone-logs/:/home/nacos/logs
ports:
- "8080:8080"
- "8848:8848"
- "9848:9848"
prometheus:

View File

@ -1,36 +0,0 @@
version: "3.8"
services:
nacos:
image: nacos/nacos-server:${NACOS_VERSION}
container_name: nacos-standalone-mysql
env_file:
- ../env/custom-application-config.env
volumes:
- ./standalone-logs/:/home/nacos/logs
- ./init.d/application.properties:/home/nacos/conf/application.properties
ports:
- "8848:8848"
- "9848:9848"
depends_on:
mysql:
condition: service_healthy
restart: on-failure
mysql:
container_name: mysql
build:
context: .
dockerfile: ./image/mysql/5.7/Dockerfile
image: example/mysql:5.7
env_file:
- ../env/mysql.env
volumes:
- ./mysql:/var/lib/mysql
ports:
- "3306:3306"
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10

View File

@ -8,6 +8,7 @@ services:
volumes:
- ./standalone-logs/:/home/nacos/logs
ports:
- "8080:8080"
- "8848:8848"
- "9848:9848"
depends_on:
@ -16,14 +17,15 @@ services:
restart: always
mysql:
container_name: mysql
build:
context: .
dockerfile: ./image/mysql/8/Dockerfile
image: example/mysql:8.0.30
image: mysql:8.0.30
env_file:
- ../env/mysql.env
volumes:
- ./mysql:/var/lib/mysql
- ./mysql-init:/docker-entrypoint-initdb.d/
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
ports:
- "3306:3306"
healthcheck: