Skip to content

Commit

Permalink
新增CMDB数据库表结构文档
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-xiaowang committed Apr 29, 2024
1 parent 759fa78 commit 6e1b3d4
Show file tree
Hide file tree
Showing 19 changed files with 1,670 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 数据库表结构设计

*说明:蓝鲸配置平台(蓝鲸CMDB)项目底层使用MongoDB进行数据存储,MongoDB是一个面向文档的数据库,因此它没有传统的表结构,而是使用集合(Collection)和文档(Document)来组织数据,本目录下文档中涉及的表结构和字段解释仅供参考,请以实际环境中的结构为准。*

## 表结构文档分类及作用

| 作用 | 分类文档 |
|----------------|---------------------------------------------------|
| 内置模型相关表 | [built-in_model](built-in_model.md) |
| 业务下相关资源表 | [business](business.md) |
| 云资源相关功能表 | [cloud_resource](cloud_resource.md) |
| 容器数据纳管功能相关表 | [container_data_manage](container_data_manage.md) |
| 字段组合模板功能相关表 | [field_template](field_template.md) |
| 主机属性自动应用功能相关表 | [host_apply_rule](host_apply_rule.md) |
| 实例相关表 | [instance](instance.md) |
| 主线模型相关表 | [mainline_model](mainline_model.md) |
| 模型相关表 | [model](model.md) |
| 运营分析功能相关表 | [operational_analysis](operational_analysis.md) |
| 管控区域相关表 | [plat](plat.md) |
| 服务模板功能相关表 | [service_template](service_template.md) |
| 集群模板功能相关表 | [set_template](set_template.md) |
| 异步任务相关表 | [task](task.md) |
| 资源目录用户自定义配置相关表 | [user_custom](user_custom.md) |
| 资源变更事件相关表 | [watch](watch.md) |
| 不归属任何一种分类的表 | [other](other.md) |

127 changes: 127 additions & 0 deletions docs/db/built-in_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# 内置模型相关表

## cc_BizSetBase

#### 作用

存放业务集信息

#### 表结构

| 字段 | 类型 | 描述 |
|---------------------|------------|--------------------|
| _id | ObjectId | 数据唯一ID |
| bk_biz_set_id | NumberLong | 业务集id |
| bk_biz_set_name | String | 业务集名称 |
| bk_biz_set_desc | String | 业务集描述 |
| bk_biz_maintainer | String | 维护者 |
| bk_scope | Object | 业务集范围 |
| default | NumberLong | 是否是默认业务集,1代表是,0代表否 |
| bk_supplier_account | String | 开发商ID,默认0 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |

**注意**:此处仅对业务集内置的模型字段做说明,业务集表结构字段取决于用户在业务集模型中定义的属性字段

#### bk_scope 字段结构示例

| 字段 | 类型 | 描述 |
|-----------|---------|------------|
| match_all | Boolean | 是否包含所有业务 |
| filter | Object | 所包含业务的条件规则 |

#### bk_scope.filter 字段结构示例

| 字段 | 类型 | 描述 |
|-----------|--------|-----------|
| condition | String | 规则操作符 |
| rules | Array | 过滤节点的范围规则 |

#### bk_scope.filter.rules 字段结构示例

过滤规则为三元组 `field`, `operator`, `value`

| 字段 | 类型 | 描述 |
|----------|--------|-----------------------------|
| field | string | 字段名 |
| operator | string | 操作符 |
| value | - | 操作数,不同的operator对应不同的value格式 |

## cc_HostBase

#### 作用

主机信息表

#### 表结构

| 字段 | 类型 | 描述 |
|--------------------------|--------------|--------------|
| _id | ObjectId | 数据唯一ID |
| bk_os_name | String | 操作系统名称 |
| bk_addressing | String | 寻址方式 |
| import_from | String | 录入方式 |
| bk_sla | String | SLA级别 |
| bk_cpu_module | String | CPU型号 |
| bk_host_innerip_v6 | String Array | 内网IPv6 |
| bk_agent_id | String | GSE Agent ID |
| bk_cloud_host_identifier | Boolean | 云主机标识 |
| bk_os_bit | String | 操作系统位数 |
| bk_sn | String | 设备SN |
| bk_host_outerip | String Array | 外网IP |
| bk_service_term | NumberLong | 质保年限 |
| bk_state_name | String | 所在国家 |
| bk_mac | String | 内网MAC地址 |
| bk_cloud_inst_id | String | 云主机实例ID |
| bk_cpu_architecture | String | CPU架构 |
| bk_os_version | String | 操作系统版本 |
| operator | String Array | 主要维护人 |
| bk_os_type | String | 操作系统类型 |
| bk_host_id | NumberLong | 主机id |
| bk_cloud_id | NumberLong | 管控区域id |
| bk_comment | String | 备注 |
| bk_cloud_host_status | NumberLong | 云主机状态 |
| bk_bak_operator | String Array | 备份维护人 |
| bk_province_name | NumberLong | 所在省份 |
| bk_isp_name | String | 所属运营商 |
| bk_disk | NumberLong | 磁盘容量(GB) |
| bk_outer_mac | String | 外网MAC |
| bk_state | String | 当前状态 |
| bk_host_outerip_v6 | String Array | 外网IPv6 |
| bk_host_name | String | 主机名称 |
| bk_asset_id | String | 固资编号 |
| bk_cloud_vendor | String | 云厂商 |
| bk_host_innerip | String Array | 内网IP |
| bk_cpu | NumberLong | CPU逻辑核心数 |
| bk_mem | NumberLong | 内存容量(MB) |
| bk_supplier_account | String | 开发商ID,默认0 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |

**注意**:此处仅对主机内置的模型字段做说明,主机表结构字段取决于用户在主机模型中定义的属性字段

## cc_ProjectBase

#### 作用

项目表

#### 表结构

| 字段 | 类型 | 描述 |
|---------------------|------------|-----------|
| _id | ObjectId | 数据唯一ID |
| id | NumberLong | 自增ID |
| bk_project_id | String | 项目ID |
| bk_project_code | String | 项目英文名 |
| bk_project_type | String | 项目类型 |
| bk_project_owner | String | 项目负责人 |
| bk_project_name | String | 项目名称 |
| bk_project_desc | String | 项目描述 |
| bk_project_sec_lvl | String | 保密级别 |
| bk_status | String | 项目状态 |
| bk_supplier_account | String | 开发商ID,默认0 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |

**注意**:此处仅对项目内置的模型字段做说明,项目表结构字段取决于用户在项目模型中定义的属性字段
136 changes: 136 additions & 0 deletions docs/db/business.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# 业务下相关资源表

## cc_ServiceCategory

#### 作用

服务分类信息表

#### 表结构

| 字段 | 类型 | 描述 |
|---------------------|------------|-----------|
| _id | ObjectId | 数据唯一ID |
| id | NumberLong | 分类id |
| name | String | 分类名称 |
| bk_root_id | NumberLong | 根节点id |
| bk_parent_id | NumberLong | 父节点id |
| is_built_in | Boolean | 是否为系统内置 |
| bk_biz_id | NumberLong | 业务id |
| bk_supplier_account | String | 开发商ID,默认0 |

## cc_HostFavourite

#### 作用

存放收藏主机搜索条件信息

#### 表结构

| 字段 | 类型 | 描述 |
|---------------------|------------|-----------|
| _id | ObjectId | 数据唯一ID |
| bk_biz_id | NumberLong | 业务id |
| id | NumberLong | 自增id |
| info | String | ip查询条件 |
| name | String | 收藏的名称 |
| count | NumberLong | 数量 |
| user | String | 创建者 |
| type | String | 收藏类型 |
| query_params | String | 通用查询条件 |
| bk_supplier_account | String | 开发商ID,默认0 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |

## cc_ServiceInstance

#### 作用

服务实例信息表

#### 表结构

| 字段 | 类型 | 描述 |
|---------------------|------------|-----------|
| _id | ObjectId | 数据唯一ID |
| id | NumberLong | 自增id |
| bk_biz_id | NumberLong | 业务id |
| name | String | 服务实例名 |
| labels | Object | 标签 |
| service_template_id | NumberLong | 服务模板id |
| bk_host_id | NumberLong | 主机id |
| bk_module_id | NumberLong | 模块id |
| creator | String | 创建人 |
| modifier | String | 更新人 |
| bk_supplier_account | String | 开发商ID,默认0 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |

#### labels 字段结构示例

| 字段 | 类型 | 描述 |
|-----|--------|-------------------------|
| env | String | 标签名称,由用户自定义,此处 env 仅为例子 |

## cc_Process

#### 作用

进程实例信息表

#### 表结构

| 字段 | 类型 | 描述 |
|----------------------|------------|-----------|
| _id | ObjectId | 数据唯一ID |
| service_instance_id | NumberLong | 服务实例id |
| start_cmd | String | 启动命令 |
| user | String | 启动用户 |
| bk_start_param_regex | String | 启动参数匹配规则 |
| restart_cmd | String | 重启命令 |
| face_stop_cmd | String | 强制停止命令 |
| work_path | String | 工作路径 |
| description | String | 备注 |
| priority | NumberLong | 启动优先级 |
| bk_process_name | String | 进程别名 |
| bk_start_check_secs | NumberLong | 启动等待时长 |
| bk_func_name | String | 进程名称 |
| reload_cmd | String | 进程重载命令 |
| pid_file | String | PID文件路径 |
| auto_start | Boolean | 是否自动拉起 |
| bk_biz_id | NumberLong | 业务ID |
| proc_num | NumberLong | 启动数量 |
| stop_cmd | String | 停止命令 |
| bk_process_id | NumberLong | 进程id |
| timeout | NumberLong | 操作超时时长 |
| bind_info | Array | 绑定信息 |
| bk_supplier_account | String | 开发商ID,默认0 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |

#### bind_info 字段结构示例

| 字段 | 类型 | 描述 |
|----------|---------|------|
| enable | Boolean | 是否启用 |
| ip | String | 绑定ip |
| port | String | 绑定端口 |
| protocol | String | 通信方式 |

## cc_ProcessInstanceRelation

#### 作用

存放进程实例关联关系信息

#### 表结构

| 字段 | 类型 | 描述 |
|---------------------|------------|-----------|
| _id | ObjectId | 数据唯一ID |
| bk_biz_id | NumberLong | 业务id |
| bk_process_id | NumberLong | 进程id |
| service_instance_id | NumberLong | 服务实例id |
| process_template_id | NumberLong | 进程模板id |
| bk_host_id | NumberLong | 主机id |
| bk_supplier_account | String | 开发商ID,默认0 |
66 changes: 66 additions & 0 deletions docs/db/cloud_resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 云资源相关功能表

## cc_CloudAccount

#### 作用

存放云账户信息

#### 表结构

| 字段 | 类型 | 描述 |
|-----------------------|------------|---------|
| _id | ObjectId | 数据唯一ID |
| bk_account_name | String | 云账户名称 |
| bk_account_id | NumberLong | 云账户id |
| bk_secret_id | String | 云账户密钥id |
| bk_secret_key | String | 云账户密钥 |
| bk_cloud_vendor | String | 云厂商 |
| bk_description | String | 云账户描述 |
| bk_can_delete_account | Boolean | 是否可删除 |
| bk_creator | String | 创建人 |
| bk_last_editor | String | 最后更新人 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |

## cc_CloudSyncHistory

#### 作用

存放云同步任务历史信息

#### 表结构

| 字段 | 类型 | 描述 |
|-----------------------|------------|-------------------------------------------------|
| _id | ObjectId | 数据唯一ID |
| bk_task_id | String | 任务ID,由taskserver生成的唯一ID |
| task_type | String | 任务标识,用于业务方识别任务,同时表示所在的任务队列,每个队列都配置了回调接口等信息 |
| bk_account_id | NumberLong | 该任务关联的实例id,用于查询一个实例对应的所有任务,并且防止对同一个实例多次创建新的同步任务 |
| bk_sync_status | String | 任务执行状态 |
| bk_status_description | String | 任务状态描述 |
| bk_detail | Object | 任务详情信息 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |
| bk_supplier_account | String | 开发商ID,默认0 |

## cc_CloudSyncTask

#### 作用

存放云同步任务表信息

#### 表结构

| 字段 | 类型 | 描述 |
|-----------------------|------------|-------------------------------------------------|
| _id | ObjectId | 数据唯一ID |
| bk_task_id | String | 任务ID,由taskserver生成的唯一ID |
| bk_task_name | String | 任务名称 |
| bk_resource_type | String | 任务标识,用于业务方识别任务,同时表示所在的任务队列,每个队列都配置了回调接口等信息 |
| bk_account_id | NumberLong | 该任务关联的实例id,用于查询一个实例对应的所有任务,并且防止对同一个实例多次创建新的同步任务 |
| bk_sync_status | String | 任务执行状态 |
| bk_status_description | String | 任务状态描述 |
| create_time | ISODate | 创建时间 |
| last_time | ISODate | 最后更新时间 |
| bk_supplier_account | String | 开发商ID,默认0 |

0 comments on commit 6e1b3d4

Please sign in to comment.