chore(deploy): Add high availability cluster deployment configuration
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# ============================================================
|
||||
# Node-01 环境变量配置 (192.168.1.101)
|
||||
# 主节点: MySQL Master, Redis Master, Nacos, NameServer, MinIO, 微服务
|
||||
# ============================================================
|
||||
|
||||
# 节点信息
|
||||
NODE_ID=1
|
||||
HOST_IP=192.168.1.101
|
||||
HOSTNAME=node-01
|
||||
|
||||
# 集群节点列表
|
||||
NACOS_SERVERS=192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848
|
||||
NAMESRV_ADDR=192.168.1.101:9876;192.168.1.102:9876;192.168.1.103:9876
|
||||
|
||||
# MySQL配置 (主节点)
|
||||
MYSQL_SERVER_ID=1
|
||||
MYSQL_HOST=mysql
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_ROOT_PASSWORD=root123456
|
||||
MYSQL_DATABASE=video_platform
|
||||
MYSQL_USER=video
|
||||
MYSQL_PASSWORD=video123
|
||||
|
||||
# Redis配置
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=redis_HA_Cluster_2024
|
||||
REDIS_MASTER_HOST=192.168.1.101
|
||||
REDIS_MASTER_PORT=6379
|
||||
|
||||
# Nacos配置
|
||||
NACOS_HOST=nacos
|
||||
NACOS_PORT=8848
|
||||
NACOS_NAMESPACE=public
|
||||
NACOS_GROUP=DEFAULT_GROUP
|
||||
|
||||
# Sentinel配置
|
||||
SENTINEL_HOST=sentinel
|
||||
SENTINEL_PORT=8080
|
||||
|
||||
# MinIO配置
|
||||
MINIO_HOST=minio
|
||||
MINIO_PORT=9000
|
||||
MINIO_EXTERNAL_PORT=9100
|
||||
MINIO_ACCESS_KEY=minioadmin
|
||||
MINIO_SECRET_KEY=minioadmin123
|
||||
MINIO_BUCKET=video-platform
|
||||
|
||||
# RocketMQ配置
|
||||
ROCKETMQ_HOST=rmqnamesrv
|
||||
ROCKETMQ_PORT=9876
|
||||
|
||||
# Java配置
|
||||
JAVA_OPTS=-Xms256m -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m
|
||||
|
||||
# 本节点部署的服务
|
||||
DEPLOY_SERVICES=mysql,redis,redis-sentinel,nacos,rmqnamesrv,minio,sentinel,video-gateway,video-auth,video-user,video-content,video-comment,video-recommend,video-admin,nginx
|
||||
@@ -0,0 +1,58 @@
|
||||
# ============================================================
|
||||
# Node-02 环境变量配置 (192.168.1.102)
|
||||
# 从节点: MySQL Slave, Redis Slave, Nacos, NameServer, Broker-A, MinIO, 微服务
|
||||
# ============================================================
|
||||
|
||||
# 节点信息
|
||||
NODE_ID=2
|
||||
HOST_IP=192.168.1.102
|
||||
HOSTNAME=node-02
|
||||
|
||||
# 集群节点列表
|
||||
NACOS_SERVERS=192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848
|
||||
NAMESRV_ADDR=192.168.1.101:9876;192.168.1.102:9876;192.168.1.103:9876
|
||||
|
||||
# MySQL配置 (从节点)
|
||||
MYSQL_SERVER_ID=2
|
||||
MYSQL_HOST=mysql
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_ROOT_PASSWORD=root123456
|
||||
MYSQL_DATABASE=video_platform
|
||||
MYSQL_USER=video
|
||||
MYSQL_PASSWORD=video123
|
||||
|
||||
# Redis配置
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=redis_HA_Cluster_2024
|
||||
REDIS_MASTER_HOST=192.168.1.101
|
||||
REDIS_MASTER_PORT=6379
|
||||
|
||||
# Nacos配置
|
||||
NACOS_HOST=nacos
|
||||
NACOS_PORT=8848
|
||||
NACOS_NAMESPACE=public
|
||||
NACOS_GROUP=DEFAULT_GROUP
|
||||
|
||||
# Sentinel配置
|
||||
SENTINEL_HOST=sentinel
|
||||
SENTINEL_PORT=8080
|
||||
|
||||
# MinIO配置
|
||||
MINIO_HOST=minio
|
||||
MINIO_PORT=9000
|
||||
MINIO_EXTERNAL_PORT=9100
|
||||
MINIO_ACCESS_KEY=minioadmin
|
||||
MINIO_SECRET_KEY=minioadmin123
|
||||
MINIO_BUCKET=video-platform
|
||||
|
||||
# RocketMQ配置 (Broker-A)
|
||||
ROCKETMQ_HOST=rmqnamesrv
|
||||
ROCKETMQ_PORT=9876
|
||||
BROKER_NAME=broker-a
|
||||
|
||||
# Java配置
|
||||
JAVA_OPTS=-Xms256m -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m
|
||||
|
||||
# 本节点部署的服务
|
||||
DEPLOY_SERVICES=mysql,redis,redis-sentinel,nacos,rmqnamesrv,rmqbroker,minio,sentinel,video-gateway,video-auth,video-user,video-content,video-comment,video-recommend,video-admin
|
||||
@@ -0,0 +1,59 @@
|
||||
# ============================================================
|
||||
# Node-03 环境变量配置 (192.168.1.103)
|
||||
# 从节点 - MySQL Slave, Redis Slave, Nacos, NameServer, Broker-B, MinIO
|
||||
# ============================================================
|
||||
|
||||
# 节点信息
|
||||
NODE_ID=3
|
||||
HOST_IP=192.168.1.103
|
||||
HOSTNAME=node-03
|
||||
|
||||
# 集群节点列表
|
||||
NACOS_SERVERS=192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848
|
||||
NAMESRV_ADDR=192.168.1.101:9876;192.168.1.102:9876;192.168.1.103:9876
|
||||
|
||||
# MySQL配置 (从节点)
|
||||
MYSQL_SERVER_ID=3
|
||||
MYSQL_HOST=mysql
|
||||
MYSQL_PORT=3306
|
||||
MYSQL_ROOT_PASSWORD=root123456
|
||||
MYSQL_DATABASE=video_platform
|
||||
MYSQL_USER=video
|
||||
MYSQL_PASSWORD=video123
|
||||
|
||||
# Redis配置
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=redis_HA_Cluster_2024
|
||||
REDIS_MASTER_HOST=192.168.1.101
|
||||
REDIS_MASTER_PORT=6379
|
||||
|
||||
# Nacos配置
|
||||
NACOS_HOST=nacos
|
||||
NACOS_PORT=8848
|
||||
NACOS_NAMESPACE=public
|
||||
NACOS_GROUP=DEFAULT_GROUP
|
||||
|
||||
# Sentinel配置
|
||||
SENTINEL_HOST=sentinel
|
||||
SENTINEL_PORT=8080
|
||||
|
||||
# MinIO配置
|
||||
MINIO_HOST=minio
|
||||
MINIO_PORT=9000
|
||||
MINIO_ACCESS_KEY=minioadmin
|
||||
MINIO_SECRET_KEY=minioadmin123
|
||||
MINIO_BUCKET=video-platform
|
||||
# MinIO分布式节点
|
||||
MINIO_ENDPOINTS=http://192.168.1.101:9000,http://192.168.1.102:9000,http://192.168.1.103:9000
|
||||
|
||||
# RocketMQ配置 (Broker-B)
|
||||
ROCKETMQ_HOST=rmqnamesrv
|
||||
ROCKETMQ_PORT=9876
|
||||
BROKER_NAME=broker-b
|
||||
|
||||
# Java配置
|
||||
JAVA_OPTS=-Xms256m -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m
|
||||
|
||||
# 本节点部署的服务
|
||||
DEPLOY_SERVICES=mysql,redis,redis-sentinel,nacos,rmqnamesrv,rmqbroker,minio,sentinel
|
||||
@@ -0,0 +1,71 @@
|
||||
# MySQL 主节点配置 (Node-01)
|
||||
# GTID 主从复制
|
||||
|
||||
[mysqld]
|
||||
# 基础配置
|
||||
user = mysql
|
||||
port = 3306
|
||||
bind-address = 0.0.0.0
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
default-authentication-plugin = mysql_native_password
|
||||
|
||||
# 连接配置
|
||||
max_connections = 500
|
||||
max_connect_errors = 100
|
||||
wait_timeout = 28800
|
||||
interactive_timeout = 28800
|
||||
connect_timeout = 10
|
||||
|
||||
# 缓冲配置 (8GB内存建议)
|
||||
innodb_buffer_pool_size = 2G
|
||||
innodb_buffer_pool_instances = 4
|
||||
innodb_log_buffer_size = 64M
|
||||
innodb_log_file_size = 512M
|
||||
innodb_flush_log_at_trx_commit = 1
|
||||
innodb_flush_method = O_DIRECT
|
||||
|
||||
# 日志配置
|
||||
log-error = /var/lib/mysql/mysql-error.log
|
||||
slow_query_log = 1
|
||||
slow_query_log_file = /var/lib/mysql/mysql-slow.log
|
||||
long_query_time = 2
|
||||
log_queries_not_using_indexes = 0
|
||||
|
||||
# 临时目录
|
||||
tmpdir = /tmp
|
||||
|
||||
# 二进制日志配置 (主节点)
|
||||
server-id = 1
|
||||
log-bin = mysql-bin
|
||||
binlog_format = ROW
|
||||
binlog_row_image = FULL
|
||||
binlog_cache_size = 1M
|
||||
max_binlog_size = 500M
|
||||
expire_logs_days = 7
|
||||
sync_binlog = 1
|
||||
|
||||
# GTID 配置
|
||||
gtid-mode = ON
|
||||
enforce-gtid-consistency = ON
|
||||
log-slave-updates = ON
|
||||
|
||||
# 复制配置
|
||||
binlog-do-db = video_auth
|
||||
binlog-do-db = video_user
|
||||
binlog-do-db = video_content
|
||||
binlog-do-db = video_comment
|
||||
binlog-do-db = video_recommend
|
||||
binlog-do-db = video_admin
|
||||
binlog-do-db = nacos_config
|
||||
|
||||
# 安全配置
|
||||
skip-name-resolve
|
||||
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
prompt = '\u@\h [\d]> '
|
||||
|
||||
[client]
|
||||
default-character-set = utf8mb4
|
||||
@@ -0,0 +1,61 @@
|
||||
# MySQL 高可用配置
|
||||
# 从节点配置 (Node-02, Node-03)
|
||||
# 注意: 每个从节点需要设置不同的 server-id
|
||||
|
||||
[mysqld]
|
||||
# 基础配置
|
||||
user = mysql
|
||||
port = 3306
|
||||
bind-address = 0.0.0.0
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
default-authentication-plugin = mysql_native_password
|
||||
|
||||
# 连接配置
|
||||
max_connections = 500
|
||||
max_connect_errors = 100
|
||||
wait_timeout = 28800
|
||||
interactive_timeout = 28800
|
||||
|
||||
# 缓冲配置
|
||||
innodb_buffer_pool_size = 1G
|
||||
innodb_buffer_pool_instances = 4
|
||||
innodb_log_buffer_size = 64M
|
||||
innodb_log_file_size = 512M
|
||||
|
||||
# 日志配置
|
||||
log-error = /var/lib/mysql/mysql-error.log
|
||||
slow_query_log = 1
|
||||
slow_query_log_file = /var/lib/mysql/mysql-slow.log
|
||||
long_query_time = 2
|
||||
|
||||
# 主从复制配置 - 从节点
|
||||
# server-id 在docker-compose中通过环境变量设置
|
||||
# server-id = 2 # Node-02
|
||||
# server-id = 3 # Node-03
|
||||
log-bin = mysql-bin
|
||||
binlog_format = ROW
|
||||
binlog_row_image = FULL
|
||||
relay-log = relay-bin
|
||||
relay-log-index = relay-bin.index
|
||||
read_only = ON
|
||||
super_read_only = ON
|
||||
|
||||
# GTID配置
|
||||
gtid-mode = ON
|
||||
enforce-gtid-consistency = ON
|
||||
|
||||
# 从节点并行复制
|
||||
slave_parallel_type = LOGICAL_CLOCK
|
||||
slave_parallel_workers = 4
|
||||
slave_preserve_commit_order = ON
|
||||
|
||||
# 半同步复制 (可选)
|
||||
# plugin-load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
|
||||
# rpl_semi_sync_slave_enabled = 1
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[client]
|
||||
default-character-set = utf8mb4
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/******************************************/
|
||||
/* 表名称 = 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(128) DEFAULT NULL COMMENT 'group_id',
|
||||
`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 COMMENT 'app_name',
|
||||
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||
`c_desc` varchar(256) DEFAULT NULL COMMENT 'configuration description',
|
||||
`c_use` varchar(64) DEFAULT NULL COMMENT 'configuration usage',
|
||||
`effect` varchar(64) DEFAULT NULL COMMENT '配置生效的描述',
|
||||
`type` varchar(64) DEFAULT NULL COMMENT '配置的类型',
|
||||
`c_schema` text COMMENT '配置的模式',
|
||||
`encrypted_data_key` varchar(1024) NOT NULL DEFAULT '' COMMENT '密钥',
|
||||
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';
|
||||
|
||||
/******************************************/
|
||||
/* 表名称 = config_info since 2.5.0 */
|
||||
/******************************************/
|
||||
CREATE TABLE `config_info_gray` (
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
|
||||
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
|
||||
`content` longtext NOT NULL COMMENT 'content',
|
||||
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
|
||||
`src_user` text COMMENT 'src_user',
|
||||
`src_ip` varchar(100) DEFAULT NULL COMMENT 'src_ip',
|
||||
`gmt_create` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'gmt_create',
|
||||
`gmt_modified` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'gmt_modified',
|
||||
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
|
||||
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
|
||||
`gray_name` varchar(128) NOT NULL COMMENT 'gray_name',
|
||||
`gray_rule` text NOT NULL COMMENT 'gray_rule',
|
||||
`encrypted_data_key` varchar(256) NOT NULL DEFAULT '' COMMENT 'encrypted_data_key',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_configinfogray_datagrouptenantgray` (`data_id`,`group_id`,`tenant_id`,`gray_name`),
|
||||
KEY `idx_dataid_gmt_modified` (`data_id`,`gmt_modified`),
|
||||
KEY `idx_gmt_modified` (`gmt_modified`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='config_info_gray';
|
||||
|
||||
/******************************************/
|
||||
/* 表名称 = 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 COMMENT 'nid, 自增长标识',
|
||||
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';
|
||||
|
||||
/******************************************/
|
||||
/* 表名称 = 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容量信息表';
|
||||
|
||||
/******************************************/
|
||||
/* 表名称 = his_config_info */
|
||||
/******************************************/
|
||||
CREATE TABLE `his_config_info` (
|
||||
`id` bigint(20) unsigned NOT NULL COMMENT 'id',
|
||||
`nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'nid, 自增标识',
|
||||
`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',
|
||||
`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',
|
||||
`op_type` char(10) DEFAULT NULL COMMENT 'operation type',
|
||||
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
|
||||
`encrypted_data_key` varchar(1024) NOT NULL DEFAULT '' COMMENT '密钥',
|
||||
`publish_type` varchar(50) DEFAULT 'formal' COMMENT 'publish type gray or formal',
|
||||
`gray_name` varchar(50) DEFAULT NULL COMMENT 'gray name',
|
||||
`ext_info` longtext DEFAULT NULL COMMENT 'ext info',
|
||||
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='多租户改造';
|
||||
|
||||
|
||||
/******************************************/
|
||||
/* 表名称 = 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 COMMENT 'username',
|
||||
`password` varchar(500) NOT NULL COMMENT 'password',
|
||||
`enabled` boolean NOT NULL COMMENT 'enabled'
|
||||
);
|
||||
|
||||
CREATE TABLE `roles` (
|
||||
`username` varchar(50) NOT NULL COMMENT 'username',
|
||||
`role` varchar(50) NOT NULL COMMENT 'role',
|
||||
UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
|
||||
);
|
||||
|
||||
CREATE TABLE `permissions` (
|
||||
`role` varchar(50) NOT NULL COMMENT 'role',
|
||||
`resource` varchar(128) NOT NULL COMMENT 'resource',
|
||||
`action` varchar(8) NOT NULL COMMENT 'action',
|
||||
UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
|
||||
);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# Nginx Upstream 配置
|
||||
# 高可用负载均衡
|
||||
|
||||
# API网关集群
|
||||
upstream gateway_cluster {
|
||||
# 负载均衡策略: 轮询 (默认)
|
||||
# 其他选项: ip_hash, least_conn, hash $request_uri
|
||||
|
||||
least_conn; # 最少连接数策略
|
||||
|
||||
server 192.168.1.101:9000 weight=1 max_fails=3 fail_timeout=30s;
|
||||
server 192.168.1.102:9000 weight=1 max_fails=3 fail_timeout=30s backup;
|
||||
|
||||
# 健康检查
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
# Nacos集群
|
||||
upstream nacos_cluster {
|
||||
server 192.168.1.101:8848 weight=1;
|
||||
server 192.168.1.102:8848 weight=1;
|
||||
server 192.168.1.103:8848 weight=1;
|
||||
|
||||
keepalive 16;
|
||||
}
|
||||
|
||||
# Sentinel集群
|
||||
upstream sentinel_cluster {
|
||||
server 192.168.1.101:8880 weight=1;
|
||||
server 192.168.1.102:8880 weight=1;
|
||||
server 192.168.1.103:8880 weight=1;
|
||||
|
||||
keepalive 16;
|
||||
}
|
||||
|
||||
# MinIO API集群 (统一使用9100端口)
|
||||
upstream minio_cluster {
|
||||
server 192.168.1.101:9100 weight=1;
|
||||
server 192.168.1.102:9100 weight=1;
|
||||
server 192.168.1.103:9000 weight=1 backup;
|
||||
|
||||
keepalive 16;
|
||||
}
|
||||
|
||||
# MinIO控制台集群 (统一使用9101端口,Node-03使用9001)
|
||||
upstream minio_console_cluster {
|
||||
server 192.168.1.101:9101 weight=1;
|
||||
server 192.168.1.102:9101 weight=1;
|
||||
server 192.168.1.103:9001 weight=1 backup;
|
||||
|
||||
keepalive 16;
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
# Nginx 主配置文件
|
||||
# 高可用负载均衡
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 10240;
|
||||
use epoll;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
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" '
|
||||
'upstream: $upstream_addr '
|
||||
'response_time: $upstream_response_time';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
# Gzip压缩配置
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript application/xml;
|
||||
|
||||
# 请求体大小限制 (用于视频上传)
|
||||
client_max_body_size 1024M;
|
||||
client_body_buffer_size 128k;
|
||||
|
||||
# 代理超时配置
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_buffer_size 128k;
|
||||
proxy_buffers 4 256k;
|
||||
proxy_busy_buffers_size 256k;
|
||||
|
||||
# 代理头配置
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# 加载upstream配置
|
||||
include /etc/nginx/conf.d/upstream.conf;
|
||||
|
||||
# 主服务配置
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name _;
|
||||
|
||||
# 首页
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
# API网关路由
|
||||
location /auth/ {
|
||||
proxy_pass http://gateway_cluster/auth/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
location /user/ {
|
||||
proxy_pass http://gateway_cluster/user/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
location /content/ {
|
||||
proxy_pass http://gateway_cluster/content/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
|
||||
# 视频流优化
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
|
||||
location /comment/ {
|
||||
proxy_pass http://gateway_cluster/comment/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
location /recommend/ {
|
||||
proxy_pass http://gateway_cluster/recommend/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
location /admin/ {
|
||||
proxy_pass http://gateway_cluster/admin/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
# Nacos控制台
|
||||
location /nacos/ {
|
||||
proxy_pass http://nacos_cluster/nacos/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
# Sentinel控制台
|
||||
location /sentinel/ {
|
||||
proxy_pass http://sentinel_cluster/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
|
||||
# MinIO API
|
||||
location /minio/ {
|
||||
proxy_pass http://minio_cluster/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_buffering off;
|
||||
}
|
||||
|
||||
# MinIO控制台
|
||||
location /minio-console/ {
|
||||
proxy_pass http://minio_console_cluster/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
# 健康检查端点
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 'OK';
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# 状态监控页面
|
||||
location /nginx_status {
|
||||
stub_status on;
|
||||
access_log off;
|
||||
allow 192.168.1.0/24;
|
||||
deny all;
|
||||
}
|
||||
|
||||
# 错误页面
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# TCP/UDP 流代理 (用于Redis, MySQL等)
|
||||
stream {
|
||||
# MySQL负载均衡
|
||||
upstream mysql_cluster {
|
||||
server 192.168.1.101:3306 weight=1;
|
||||
server 192.168.1.102:3306 weight=1 backup;
|
||||
server 192.168.1.103:3306 weight=1 backup;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 13306;
|
||||
proxy_pass mysql_cluster;
|
||||
proxy_connect_timeout 10s;
|
||||
}
|
||||
|
||||
# Redis负载均衡 (读写分离)
|
||||
upstream redis_master {
|
||||
server 192.168.1.101:6379;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 16379;
|
||||
proxy_pass redis_master;
|
||||
proxy_connect_timeout 5s;
|
||||
}
|
||||
|
||||
# Redis Sentinel
|
||||
upstream redis_sentinel {
|
||||
server 192.168.1.101:26379;
|
||||
server 192.168.1.102:26379;
|
||||
server 192.168.1.103:26379;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 26379;
|
||||
proxy_pass redis_sentinel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
# Redis 主节点配置 (Node-01)
|
||||
|
||||
# 网络配置
|
||||
bind 0.0.0.0
|
||||
port 6379
|
||||
protected-mode no
|
||||
|
||||
# 进程配置
|
||||
daemonize no
|
||||
pidfile /var/run/redis/redis-server.pid
|
||||
logfile /var/log/redis/redis-server.log
|
||||
|
||||
# 数据目录
|
||||
dir /data
|
||||
|
||||
# 内存配置
|
||||
maxmemory 2gb
|
||||
maxmemory-policy allkeys-lru
|
||||
|
||||
# 持久化配置 - RDB
|
||||
save 900 1
|
||||
save 300 10
|
||||
save 60 10000
|
||||
stop-writes-on-bgsave-error yes
|
||||
rdbcompression yes
|
||||
rdbchecksum yes
|
||||
dbfilename dump.rdb
|
||||
|
||||
# 持久化配置 - AOF
|
||||
appendonly yes
|
||||
appendfilename "appendonly.aof"
|
||||
appendfsync everysec
|
||||
no-appendfsync-on-rewrite no
|
||||
auto-aof-rewrite-percentage 100
|
||||
auto-aof-rewrite-min-size 64mb
|
||||
|
||||
# 密码配置
|
||||
requirepass redis_HA_Cluster_2024
|
||||
masterauth redis_HA_Cluster_2024
|
||||
|
||||
# 性能配置
|
||||
tcp-keepalive 300
|
||||
tcp-backlog 511
|
||||
timeout 0
|
||||
|
||||
# 慢查询日志
|
||||
slowlog-log-slower-than 10000
|
||||
slowlog-max-len 128
|
||||
|
||||
# 客户端配置
|
||||
maxclients 10000
|
||||
|
||||
# 集群配置 (单机模式不需要)
|
||||
# cluster-enabled no
|
||||
@@ -0,0 +1,60 @@
|
||||
# Redis 从节点配置 (Node-02, Node-03)
|
||||
|
||||
# 网络配置
|
||||
bind 0.0.0.0
|
||||
port 6379
|
||||
protected-mode no
|
||||
|
||||
# 进程配置
|
||||
daemonize no
|
||||
pidfile /var/run/redis/redis-server.pid
|
||||
logfile /var/log/redis/redis-server.log
|
||||
|
||||
# 数据目录
|
||||
dir /data
|
||||
|
||||
# 内存配置
|
||||
maxmemory 2gb
|
||||
maxmemory-policy allkeys-lru
|
||||
|
||||
# 持久化配置 - RDB
|
||||
save 900 1
|
||||
save 300 10
|
||||
save 60 10000
|
||||
stop-writes-on-bgsave-error yes
|
||||
rdbcompression yes
|
||||
rdbchecksum yes
|
||||
dbfilename dump.rdb
|
||||
|
||||
# 持久化配置 - AOF
|
||||
appendonly yes
|
||||
appendfilename "appendonly.aof"
|
||||
appendfsync everysec
|
||||
no-appendfsync-on-rewrite no
|
||||
auto-aof-rewrite-percentage 100
|
||||
auto-aof-rewrite-min-size 64mb
|
||||
|
||||
# 密码配置
|
||||
requirepass redis_HA_Cluster_2024
|
||||
masterauth redis_HA_Cluster_2024
|
||||
|
||||
# 从节点配置 (启动后手动执行 REPLICAOF 命令)
|
||||
# replicaof 192.168.1.101 6379
|
||||
replica-serve-stale-data yes
|
||||
replica-read-only yes
|
||||
repl-diskless-sync no
|
||||
repl-diskless-sync-delay 5
|
||||
repl-disable-tcp-nodelay no
|
||||
repl-backlog-size 1mb
|
||||
|
||||
# 性能配置
|
||||
tcp-keepalive 300
|
||||
tcp-backlog 511
|
||||
timeout 0
|
||||
|
||||
# 慢查询日志
|
||||
slowlog-log-slower-than 10000
|
||||
slowlog-max-len 128
|
||||
|
||||
# 客户端配置
|
||||
maxclients 10000
|
||||
@@ -0,0 +1,40 @@
|
||||
# Redis Sentinel 配置
|
||||
# 所有节点使用相同配置
|
||||
|
||||
port 26379
|
||||
daemonize no
|
||||
pidfile /var/run/redis/redis-sentinel.pid
|
||||
logfile /var/log/redis/redis-sentinel.log
|
||||
dir /tmp
|
||||
|
||||
# 监控主节点配置
|
||||
# sentinel monitor <master-name> <ip> <redis-port> <quorum>
|
||||
# quorum: 需要多少个sentinel同意才能判断主节点客观下线
|
||||
sentinel monitor mymaster 192.168.1.101 6379 2
|
||||
|
||||
# 主节点密码
|
||||
sentinel auth-pass mymaster redis_HA_Cluster_2024
|
||||
|
||||
# 主观下线时间 (毫秒)
|
||||
# 如果主节点在这个时间内没有响应PING,则标记为主观下线
|
||||
sentinel down-after-milliseconds mymaster 30000
|
||||
|
||||
# 故障转移超时时间 (毫秒)
|
||||
sentinel failover-timeout mymaster 180000
|
||||
|
||||
# 同时可以有多少个从节点对新主节点进行同步
|
||||
sentinel parallel-syncs mymaster 1
|
||||
|
||||
# 通知脚本 (可选)
|
||||
# sentinel notification-script mymaster /var/redis/notify.sh
|
||||
|
||||
# 客户端重配置脚本 (可选)
|
||||
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
|
||||
|
||||
# 允许Sentinel在启动时更新配置文件
|
||||
# sentinel announce-ip <ip>
|
||||
# sentinel announce-port <port>
|
||||
|
||||
# 其他配置
|
||||
protected-mode no
|
||||
bind 0.0.0.0
|
||||
@@ -0,0 +1,47 @@
|
||||
# RocketMQ Broker 配置
|
||||
# 主节点配置 (Node-02) - 与Node-03互为主备
|
||||
|
||||
brokerClusterName = DefaultCluster
|
||||
brokerName = broker-a
|
||||
brokerId = 0
|
||||
|
||||
# NameServer地址
|
||||
namesrvAddr = 192.168.1.101:9876;192.168.1.102:9876;192.168.1.103:9876
|
||||
|
||||
# 网络配置
|
||||
brokerIP1 = 192.168.1.102
|
||||
listenPort = 10911
|
||||
|
||||
# 存储配置
|
||||
storePathRootDir = /home/rocketmq/store
|
||||
storePathCommitLog = /home/rocketmq/store/commitlog
|
||||
|
||||
# 性能配置
|
||||
sendMessageThreadPoolNums = 16
|
||||
pullMessageThreadPoolNums = 16
|
||||
queryMessageThreadPoolNums = 8
|
||||
|
||||
# 刷盘配置
|
||||
flushDiskType = ASYNC_FLUSH
|
||||
|
||||
# 主从复制配置
|
||||
brokerRole = ASYNC_MASTER
|
||||
|
||||
# 消息保留时间 (小时)
|
||||
fileReservedTime = 72
|
||||
|
||||
# 提交日志文件大小
|
||||
mapedFileSizeCommitLog = 1073741824
|
||||
|
||||
# 消费队列文件大小
|
||||
mapedFileSizeConsumeQueue = 300000
|
||||
|
||||
# 自动创建Topic
|
||||
autoCreateTopicEnable = true
|
||||
autoCreateSubscriptionGroup = true
|
||||
|
||||
# 消息最大大小
|
||||
maxMessageSize = 4194304
|
||||
|
||||
# 内存配置
|
||||
brokerMemory = 512m
|
||||
@@ -0,0 +1,47 @@
|
||||
# RocketMQ Broker 配置
|
||||
# 主节点配置 (Node-03) - 与Node-02互为主备
|
||||
|
||||
brokerClusterName = DefaultCluster
|
||||
brokerName = broker-b
|
||||
brokerId = 0
|
||||
|
||||
# NameServer地址
|
||||
namesrvAddr = 192.168.1.101:9876;192.168.1.102:9876;192.168.1.103:9876
|
||||
|
||||
# 网络配置
|
||||
brokerIP1 = 192.168.1.103
|
||||
listenPort = 10911
|
||||
|
||||
# 存储配置
|
||||
storePathRootDir = /home/rocketmq/store
|
||||
storePathCommitLog = /home/rocketmq/store/commitlog
|
||||
|
||||
# 性能配置
|
||||
sendMessageThreadPoolNums = 16
|
||||
pullMessageThreadPoolNums = 16
|
||||
queryMessageThreadPoolNums = 8
|
||||
|
||||
# 刷盘配置
|
||||
flushDiskType = ASYNC_FLUSH
|
||||
|
||||
# 主从复制配置
|
||||
brokerRole = ASYNC_MASTER
|
||||
|
||||
# 消息保留时间 (小时)
|
||||
fileReservedTime = 72
|
||||
|
||||
# 提交日志文件大小
|
||||
mapedFileSizeCommitLog = 1073741824
|
||||
|
||||
# 消费队列文件大小
|
||||
mapedFileSizeConsumeQueue = 300000
|
||||
|
||||
# 自动创建Topic
|
||||
autoCreateTopicEnable = true
|
||||
autoCreateSubscriptionGroup = true
|
||||
|
||||
# 消息最大大小
|
||||
maxMessageSize = 4194304
|
||||
|
||||
# 内存配置
|
||||
brokerMemory = 512m
|
||||
Reference in New Issue
Block a user