docker-compose部署emqx、minio、redis、nacos、kafka集群(在一台虚拟机上)
docker-compose部署minio集群
创建一个新的文件夹,并在文件夹下创建一个docker-compose.yaml
vi docker-compose.yaml
把一下内容复制进去
#docker-compose.yaml
version: '3.7'
# starts 4 docker containers running minio server instances. Each
# minio server's web interface will be accessible on the host at port
# 9001 through 9004.
services:
minio1:
image: minio/minio:RELEASE.2020-08-08T04-50-06Z
volumes:
- data1-1:/data1
- data1-2:/data2
ports:
- "9001:9000"
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
command: server http://minio{1...4}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
minio2:
image: minio/minio:RELEASE.2020-08-08T04-50-06Z
volumes:
- data2-1:/data1
- data2-2:/data2
ports:
- "9002:9000"
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
command: server http://minio{1...4}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
minio3:
image: minio/minio:RELEASE.2020-08-08T04-50-06Z
volumes:
- data3-1:/data1
- data3-2:/data2
ports:
- "9003:9000"
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
command: server http://minio{1...4}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
minio4:
image: minio/minio:RELEASE.2020-08-08T04-50-06Z
volumes:
- data4-1:/data1
- data4-2:/data2
ports:
- "9004:9000"
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
command: server http://minio{1...4}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
## By default this config uses default local driver,
## For custom volumes replace with volume driver configuration.
volumes:
data1-1:
data1-2:
data2-1:
data2-2:
data3-1:
data3-2:
data4-1:
data4-2:
- 在此文件夹下,执行docker-compose命令,创建集群环境
docker-compose up -d
- 启动成功后,可以查看docker当前运行的容器,有4个minio容器,端口分别为9001,9002,9003,9004
创建的时候可能会提示错误,是因为版本不匹配,只需要把yaml文件的版本改成匹配的版本即可。此处改成 version: ‘3.2’
========================================================
ERROR: Version in "./docker-compose.yaml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version ("2.0", "2.1", "3.0", "3.1", "3.2") and place your service definitions under theservices
key, or omit theversion
key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
docker-compose部署redis
参考(https://blog.csdn.net/weixin_46129192/article/details/124072784)
docker-compose部署redis哨兵模式参考(https://blog.csdn.net/u010797364/article/details/122623715)
先创建网桥:
docker network create -d bridge --subnet=172.38.0.0/16 redis
在执行以下脚本配置环境和部署容器
#通过脚本一次创建6个redis配置
for port in $(seq 1 6); \
do \
mkdir -p /mydata/redis/node-${port}/conf
touch /mydata/redis/node-${port}/conf/redis.conf
cat << EOF >/mydata/redis/node-${port}/conf/redis.conf
port 6379
bind 0.0.0.0
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-announce-ip 172.38.0.1${port}
cluster-announce-port 6379
cluster-announce-bus-port 16379
appendonly yes
EOF
# 通过脚本一次启动6个redis容器
docker run -p 637${port}:6379 -p 1637${port}:16379 --name redis-${port} \
-v /mydata/redis/node-${port}/data:/data \
-v /mydata/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \
-d --net redis --ip 172.38.0.1${port} redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf
done
创建成功
查看创建的容器
docker-compose部署emqx+nginx
参考(https://www.cnblogs.com/innocenter/p/16175989.html)
拉取镜像
docker pull emqx/emqx;
创建虚拟网络
docker network create -d bridge --subnet=172.18.0.0/16 emqx_bridge
启动服务
节点1
docker run -d --hostname emqx01 --name emqx01 --network emqx_bridge --ip 172.18.0.2 -p 60001:1883 -p 60004:8083 -p 60007:8883 -p 60010:8084 -p 60017:18083 -p 60013:11883 -v /etc/localtime:/etc/localtime:ro emqx/emqx:latest
节点2
docker run -d --hostname emqx02 --name emqx02 --network emqx_bridge --ip 172.18.0.3 -p 60002:1883 -p 60005:8083 -p 60008:8883 -p 60011:8084 -p 60018:18083 -p 60014:11883 -v /etc/localtime:/etc/localtime:ro emqx/emqx:latest
节点3
docker run -d --hostname emqx03 --name emqx03 --network emqx_bridge --ip 172.18.0.4 -p 60003:1883 -p 60006:8083 -p 60009:8883 -p 60012:8084 -p 60019:18083 -p 60015:11883 -v /etc/localtime:/etc/localtime:ro emqx/emqx:latest
配置集群归属
节点2
docker exec -it emqx02 sh
bin/emqx_ctl cluster join emqx01@172.18.0.2
exit
节点3
docker exec -it emqx03 sh
bin/emqx_ctl cluster join emqx01@172.18.0.2
bin/emqx_ctl cluster status
exit
负载均衡
拉取镜像
Docker pull nginx
启动项目
docker run --name nginx -p 80:80 -d nginx
本地映射配置文件
mkdir -p /data/nginx
mkdir -p /data/nginx/www
mkdir -p /data/nginx/conf
mkdir -p /data/nginx/logs
复制配置文件到主机
如果通过docker ps查看的容器ID不行就通过以下命令查询容器长id:
docker inspect -f '{{.ID}}' 容器名称
docker cp 容器id:/etc/nginx/nginx.conf /data/nginx/
docker cp 容器id:/etc/nginx/conf.d /data/nginx/conf/
docker cp 容器id:/usr/share/nginx/html/ /data/nginx/www/
docker cp 容器id:/var/log/nginx/ /data/nginx/logs/
移除之前的服务
docker stop 容器id docker rm 容器id
配置文件编辑
/data/nginx/conf/default.conf此处文件配置不变
/data/nginx/nginx.conf 配置文件进行修改
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
stream{
# emqx tcp
upstream emqxTcp {
#hash $remote_addr consistent;
server 192.168.86.63:60001 max_fails=3 fail_timeout=30s;
server 192.168.86.63:60002 max_fails=3 fail_timeout=30s;
server 192.168.86.63:60003 max_fails=3 fail_timeout=30s;
}
# emqx tcp server
server {
listen 1883;
#proxy_timeout 180s;
proxy_pass emqxTcp;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf; #嵌套
upstream stream_backend {
server 192.168.86.63:60017 max_fails=2 fail_timeout=30s;
server 192.168.86.63:60018 max_fails=2 fail_timeout=30s;
server 192.168.86.63:60019 max_fails=2 fail_timeout=30s;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://stream_backend;
}
}
}
启动文件
docker run --name nginx -p 80:80 -p 1883:1883 --network emqx_bridge --ip 172.18.0.6 -v /data/nginx/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/www/:/usr/share/nginx/html/ -v /data/nginx/logs/:/var/log/nginx/ -v /data/nginx/conf/:/etc/nginx/conf.d --privileged=true -d nginx
页面展示
192.168.86.63:80
Nginx跳转随机切换emqx(目前采用的轮询策略)
docker-compose部署kafka集群
创建一个文件夹,在文件里面创建一个docker-compose.yaml,把下面内容复制进去
version: '3.3'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
ports:
- 2181:2181
volumes:
- /data/zookeeper/data:/data
- /data/zookeeper/datalog:/datalog
- /data/zookeeper/logs:/logs
restart: always
kafka1:
image: wurstmeister/kafka
depends_on:
- zookeeper
container_name: kafka1
ports:
- 9092:9092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 192.168.86.63:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.86.63:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_LOG_DIRS: /data/kafka-data
KAFKA_LOG_RETENTION_HOURS: 24
volumes:
- /data/kafka1/data:/data/kafka-data
restart: unless-stopped
kafka2:
image: wurstmeister/kafka
depends_on:
- zookeeper
container_name: kafka2
ports:
- 9093:9093
environment:
KAFKA_BROKER_ID: 2
KAFKA_ZOOKEEPER_CONNECT: 192.168.86.63:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.86.63:9093
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9093
KAFKA_LOG_DIRS: /data/kafka-data
KAFKA_LOG_RETENTION_HOURS: 24
volumes:
- /data/kafka2/data:/data/kafka-data
restart: unless-stopped
kafka3:
image: wurstmeister/kafka
depends_on:
- zookeeper
container_name: kafka3
ports:
- 9094:9094
environment:
KAFKA_BROKER_ID: 3
KAFKA_ZOOKEEPER_CONNECT: 192.168.86.63:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.86.63:9094
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9094
KAFKA_LOG_DIRS: /data/kafka-data
KAFKA_LOG_RETENTION_HOURS: 24
volumes:
- /data/kafka3/data:/data/kafka-data
restart: unless-stopped
参数说明:
- KAFKA_ZOOKEEPER_CONNECT: zookeeper服务地址
- KAFKA_ADVERTISED_LISTENERS: kafka服务地址
- KAFKA_BROKER_ID: kafka节点ID,不可重复
- KAFKA_LOG_DIRS: kafka数据文件地址(非必选。下面的volumes会将容器内文件挂载到宿主机上)
- KAFKA_LOG_RETENTION_HOURS: 数据文件保留时间(非必选。缺省168小时)
- 启动
docke-compose up -d
出现如上结果表示启动成功 - 创建kafka图形化管理kafka-manger
//1、拉取kafka-manager管理端镜像 不指定版本就拉取默认版本
docker pull sheepkiller/kafka-manager
//2、启动命令
docker run -d --name kfk-manager -p 9000:9000 -e ZK_HOSTS={你的ip地址}:2181 sheepkiller/kafka-manager:latest
docker-compose部署nacos集群
先创建文件和文件夹
mkdir app
cd /app
touch docker-compose.yaml
touch nginx.conf
准备好对应的docker-compose配置文件,内容如下
version: '3'
services:
# nacos-server服务注册与发现,配置中心服务
mysql5.72:
image: mysql:5.7
container_name: mysql5.7-nacos
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: nacos
MYSQL_USER: nacos
MYSQL_PASSWORD: 123456
TZ: Asia/Shanghai
ports:
- 3308:3306
volumes: # 挂载持久化地址(个人理解)
- /app/docker-compose2/mysql:/var/lib/mysql
docker-nacos-1:
image: nacos/nacos-server:latest
container_name: nacos-server-1
hostname: docker-nacos-1
ports:
- "8860:8848"
restart: always
volumes:
- /app/nacos1/logs/:/home/nacos/logs
environment:
PREFER_HOST_MODE: hostname #如果支 持主机名可以使用hostname,否则使用ip,默认也是ip
NACOS_SERVERS: docker-nacos-1:8848 docker-nacos-2:8848 docker-nacos-3:8848
MYSQL_SERVICE_HOST: mysql5.72 #mysql配置,Master为主节点,Slave为从节点
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_DB_NAME: nacos
MYSQL_SERVICE_USER: nacos
MYSQL_SERVICE_PASSWORD: 123456
TIME_ZONE: Asia/Shanghai
docker-nacos-2:
image: nacos/nacos-server:latest
container_name: nacos-server-2
hostname: docker-nacos-2
ports:
- "8861:8848"
restart: always
environment:
PREFER_HOST_MODE: hostname #如果支持主机名可以使用hostname,否则使用ip,默认也是ip
NACOS_SERVERS: docker-nacos-1:8848 docker-nacos-2:8848 docker-nacos-3:8848
MYSQL_SERVICE_HOST: mysql5.72 #mysql配置,Ma ster为主节点,Slave为从节点
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_DB_NAME: nacos
MYSQL_SERVICE_USER: nacos
MYSQL_SERVICE_PASSWORD: 123456
TIME_ZONE: Asia/Shanghai
volumes:
- /app/nacos2/logs/:/home/nacos/logs
docker-nacos-3:
image: nacos/nacos-server:latest
container_name: nacos-server-3
hostname: docker-nacos-3
ports:
- "8862:8848"
restart: always
environment:
PREFER_HOST_MODE: hostname #如果支持主机名可以使用hostname,否则使用ip,默认也是ip
NACOS_SERVERS: docker-nacos-1:8848 docker-nacos-2:8848 docker-nacos-3:8848
MYSQL_SERVICE_HOST: mysql5.72 #mysql配置,Ma ster为主节点,Slave为从节点
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_DB_NAME: nacos
MYSQL_SERVICE_USER: nacos
MYSQL_SERVICE_PASSWORD: 123456
TIME_ZONE: Asia/Shanghai
volumes:
- /app/nacos3/logs/:/home/nacos/logs
nginx:
restart: always
image: 18684929379/nginx
container_name: nginx_1.17_nacos
ports:
- 8189:8189
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
在同一目录下创建nginx.conf,内容如下
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
# 根据实际情况修改一下文件即可. yzb
upstream cluster{
server docker-nacos-2:8848 weight=1 max_fails=2 fail_timeout=30s;
server docker-nacos-1:8848 weight=1 max_fails=2 fail_timeout=30s;
server docker-nacos-3:8848 weight=1 max_fails=2 fail_timeout=30s;
}
server{
listen 8189;
server_name 192.168.86.63;
large_client_header_buffers 4 16k; # 读取大型客户端请求头的缓冲区的最大数量和大小
client_max_body_size 300m; #设置nginx能处理的最大请求主体大小。
client_body_buffer_size 128k; #请求主体的缓冲区大小。
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 8 32k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 64k;
location / {
proxy_pass http://cluster;
}
}
include /etc/nginx/conf.d/*.conf;
}
cd /app
#执行运行命令 -d 后台运行
docker-compose up -d
#查看是否运行成功
docker-compose ps
然后进去mysql容器运行nacos的脚本
docker exec -it mysql5.7-nacos bash
密码在docke-compose.yaml中配置了为:123456
use nacos
运行以下脚本
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/******************************************/
/* 数据库全名 = 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(50) 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(50) 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(50) 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(50) 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,
`resource` varchar(255) NOT NULL,
`action` varchar(8) NOT NULL,
UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
);
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
然后重新启动docker-compose restart
访问nginx中配置的ip:端口/nacos