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

    数据库配置有错误

相关推荐
小此方9 小时前
Re:Mysql数据库基础篇(八):详细讲解复合查询、多表查询、自连接、多行、多列子查询与合并查询
数据库·mysql
smile_life_10 小时前
MySQL 设置 防止账户被暴力破解
数据库·mysql
滕州市燕猫虎计算机科技工作室个体工商户11 小时前
MySQL、MVCC、多版本并发控制
数据库·mysql·mvcc·数据库事务
Decay__13 小时前
09_MySQL 闪回与时间点恢复 —— binlog 回放、mysqlbinlog、PITR 与误删恢复
运维·数据库·sql·mysql·架构
太理摆烂哥13 小时前
MySQL用户管理
数据库·mysql
DarkAthena13 小时前
wslc ps 卡死的排查:一次「停容器不停 VM」引发的连环故障
docker
小沈同学呀14 小时前
【Agent开发第十五期】部署上线:把 Alex 搬进浏览器,15 期全栈串联收官
docker·agent·从零搭建ai助手
lwx91485215 小时前
Docker-安装SSH服务
docker·容器·ssh
梦影_15 小时前
MySQL进阶教程(五)—— SQL调优(下)
android·大数据·数据库·后端·sql·mysql·database
John_Hui16 小时前
Windows 10 安装版本:mysql-8.1.0-winx64.zip
数据库·windows·mysql