-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcmdb.txt
96 lines (72 loc) · 1.48 KB
/
cmdb.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
1、存储、查询 + -> 倒排索引
2、自定义表结构 -> 文档数据库:mongodb
3、支持外键 -> RDBMS
4、API +
5、历史版本 -> append only
6、事务 * -> 非原子操作
entity -> json
schema -> field {
ref -> schema.field
}
文档数据库:mongodb、elasticsearch、rika
B+ Tree
倒排索引:
{
"uuid": "xxxxxxxx",
"ip": "127.0.0.1",
"hostname": "localhost"
}
localhost -> xxxxxxxx
127.0.0.1 -> xxxxxxxx
schema => 数据的结构 => {
1、名字
2、主键
3、Fields
4、version
5、timestamp
}
field => 描述一列数据的属性 => {
1、名字
2、类型
3、唯一
4、多值
5、必须
6、ref -> schema::field
}
entity => 实际的数据 => {
1、_meta:{
1、schema
2、version
3、timestamp
}
...
}
schema 创建 和 更新
0、加锁 /cmdb/lock/schema_name
1、检查schema的合法性
1、检查是否存在
2、计算版本号
3、创建mapping
4、写history
5、写current
-1、 解锁
entity 创建和更新
0、加锁
1、检查entity的合法性
1、获取到schema
2、逐个字段检查
2、计算版本号
3、写history
4、写current
-1、解锁
elasticsearch: 同一个索引下,同名字段,类型必须相同
1、index
2、type
3、doc
mapping:规范了存入elasticsearch的数据类型,数据类型决定了检索方式
schema: {
schema:
schema_history:
entity:
entity_history:
}