概要
微服务nacos环境搭建。
mysql-nacos.yml【docker-compose文件】
提示:docker-compose文件,nacos采用mysql数据库进行数据保存,根据实际的数据库地址进行修改。
version: "3"
services:
cc-nacos:
container_name: cc-nacos
image: nacos/nacos-server:v2.2.3
environment:
- PREFER_HOST_MODE=ip
- MODE=standalone
# - NACOS_SERVERS=
- SPRING_DATASOURCE_PLATFORM=mysql
- MYSQL_SERVICE_HOST=127.0.0.1
- MYSQL_SERVICE_DB_NAME=cc-nacos
- MYSQL_SERVICE_PORT=3306
- MYSQL_SERVICE_USER=root
- MYSQL_SERVICE_PASSWORD=shenyijie
- MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
- NACOS_AUTH_ENABLE=true
- JVM_XMS=512m
- JVM_XMX=512m
- JVM_XMN=256m
ports:
- '8848:8848'
- '9848:9848'
- '9849:9849'
restart: always
volumes:
- '/etc/localtime:/etc/localtime:ro'
- '/Users/shenyijie/data/soft/nacos/logs:/home/nacos/logs:rw'
- '/Users/shenyijie/data/soft/nacos/conf/application.properties:/home/nacos/conf/application.properties:rw'
- '/Users/shenyijie/data/soft/nacos/conf:/home/nacos/conf:rw'
nacos配置【配置信息】
提示:注意数据库连接地址信息,根据实际的数据库地址进行修改。
# spring
server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
server.contextPath=/nacos
server.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 ***************#
spring.sql.init.platform=mysql
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
db.num=1
# 此处配置数据库连接地址信息
db.url.0=jdbc:mysql://127.0.0.1:3306/cc-nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
db.user.0=root
db.password.0=shenyijie
###
nacos.core.auth.enabled=true
nacos.core.auth.system.type=nacos
nacos.core.auth.plugin.nacos.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}
nacos.core.auth.plugin.nacos.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey012345678901234567890123456789012345678901234567890123456789}
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:example}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:example}
### 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配置【脚本命令】
docker-compose -f /Users/shenyijie/data/docker-file/nacos-docker.yml -p nacos up -d
小结
提示:完毕。