Docker 安装 单机Nacos,方便部署使用,版本基于v2.2.0。
docker 拉取nacos镜像
1 2
| docker pull nacos/nacos-server:2.2.0
|
创建挂载目录
1 2
| mkdir -p /projects/nacos/logs/ mkdir -p /projects/nacos/conf/
|
在配置目录下增加application.properties文件
主要目的是为配置nacos数据库存储信息
内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| server.servlet.contextPath=/nacos server.error.include-message=ALWAYS server.port=8848
spring.datasource.platform=mysql db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8 db.user.0=root db.password.0=123456
db.pool.config.connectionTimeout=30000 db.pool.config.validationTimeout=10000 db.pool.config.maximumPoolSize=20 db.pool.config.minimumIdle=2 management.metrics.export.elastic.enabled=false management.metrics.export.influx.enabled=false server.tomcat.accesslog.enabled=true server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i server.tomcat.basedir=file:. nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** nacos.core.auth.system.type=nacos nacos.core.auth.enabled=false nacos.core.auth.caching.enabled=true nacos.core.auth.enable.userAgentAuthWhite=false nacos.core.auth.server.identity.key=serverIdentity nacos.core.auth.server.identity.value=security nacos.core.auth.plugin.nacos.token.expire.seconds=18000 nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789 nacos.istio.mcp.server.enabled=false
|
启动nacos
使用docker命令启动nacos
根据下载镜像自行修改启动镜像
8848UI界面
9848服务注册、健康状态
9849nacos权限管理
docker 安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| docker run \ --name nacos -d \ -p 8848:8848 \ -p 9848:9848 \ -p 9849:9849 \ --privileged=true \ --restart=always \ -e JVM_XMS=256m \ -e JVM_XMX=256m \ -e MODE=standalone \ -e PREFER_HOST_MODE=hostname \ -v /projects/nacos/logs:/home/nacos/logs \ -v /projects/nacos/conf/application.properties:/home/nacos/conf/application.properties \ nacos/nacos-server:v2.2.0
|
docker-compose 安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| version: '3.8'
services: nacos: image: nacos/nacos-server:v2.2.0 container_name: nacos ports: - "8848:8848" - "9848:9848" - "9849:9849" environment: - JVM_XMS=256m - JVM_XMX=256m - MODE=standalone - PREFER_HOST_MODE=hostname volumes: - /projects/nacos/logs:/home/nacos/logs - /projects/nacos/conf/application.properties:/home/nacos/conf/application.properties privileged: true restart: always
|