parent
19e50fbb6c
commit
0f6c9b9512
40
README.md
40
README.md
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
This project contains a Docker image meant to facilitate the deployment of [Nacos](https://github.com/alibaba/nacos).
|
This project contains a Docker image meant to facilitate the deployment of [Nacos](https://github.com/alibaba/nacos).
|
||||||
|
|
||||||
|
[**中文**](README_ZH.md)
|
||||||
|
|
||||||
## Project directory
|
## Project directory
|
||||||
|
|
||||||
@ -12,6 +13,15 @@ This project contains a Docker image meant to facilitate the deployment of [Naco
|
|||||||
* example: Docker compose example for Nacos server
|
* example: Docker compose example for Nacos server
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Precautions
|
||||||
|
|
||||||
|
After the latest `nacos/nacos-server:latest` image, the **database master-slave image** has been removed. For specific reasons, refer to [Removing the Master-Slave Image Configuration](https://github.com/nacos-group/nacos-docker/wiki/%E7%A7%BB%E9%99%A4%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%BB%E4%BB%8E%E9%95%9C%E5%83%8F%E9%85%8D%E7%BD%AE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
Run the following command:
|
Run the following command:
|
||||||
@ -74,7 +84,6 @@ Run the following command:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Common property configuration
|
## Common property configuration
|
||||||
|
|
||||||
| name | description | option |
|
| name | description | option |
|
||||||
@ -85,14 +94,19 @@ Run the following command:
|
|||||||
| NACOS_SERVER_PORT | nacos server port | default **8848** |
|
| NACOS_SERVER_PORT | nacos server port | default **8848** |
|
||||||
| NACOS_SERVER_IP | custom nacos server ip when network was mutil-network | |
|
| NACOS_SERVER_IP | custom nacos server ip when network was mutil-network | |
|
||||||
| SPRING_DATASOURCE_PLATFORM | standalone support mysql | mysql / empty default empty |
|
| SPRING_DATASOURCE_PLATFORM | standalone support mysql | mysql / empty default empty |
|
||||||
| MYSQL_MASTER_SERVICE_HOST | mysql master host | |
|
| MYSQL_SERVICE_HOST | mysql host | |
|
||||||
| MYSQL_MASTER_SERVICE_PORT | mysql master database port | default : **3306** |
|
| MYSQL_SERVICE_PORT | mysql database port | default : **3306** |
|
||||||
| MYSQL_MASTER_SERVICE_DB_NAME | mysql master database name | |
|
| MYSQL_SERVICE_DB_NAME | mysql database name | |
|
||||||
| MYSQL_MASTER_SERVICE_USER | username of master database | |
|
| MYSQL_SERVICE_USER | username of database | |
|
||||||
| MYSQL_MASTER_SERVICE_PASSWORD | password of master database | |
|
| MYSQL_SERVICE_PASSWORD | password of database | |
|
||||||
| MYSQL_SLAVE_SERVICE_HOST | mysql slave host | |
|
| ~~MYSQL_MASTER_SERVICE_HOST~~ | The **latest** version of the image removes this attribute, using MYSQL_SERVICE_HOST | |
|
||||||
| MYSQL_SLAVE_SERVICE_PORT | mysql slave database port | default :3306 |
|
| ~~MYSQL_MASTER_SERVICE_PORT~~ | The **latest** version of the image removes this attribute, using MYSQL_SERVICE_PORT | default : **3306** |
|
||||||
| MYSQL_DATABASE_NUM | It indicates the number of database | default :2 |
|
| ~~MYSQL_MASTER_SERVICE_DB_NAME~~ | The **latest** version of the image removes this attribute, using MYSQL_SERVICE_DB_NAME | |
|
||||||
|
| ~~MYSQL_MASTER_SERVICE_USER~~ | The **latest** version of the image removes this attribute, using MYSQL_SERVICE_USER | |
|
||||||
|
| ~~MYSQL_MASTER_SERVICE_PASSWORD~~ | The **latest** version of the image removes this attribute, using MYSQL_SERVICE_PASSWORD | |
|
||||||
|
| ~~MYSQL_SLAVE_SERVICE_HOST~~ | The **latest** version of the image removes this attribute | |
|
||||||
|
| ~~MYSQL_SLAVE_SERVICE_PORT~~ | The **latest** version of the image removes this attribute | default :3306 |
|
||||||
|
| MYSQL_DATABASE_NUM | It indicates the number of database | default :**1** |
|
||||||
| JVM_XMS | -Xms | default :2g |
|
| JVM_XMS | -Xms | default :2g |
|
||||||
| JVM_XMX | -Xmx | default :2g |
|
| JVM_XMX | -Xmx | default :2g |
|
||||||
| JVM_XMN | -Xmn | default :1g |
|
| JVM_XMN | -Xmn | default :1g |
|
||||||
@ -100,8 +114,14 @@ Run the following command:
|
|||||||
| JVM_MMS | -XX:MaxMetaspaceSize | default :320m |
|
| JVM_MMS | -XX:MaxMetaspaceSize | default :320m |
|
||||||
| NACOS_DEBUG | enable remote debug | y/n default :n |
|
| NACOS_DEBUG | enable remote debug | y/n default :n |
|
||||||
| TOMCAT_ACCESSLOG_ENABLED | server.tomcat.accesslog.enabled | default :false |
|
| TOMCAT_ACCESSLOG_ENABLED | server.tomcat.accesslog.enabled | default :false |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Nacos + Grafana + Prometheus
|
## Nacos + Grafana + Prometheus
|
||||||
|
|
||||||
Usage reference:[Nacos monitor-guide](https://nacos.io/zh-cn/docs/monitor-guide.html)
|
Usage reference:[Nacos monitor-guide](https://nacos.io/zh-cn/docs/monitor-guide.html)
|
||||||
|
|
||||||
**Note**: When Grafana creates a new data source, the data source address must be **http://prometheus:9090**
|
**Note**: When Grafana creates a new data source, the data source address must be **http://prometheus:9090**
|
||||||
|
|
||||||
|
|
||||||
|
126
README_ZH.md
Normal file
126
README_ZH.md
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# Nacos Docker
|
||||||
|
|
||||||
|
本项目是 [Nacos](https://github.com/alibaba/nacos) Server的docker镜像的build源码,以及Nacos server 在docker的单机和集群的运行例子.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 项目目录
|
||||||
|
|
||||||
|
* build:nacos 镜像制作的源码
|
||||||
|
* env: docker compose 环境变量文件
|
||||||
|
* example: docker-compose编排例子
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 运行环境
|
||||||
|
|
||||||
|
* [Docker](https://www.docker.com/)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 注意事项
|
||||||
|
|
||||||
|
从最新的nacos:nacos-server/latest 镜像以后,移除了数据库主从镜像,具体原因请参考[移除主从镜像配置](https://github.com/nacos-group/nacos-docker/wiki/%E7%A7%BB%E9%99%A4%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%BB%E4%BB%8E%E9%95%9C%E5%83%8F%E9%85%8D%E7%BD%AE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
打开命令窗口执行:
|
||||||
|
|
||||||
|
``` powershell
|
||||||
|
docker run --name nacos-standalone -e MODE=standalone -p 8848:8848 -d nacos/nacos-server:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 其他使用方式
|
||||||
|
|
||||||
|
打开命令窗口执行:
|
||||||
|
|
||||||
|
* Clone 项目 并且进入项目根目录
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
git clone https://github.com/paderlol/nacos-docker.git
|
||||||
|
cd nacos-docker
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
* 单机
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
docker-compose -f standalone.yaml up
|
||||||
|
```
|
||||||
|
|
||||||
|
* 集群
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
docker-compose -f cluster.yaml up
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
* 注册服务
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
curl -X PUT 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080'
|
||||||
|
```
|
||||||
|
|
||||||
|
* 注册配置
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=helloWorld"
|
||||||
|
```
|
||||||
|
|
||||||
|
* 访问控制台
|
||||||
|
|
||||||
|
浏览器访问:http://127.0.0.1:8848/nacos/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 属性配置列表
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| 属性名称 | 描述 | 选项 |
|
||||||
|
| --------------------------------- | ------------------------------------------------------------ | ----------------------------------- |
|
||||||
|
| MODE | 系统启动方式: 集群/单机 | cluster/standalone默认 **cluster** |
|
||||||
|
| NACOS_SERVERS | nacos cluster address | p1:port1空格ip2:port2 空格ip3:port3 |
|
||||||
|
| PREFER_HOST_MODE | 支持IP还是域名模式 | hostname/ip 默认 **ip** |
|
||||||
|
| NACOS_SERVER_PORT | Nacos 运行端口 | 默认 **8848** |
|
||||||
|
| NACOS_SERVER_IP | 多网卡模式下可以指定IP | |
|
||||||
|
| SPRING_DATASOURCE_PLATFORM | standalone support mysql | mysql / 空 默认:空 |
|
||||||
|
| MYSQL_SERVICE_HOST | mysql host | |
|
||||||
|
| MYSQL_SERVICE_PORT | mysql database port | 默认 : **3306** |
|
||||||
|
| MYSQL_SERVICE_DB_NAME | mysql database name | |
|
||||||
|
| MYSQL_SERVICE_USER | username of database | |
|
||||||
|
| MYSQL_SERVICE_PASSWORD | password of database | |
|
||||||
|
| ~~MYSQL_MASTER_SERVICE_HOST~~ | **latest(目前latest 是1.1.4)以后**版本镜像移除, 使用 MYSQL_SERVICE_HOST | |
|
||||||
|
| ~~MYSQL_MASTER_SERVICE_PORT~~ | **latest(目前latest 是1.1.4)以后**版本镜像移除, 使用 using MYSQL_SERVICE_PORT | 默认 : **3306** |
|
||||||
|
| ~~MYSQL_MASTER_SERVICE_DB_NAME~~ | **latest(目前latest 是1.1.4)以后**版本镜像移除, 使用 MYSQL_SERVICE_DB_NAME | |
|
||||||
|
| ~~MYSQL_MASTER_SERVICE_USER~~ | **latest(目前latest 是1.1.4)以后**版本镜像移除, 使用 MYSQL_SERVICE_USER | |
|
||||||
|
| ~~MYSQL_MASTER_SERVICE_PASSWORD~~ | **latest(目前latest 是1.1.4)以后**版本镜像移除, 使用, using MYSQL_SERVICE_PASSWORD | |
|
||||||
|
| ~~MYSQL_SLAVE_SERVICE_HOST~~ | **latest(目前latest 是1.1.4)以后**版本镜像移除 | |
|
||||||
|
| ~~MYSQL_SLAVE_SERVICE_PORT~~ | **latest(目前latest 是1.1.4)以后**版本镜像移除 | 默认 :3306 |
|
||||||
|
| MYSQL_DATABASE_NUM | It indicates the number of database | 默认 :**1** |
|
||||||
|
| JVM_XMS | -Xms | 默认 :2g |
|
||||||
|
| JVM_XMX | -Xmx | 默认 :2g |
|
||||||
|
| JVM_XMN | -Xmn | 默认 :1g |
|
||||||
|
| JVM_MS | -XX:MetaspaceSize | 默认 :128m |
|
||||||
|
| JVM_MMS | -XX:MaxMetaspaceSize | 默认 :320m |
|
||||||
|
| NACOS_DEBUG | enable remote debug | y/n 默认 :n |
|
||||||
|
| TOMCAT_ACCESSLOG_ENABLED | server.tomcat.accesslog.enabled | 默认 :false |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Nacos + Grafana + Prometheus
|
||||||
|
|
||||||
|
使用参考:[Nacos monitor-guide](https://nacos.io/zh-cn/docs/monitor-guide.html)
|
||||||
|
|
||||||
|
**Note**: 当使用Grafana创建数据源的时候地址必须是: **http://prometheus:9090**
|
@ -7,11 +7,11 @@ nacos.cmdb.dumpTaskInterval=3600
|
|||||||
nacos.cmdb.eventTaskInterval=10
|
nacos.cmdb.eventTaskInterval=10
|
||||||
nacos.cmdb.labelTaskInterval=300
|
nacos.cmdb.labelTaskInterval=300
|
||||||
nacos.cmdb.loadDataAtStart=false
|
nacos.cmdb.loadDataAtStart=false
|
||||||
db.num=${MYSQL_DATABASE_NUM:2}
|
db.num=${MYSQL_DATABASE_NUM:1}
|
||||||
db.url.0=jdbc:mysql://${MYSQL_MASTER_SERVICE_HOST}:${MYSQL_MASTER_SERVICE_PORT:3306}/${MYSQL_MASTER_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
|
db.url.0=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
|
||||||
db.url.1=jdbc:mysql://${MYSQL_SLAVE_SERVICE_HOST}:${MYSQL_SLAVE_SERVICE_PORT:3306}/${MYSQL_MASTER_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
|
db.url.1=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
|
||||||
db.user=${MYSQL_MASTER_SERVICE_USER}
|
db.user=${MYSQL_SERVICE_USER}
|
||||||
db.password=${MYSQL_MASTER_SERVICE_PASSWORD}
|
db.password=${MYSQL_SERVICE_PASSWORD}
|
||||||
server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
|
server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
|
||||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||||
# default current work dir
|
# default current work dir
|
||||||
|
4
env/mysql-common.env
vendored
4
env/mysql-common.env
vendored
@ -1,4 +0,0 @@
|
|||||||
# mysql template env
|
|
||||||
MYSQL_ROOT_PASSWORD=root
|
|
||||||
MYSQL_REPLICATION_USER=nacos_ru
|
|
||||||
MYSQL_REPLICATION_PASSWORD=nacos_ru
|
|
1
env/mysql-slave.env
vendored
1
env/mysql-slave.env
vendored
@ -1 +0,0 @@
|
|||||||
MYSQL_MASTER_SERVICE_HOST=mysql-master
|
|
1
env/mysql-master.env → env/mysql.env
vendored
1
env/mysql-master.env → env/mysql.env
vendored
@ -1,3 +1,4 @@
|
|||||||
|
MYSQL_ROOT_PASSWORD=root
|
||||||
MYSQL_DATABASE=nacos_devtest
|
MYSQL_DATABASE=nacos_devtest
|
||||||
MYSQL_USER=nacos
|
MYSQL_USER=nacos
|
||||||
MYSQL_PASSWORD=nacos
|
MYSQL_PASSWORD=nacos
|
12
env/nacos-hostname.env
vendored
12
env/nacos-hostname.env
vendored
@ -1,10 +1,8 @@
|
|||||||
#nacos dev env
|
#nacos dev env
|
||||||
PREFER_HOST_MODE=hostname
|
PREFER_HOST_MODE=hostname
|
||||||
NACOS_SERVERS=nacos1:8848 nacos2:8848 nacos3:8848
|
NACOS_SERVERS=nacos1:8848 nacos2:8848 nacos3:8848
|
||||||
MYSQL_MASTER_SERVICE_HOST=mysql-master
|
MYSQL_SERVICE_HOST=mysql
|
||||||
MYSQL_MASTER_SERVICE_DB_NAME=nacos_devtest
|
MYSQL_SERVICE_DB_NAME=nacos_devtest
|
||||||
MYSQL_MASTER_SERVICE_PORT=3306
|
MYSQL_SERVICE_PORT=3306
|
||||||
MYSQL_SLAVE_SERVICE_HOST=mysql-slave
|
MYSQL_SERVICE_USER=nacos
|
||||||
MYSQL_SLAVE_SERVICE_PORT=3306
|
MYSQL_SERVICE_PASSWORD=nacos
|
||||||
MYSQL_MASTER_SERVICE_USER=nacos
|
|
||||||
MYSQL_MASTER_SERVICE_PASSWORD=nacos
|
|
12
env/nacos-ip.env
vendored
12
env/nacos-ip.env
vendored
@ -1,10 +1,8 @@
|
|||||||
#nacos dev env
|
#nacos dev env
|
||||||
PREFER_HOST_MODE=hostname
|
PREFER_HOST_MODE=hostname
|
||||||
NACOS_SERVERS=172.16.238.10:8848 172.16.238.11:8848 172.16.238.12:8848
|
NACOS_SERVERS=172.16.238.10:8848 172.16.238.11:8848 172.16.238.12:8848
|
||||||
MYSQL_MASTER_SERVICE_HOST=mysql-master
|
MYSQL_SERVICE_HOST=mysql
|
||||||
MYSQL_MASTER_SERVICE_DB_NAME=nacos_devtest
|
MYSQL_SERVICE_DB_NAME=nacos_devtest
|
||||||
MYSQL_MASTER_SERVICE_PORT=3306
|
MYSQL_SERVICE_PORT=3306
|
||||||
MYSQL_SLAVE_SERVICE_HOST=mysql-slave
|
MYSQL_SERVICE_USER=nacos
|
||||||
MYSQL_SLAVE_SERVICE_PORT=3306
|
MYSQL_SERVICE_PASSWORD=nacos
|
||||||
MYSQL_MASTER_SERVICE_USER=nacos
|
|
||||||
MYSQL_MASTER_SERVICE_PASSWORD=nacos
|
|
8
env/nacos-standlone-mysql.env
vendored
Normal file
8
env/nacos-standlone-mysql.env
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
PREFER_HOST_MODE=hostname
|
||||||
|
MODE=standalone
|
||||||
|
SPRING_DATASOURCE_PLATFORM=mysql
|
||||||
|
MYSQL_SERVICE_HOST=mysql
|
||||||
|
MYSQL_SERVICE_DB_NAME=nacos_devtest
|
||||||
|
MYSQL_SERVICE_PORT=3306
|
||||||
|
MYSQL_SERVICE_USER=nacos
|
||||||
|
MYSQL_SERVICE_PASSWORD=nacos
|
@ -14,8 +14,7 @@ services:
|
|||||||
- ../env/nacos-hostname.env
|
- ../env/nacos-hostname.env
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql-master
|
- mysql
|
||||||
- mysql-slave
|
|
||||||
|
|
||||||
nacos2:
|
nacos2:
|
||||||
hostname: nacos2
|
hostname: nacos2
|
||||||
@ -30,8 +29,7 @@ services:
|
|||||||
- ../env/nacos-hostname.env
|
- ../env/nacos-hostname.env
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql-master
|
- mysql
|
||||||
- mysql-slave
|
|
||||||
nacos3:
|
nacos3:
|
||||||
hostname: nacos3
|
hostname: nacos3
|
||||||
image: nacos/nacos-server:latest
|
image: nacos/nacos-server:latest
|
||||||
@ -45,28 +43,15 @@ services:
|
|||||||
- ../env/nacos-hostname.env
|
- ../env/nacos-hostname.env
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql-master
|
- mysql
|
||||||
- mysql-slave
|
mysql:
|
||||||
mysql-master:
|
container_name: mysql
|
||||||
container_name: mysql-master
|
image: mysql:5.7
|
||||||
image: nacos/nacos-mysql-master:latest
|
|
||||||
env_file:
|
env_file:
|
||||||
- ../env/mysql-common.env
|
- ../env/mysql.env
|
||||||
- ../env/mysql-master.env
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./mysql-master:/var/lib/mysql
|
- ./init-db:/docker-entrypoint-initdb.d
|
||||||
|
- ./mysql:/var/lib/mysql
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
mysql-slave:
|
|
||||||
container_name: mysql-slave
|
|
||||||
image: nacos/nacos-mysql-slave:latest
|
|
||||||
env_file:
|
|
||||||
- ../env/mysql-common.env
|
|
||||||
- ../env/mysql-slave.env
|
|
||||||
volumes:
|
|
||||||
- ./mysql-slave:/var/lib/mysql
|
|
||||||
ports:
|
|
||||||
- "3305:3306"
|
|
||||||
depends_on:
|
|
||||||
- mysql-master
|
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ services:
|
|||||||
- ../env/nacos-ip.env
|
- ../env/nacos-ip.env
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql-master
|
- mysql
|
||||||
- mysql-slave
|
|
||||||
|
|
||||||
nacos2:
|
nacos2:
|
||||||
image: nacos/nacos-server:latest
|
image: nacos/nacos-server:latest
|
||||||
@ -32,8 +31,7 @@ services:
|
|||||||
- ../env/nacos-ip.env
|
- ../env/nacos-ip.env
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql-master
|
- mysql
|
||||||
- mysql-slave
|
|
||||||
nacos3:
|
nacos3:
|
||||||
image: nacos/nacos-server:latest
|
image: nacos/nacos-server:latest
|
||||||
container_name: nacos3
|
container_name: nacos3
|
||||||
@ -48,36 +46,20 @@ services:
|
|||||||
- ../env/nacos-ip.env
|
- ../env/nacos-ip.env
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql-master
|
- mysql
|
||||||
- mysql-slave
|
mysql:
|
||||||
mysql-master:
|
container_name: mysql
|
||||||
container_name: mysql-master
|
image: mysql:5.7
|
||||||
image: nacos/nacos-mysql-master:latest
|
|
||||||
networks:
|
networks:
|
||||||
nacos_net:
|
nacos_net:
|
||||||
ipv4_address: 172.16.238.13
|
ipv4_address: 172.16.238.13
|
||||||
env_file:
|
env_file:
|
||||||
- ../env/mysql-common.env
|
- ../env/mysql.env
|
||||||
- ../env/mysql-master.env
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./mysql-master:/var/lib/mysql
|
- ./init-db:/docker-entrypoint-initdb.d
|
||||||
|
- ./mysql:/var/lib/mysql
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
mysql-slave:
|
|
||||||
container_name: mysql-slave
|
|
||||||
image: nacos/nacos-mysql-slave:latest
|
|
||||||
networks:
|
|
||||||
nacos_net:
|
|
||||||
ipv4_address: 172.16.238.14
|
|
||||||
env_file:
|
|
||||||
- ../env/mysql-common.env
|
|
||||||
- ../env/mysql-slave.env
|
|
||||||
volumes:
|
|
||||||
- ./mysql-slave:/var/lib/mysql
|
|
||||||
ports:
|
|
||||||
- "3305:3306"
|
|
||||||
depends_on:
|
|
||||||
- mysql-master
|
|
||||||
networks:
|
networks:
|
||||||
nacos_net:
|
nacos_net:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
203
example/init-db/nacos-mysql.sql
Normal file
203
example/init-db/nacos-mysql.sql
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = config_info */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `config_info` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
|
`group_id` varchar(255) DEFAULT NULL,
|
||||||
|
`content` longtext NOT NULL COMMENT 'content',
|
||||||
|
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
||||||
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
|
`src_user` text COMMENT 'source user',
|
||||||
|
`src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
|
||||||
|
`app_name` varchar(128) DEFAULT NULL,
|
||||||
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
|
`c_desc` varchar(256) DEFAULT NULL,
|
||||||
|
`c_use` varchar(64) DEFAULT NULL,
|
||||||
|
`effect` varchar(64) DEFAULT NULL,
|
||||||
|
`type` varchar(64) DEFAULT NULL,
|
||||||
|
`c_schema` text,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
|
||||||
|
|
||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = config_info_aggr */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `config_info_aggr` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
|
`group_id` varchar(255) NOT NULL COMMENT 'group_id',
|
||||||
|
`datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
|
||||||
|
`content` longtext NOT NULL COMMENT '内容',
|
||||||
|
`gmt_modified` datetime NOT NULL COMMENT '修改时间',
|
||||||
|
`app_name` varchar(128) DEFAULT NULL,
|
||||||
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = config_info_beta */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `config_info_beta` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
|
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
||||||
|
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
||||||
|
`content` longtext NOT NULL COMMENT 'content',
|
||||||
|
`beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
|
||||||
|
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
||||||
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
|
`src_user` text COMMENT 'source user',
|
||||||
|
`src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
|
||||||
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
|
||||||
|
|
||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = config_info_tag */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `config_info_tag` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
|
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
||||||
|
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
|
||||||
|
`tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
|
||||||
|
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
||||||
|
`content` longtext NOT NULL COMMENT 'content',
|
||||||
|
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
||||||
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
|
`src_user` text COMMENT 'source user',
|
||||||
|
`src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
|
||||||
|
|
||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = config_tags_relation */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `config_tags_relation` (
|
||||||
|
`id` bigint(20) NOT NULL COMMENT 'id',
|
||||||
|
`tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
|
||||||
|
`tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
|
||||||
|
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||||
|
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
||||||
|
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
|
||||||
|
`nid` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
PRIMARY KEY (`nid`),
|
||||||
|
UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
|
||||||
|
KEY `idx_tenant_id` (`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
|
||||||
|
|
||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = group_capacity */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `group_capacity` (
|
||||||
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
|
`group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
|
||||||
|
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
|
||||||
|
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
|
||||||
|
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
|
||||||
|
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
|
||||||
|
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
|
||||||
|
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
|
||||||
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_group_id` (`group_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
|
||||||
|
|
||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = his_config_info */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `his_config_info` (
|
||||||
|
`id` bigint(64) unsigned NOT NULL,
|
||||||
|
`nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`data_id` varchar(255) NOT NULL,
|
||||||
|
`group_id` varchar(128) NOT NULL,
|
||||||
|
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
||||||
|
`content` longtext NOT NULL,
|
||||||
|
`md5` varchar(32) DEFAULT NULL,
|
||||||
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`src_user` text,
|
||||||
|
`src_ip` varchar(20) DEFAULT NULL,
|
||||||
|
`op_type` char(10) DEFAULT NULL,
|
||||||
|
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||||
|
PRIMARY KEY (`nid`),
|
||||||
|
KEY `idx_gmt_create` (`gmt_create`),
|
||||||
|
KEY `idx_gmt_modified` (`gmt_modified`),
|
||||||
|
KEY `idx_did` (`data_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************/
|
||||||
|
/* 数据库全名 = nacos_config */
|
||||||
|
/* 表名称 = tenant_capacity */
|
||||||
|
/******************************************/
|
||||||
|
CREATE TABLE `tenant_capacity` (
|
||||||
|
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
|
`tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
|
||||||
|
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
|
||||||
|
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
|
||||||
|
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
|
||||||
|
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
|
||||||
|
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
|
||||||
|
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
|
||||||
|
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_tenant_id` (`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `tenant_info` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
|
`kp` varchar(128) NOT NULL COMMENT 'kp',
|
||||||
|
`tenant_id` varchar(128) default '' COMMENT 'tenant_id',
|
||||||
|
`tenant_name` varchar(128) default '' COMMENT 'tenant_name',
|
||||||
|
`tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
|
||||||
|
`create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
|
||||||
|
`gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
|
||||||
|
`gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
|
||||||
|
KEY `idx_tenant_id` (`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
|
||||||
|
|
||||||
|
CREATE TABLE `users` (
|
||||||
|
`username` varchar(50) NOT NULL PRIMARY KEY,
|
||||||
|
`password` varchar(500) NOT NULL,
|
||||||
|
`enabled` boolean NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `roles` (
|
||||||
|
`username` varchar(50) NOT NULL,
|
||||||
|
`role` varchar(50) NOT NULL,
|
||||||
|
UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `permissions` (
|
||||||
|
`role` varchar(50) NOT NULL,
|
||||||
|
`permission` varchar(512) NOT NULL,
|
||||||
|
`gmt_create` bigint NULL,
|
||||||
|
`gmt_modified` bigint NULL,
|
||||||
|
UNIQUE INDEX `idx_role_resource` (`role` ASC, `permission` ASC) USING BTREE
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
|
||||||
|
|
||||||
|
INSERT INTO roles (username, role) VALUES ('nacos', 'GLOBAL_ADMIN');
|
@ -3,17 +3,8 @@ services:
|
|||||||
nacos:
|
nacos:
|
||||||
image: nacos/nacos-server:latest
|
image: nacos/nacos-server:latest
|
||||||
container_name: nacos-standalone-mysql
|
container_name: nacos-standalone-mysql
|
||||||
environment:
|
env_file:
|
||||||
- PREFER_HOST_MODE=hostname
|
- ../env/nacos-standlone-mysql.env
|
||||||
- MODE=standalone
|
|
||||||
- SPRING_DATASOURCE_PLATFORM=mysql
|
|
||||||
- MYSQL_MASTER_SERVICE_HOST=mysql-master
|
|
||||||
- MYSQL_MASTER_SERVICE_DB_NAME=nacos_devtest
|
|
||||||
- MYSQL_MASTER_SERVICE_PORT=3306
|
|
||||||
- MYSQL_SLAVE_SERVICE_HOST=mysql-slave
|
|
||||||
- MYSQL_SLAVE_SERVICE_PORT=3305
|
|
||||||
- MYSQL_MASTER_SERVICE_USER=nacos
|
|
||||||
- MYSQL_MASTER_SERVICE_PASSWORD=nacos
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./standalone-logs/:/home/nacos/logs
|
- ./standalone-logs/:/home/nacos/logs
|
||||||
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
|
- ./init.d/custom.properties:/home/nacos/init.d/custom.properties
|
||||||
@ -21,30 +12,18 @@ services:
|
|||||||
- "8848:8848"
|
- "8848:8848"
|
||||||
- "9555:9555"
|
- "9555:9555"
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql-slave
|
- mysql
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
mysql-master:
|
mysql:
|
||||||
container_name: mysql-master
|
container_name: mysql
|
||||||
image: nacos/nacos-mysql-master:latest
|
image: mysql:5.7
|
||||||
env_file:
|
env_file:
|
||||||
- ../env/mysql-common.env
|
- ../env/mysql.env
|
||||||
- ../env/mysql-master.env
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./mysql-master:/var/lib/mysql
|
- ./init-db:/docker-entrypoint-initdb.d
|
||||||
|
- ./mysql:/var/lib/mysql
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
mysql-slave:
|
|
||||||
container_name: mysql-slave
|
|
||||||
image: nacos/nacos-mysql-slave:latest
|
|
||||||
env_file:
|
|
||||||
- ../env/mysql-common.env
|
|
||||||
- ../env/mysql-slave.env
|
|
||||||
volumes:
|
|
||||||
- ./mysql-slave:/var/lib/mysql
|
|
||||||
ports:
|
|
||||||
- "3305:3306"
|
|
||||||
depends_on:
|
|
||||||
- mysql-master
|
|
||||||
prometheus:
|
prometheus:
|
||||||
container_name: prometheus
|
container_name: prometheus
|
||||||
image: prom/prometheus:latest
|
image: prom/prometheus:latest
|
||||||
|
Loading…
Reference in New Issue
Block a user