nacos--基础--2.6--部署--docker

nacos–基础–2.6–部署–docker


前提

使用hd用户登陆
完成基础环境搭建
	https://blog.csdn.net/zhou920786312/article/details/118212302

1、准备工作

1.1、Clone 项目

cd 
git clone https://github.com/nacos-group/nacos-docker.git
cd nacos-docker/

2、单机模式

2.1、单机模式 Derby

# 启动
docker-compose -f example/standalone-derby.yaml up

# 停止
docker-compose -f example/standalone-derby.yaml down

2.1.1、standalone-derby.yaml

version: "2"
services:
  nacos:
    image: nacos/nacos-server:${NACOS_VERSION}
    container_name: nacos-standalone
    environment:
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
    volumes:
      - ./standalone-logs/:/home/nacos/logs
    ports:
      - "8848:8848"
      - "9848:9848"
  prometheus:
    container_name: prometheus
    image: prom/prometheus:latest
    volumes:
      - ./prometheus/prometheus-standalone.yaml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"
    depends_on:
      - nacos
    restart: on-failure
  grafana:
    container_name: grafana
    image: grafana/grafana:latest
    ports:
      - 3000:3000
    restart: on-failure

2.1.2、结果

在这里插入图片描述
在这里插入图片描述

2.2、单机模式 MySQL

2.2.1、使用MySQL5.7

# 开始
docker-compose -f example/standalone-mysql-5.7.yaml up

# 停止
docker-compose -f example/standalone-mysql-5.7.yaml down
standalone-mysql-5.7.yaml
version: "3.8"
services:
  nacos:
    image: nacos/nacos-server:${NACOS_VERSION}
    container_name: nacos-standalone-mysql
    env_file:
      - ../env/nacos-standlone-mysql.env
    volumes:
      - ./standalone-logs/:/home/nacos/logs
      - ./init.d/custom.properties:/home/nacos/init.d/custom.properties
    ports:
      - "8848:8848"
      - "9848:9848"
      - "9555:9555"
    depends_on:
      mysql:
        condition: service_healthy

    restart: on-failure
  mysql:
    container_name: mysql
    build:
      context: .
      dockerfile: ./image/mysql/5.7/Dockerfile
      tags:
        - "example/mysql:5.7"
    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
#  prometheus:
#    container_name: prometheus
#    image: prom/prometheus:latest
#    volumes:
#      - ./prometheus/prometheus-standalone.yaml:/etc/prometheus/prometheus.yml
#    ports:
#      - "9090:9090"
#    depends_on:
#      - nacos
#    restart: on-failure
#  grafana:
#    container_name: grafana
#    image: grafana/grafana:latest
#    ports:
#      - 3000:3000
#    restart: on-failure



2.2.2、使用MySQL8

# 开始
docker-compose -f example/standalone-mysql-8.yaml up


# 停止
docker-compose -f example/standalone-mysql-8.yaml down
standalone-mysql-8.yaml
version: "3.8"
services:
  nacos:
    image: nacos/nacos-server:${NACOS_VERSION}
    container_name: nacos-standalone-mysql
    env_file:
      - ../env/nacos-standlone-mysql.env
    volumes:
      - ./standalone-logs/:/home/nacos/logs
    ports:
      - "8848:8848"
      - "9848:9848"
      - "9555:9555"
    depends_on:
      mysql:
        condition: service_healthy
    restart: always
  mysql:
    container_name: mysql
    build:
      context: .
      dockerfile: ./image/mysql/8/Dockerfile
      tags:
        - "example/mysql:8.0.30"
    image: example/mysql:8.0.30
    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




3、集群模式

# 开始
docker-compose -f example/cluster-hostname.yaml up 
 
# 停止
docker-compose -f example/cluster-hostname.yaml down
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值