赞
踩
目的:存储nacos元数据
步骤请参考: docker部署mysql
说明:该步骤并非必要步骤,只是笔者喜欢Adminer这个数据库管理工具。如果你们的电脑已经安装了navicat 或者 sqlyog等数据库管理工具的话,可以跳过此步。
目的:可以在网页上操作mysql,用于执行nacos-db.sql脚本。
步骤请参考:docker部署Adminer
步骤:
- docker search nacos
- docker pull nacos/nacos-server
mkdir -p /home/nacos/init.d /home/nacos/logs
touch /home/nacos/init.d/custom.properties
在新建的custom.properties中写入如下配置(直接复制即可):
management.endpoints.web.exposure.include=*
mkdir -p /home/nacos/conf
touch /home/nacos/application.properties
在新建的application.properties中写入如下配置(直接复制即可):
- # spring
- server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
- server.contextPath=/nacos
- server.port=${NACOS_SERVER_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}?
- characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
- db.url.1=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?
- characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
- 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}
- 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=/,/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

操作完第2步和第3步,目录结构变成如下:
- docker run -d -p 8848:8848
- -e MODE=standalone
- -e PREFER_HOST_MODE=hostname
- -e SPRING_DATASOURCE_PLATFORM=mysql
- -e MYSQL_SERVICE_HOST=XXXX
- -e MYSQL_SERVICE_PORT=3306
- -e MYSQL_SERVICE_DB_NAME=nacos
- -e MYSQL_SERVICE_USER=root
- -e MYSQL_SERVICE_PASSWORD=root
- -e MYSQL_DATABASE_NUM=1
- -v /home/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties
- -v /home/nacos/logs:/home/nacos/logs
- --restart always --name nacos nacos/nacos-server
参数说明:
登录云服务器,新增规则,允许访问8848端口。
Nacos访问地址:http://ip:8848/nacos
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。