nacos schema.sql的内容
时间: 2023-07-09 15:14:45 浏览: 167
nacos schema.sql 是 Nacos 的服务注册中心使用的 MySQL 数据库初始化脚本,它包含了创建 Nacos 服务注册中心所需的数据库、表和索引等 SQL 语句。具体内容如下:
```
-- 创建数据库
CREATE DATABASE IF NOT EXISTS `nacos_server` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
-- 切换到 nacos_server 数据库
USE `nacos_server`;
-- 创建数据表:service_info
CREATE TABLE `service_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`service_name` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_name` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`namespace_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`protect_threshold` int(11) NOT NULL DEFAULT '0',
`metadata` varchar(2048) COLLATE utf8_bin NOT NULL DEFAULT '',
`selector` varchar(2048) COLLATE utf8_bin NOT NULL DEFAULT '',
`cluster_name` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`service_key` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`app_name` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`weight` double DEFAULT NULL,
`enable` tinyint(1) NOT NULL DEFAULT '1',
`healthy` tinyint(1) NOT NULL DEFAULT '0',
`ephemeral` tinyint(1) NOT NULL DEFAULT '0',
`ip` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`port` int(11) NOT NULL,
`cluster_sync_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`use_ip_port4check` tinyint(1) NOT NULL DEFAULT '0',
`marked` tinyint(1) NOT NULL DEFAULT '0',
`instance_id` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`last_update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_service_info` (`namespace_id`,`group_name`,`service_name`,`cluster_name`,`ip`,`port`,`instance_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_info_beta
CREATE TABLE `config_info_beta` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_config_info_beta_data_id_group_id` (`data_id`,`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_info_tag
CREATE TABLE `config_info_tag` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`tag_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_config_info_tag_data_id_group_id_tag_id` (`data_id`,`group_id`,`tag_id`),
KEY `idx_config_info_tag_gmt_create` (`gmt_create`),
KEY `idx_config_info_tag_data_id` (`data_id`),
KEY `idx_config_info_tag_group_id` (`group_id`),
KEY `idx_config_info_tag_tag_id` (`tag_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_info_history
CREATE TABLE `config_info_history` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_config_info_history_gmt_create` (`gmt_create`),
KEY `idx_config_info_history_data_id` (`data_id`),
KEY `idx_config_info_history_group_id` (`group_id`),
KEY `idx_config_info_history_md5` (`md5`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:service_info_sync
CREATE TABLE `service_info_sync` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`service_name` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_name` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`namespace_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`protect_threshold` int(11) NOT NULL DEFAULT '0',
`metadata` varchar(2048) COLLATE utf8_bin NOT NULL DEFAULT '',
`selector` varchar(2048) COLLATE utf8_bin NOT NULL DEFAULT '',
`cluster_name` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`service_key` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`app_name` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`weight` double DEFAULT NULL,
`enable` tinyint(1) NOT NULL DEFAULT '1',
`healthy` tinyint(1) NOT NULL DEFAULT '0',
`ephemeral` tinyint(1) NOT NULL DEFAULT '0',
`ip` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`port` int(11) NOT NULL,
`cluster_sync_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`use_ip_port4check` tinyint(1) NOT NULL DEFAULT '0',
`marked` tinyint(1) NOT NULL DEFAULT '0',
`instance_id` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`last_update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_service_info_sync` (`namespace_id`,`group_name`,`service_name`,`cluster_name`,`ip`,`port`,`instance_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_info_aggr
CREATE TABLE `config_info_aggr` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_config_info_aggr_data_id_group_id` (`data_id`,`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- 创建数据表:config_info_beta_history
CREATE TABLE `config_info_beta_history` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`data_id` varchar(256) COLLATE utf8_bin NOT NULL DEFAULT '',
`group_id` varchar(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`content` longtext COLLATE utf8_bin NOT NULL,
`md5` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_config_info_beta_history_gmt_create` (`gmt_create`),
KEY `idx_config_info_beta_history_data_id` (`data_id`),
KEY `idx_config_info_beta_history_group_id` (`group_id`),
KEY `idx_config_info_beta_history_md5` (`md5`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
```
以上是 nacos schema.sql 的内容,执行这些 SQL 语句可以初始化 Nacos 服务注册中心所需的数据库表结构。
阅读全文