docker 安装nacos,使用自定义mysql

Clone 项目

shell 复制代码
git clone https://github.com/nacos-group/nacos-docker.git
cd nacos-docker

使用自定义数据库

  • 创建数据库
sql 复制代码
    create database nacos_config;
    use nacos_config;
  • 初始化表结构
sql 复制代码
执行数据库脚本: https://github.com/alibaba/nacos/blob/master/distribution/conf/mysql-schema.sql
  • 修改配置文件
shell 复制代码
vim env/nacos-standlone-mysql.env
# 修改以下配置:
# mysql host
MYSQL_SERVICE_HOST=本机ip
# 数据库名称, 与上面创建的数据库保持一致
MYSQL_SERVICE_DB_NAME=nacos_config
# 端口号
MYSQL_SERVICE_PORT=3306
# 用户名
MYSQL_SERVICE_USER=root
# 密码
MYSQL_SERVICE_PASSWORD=123456
shell 复制代码
# Using mysql 5.7:
vim example/standalone-mysql-5.7.yaml
# Using mysql 8: 
vim example/standalone-mysql-8.yaml

删除:services.depends_on 相关配置
删除:services.mysql 相关配置
修改后:
% cat 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"
    restart: always
  • 执行
shell 复制代码
# Using mysql 5.7: 
docker-compose -f example/standalone-mysql-5.7.yaml up
# Using mysql 8: 
docker-compose -f example/standalone-mysql-8.yaml up

异常:

  • No DataSource set

    数据库配置有错误

相关推荐
leeyi3 分钟前
把软件装进不能上网的机房——一套建好了、还没上过战场的交付工程(第101篇)
docker·aigc·agent
YIAN2 小时前
Docker + Nginx 核心原理扫盲:从环境隔离到反向代理,运维面试必考点
后端·docker·面试
IT大白鼠5 小时前
Docker 实战 ELKF 日志监控:容器日志全栈收集分析方案
运维·docker·容器
九皇叔叔13 小时前
《MySQL 体系架构详解:Server 层、SQL 执行流程与 InnoDB、MyISAM、MEMORY 存储引擎》
sql·mysql·架构
报错小能手15 小时前
Kubernetes入门实战课 3
云原生·容器·kubernetes
愤怒的苹果ext16 小时前
MySQL Shell备份恢复数据库
数据库·mysql·备份恢复·mysqlsh
小张同学a.17 小时前
Docker 容器实战 1—— docker 基础与镜像构建
linux·运维·docker·容器
NJCloud18 小时前
Docker 容器技术入门:部署、核心概念与基础命令
运维·docker·容器
2601_9620723318 小时前
docker自建rustdesk-server远程桌面
运维·docker·容器
超兔一体云19 小时前
MySQL索引优化实战——从慢查询到索引调优
后端·mysql