首页 > 基础资料 博客日记
Docker构建Java服务 docker-compose部署微服务
2024-08-21 17:00:06基础资料围观143次
文章Docker构建Java服务 docker-compose部署微服务分享给大家,欢迎收藏Java资料网,专注分享技术知识
目录
1. 安装Docker前置准备 设置Docker开机自启动 配置Docker阿里云镜像加速 安装Docker-compose
4. 创建数据映射容器挂载目录 ,以下是nacos xxl-job-admin sql脚本文件
1. 安装Docker前置准备 设置Docker开机自启动 配置Docker阿里云镜像加速 安装DockerCompose
[root@docker-compose ~]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@docker-compose ~]# mv docker-ce.repo /etc/yum.repos.d/
[root@docker-compose ~]# yum -y install docker-ce
[root@docker-compose ~]# systemctl start docker-ce && systemctl enable docker
[root@docker-compose ~]# docker -v
配置镜像源 Docker阿里云镜像加速
[root@docker-compose ~]# vi /etc/docker/daemon.json
{ "registry-mirrors": ["https://cq20bk8v.mirror.aliyuncs.com"] }
Docker-compose安装
#curl -L https://get.daocloud.io/docker/compose/releases/download/v2.5.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
#######修改docker 数据目录########
查看存储路径
[root@docker-server ~]# docker info | grep Root
Docker Root Dir: /var/lib/docker
首先停止docker
[root@docker-server ~]# systemctl stop docker
修改默认存储位置:
在dockerd的启动命令后面追加--data-root参数指定新的位置
[root@docker-server ~]# mkdir /data/
[root@docker-server ~]# cp -r /var/lib/docker /data/
[root@docker-server ~]# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --data-root=/data/docker
[root@docker-server ~]# systemctl daemon-reload
[root@docker-server ~]# systemctl restart docker
查看是否生效:
[root@docker-server ~]# docker info | grep Root
Docker Root Dir: /data/docker
2、镜像拉取
[root@docker-server ~]# docker pull mysql:8.0.33
[root@docker-server ~]# docker pull minio/minio:RELEASE.2022-02-16T00-35-27Z
[root@docker-server ~]# docker pull xuxueli/xxl-job-admin:2.3.1
[root@docker-server ~]# docker pull nacos/nacos-server:2.0.3
[root@docker-server ~]# docker pull rabbitmq:3.8.3-management
[root@docker-server ~]# docker pull tdengine/tdengine:latest
[root@docker-server ~]# docker pull nginx:1.18.0
[root@docker-server ~]# docker pull redis:5.0.10
[root@docker-server ~]# docker pull openjdk:8
3、Java 项目制作Dockerfile
[root@docker-server ~]#cat Nameidockerfile
FROM openjdk:8
MAINTAINER Namei <202023772@qq.com>
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
VOLUME /tmp
ADD Namei-1.0.0.jar app.jar
ADD equipment-cloud-financing /opt/data/equipment-cloud-financing
CMD ["java","-jar","/app.jar"]
EXPOSE 8193 9992
[root@docker-server ~]# docker build -t Namei:1.0 .
[root@localhost dockerfile]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Namei 1.0 e0316e2ed3a5 About a minute ago 409MB
[root@docker-server ~]# pwd
/opt/application
4、创建docker-comepose.yaml文件
cat docker-comepose.yaml
version: '3'
networks:
# compose-network:
# external: # 指定network,network需存在
# name: docker-compose
compose-network:
driver: bridge
ipam: #自定义IPAM配置
config:
- subnet: 172.28.0.0/16 # version 3 不支持 gateway 2.3支持
driver: default
services:
Namei:
build:
context: /opt/application ### dockerfile 路径
dockerfile: Nameidockfile ### dockerfile 名称
image: Namei:1.0.0 # 如果同时指定image和build两个标签,那么Compose会构建镜像并且把镜像命名为image值指定的名字。
restart: always # 容器退出时,重启容器
hostname: Namei #容器的hostname名称
container_name: Namei # 指定固定的容器名,如果固定的话,就不能通过scale横向扩展,如果横向扩展需要删除此项,
depends_on: #依赖于哪两个容器,解决容器启动的先后顺序问题。
- mysql
- redis
- minio
- rabbitmq
- nacos
volumes:
- "/data/logs:/home/logs"
- "/etc/timezone:/etc/timezone"
- "/etc/localtime:/etc/localtime"
- "/opt/application/images:/opt/application/images"
command: java -Dspring.profiles.active=prd -Dqueue.node=1 -Xms1024m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -jar /app.jar
networks:
compose-network: #指定network
ipv4_address: 172.28.0.11
redis:
image: redis:5.0.10
restart: always
hostname: app-redis
container_name: redis
ports:
- 6379:6379
command: redis-server --requirepass 12345678 --appendonly yes
networks:
compose-network: #指定network
ipv4_address: 172.28.0.12
mysql:
image: mysql:8.0.33
restart: always
hostname: app-mysql
container_name: mysql
ports:
- 3306:3306
volumes:
- "/disk01/application-data/mysql/conf.d/:/etc/mysql/conf.d"
- "/disk01/application-data/mysql/log:/var/log/mysql"
- "/disk01/application-data/mysql/data:/var/lib/mysql"
environment:
- "MYSQL_ROOT_PASSWORD=12345678"
networks:
compose-network: #指定network
ipv4_address: 172.28.0.13
minio:
image: minio/minio:RELEASE.2022-02-16T00-35-27Z
restart: always
hostname: app-minio
container_name: minio
ports:
- 9000:9000
- 9001:9001
volumes:
- "/disk01/application-data/minio/data:/data"
- "/disk01/application-data/minio/config:/root/.minio"
environment:
- "MINIO_ACCESS_KEY=qeubAYSuoZG5p"
- "MINIO_SECRET_KEY=nGhuv1d7y"
command: server /data --console-address ":9001"
networks:
compose-network: #指定network
ipv4_address: 172.28.0.14
taos:
restart: always
image: tdengine:2.6.04
hostname: taos
container_name: taos
privileged: true
ports:
- 6020:6020
- 6030-6042:6030-6042/tcp
- 6030-6042:6030-6042/udp
volumes:
- /etc/localtime:/etc/localtime:ro
- /disk01/application-data/taos/data:/var/lib/taos
- /disk01/application-data/taos/etc:/etc/taos
- /disk01/application-data/taos/log:/var/log/taos
networks:
compose-network: #指定network
ipv4_address: 172.28.0.15
xxl-job-admin:
restart: always
image: xuxueli/xxl-job-admin:2.3.1
# 容器名称
container_name: xxl-job-admin
volumes:
# 日志目录映射到主机目录
- /disk01/application-data/xxl-job-admin/logs:/data/applogs
ports:
# 端口映射
- "8800:8800"
environment:
# 设置启动参数
PARAMS: '
--server.port=8800
--server.servlet.context-path=/xxl-job-admin
--spring.datasource.url=jdbc:mysql://192.168.0.207:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
--spring.datasource.username=root
--spring.datasource.password=12345678
--spring.mail.host=smtp.qq.com
--spring.mail.port=465
--spring.mail.username=test_mail@qq.com
--spring.mail.from=test_mail@qq.com
--spring.mail.password=password123456
--spring.mail.properties.mail.smtp.starttls.enable=true
--spring.mail.properties.mail.smtp.starttls.required=true
--xxl.job.accessToken=Lpoms_xxljob_default_token'
networks:
compose-network: #指定network
ipv4_address: 172.28.0.16
nacos:
image: nacos/nacos-server:2.0.3
container_name: nacos
restart: always
volumes:
# 日志挂载
- /nacos/logs:/home/nacos/logs
# 配置文件挂载
- /nacos/conf/application.properties:/home/nacos/conf/application.properties
ports:
- "8848:8848"
environment:
- PREFER_HOST_MODE=ip
- MODE=standalone
- SPRING_DATASOURCE_PLATFORM=mysql
- MYSQL_MASTER_SERVICE_HOST=192.168.0.207
- MYSQL_MASTER_SERVICE_PORT=3306
- MYSQL_MASTER_SERVICE_USER=root
- MYSQL_MASTER_SERVICE_PASSWORD=12345678
- JVM_XMS=512m
- JVM_MMS=512m
networks:
compose-network: #指定network
ipv4_address: 172.28.0.17
rabbitmq:
image: rabbitmq:3.8.3-management
restart: always
hostname: app-rabbitmq
privileged: true
container_name: rabbitmq
ports:
- 15672:15672
- 5672:5672
volumes:
- "/data/rabbitmq/data:/var/lib/rabbitmq"
- "/data/rabbitmq/conf:/etc/rabbitmq"
- "/data/rabbitmq/log:/var/log/rabbitmq"
environment:
- "RABBITMQ_DEFAULT_VHOST=my_vhost"
- "RABBITMQ_DEFAULT_USER=admin"
- "RABBITMQ_DEFAULT_PASS=12345678"
networks:
compose-network: #指定network
ipv4_address: 172.28.0.18
nginx:
image: nginx:1.18.0
restart: always
hostname: app-nginx
container_name: nginx
ports:
- 80:80
volumes: # 挂载一个目录或者一个已存在的数据卷容器
- "/data/nginx/www:/usr/share/nginx/html"
- "/data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf"
- "/data/nginx/logs:/var/log/nginx"
networks:
compose-network: #指定network
ipv4_address: 172.28.0.19
5.创建数据映射容器挂载目录 ,以下是nacos xxl-job-admin sql脚本文件
导入mysql 容器内 source 创建。
[root@localhost ~]# cat xxl-job.sql
# XXL-JOB v2.3.1
# Copyright (c) 2015-present, xuxueli.
CREATE database if NOT EXISTS `xxl_job` default character set utf8mb4 collate utf8mb4_unicode_ci;
use `xxl_job`;
SET NAMES utf8mb4;
CREATE TABLE `xxl_job_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_group` int(11) NOT NULL COMMENT '执行器主键ID',
`job_desc` varchar(255) NOT NULL,
`add_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`author` varchar(64) DEFAULT NULL COMMENT '作者',
`alarm_email` varchar(255) DEFAULT NULL COMMENT '报警邮件',
`schedule_type` varchar(50) NOT NULL DEFAULT 'NONE' COMMENT '调度类型',
`schedule_conf` varchar(128) DEFAULT NULL COMMENT '调度配置,值含义取决于调度类型',
`misfire_strategy` varchar(50) NOT NULL DEFAULT 'DO_NOTHING' COMMENT '调度过期策略',
`executor_route_strategy` varchar(50) DEFAULT NULL COMMENT '执行器路由策略',
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
`executor_block_strategy` varchar(50) DEFAULT NULL COMMENT '阻塞处理策略',
`executor_timeout` int(11) NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒',
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
`glue_type` varchar(50) NOT NULL COMMENT 'GLUE类型',
`glue_source` mediumtext COMMENT 'GLUE源代码',
`glue_remark` varchar(128) DEFAULT NULL COMMENT 'GLUE备注',
`glue_updatetime` datetime DEFAULT NULL COMMENT 'GLUE更新时间',
`child_jobid` varchar(255) DEFAULT NULL COMMENT '子任务ID,多个逗号分隔',
`trigger_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '调度状态:0-停止,1-运行',
`trigger_last_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '上次调度时间',
`trigger_next_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '下次调度时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`job_group` int(11) NOT NULL COMMENT '执行器主键ID',
`job_id` int(11) NOT NULL COMMENT '任务,主键ID',
`executor_address` varchar(255) DEFAULT NULL COMMENT '执行器地址,本次执行的地址',
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
`executor_sharding_param` varchar(20) DEFAULT NULL COMMENT '执行器任务分片参数,格式如 1/2',
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
`trigger_time` datetime DEFAULT NULL COMMENT '调度-时间',
`trigger_code` int(11) NOT NULL COMMENT '调度-结果',
`trigger_msg` text COMMENT '调度-日志',
`handle_time` datetime DEFAULT NULL COMMENT '执行-时间',
`handle_code` int(11) NOT NULL COMMENT '执行-状态',
`handle_msg` text COMMENT '执行-日志',
`alarm_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '告警状态:0-默认、1-无需告警、2-告警成功、3-告警失败',
PRIMARY KEY (`id`),
KEY `I_trigger_time` (`trigger_time`),
KEY `I_handle_code` (`handle_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_log_report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`trigger_day` datetime DEFAULT NULL COMMENT '调度-时间',
`running_count` int(11) NOT NULL DEFAULT '0' COMMENT '运行中-日志数量',
`suc_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量',
`fail_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `i_trigger_day` (`trigger_day`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_logglue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_id` int(11) NOT NULL COMMENT '任务,主键ID',
`glue_type` varchar(50) DEFAULT NULL COMMENT 'GLUE类型',
`glue_source` mediumtext COMMENT 'GLUE源代码',
`glue_remark` varchar(128) NOT NULL COMMENT 'GLUE备注',
`add_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_registry` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`registry_group` varchar(50) NOT NULL,
`registry_key` varchar(255) NOT NULL,
`registry_value` varchar(255) NOT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `i_g_k_v` (`registry_group`,`registry_key`,`registry_value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`app_name` varchar(64) NOT NULL COMMENT '执行器AppName',
`title` varchar(12) NOT NULL COMMENT '执行器名称',
`address_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '执行器地址类型:0=自动注册、1=手动录入',
`address_list` text COMMENT '执行器地址列表,多地址逗号分隔',
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL COMMENT '账号',
`password` varchar(50) NOT NULL COMMENT '密码',
`role` tinyint(4) NOT NULL COMMENT '角色:0-普通用户、1-管理员',
`permission` varchar(255) DEFAULT NULL COMMENT '权限:执行器ID列表,多个逗号分割',
PRIMARY KEY (`id`),
UNIQUE KEY `i_username` (`username`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_lock` (
`lock_name` varchar(50) NOT NULL COMMENT '锁名称',
PRIMARY KEY (`lock_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `xxl_job_group`(`id`, `app_name`, `title`, `address_type`, `address_list`, `update_time`) VALUES (1, 'xxl-job-executor-sample', '示例执行器', 0, NULL, '2018-11-03 22:21:31' );
INSERT INTO `xxl_job_info`(`id`, `job_group`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`, `schedule_type`, `schedule_conf`, `misfire_strategy`, `executor_route_strategy`, `executor_handler`, `executor_param`, `executor_block_strategy`, `executor_timeout`, `executor_fail_retry_count`, `glue_type`, `glue_source`, `glue_remark`, `glue_updatetime`, `child_jobid`) VALUES (1, 1, '测试任务1', '2018-11-03 22:21:31', '2018-11-03 22:21:31', 'XXL', '', 'CRON', '0 0 0 * * ? *', 'DO_NOTHING', 'FIRST', 'demoJobHandler', '', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'GLUE代码初始化', '2018-11-03 22:21:31', '');
INSERT INTO `xxl_job_user`(`id`, `username`, `password`, `role`, `permission`) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, NULL);
INSERT INTO `xxl_job_lock` ( `lock_name`) VALUES ( 'schedule_lock');
commit;
[root@localhost ~]# docker cp ./xxl-job.sql mysql-id:/home/
[root@localhost ~]# docker exec -it mysqlid bash
[root@localhost ~]# mysql -uroot -p'123456'
mysql> source /home/xxl-job.sql
####xxl-job sql语句
调度中心访问地址:http://localhost:8080/xxl-job-admin (该地址执行器将会使用到,作为回调地址)
默认登录账号 “admin/123456”, 登录后运行界面如下图所示。
[root@localhost ~]# cat /home/nacos.sql
/******************************************/
/* 数据库全名 = 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 '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' 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,
`encrypted_data_key` varchar(255) DEFAULT NULL,
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 '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' 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 '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' 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 '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' 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 '2010-05-05 00:00:00',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
`src_user` text,
`src_ip` varchar(20) DEFAULT NULL,
`op_type` char(10) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
`encrypted_data_key` varchar(255) DEFAULT NULL,
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 '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' 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,
constraint uk_username_role UNIQUE (username,role)
);
CREATE TABLE permissions (
role varchar(50) NOT NULL,
resource varchar(512) NOT NULL,
action varchar(8) NOT NULL,
constraint uk_role_permission UNIQUE (role,resource,action)
);
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
[root@localhost ~]# docker cp ./nacos.sql mysql-id:/home/
[root@localhost ~]# docker exec -it mysqlid bash
[root@localhost ~]# mysql -uroot -p'123456'
mysql> create database nacos
mysql> use nacos
mysql> source /home/nacos.sql
6.docker-comepose 部署
[root@localhost ~]# docker-comepose -f docker-comepose.yaml up -d
7.docker-compose 基本命令
docker-compose stop 容器名称 停止后端jar运行
docker-compose rm 容器名称 删除容器
docker rmi 镜像id 删除镜像
docker-compose -f docker-comepose.yaml up -d 后台运行
文章来源:https://blog.csdn.net/qyf199817/article/details/135669301
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
标签: