一,Windows下Docker安装文档
1.前期准备工作
- 首先需要明确,在Windows下Vmware虚拟机和docker只能二选一,不能共存。
- 关于Vmware的卸载和注册表的清理
- 卸载:通过控制面板
- 注册表清理:进入注册表编辑面板,ctrl+F搜索vmware,相关的东西全干掉,一个不留
- 确保虚拟化的开启,开启需要进入BIOS
- 进入控制面板-程序-启用或关闭windows功能,把Hyper-v勾选上,启用后电脑会重启,完成后即可下载安装docker。
2.安装
- 下载链接
https://docs.docker.com/docker-for-windows/install/#download-docker-for-windows
- 如果提示是启动失败,(小米电脑直接成功了,但是华硕失败了),大概原因是因为虚拟化的原因,失败了也不要慌。按照给出的错误提示链接点击进去下载相应的虚拟化软件包安装即可。
- 后续会在文档末尾提供相关的软件包,我的电脑不是基于ARM架构的,所以需要ARM架构安装包的同学根据错误提示链接自行下载安装即可。
3.干一波
拉个nginx试试
看着没啥毛病
4.配置源
不开vpn拉镜像慢?小意思,操作一波
{
"registry-mirrors": [
"https://pb5bklzr.mirror.aliyuncs.com",
"https://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
],
"insecure-registries": [],
"debug": false,
"experimental": false,
"features": {
"buildkit": true
},
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
}
}
二,Linux下安装Docker文档
1.安装软件包
yum install -y yum-utils device-mapper-persistent-data lvm2
2.设置镜像仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.更新yum索引包
yum makecache fast
4.安装docker CE(社区版) EE 旗舰版=收费
yum -y install docker-ce
5.启动docker
systemctl start docker
systemctl enable docker.service
6.配置阿里云加速器
mkdir -p /etc/docker
vim /etc/docker/daemon.json
---------------------------
{
"registry-mirrors": ["https://dx4hocp4.mirror.aliyuncs.com"]
}
--------------------------
systemctl daemon-reload
systemctl restart docker
7.docker可视化界面
Portainer
**https://documentation.portainer.io/**
# 服务端部署
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
# 访问 9000 端口即可
#agent端部署
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent
三,使用docker快速搭建环境
1.docker安装MySQL
# 从远程拉取MySQL的镜像
docker pull mysql:5.7
# 运行拉下来的镜像
docker run -p 3306:3306 --name ershi-mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
# 已交互式的方式进入运行中的容器
docker exec -it mysql的容器ID bin/bash
#一般docker容器都是基于ubuntu系统的,因为更加轻量级,所以进入以后记得先更新源
apt update
# 安装vim,不安装也无所谓,个人强迫症
apt install vim
#编辑MySQL的配置文件
vim /etc/mysql/my.cnf
加入如下代码块
[client]
default_character_set=utf8
[mysqld]
collation_server = utf8_general_ci
character_set_server = utf8
:wq!
# 退出容器
ctrl + P + Q
# 重启MySQL容器
docker restart mysql的容器ID
连接上mysql
# 查看字符编码
SHOW VARIABLES LIKE 'character%';
# 给用户设置权限和密码
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY "root";
# 刷新
FLUSH PRIVILEGES;
over!
2.docker安装rabbitmq并安装死信队列插件
#拉取镜像
docker pull rabbitmq
#展示镜像
docker images
# 后台运行mq镜像生成实例
docker run -d -p 5672:5672 -p 15672:15672 --name myrabbitmq 镜像ID
# 查看运行中的镜像列表
docker ps
# 交互模式进入docker容器
docker exec -it 容器ID bin/bash
# 开启rabbitmq控制台插件命令
rabbitmq-plugins enable rabbitmq_management
# 进入插件目录下
cd plugins
# 下载插件到当前目录下
wget https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/v3.8.0/rabbitmq_delayed_message_exchange-3.8.0.ez
# 开启插件
rabbitmq-plugins enable rabbitmq_delayed_message_exchange
# 退出容器
ctrl + P + Q
3.docker安装redis
# 拉取镜像
docker pull redis
# 查看镜像
docker images
# 本地搞一个redis的配置文件
http://download.redis.io/redis-stable/redis.conf
# 比如说这个文件在本地的路径为 c://root/software/redis/docker/conf
# 将镜像作为容器运行,具体解释
# -v 挂载目录,规则与端口映射相同
# redis-server /etc/redis/redis.conf 以配置文件启动redis,加载容器内的conf文件,最终找到的是挂载的目录/usr/local/docker/redis.conf
docker run -itd -p 6379:6379 --name ershi-redis -v c://root/software/redis/docker/conf/redis.conf:/etc/redis/redis.conf redis redis-server /etc/redis/redis.conf
4.docker安装ElasticSearch
# 安装es
#拉取镜像
docker pull elasticsearch:7.7.0
#启动镜像
docker run --name elasticsearch -d -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -p 9200:9200 -p 9300:9300 elasticsearch:7.7.0
访问localhost:9200 出现json串表示安装成功
# 安装elasticsearch-head
#拉取镜像
docker pull mobz/elasticsearch-head:5
#创建容器
docker create --name elasticsearch-head -p 9100:9100 mobz/elasticsearch-head:5
#启动容器
docker start elasticsearch-head
or
docker start 容器id (docker ps -a 查看容器id )
# 访问localhost:9100 出现插件管理控制台 说明安装成功
尝试连接easticsearch会发现无法连接上,由于是前后端分离开发,所以会存在跨域问题,需要在服务端做CORS的配置。
# 解决办法:修改docker中elasticsearch的elasticsearch.yml文件
docker exec -it elasticsearch /bin/bash (进不去使用容器id进入)
vi config/elasticsearch.yml
# 在最下面添加2行
http.cors.enabled: true
http.cors.allow-origin: "*"
# 退出并重启
exit
docker restart 容器id
# 访问localhost:9100 可以连接成功
# bug修复 ElasticSearch-head 操作时不修改配置,默认会报 406错误码
# 进入es-haed 插件容器
docker exec -it elasticsearch-head /bin/bash
# 编辑他的前端交互js文件
vim /usr/src/app/_site/vendor.js
第6886行:把 application/x-www-form-urlencoded 改成 application/json;charset=UTF-8
第7574行:把 application/x-www-form-urlencoded 改成 application/json;charset=UTF-8
#保存退出,重启容器,成功查询到es数据
# 安装ik分词器
docker exec -it elasticsearch /bin/bash (进不去使用容器id进入)
cd /usr/share/elasticsearch/plugins
mkdir ik
cd ik
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip
#解压
unzip elasticsearch-analysis-ik-7.7.0.zip
#删除压缩包
rm -rf elasticsearch-analysis-ik-7.7.0.zip
5.docker安装nginx
docker pull nginx
docker images
docker run -itd -p 80:80 --name ershi-nginx imageID
6.docker搭建RocketMQ和控制台
#创建RocketMQ使用的共有网络,便于相互访问
docker network create rocketmq_network
#foxiswho/rocketmq 4.7.0以后不再分别创建broker及nameserver的镜像,统一使用rocketmq镜像,只是在启动命令上区分
docker pull foxiswho/rocketmq:4.8.0
#rocketmq控制台2.0.0版本,源码来自于官方仓库https://github.com/apache/rocketmq-externals#rocketmq-console
docker pull 56553655/rocketmq-console-ng:2.0.0
#启动rocketmq nameserver
docker run -d --network rocketmq_network --network-alias rmqnamesrv --name rmqnamesrv -e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" -p 9876:9876 foxiswho/rocketmq:4.8.0 sh mqnamesrv
#启动rocketmq broker
docker run -d --network rocketmq_network --network-alias rmqbroker --name rmqbroker -e "NAMESRV_ADDR=rmqnamesrv:9876" -e "JAVA_OPT_EXT=-Xms512M -Xmx512M -Xmn128m" -p 10911:10911 -p 10912:10912 -p 10909:10909 foxiswho/rocketmq:4.8.0 sh mqbroker
#启动rocketmq-console-ng
docker run -d --network rocketmq_network --network-alias rocketmq-console-ng -p 8080:8080 --name rocketmq-console-ng 56553655/rocketmq-console-ng:2.0.0
# 访问localhost:8080 成功出现控制台 over!
7.docker安装xxl-job
docker pull xuxueli/xxl-job-admin:2.2.0
docker stop xxl-job-admin && docker rm xxl-job-admin
## 执行数据库脚本,脚本在下面的代码块
docker run -e PARAMS="--spring.datasource.url=jdbc:mysql://localhost:3316/xxl_job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=root" -p 8000:8080 --name xxl-job-admin -d xuxueli/xxl-job-admin:2.2.0
#访问 localhost:8000/xxl-job-admin/ admin 123456
数据库脚本
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;
8.docker安装nacos
docker pull nacos/nacos-server
# 往数据库导入nacos脚本
# 运行容器
docker run -d -e MODE=standalone -e SPRING_DATASOURCE_PLATFORM=mysql -e MYSQL_SERVICE_HOST=192.168.1.6 -e MYSQL_SERVICE_PORT=3316 -e MYSQL_SERVICE_USER=root -e MYSQL_SERVICE_PASSWORD=root -e MYSQL_SERVICE_DB_NAME=nacos_test -p 8848:8848 --restart=always --name nacos nacos/nacos-server
数据库脚本
create database nacos_test;
use nacos_test;
CREATE TABLE `config_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'data_id',
`group_id` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`content` longtext COLLATE utf8_bin NOT NULL COMMENT 'content',
`md5` varchar(32) COLLATE utf8_bin 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 COLLATE utf8_bin COMMENT 'source user',
`src_ip` varchar(20) COLLATE utf8_bin DEFAULT NULL COMMENT 'source ip',
`app_name` varchar(128) COLLATE utf8_bin DEFAULT NULL,
`tenant_id` varchar(128) COLLATE utf8_bin DEFAULT '' COMMENT '租户字段',
`c_desc` varchar(256) COLLATE utf8_bin DEFAULT NULL,
`c_use` varchar(64) COLLATE utf8_bin DEFAULT NULL,
`effect` varchar(64) COLLATE utf8_bin DEFAULT NULL,
`type` varchar(64) COLLATE utf8_bin DEFAULT NULL,
`c_schema` text COLLATE utf8_bin,
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';
# Dump of table config_info_aggr
# ------------------------------------------------------------
CREATE TABLE `config_info_aggr` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'data_id',
`group_id` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'group_id',
`datum_id` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'datum_id',
`content` longtext COLLATE utf8_bin NOT NULL COMMENT '内容',
`gmt_modified` datetime NOT NULL COMMENT '修改时间',
`app_name` varchar(128) COLLATE utf8_bin DEFAULT NULL,
`tenant_id` varchar(128) COLLATE utf8_bin 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='增加租户字段';
# Dump of table config_info_beta
# ------------------------------------------------------------
CREATE TABLE `config_info_beta` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'data_id',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'group_id',
`app_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT 'app_name',
`content` longtext COLLATE utf8_bin NOT NULL COMMENT 'content',
`beta_ips` varchar(1024) COLLATE utf8_bin DEFAULT NULL COMMENT 'betaIps',
`md5` varchar(32) COLLATE utf8_bin 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 COLLATE utf8_bin COMMENT 'source user',
`src_ip` varchar(20) COLLATE utf8_bin DEFAULT NULL COMMENT 'source ip',
`tenant_id` varchar(128) COLLATE utf8_bin 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';
# Dump of table config_info_tag
# ------------------------------------------------------------
CREATE TABLE `config_info_tag` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'data_id',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) COLLATE utf8_bin DEFAULT '' COMMENT 'tenant_id',
`tag_id` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'tag_id',
`app_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT 'app_name',
`content` longtext COLLATE utf8_bin NOT NULL COMMENT 'content',
`md5` varchar(32) COLLATE utf8_bin 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 COLLATE utf8_bin COMMENT 'source user',
`src_ip` varchar(20) COLLATE utf8_bin 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';
# Dump of table config_tags_relation
# ------------------------------------------------------------
CREATE TABLE `config_tags_relation` (
`id` bigint(20) NOT NULL COMMENT 'id',
`tag_name` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'tag_name',
`tag_type` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT 'tag_type',
`data_id` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'data_id',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) COLLATE utf8_bin 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';
# Dump of table group_capacity
# ------------------------------------------------------------
CREATE TABLE `group_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`group_id` varchar(128) COLLATE utf8_bin 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容量信息表';
# Dump of table 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) COLLATE utf8_bin NOT NULL,
`group_id` varchar(128) COLLATE utf8_bin NOT NULL,
`app_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT 'app_name',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin DEFAULT NULL,
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`src_user` text COLLATE utf8_bin,
`src_ip` varchar(20) COLLATE utf8_bin DEFAULT NULL,
`op_type` char(10) COLLATE utf8_bin DEFAULT NULL,
`tenant_id` varchar(128) COLLATE utf8_bin 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='多租户改造';
# Dump of table permissions
# ------------------------------------------------------------
CREATE TABLE `permissions` (
`role` varchar(50) NOT NULL,
`resource` varchar(255) NOT NULL,
`action` varchar(8) NOT NULL,
UNIQUE KEY `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
# Dump of table roles
# ------------------------------------------------------------
CREATE TABLE `roles` (
`username` varchar(50) NOT NULL,
`role` varchar(50) NOT NULL,
UNIQUE KEY `idx_user_role` (`username`,`role`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
# Dump of table tenant_capacity
# ------------------------------------------------------------
CREATE TABLE `tenant_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`tenant_id` varchar(128) COLLATE utf8_bin 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='租户容量信息表';
# Dump of table tenant_info
# ------------------------------------------------------------
CREATE TABLE `tenant_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`kp` varchar(128) COLLATE utf8_bin NOT NULL COMMENT 'kp',
`tenant_id` varchar(128) COLLATE utf8_bin DEFAULT '' COMMENT 'tenant_id',
`tenant_name` varchar(128) COLLATE utf8_bin DEFAULT '' COMMENT 'tenant_name',
`tenant_desc` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT 'tenant_desc',
`create_source` varchar(32) COLLATE utf8_bin 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';
# Dump of table users
# ------------------------------------------------------------
CREATE TABLE `users` (
`username` varchar(50) NOT NULL,
`password` varchar(500) NOT NULL,
`enabled` tinyint(1) NOT NULL,
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `users` (`username`, `password`, `enabled`)
VALUES
('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', 1);
9.docker安装sentinel
docker pull bladex/sentinel-dashboard
docker run --name sentinel -d -p 8858:8858 -d bladex/sentinel-dashboard
10.docker安装zipkin
docker pull openzipkin/zipkin
docker run -d --restart always -p 9411:9411 --name zipkin openzipkin/zipkin
11.docker安装mongo
docker pull mongo:latest
docker run -itd --name mongo -p 27017:27017 mongo
12.docker安装zookeeper
docker pull zookeeper
docker run --privileged=true -d --name zookeeper --publish 2181:2181 -d zookeeper:latest
13.docker安装seata
docker pull seata
docker run -d --name seata-server -p 8091:8091 seataio/seata-server:1.2.0
docker exec -it seataio/seata-server:1.2.0 sh
# 创建数据库
vim file.conf 修改模式为db 修改数据库连接信息
vim registry.conf 将seata 注册进nacos中
docker restart seataio/seata-server:1.2.0 sh
docker logs -f seataio/seata-server:1.2.0 sh
数据库脚本
create database seata;
use seata;
CREATE TABLE IF NOT EXISTS `global_table`
(
`xid` VARCHAR(128) NOT NULL,
`transaction_id` BIGINT,
`status` TINYINT NOT NULL,
`application_id` VARCHAR(32),
`transaction_service_group` VARCHAR(32),
`transaction_name` VARCHAR(128),
`timeout` INT,
`begin_time` BIGINT,
`application_data` VARCHAR(2000),
`gmt_create` DATETIME,
`gmt_modified` DATETIME,
PRIMARY KEY (`xid`),
KEY `idx_gmt_modified_status` (`gmt_modified`, `status`),
KEY `idx_transaction_id` (`transaction_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS `branch_table`
(
`branch_id` BIGINT NOT NULL,
`xid` VARCHAR(128) NOT NULL,
`transaction_id` BIGINT,
`resource_group_id` VARCHAR(32),
`resource_id` VARCHAR(256),
`branch_type` VARCHAR(8),
`status` TINYINT,
`client_id` VARCHAR(64),
`application_data` VARCHAR(2000),
`gmt_create` DATETIME(6),
`gmt_modified` DATETIME(6),
PRIMARY KEY (`branch_id`),
KEY `idx_xid` (`xid`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- the table to store lock data
CREATE TABLE IF NOT EXISTS `lock_table`
(
`row_key` VARCHAR(128) NOT NULL,
`xid` VARCHAR(96),
`transaction_id` BIGINT,
`branch_id` BIGINT NOT NULL,
`resource_id` VARCHAR(256),
`table_name` VARCHAR(32),
`pk` VARCHAR(36),
`gmt_create` DATETIME,
`gmt_modified` DATETIME,
PRIMARY KEY (`row_key`),
KEY `idx_branch_id` (`branch_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
14.docker安装Apache-abTest
docker run --rm russmckendrick/ab -v -k -n 10000 -c 30 http://10.225.20.87:9006/order-server/order/add/1/1
请求数 和 并发数
ab -n1000 -c100 http://10.225.20.87:9006/order-server/order/add/1/1