tongsiying

阅读|运动|自律

0%

BlockStorage-Gateway

1
2
3
4
5
池三副本,卷三副本
池只有三副本,卷有两副本和三副本
若是卷未指定副本数,采用池的副本数
若是卷指定副本数,采用卷的副本数
常用接口都走gateway

001-拓扑接口:

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
1.创建region:
curl -X PUT "http://127.0.0.1:8686/region?regionid=region1"

2.删除region:
curl -X DELETE "http://127.0.0.1:8686/region?regionid=region1"

3.创建zone:
curl -X PUT "http://127.0.0.1:8686/region/zone?regionid=region1&zoneid=zone1"

4.删除zone:
curl -X DELETE "http://127.0.0.1:8686/region/zone?regionid=region1&zoneid=zone1"

5.创建node:
curl -X PUT "http://127.0.0.1:8686/region/zone/dev?regionid=region1&zoneid=zone1&nodeips=127.0.0.1:9595,10.242.4.92:9595"

6.删除node:(删除node前需要先将节点数据迁移走,之后才能从zone剔除节点)
curl -X DELETE "http://10.242.231.123:8686/region/zone/dev?regionid=region-tt&zoneid=zone-tt1&ipport=10.242.231.120:9595&type=migrate"
【迁移数据需要手动经过多轮,每次确认是否需要第二次,需要到迁出节点看是否还有extent,原卷上面有克隆的卷第一轮暂时不会迁移】

curl -X DELETE "http://10.242.231.123:8686/region/zone/dev?regionid=region-tt&zoneid=zone-tt1&ipport=10.242.231.120:9595&type=cancel"
curl -X DELETE "http://10.242.231.123:8686/region/zone/dev?regionid=region-tt&zoneid=zone-tt1&ipport=10.242.231.120:9595&type=delete"

参数:
regionid:region 的名称
zoneid :zone名称
ipport  :node ip,port
type :值有"migrate" "cancel" "delete"
"migrate" : 表示迁移数据,可以在老extent上读写,不能新建extent
"cancel" :表示取消迁移,节点继续用,不能删;准备迁移的取消任务,在迁移的要迁移完,迁移过的不再动
"delete" :表示删除节点,盘中有数据前不能删节点

7.创建pool
curl -X PUT "http://127.0.0.1:8686/pool?poolname=SNPOOL001&regionid=region1&replica=3"

8.删除pool
curl -X DELETE "http://127.0.0.1:8686/pool?poolname=SNPOOL001"

9.将zone分配到pool
curl -X PUT "http://127.0.0.1:8686/pool/zone?poolname=SNPOOL001&regionid=region1&zoneids=zone1,zone2"

10.将zone从pool删除
curl -X DELETE "http://127.0.0.1:8686/pool/zone?poolname=SNPOOL001&regionid=region1&zoneids=zone1,zone2"

11.查看region信息
curl -X GET "http://127.0.0.1:8686/region?regionid=region1&pretty=y"

12、查看有所有池的信息
范围查询pool
curl "http://127.0.0.1:8686/pool/list?marker=SN&prefix=SN&pretty=y"
#pool列表
curl -X GET "http://127.0.0.1:8686/pool/list?pretty=y"
{
"Pools": [{
"poolname": "pool-tt",
"createtime": "2019-08-02 17:50:25",
"regionid": "region-tt"
"rebalancetime": "22:15", #设置的定时均衡时间
"rebalanceswitch": 1, #设置的定时均衡开关,非0即为开
"faultdomainnum": 5,
"node_active_num": 5,
"node_num": 5,
"volume_num": 16,
"total_byte": 4949320663040,
"free_byte": 2508957155328,
"used_byte": 2440363507712
} ]}

13.查询某个池的信息
curl -X GET "http://127.0.0.1:8686/pool?poolname=pool-tt&pretty=y" #pool基本信息

14.查看pool下zone、节点
curl -X GET "http://127.0.0.1:8686/pool/info?poolname=SNPOOL001&pretty=y"
#节点在线、zone信息

002-池相关:

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
1.资源池信息
curl "http://10.242.231.121:8686/pool?pretty=y&poolname=pool-tt"
{
"poolname": "pool-tt",
"createtime": "2019-08-02 17:50:25",
"regionid": "region-tt",
"rebalancetime": "19:15",  #定时均衡时间,支持分钟级别
"rebalanceswitch": 1,  #非0即为打开
"faultdomainnum": 6, #故障域,zone的个数
"node_active_num": 5,
"node_num": 5,
"volume_num": 16,
"total_byte": 4949320663040,
"free_byte": 2648694587392,
"used_byte": 2300626075648
}

2.池的状态查询(不是实时的)
curl "http://10.242.231.65:8686/pool/status?pretty=y" 
[{
"PoolName": "pool-tt",
"Region": "region-tt",
"TotalMigrateExtentCount": 0,
"PrepareMigrateExtentCount": 0,
"MigratingExtentCount": 0,
"PrepareRepairExtentCount": 0,
"RepairingExtentCount": 0,
"TotalExtentCount": 3216,
"DowngradeExtentCount": 0,
"UnwriteExtentCount": 0,
"UnavailableExtentCount": 0,
"DowngradeVolume": [],
"UnwriteVolume": [],
"UnavailableVolume": [vol001,vol002]
}]
TotalMigrateExtentCount:所有需要迁移的chunk/Extent个数
PrepareMigrateExtentCount:准备迁移的Extent个数
MigratingExtentCount:正在迁移的Extent个数
PrepareRepairExtentCount:准备修复的Extent个数
RepairingExtentCount:正在修复的Extent个数
TotalExtentCount:目前总创建的Extent个数
DowngradeExtentCount:降级的Extent个数,健康副本数大于一半
UnwriteExtentCount:不可写的Extent个数,健康副本数小于1半
UnavailableExtentCount:不可用的Extent个数,无健康副本
DowngradeVolume:降级的卷
UnwriteVolume:不可写的卷
UnavailableVolume:不可用的卷
迁移成功可以通过做计算得出:迁移成功的=总共的-准备迁移的-正在迁移的

003-卷相关:

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
1.创建卷
curl -X PUT "http://127.0.01:8686/region/pool/vol?pool=SNPOOL001&volume=test1&size=102400000"
size:卷大小,单位:字节byte
repnum:副本数

2.扩容卷
curl -X POST "http://127.0.01:8686/region/pool/vol?volume=test1&size=204800000"

3.查询卷
curl -X GET "http://127.0.01:8686/region/pool/vol?volume=test1-c1&pretty=y"
卷查询结果解释:
{
"FileName": "test1-c1", //卷名称
"Prefix": "000000000010c8ec", //卷的UUID
"Size": 107374182400,  //卷大小
"Provisioning": "thin",
"Creation_Time": "2019-08-01 09:43:44", //创建时间
"Copies": 3,    //副本数
"Type": "linkclone",  //卷类型:有linkclone、fullclone、snap、origin
"Parent": "ttest1",  //父卷
"Pool": "pool-tt",  //所属资源池
"Ref": 0,  //是否被引用,若有则无法删除卷
"Status": 1, //0表示正常;1表示正在执行中;2表示执行失败
"Index": 0,  
"ReadOnly": false  //是否只读
"RDBW": 0, //read kbps ,读每秒流量带宽
"RDQps": 0, //read iops ,读每秒次数
"WRBW": 0, //write kbps ,写每秒流量带宽
"WRQps": 0 //write iops ,写每秒次数
}

4.删除卷
curl -X DELETE "http://127.0.01:8686/region/pool/vol?volume=test1&pretty=y"

5.资源池中所有卷查询
curl "http://127.0.0.1:8686/region/pool?pretty=y"

查询池里面有多少卷
curl -X GET "http://127.0.0.1:8787/pool/info?poolname=pool-openstack&pretty=y"
curl -X GET "http://127.0.0.1:8787/pool?poolname=pool-openstack&pretty=y"
6.查询单个卷
curl "http://127.0.01:8686/region/pool/vol?volume=9907d48b-a33c-42db-a24d-683ac0b5622a&pretty=y"

卷名前缀匹配查询
curl "http://127.0.0.1:8686/region/pool?pretty=y&prefix=m11"
查询前1000个卷,不加max-keys默认显示100个卷
curl "http://127.0.0.1:8686/region/pool?pretty=y&max-keys=1000"

查询1000个卷以后的卷
curl "http://127.0.0.1:8686/region/pool?pretty=y&max-keys=1000&marker=YWPtest7"

7.创建链接克隆
可以不加newname,支持默认的
curl -X PUT "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=dev100&newname=c400&type=linkclone"

8.创建独立克隆(异步;可以不加newname,支持默认的)
curl -X PUT "http://127.0.0.1:8686/region/pool/vol/snapshot?poolname=store&volname=dev100&newname=f300&type=fullclone"

9.查询独立克隆进度
curl -X GET "http://127.0.0.1:8686/region/pool/vol/snapshot?newname=v4v001-fullclone-001&type=fullclone&volname=v4v001"

10.创建快照(可以不加newname,支持默认的)
curl -X PUT "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=dev100&newname=s300&type=snap"

10.查看快照恢复进度
curl -X POST "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=936e2c54-e1dc-4517-8d16-a2052b341806&progress=1"

11.快照恢复
curl -X POST "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=dev100&snapname=c300"

12.断开关系链-异步
curl -X PUT "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=dev100-c1&type=unlink"
注:将linkclone变为独立克隆,断链后可以删除父卷;快照克隆结束后手动将新克隆出来的卷加到lun里面

13.查询断链进度
curl -X GET "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=c100-10&type=unlink"
curl -X GET "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=v4v001-linkclone-003&type=unlink&newname=v4v001-linkclone-003"

14.创建镜像卷-异步(在系统卷上创建一个系统自定义名的独立克隆)
curl -X PUT "http://127.0.0.1:8686/region/pool/vol/fullclone?volname=dev300"
{"newname":"dev300-1-f"}

15.镜像克隆卷进度查询
curl -X GET "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=dev300&newname=dev300-1-f&type=fullclone"

16.镜像卷上建链接克隆卷:(在特殊的独立克隆上创建链接克隆)
curl -X PUT "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=dev300&origin=fullclone&newname=dev300-lc1&type=linkclone"

http://10.238.161.6:8686/region/pool/vol/snapshot?volname=f97c04a7-8208-419f-9e19-43a1a9c51921&newname=3fb8b90b-c20e-494f-8286-5e4de58f9e65&type=linkclone&origin=fullclone

004-迁移均衡:

1
2
3
4
5
6
7
8
9
10
11
1.定时均衡设置(资源池)
curl -X POST "http://127.0.0.1:8686/pool?poolname=pool1&retime=03:00&switch=1"

2.手动均衡命令
curl  "http://127.0.0.1:8686/rebalance"
一般返回200及{"result":"Success"}
均衡也需要均衡多轮,是自动的多轮
可以设置每轮均衡数master参数里面设置:migratebatch

3.取消迁移
curl "http://127.0.0.1:8686/cancelmigrate?poolname=pool-tt&pretty=y" -v

005-监控相关:

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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
1.查看节点信息
curl "http://10.242.180.212:8686/dev/info?ipport=10.242.180.208:9595&pretty=y"
{
"ExtentCount": 1157,
"Free": 709026119680,
"Online": true,
"RegionID": "region-openstack",
"Total": 1073599217664,
"Used": 364573097984,
"ZoneID": "zone1",
"ipport": "10.242.180.208:9595"
}

2.分配到该Gateway上的卷信息,每个Gateway都不一样
curl "http://127.0.0.1:8686/snbs/volume/info?pretty=y"
注:10s汇总统计一次
[
{
"name": "m0929mfc1",
"size": 107374182400,
"Type": "linkclone",
"poolName": "pool-tt",
"createTime": "0001-01-01T00:00:00Z",
"status": 0,
"readerr": 0,
"readiops": 0,
"readkbps": 0,
"readdelay": 0,
"writeerr": 0,
"writeiops": 7,
"writekbps": 1752,
"writedelay": 38,
"readCa": "off",
"writeCa": "off"
}
]
上面接口的卷汇总到TgtMaster中的访问方式:  curl "http://10.242.180.207:8888/tgtmaster/volume/status?pretty=y"

3.累计I/O数和Kb数,读取一次清零的接口(SNBSP中查卷读写IOPS、带宽)
curl "http://10.242.180.210:8686/snbs/volume/info/reg?pretty=y"
[
{
"name": "m1016t1",
"poolName": "pool-tt",
"readioreg": 0,#读取数据量,单位kb
"readkbreg": 0,#io操作次数
"readdelayreg": 0,#读取平均时延
"writeioreg": 122784,
"writekbreg": 491136,
"writedelayreg": 7
}
]
注:上次访问该接口到本次访问期间累加的数据,每请求一次清零


4.设置QoS
curl "http://127.0.0.1:8686/snbs/volume/qos/QosSet?volname=dev300&readiops=2000&readkbps=2000&active=on"
注:
volname :必填
readiops、readkbps、writeiops、writekbps:这几个参数可以任选一个或者多个。
active=on/off :必填

5.查询设置的卷信息
curl "http://10.242.180.212:8686/region/pool/vol?pretty=y&volume=dev300"
 
6.IOModel接口增加操作模式识别和extent操作次数统计
curl "http://10.242.180.212:8686/snbs/volume/IOModel?pretty=y"
[
{
"name": "test002",
"size": 107374182400,
"readiops": 125,
"readkbps": 14386,
"readdelay": 25,
"readdelaydis": "DelayDis(ms) (0,4]ms:44 (4,8]ms:68 (8,12]ms:137 (12,16]ms:188 (16,20]ms:147 (20,30]ms:279 (30,...]ms:388 ",
"readblockdis": "BlockDis(KB) (0,4]KB:0 (4,16]KB:317 (16,64]KB:0 (64,128]KB:298 (128,256]KB:307 (256,512]KB:329 (512,...]KB:0 ",
"readavgdis": "AvgDelay:25 (ms) AvgBlock:114 (KB) Total data:143860 (KB) Mode: rand",
#AvgDelay 平均时延 AvgBlock平均块大小 Total data读/写总大小 Mode操作时顺序还是随机
"readextenthis": [#writeextenthisExtent进行写操作最多的10个纪录,ExtentLba时extent对应的LBA值,hit是操作的次数
"ExtentLba: 23622320128, hit: 10",
"ExtentLba: 81067507712, hit: 9",
"ExtentLba: 104421392384, hit: 9",
"ExtentLba: 67645734912, hit: 9",
"ExtentLba: 1342177280, hit: 8",
"ExtentLba: 103616086016, hit: 8",
"ExtentLba: 33822867456, hit: 8",
"ExtentLba: 21743271936, hit: 8",
"ExtentLba: 76235669504, hit: 7",
"ExtentLba: 76772540416, hit: 7"
],
"writeiops": 53,
"writekbps": 6189,
"writedelay": 12,
"writedelaydis": "DelayDis(ms) (0,4]ms:3 (4,8]ms:141 (8,12]ms:176 (12,16]ms:111 (16,20]ms:51 (20,30]ms:39 (30,...]ms:17 ",
"writeblockdis": "BlockDis(KB) (0,4]KB:0 (4,16]KB:146 (16,64]KB:0 (64,128]KB:118 (128,256]KB:128 (256,512]KB:146 (512,...]KB:0 ",
"writeavgdis": "AvgDelay:12 (ms) AvgBlock:115 (KB) Total data:61896 (KB) Mode: rand",
"writeextenthis": [
"ExtentLba: 18253611008, hit: 6",
"ExtentLba: 3758096384, hit: 5",
"ExtentLba: 66840428544, hit: 5",
"ExtentLba: 77577846784, hit: 5",
"ExtentLba: 46170898432, hit: 5",
"ExtentLba: 4026531840, hit: 5",
"ExtentLba: 103884521472, hit: 4",
"ExtentLba: 77309411328, hit: 4",
"ExtentLba: 9932111872, hit: 4",
"ExtentLba: 46707769344, hit: 4"
]
},

注:
AvgDelay :平均时延
AvgBlock:平均块大小
Total data:读/写总大小
Mode:操作时顺序还是随机
writeextenthis:对Extent进行写操作最多的10个纪录,
ExtentLba:extent对应的LBA值,hit是操作的次数

006-调试接口:

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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
1.调试接口
curl "http://127.0.0.1:8686/snbs/debug/stat?name=SNBS000&type=dump"

2.查看gateway的io情况
curl "http://127.0.0.1:8686/snbs/debug/stat?name=SNBS004&type=iodelayon"
curl "http://127.0.0.1:8686/snbs/debug/stat?name=SNBS004&type=iodelayoff"

3.打开日志级别接口
curl "http://127.0.0.1:8686/snbs/debug/stat?name=SNBS000&type=logon"
curl "http://127.0.0.1:8686/snbs/debug/stat?name=SNBS000&type=logoff"

4.三副本的一致性检查(日志中显示结果)
curl "http://127.0.0.1:8686/snbs/debug/stat?name=volxxx&type=dcon" 
curl "http://127.0.0.1:8686/snbs/debug/stat?name=volxxx&type=dcoff"
注:没法校验数据的正确性,只能校验seq id是否一致

5.设置gateway链接数
curl "http://127.0.0.1:8686/snbs/volume/SetConnNum?connNum=256"

curl "http://127.0.0.1:8686/snbs/debug/stat?type=allchunkid"                                 ---------获取所有故障extent的序列号信息
curl "http://127.0.0.1:8686/snbs/debug/stat?type=chunkid&chunkid=xxxxx"        ---------获取指定extent的序列号信息
curl "http://127.0.0.1:8686/snbs/debug/stat?type=updateseqnum&chunkid=xxxxxx"   ---------更新指定序列号信息

6.server.GATEWAYARC打印概率调整:
curl "http://127.0.0.1:8686/log?p=0.4"
表示40%的概率打印
只要在0~1之间就可以,默认万分之一
curl "http://127.0.0.1:8686/log?p=0.01"

7.查询所有卷所有的序列号不一致的chunkid信息
curl "http://127.0.0.1:8686/snbs/debug/stat?type=allchunkid"
{
"ckunkid": "00000000009896890000063e",
"status": 3,
"repsn": [
{
"ckaddr": "10.238.161.1:9595",
"sn": 0
},
{
"ckaddr": "10.238.161.5:9595",
"sn": 0
},
{
"ckaddr": "10.238.161.4:9595",
"sn": 0
}

status:
CpInvalid = 0
CpNormal = 1 这个是正常,其他都是不正常状态
CpDegrade = 2
CpFault = 3 从chunkserver没加载到序列号
CpOffline = 4
CpRollback = 5

8.查询指定卷指定chunkid的信息
curl "http://127.0.0.1:8686/snbs/debug/stat?type=chunkid&chunkid=xxxx&name=xxx"    
[root@host102442551 Speed]# curl "http://127.0.0.1:8686/snbs/debug/stat?type=chunkid&chunkid=000000000098968300000298&name=v4v001&pretty=y"
[
{
"ckunkid": "000000000098968300000298",
"status": 3,
"repsn": [
{
"ckaddr": "10.238.161.5:9595",
"sn": 0
},
{
"ckaddr": "10.238.161.3:9595",
"sn": 0
},
{
"ckaddr": "10.238.161.2:9595",
"sn": 0
}
]
}
]
status:
CpInvalid = 0
CpNormal = 1 这个是正常,其他都是不正常状态
CpDegrade = 2
CpFault = 3 从chunkserver没加载到序列号
CpOffline = 4
CpRollback = 5

9.更新指定序列号信息,chunkserver修复序列号后需要更新到gateway(当出现三个副本序列号不一致时,chunkserver进行修复,修复一个ckid,就调用,通知gateway重新加载下序列号)
适用场景:出现序列号异常,fullcheck也解决不了,人为介入的时候使用
curl "http://127.0.0.1:8686/snbs/debug/stat?type=updateseqnum&chunkid=xxxxxx"  

10.提前知道chunkid,直接去chunkserver读取数据,每次都是读取4k数据
陈玉强 2020-02-08 14:48:13
curl "http://127.0.0.1:8686/snbs/debug/stat?name=f2b99567-1422-4b27-98a5-0361e09c8d4b&type=chunkdata&ctbl=00000000011bd05b00000000&file=/cyq/datafile2&lba=0"
name---卷名字
type ---操作类型
ctbl----读取哪个chunkid
file ----保存数据的文件(绝对路径)
lba ----字节,相对于ctbl指定chunkid的偏移地址
如果ctbl=xxxxx,lba=4096.这个lba就是在读取ctbl这个chunkid内,从4096字节开始的4k长度的数据。
因为三个副本读出来所有最后是12k

11.设置流控(每个gateway都要执行)
陈玉强:
1.流控现在默认值太低,领导让提高。我是做个版本给你,还是你用curl命令临时修改??
2.嗯,现在流控阀值很低,内存积压达默认到1GB就会对io流控。需要调大默认值。。。。我改到版本里面,你可以选择换版本或者不换版本情况下使用curl命令@王俊凯

curl "http://127.0.0.1:8686/snbs/debug/config?opc=DownSpeed&arg=MemUsageLow&value=3072000" ----------流控取消阈值 单位都是KB

curl "http://127.0.0.1:8686/snbs/debug/config?opc=DownSpeed&arg=MemUsageHigh3&value=4096000 "----------三级流控阈值

curl "http://127.0.0.1:8686/snbs/debug/config?opc=DownSpeed&arg=MemUsageHigh2&value=5120000"----------二级流控阈值

curl "http://127.0.0.1:8686/snbs/debug/config?opc=DownSpeed&arg=MemUsageHigh1&value=6144000"----------一级流控阈值

007-超时重试:

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
提示下:
1.要模拟两个chunkserver错误,这个是在gateway节点,模拟chunkserver的错误,模拟一个不顶用,这两个chunkserver要不同zone
2.错误码后端存储错误分成两种:可重试能成功/不需要重试重试了也不会成功,观察日志里面错误
3.tgt来判断是否需要重试,tgtd需要根据黄涛贻给的超时时间设置,为了可重试能成功可以一直重试
linux 超时命令,添加系统配置文件,加lun自动设置

(需要在相应的gateway上执行)
1.设置这个chuankserver的写错误码为1024,该错误需要错误重试
curl "http://127.0.0.1:8686/snbs/debug/config?opc=addErrIp&ip=10.238.161.1:9595&errcode=1024"

取消这个chuankserver的错误码
curl "http://127.0.0.1:8686/snbs/debug/config?opc=delErrIp&ip=10.238.161.1:9595"                  

下面这些错误码是不需要重试的:(重试也不会成功的)(这写错误码是chunkserver的)
ErrChecksum: 102016
ErrWriteDataShort: 102021
ErrReadDataShort: 102020
ErrReadSegmentShort: 102022
ErrLegalSegmentID: 102025
ErrLegalSegmentOff: 102026
ErrExtentIDTooLong: 101003
ErrCloneExtentIDExist: 101004
ErrExtentCloned: 101005
ErrBadExtentPos: 101006
ErrExtentNodeIsNull: 101008
ErrBadOffset2: 101010
ErrBadOffset3: 101011
可以重试成功:除了上面那些错误码都可以重试成功
例如错误码:1

2.设置ip这个chunkserver的写时延为duration 毫秒   
curl "http://127.0.0.1:8686/snbs/debug/config?opc=addDelayIp&ip=10.238.161.1:9595&duration=600"  

取消ip这个chuankserver的写时延
curl "http://127.0.0.1:8686/snbs/debug/config?opc=delDelayIp&ip=10.238.161.1:9595"

3.这个可以打印当前你模拟了哪些错误,在对应gateway日志中查看
curl "http://127.0.0.1:8686/snbs/debug/config?opc=csIoDebug"

008-读缓存

1
2
涉及模块:gateway
使用盘:ssd或者hhd

1585134520722

1
2
3
4
5
6
7
8
9
10
11
12
13
14
理解:
1.gateway读缓存中blk的大小为256k
2.blk中有bh和stat,bh是记录数据位置,stat就是记录位信息以及访问次数和访问量,判断是否是热度
3.一个用户来64k来读请求,会判断这64k是否在bh上,如果都在那就从缓存读出来,如果不全在,就从chunkserver读。
4.一个用户1m(大于256k)来读请求,分切割成多个256k,如果都在就从缓存读出来。
5.热数据怎么变冷:如果该数据访问次数变少,该数据在ssd上不会主动删除,而是热度衰减成0,但是如果有新的热数据来了会选择热度为0的先删除。1小时候的blk会被衰减完
6.一个用户16k来读,16k成为热点,会缓存256k的壳子以及壳子中16k数据,256k-16k的数据未缓存,只有实际热点了才会缓存。
所以说看到blk都缓存了,但是命中率还不是很高,说明只缓存了一个壳子,实际数据没缓存


测试:ssd500G
1.一个卷400g都成了读缓存,性能
2.一个卷600g,只能有500G的缓存,性能
3.vdbench range方式读成热度,查看range是否存在在ssd盘上

接口:

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
97
98
99
100
101
1.启动模块时增加-CaDev=sdxx 指定缓存磁盘参数(注意supervisor改配置文件需要重启)
./server -log_dir=/tmp/gateway Gateway -CaDev=sdxx -masterip=10.37.2.18 -masterport=9393 -etcdip=10.37.2.18 -etcdport=2379 -ip=10.243.80.22 -port=8585            

2.开启卷是否读缓存:
【开启读缓存:有些参数不设置,就是默认】
curl -X PUT "http://127.0.0.1:8686/snbs/volume/CacheModify?volname=test001&cacheonoff=on&hotcycle=xx&statcycle=xx&hotstatpolicy=xx&hotthreshold=xx"

【关闭读缓存】
curl -X PUT "http://127.0.0.1:8686/snbs/volume/CacheModify?volname=test001&cacheonoff=off"

volname   --卷名
cacheonoff   --缓存开关 on:打开 off:关闭
hotcycle     --热度衰减周期  ,单位:秒  (默认420秒)    //建议保持默认
statcycle     --统计周期,单位:秒  (默认300秒)            //建议保持默认
hotstatpolicy   --热度统计策略,0:按次统计,1:按流量统计  (默认按次统计)    //建议保持默认
hotthreshold   --热度门限值,单位:次   (默认16次)     //根据卷做调整


举例:
curl -X PUT "http://127.0.0.1:8686/snbs/volume/CacheModify?volname=test001&cacheonoff=on&hotcycle=420&statcycle=300&hotstatpolicy=0&hotthreshold=16"

curl -X PUT "http://127.0.0.1:8686/snbs/volume/CacheModify?volname=test001&cacheonoff=on&hotthreshold=1"

3.gateway读缓存的热插拔(不需要人为手动格式化,使用过的也不用)
sdxxx盘作为读缓存插入gateway进程
curl "http://127.0.0.1:8686/snbs/debug/Cache?ops=ssd&ssdname=sdxxx&onoff=on"  

sdxxx盘拔出gateway进程
curl "http://127.0.0.1:8686/snbs/debug/Cache?ops=ssd&ssdname=sdxxx&onoff=off"

4.查看卷的缓存命中情况(直接返回)
curl "http://127.0.0.1:8686/snbs/debug/CacheHit?pretty=y"
{
"name": "test011",
"readioin": 22314500,
"readioout": 22314500,
"readiohit": 12896568
}

日志也会打印:
2019-12-03 13:46:23.878 [I 02556 gatewaycli.go:709] volume:test011 Prefix:00000000005d1425 Vc:0xc44441eb40 #说明卷打开了
2019-12-03 13:46:23.878 [I 02556 readcache.go:2002] Prefix:00000000005d1425 Vc:0xc44441eb40 BlkMap:116335 VcRefCnt:1 DelFlag:0
2019-12-03 13:46:23.878 [I 02556 readcache.go:2003] VcReadIOIn:4579901 VcReadIOOut:4579901 VcReadIOHit:0 VcReadIOTotalIn:4579901 VcReadIOTotalOut:4579901
#表示命中0
2019-12-03 13:46:23.878 [I 02556 readcache.go:2005] VcWriteIOTotalIn:0 VcWriteIOTotalOut:0 VcUpdateIOTotalIn:12 VcUpdateIOTotalOut:12

VcReadIOIn:22314500          -------当前一个小时内读请求个数
VcReadIOOut:22314500      -------当前一个小时内读请求完成个数
VcReadIOHit:12896568      -------当前一个小时内读请求缓存命中个数
VcReadIOTotalIn:22314500    -------总的读请求个数
VcReadIOTotalOut:22314500  -------总的读请求完成个数

5.设置卷到固定的gateway(在所有tgtmater上设置,同时开同时关)
curl -X PUT "http://127.0.0.1:8888/sys/debug/fixedmode?gateway=10.238.161.4:8585"
curl -X DELETE "http://127.0.0.1:8888/sys/debug/fixedmode"

6.查看卷上所有blk情况,是否在ssd中缓存,blk的热度等信息
curl "http://127.0.0.1:8686/snbs/debug/CacheDump?volname=test014"

[root@host102442549 Gateway]# curl "http://127.0.0.1:8686/snbs/debug/CacheDump?volname=v4v010&pretty=y"
[
"SSD BLK NUM :2643detail:",
"5--10GB BLK NUM:120per:4%",
"70--75GB BLK NUM:107per:4%",
"85--90GB BLK NUM:119per:4%",
"80--85GB BLK NUM:137per:5%",
"30--35GB BLK NUM:144per:5%",
"10--15GB BLK NUM:138per:5%",
"90--95GB BLK NUM:157per:5%",
"40--45GB BLK NUM:130per:4%",
"45--50GB BLK NUM:140per:5%",
"55--60GB BLK NUM:138per:5%",
"65--70GB BLK NUM:129per:4%",
"50--55GB BLK NUM:138per:5%",
"0--5GB BLK NUM:142per:5%",
"60--65GB BLK NUM:125per:4%",
"20--25GB BLK NUM:144per:5%",
"15--20GB BLK NUM:115per:4%",
"25--30GB BLK NUM:124per:4%",
"95--100GB BLK NUM:145per:5%",
"35--40GB BLK NUM:135per:5%",
"75--80GB BLK NUM:116per:4%"
]

在log中看,很多信息:
blk id : 12942 offset : 3392667648 hot : 0
disk:name:sdc1 PullOut:0 UsedBlkCnt:163499 DiskStatus:2000 RunFlag:0 RecycleRunFlag:0 LoadOffset:2097152 BhPage:102265 DirtyList:0 FreeList:1063682
UsedBlkCnt:163499
FreeList:1063682
-两个加起来是磁盘能占用的总blk数,*256k

7.
curl "http://10.242.180.212:8686/region/pool/vol?pretty=y=&volume=v4v010" -v
"BHC"` //blk热度值有效周期
"BSC"` //blk热度统计周期
"HSP"` //热度统计策略
"HT"`  //热度阀值
"CF"`  //0:关闭缓存功能,1:缓存功能打开
WR //写打开的数量
RD //读打开的数量
就是gateway 打开了几次

009-租约

1
2
网上关于租约机制的解释:
在租约期限内,客户端可以保证其缓存中的数据是最新的。同时,租约可以容忍各种非拜占庭式失效(机器崩溃、网络分割等)。如果客户端崩溃或者网络中断,服务器只需要等待其租约过期就可以进行修改操作。如果服务器出错丢失了所有客户端的信息,它只需要知道租约的最长期限,就可以在这个期限之后安全的修改数据。与回调方式相比,服务器只需记住还拥有租约的客户端即可。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
和开发(金鑫、陈玉强)交流的理解:
租约的目的:确保只有一个gateway打开某一个卷,gateway每次打开卷都需要到master查下;没有租约的话只能保证某个卷分配给某一个gateway,但是不能保证这个卷可以在不同的gateway上打开;租约是gateway上的卷和主master建立租约。
1.gateway是客户端,master是服务端
2.gateway不再续约,超时租约的期限就会过期;
3.master如果30s(一次10s,共3次收不到gateway的心跳认为是租约过期)
4.gateway每上报一次master,master就会帮gateway续约10s
5.客户端gateway出现崩溃或者网络中断,master(服务器)只需要等待其租约过期就可以进行修改操作;gateway恢复之后重新续租
【上面的修改:master(服务端)清空gateway上加载的卷的打开记录,gateway恢复正常,重新加载重新续约;】
gateway只和主master签订租约,master操作etcd

涉及场景:分带io和没io
1.有io的,gateway异常,卷带着租约一起切换gateway
2.没有io
gateway异常,30s后恢复gateway,租约失效,如果30s有io访问该卷会重新和master建立租约。
gateway异常,30s内恢复gateway,30s内有io,gateway才去建立租约,mster发现租约已存在,返回之前未失效的租约,然后该卷续约。
gateway异常,30s内恢复gateway,30s内没io,gateway未去建立租约,mster过了30s租约失效。
gateway异常,30s内恢复gateway,30s后有io,gateway才去建立租约,mster创建新的租约,返回新租约,然后该卷重新续约。(和上一条合并测试)

010-模拟seq不一致

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
主要目的:测试seq回滚

1.测试接口:不能重复设置
http://127.0.0.1:8686/snbs/debug/drop?name=test1&probability=0&record=150
name 卷名
probability 丢弃概率,取值范围[0, 100],其中0为关闭,其他为打开
record 纪录最近多少条 默认100条,最大1000(打开时候设置)

2.seq理解:
887 这种不会触发回滚seq ,触发chunkserver自修复
889 这种才会触发9回滚到8

1、正常的流程是gateway串行的严格递增1的发往chunkserver
2、seq从0 到无穷大
3、seq可能出现不连续的,这样chunkserver会触发修复

举例:
打开:(在卷所在gateway上执行)
curl "http://10.238.161.6:8686/snbs/debug/drop?name=test001&probability=50&record=1000"

关闭:curl "http://10.238.161.6:8686/snbs/debug/drop?name=test001&probability=0"
关闭返回:
{
        "ChunkId": "0000000000155d3c000000f0",
        "Sn": 289833,
        "PkgSn": 289834,
        "Success": [
            "10.238.161.1:9595"
        ],
        "Fail": [
            "10.238.161.4:9595",
            "10.238.161.5:9595"
        ],
        "Result": 3,
        "StartTime": "2019-11-29 14:50:50.251",
        "EndTime": "2019-11-29 14:50:50.426"
    },

注释:
result是指3个副本,回滚操作成功的数量
10.238.161.4:9595",
"10.238.161.5:9595"
这两个的seq是289833

"10.238.161.1:9595"
seq是289833

011-理解克隆

1
2
3
1、独立克隆是完全拷贝实际数据,生成新的extent指向新数据。
2、链接克隆+快照是拷贝chunkserver元数据,seq一起拷贝,生成新的extent指向父卷数据。
【元数据是指chunkserver的索引hdb,hdb指向磁盘具体位置】

012-gateway反馈序号缺失chunkid到master进行修复功能

gateway上报异常chunk到master

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
陈玉强场景:
存在一个chunkserver、全部io写错误,gateway将错误chunkid上报,master修复,一段时间后将chunkserver的io恢复正常
存在一个chunkserver、部分io写错误,gateway将错误错误chunkid上报,master修复,一段时间后将chunkserver的io恢复正常
存在多个chunkserver、全部io写错误,gateway将错误错误chunkid上报,master修复,一段时间后将chunkserver的io恢复正常
存在多个chunkserver、部分io写错误,gateway将错误错误chunkid上报,master修复,一段时间后将chunkserver的io恢复正常
@王俊凯

金鑫:
Gateway异常上报Master:
1、查询chunkserver上面上报的异常extent
curl -X GET "http://127.0.0.1:8787/snbs/abnormalchunk?chunkserver=10.37.2.19:9191&pretty=y"
2、查询gateway上报的chunk数量与分布:
curl -X GET http://127.0.0.1:8787/snbs/abnormalchunk?gateway=10.37.2.19:8686&pretty=y
3、触发chunkserver开始修复
curl –X PUT http://127.0.0.1:8787/snbs/abnormalchunk?chunkserver=10.37.2.19:9191&opt=fix&pretty=y
4、取消chunkserver上报的extent
curl –X PUT http://127.0.0.1:8787/snbs/abnormalchunk?chunkserver=10.37.2.19:9191&opt=destroy&pretty=y


黄涛贻
Gateway 模拟部分extent异常:
1. 设置部分extent报错比例
http://10.37.2.20:8686/snbs/debug/config?opc=setErrPct&percent=9
2. 设置部分extent延时比例
http://10.37.2.20:8686/snbs/debug/config?opc=setDelayPct&percent=9
percent取值范围[0, 9],默认值为00为全部模拟,1模拟10%extent,2模拟20%extent,以此类推
先设置错误模拟,再设置错误比例(延时模拟同)
删除所有的错误模拟,错误比例自动置零(延时模拟同)
赞赏一下吧~