1. 相关资料
2. 独立mysql部署
- mysql版本 5.7+
2.1 初始化数据库
独立安装mysql, 创建数据库nacos, 执行脚本 nacos-db.sql
2.2 docker部署 nacos-server
docker run -d \
 -v /standalone-logs/:/home/nacos/logs
 -v ./custom.properties:/home/nacos/init.d/custom.properties
-e PREFER_HOST_MODE=ip \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_MASTER_SERVICE_HOST=10.5.96.32 \
-e MYSQL_MASTER_SERVICE_PORT=3306 \
-e MYSQL_MASTER_SERVICE_USER=root \
-e MYSQL_MASTER_SERVICE_PASSWORD=123456 \
-e MYSQL_MASTER_SERVICE_DB_NAME=nacos \
-e MYSQL_SLAVE_SERVICE_HOST=从数据库ip \
-p 7110:8848 \
-p 7111:9555 \
--name nacos1 \
nacos/nacos-server
需先下载 custom.properties
访问 http://10.5.96.62:7110/nacos , 默认用户名密码 nacos/nacos, 界面如下:

查看  http://10.5.96.62:7110/nacos/actuator/prometheus 是否有信息返回。
2.3 docker部署prometheus
docker run -d \
-v ./prometheus-standalone.yaml:/etc/prometheus/prometheus.yml \
-p 7120:9090 \
-- name prom/prometheus:latest \
prometheus1
下载 prometheus.yml。ip端口使用默认,无需更改,即使对外端口已经改变。
访问 http://10.5.96.62:7120/graph , 如图下:
 输入nacos_monitor 查询。
输入nacos_monitor 查询。
2.4 docker 部署grafana
docker run -d \
-p 7130:3000 \
-- name grafana/grafana:latest
grafana1
查看 http://10.5.96.62:7130/ ,默认用户名密码:admin/admin , 界面如下:

配置 prometheus 数据源, import 导入 dashboard 模板。模板地址:https://github.com/nacos-group/nacos-template/blob/master/nacos-grafana.json
3. docker-compose 部署脚本
version: "2"
services:
  nacos:
    image: nacos/nacos-server:latest
    container_name: nacos1
    volumes:
      - ./standalone-logs/:/home/nacos/logs
      - ./custom.properties:/home/nacos/init.d/custom.properties
    ports:
      - 7110:8848
      - 7111:9555
    environment:
      - "PREFER_HOST_MODE=ip"
      - "MODE=standalone"
      - "SPRING_DATASOURCE_PLATFORM=mysql"
      - "MYSQL_SERVICE_HOST=10.5.96.32"
      - "MYSQL_SERVICE_PORT=3306"
      - "MYSQL_SERVICE_USER=root"
      - "MYSQL_SERVICE_PASSWORD=Mysql@0000"
      - "MYSQL_SERVICE_DB_NAME=nacos"
    restart: on-failure
  prometheus:
    container_name: prometheus1
    image: prom/prometheus:latest
    volumes:
      - ./prometheus-standalone.yaml:/etc/prometheus/prometheus.yml
    ports:
      - 7120:9090
    depends_on:
      - nacos
    restart: on-failure
  grafana:
    container_name: grafana1
    image: grafana/grafana:latest
    ports:
      - 7130:3000
    restart: on-failure
//启动容器
docker-compose -f nacos.yaml up
//停止并删除容器
docker-compose -f nacos.yaml down
来源:oschina
链接:https://my.oschina.net/u/590281/blog/4739966