tongsiying

阅读|运动|自律

0%

BlockStorage-tgtmaster

# 001-tgtmaster理解:
1
2
3
4
5
6
7
8
1. tgtMaster全挂了到启动之间,这段时间启动的tgtd需要重启,其他不需要
2. tgtd只有再加LUN,重启,切换,切回等时候才会需要gateway信息
3. tgtd会判断TgtMaster分配的gateway信息
(
读写的时候不会判断这个gateway是否正常是吧?
a.读写时候是被动判断,读写请求超时了,会认为这个gateway异常
b. 现在tgtd读超时60s,写超时100s就会触发了切gateway
c. 不影响重试的,切换过程中,读写操作不会返回报错,一直重试,等切换完成后,会向新的gateway发送数据)

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
1.超时接口:
http://10.37.2.19:8888/sys/iscsi?ops=timeout&type=readretry&duration=864000

duration为时间,单位s,其中recovery和reconnect需要10的倍数
除了switch类型 duration可以设置>=0,其他的都>0
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
type有:
read 读超时 默认60s
write 写超时 默认60s
解释:写超时时间设置成60s,60s后还未收到gateway的反馈,认为gateway有问题,会切换gateway,这边60s指一次操作请求的超时时间
--------------------------------------------------------------------------------
readretry 读重试超时 默认86400【平时你测试只要设置成10分钟就行,不然重试太久日志受不了】
writeretry 写重试超时 默认86400【平时你测试只要设置成10分钟就行,不然重试太久日志受不了】
解释:默认重试1天时间,当有可重试的错误码过来立马重试,重试1天时间,这个只对可重试成功的错误码有用
--------------------------------------------------------------------------------
switch 切换等待时间 默认0
异常导致触发gateway切换,gateway上可能还有io,tgtd等待设置等待一段时间切换gateway
--------------------------------------------------------------------------------
recovery 切回等待时间 默认120s
解释:gateway恢复之后,上面的卷等待多长时间切回到原gateway
--------------------------------------------------------------------------------
reconnect 重连等待时间 默认60s
解释:某个时间段gateway都失效,卷在tgtd里状态是fault(2),隔多长时间去重连,三个gateway异常不会出现io错误。可能跳零。链接成功io恢复
curl -s "http://127.0.0.1:8888/tgtmaster/volume/status?pretty=y"

2.接口还支持指定tgt修改(tgt为指定的tgt节点)
http://10.37.2.19:8888/sys/iscsi?ops=timeout&type=readretry&duration=864000&pretty=y&tgt=10.37.2.19

3.查询超时的接口
查询所有的:
http://10.37.2.19:8888/sys/iscsi?ops=timeout&type=show&pretty=y
查询指定的:
http://10.37.2.19:8888/sys/iscsi?ops=timeout&type=show&pretty=y&tgt=10.37.2.19

4.测试建议:
1.停所有gateway
2.停两个chunkserver(不同zone中的)
3.测试可重试的错误码和不可重试的错误码

003-gateway注册

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
功能变更:
1、启动的时候可以不用配置etcd参数,tgtd上报心跳给tgtmaster,gateway默认有master就有tgtmaster,gateway也会上报心跳给tgtmaster
2、tgtmater不选主

1.注册gateway:
curl -X PUT "http://10.37.2.19:8888/tgtmaster/register/gateway?pretty=y&gateway=10.37.2.20:8585:8686"

2.注销gateway:
curl -X DELETE "http://10.37.2.19:8888/tgtmaster/register/gateway?pretty=y&gateway=10.37.2.19:8585:8686"

注:
1.参数gateway有两个端口,第一个端口(8585)表示gateway的tcp监听端口,第二个端口表示gateway的restful端口(8686
2.在注册/注销gateway后需要查看各个tgtmaster的信息是否一致
curl -X PUT http://10.37.2.19:8888/tgtmaster/gatewaymap?pretty=y
curl -X PUT http://10.37.2.19:8888/tgtmaster/tgtmap?pretty=y

3.测试建议
tgtmaster的所有功能需要做回归测试。
重点测试gateway的切换

004-设置卷到固定gateway

1
2
3
1.设置卷到固定的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"

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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
开发建议:
测试步骤:
1、创建卷vol1
2、在tgt1节点中将vol1 加入lun,成功
3、在tgt2节点中将vol1加入lun,成功
4、对tgt1节点的卷lun进行读写io,无异常
5、对tgt2节点的卷lun进行读io,无异常

测试案例:
1.裸卷
裸卷test001加入160.1的客户端
step1:dd if=/dev/zero of=/dev/sdc bs=1M count=100
step2:dd if=/dev/sdc of=/opt/100M.dd bs=1M count=100
[root@xgto01n010244025044 snbs]# md5sum /opt/100M.dd
2f282b84e7e608d5852449ed940bfc51 /opt/100M.dd

裸卷test001加入160.2的客户端
curl "http://10.238.161.1:8888/sys/iscsi?name=test001&ops=add_lun"
[root@xgto01n010244025048 peace]# curl "http://10.238.161.1:8888/sys/iscsi?name=test001&ops=add_lun&tgt=10.238.160.2"
{"Result":"success","ip":"10.238.160.2","iqn":"iqn.2019-01.com.suning:storage.snbs.test001"}
iscsiadm --mode discovery --type sendtargets --portal 10.238.160.2:3261
iscsiadm -m node --targetname iqn.2019-01.com.suning:storage.snbs.test001 --portal 10.238.160.2:3261 --login

160.2上的test001
dd if=/dev/sdc of=/opt/100M.dd bs=1M count=100
[root@xgto01n010244025048 peace]# md5sum /opt/100M.dd
2f282b84e7e608d5852449ed940bfc51 /opt/100M.dd
md5一致

160.2上的test001【可写】
dd if=/dev/zero of=/dev/sdc bs=1M count=200
160.2的test001
dd if=/dev/sdc of=/opt/200M.dd bs=1M count=200
[root@xgto01n010244025048 peace]# md5sum /opt/200M.dd
3566de3a97906edb98d004d6b947ae9b /opt/200M.dd

160.1上的test001
[root@xgto01n010244025044 snbs]# dd if=/dev/sdc of=/opt/200M.dd bs=1M count=200
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 1.16143 s, 181 MB/s
[root@xgto01n010244025044 snbs]# md5sum /opt/200M.dd
3566de3a97906edb98d004d6b947ae9b /opt/200M.dd

160.1上test001
dd if=/dev/zero of=/dev/sdc bs=1M count=300
160.1的test001
dd if=/dev/sdc of=/opt/300M.dd bs=1M count=300
[root@xgto01n010244025044 snbs]# dd if=/dev/sdc of=/opt/300M.dd bs=1M count=300
[root@xgto01n010244025044 snbs]# md5sum /opt/300M.dd
0d97a9cd8bbd7ce75a2a76bb06258915 /opt/300M.dd
160.2的test001
[root@xgto01n010244025048 peace]# dd if=/dev/sdc of=/opt/300M.dd bs=1M count=300
[root@xgto01n010244025048 peace]# md5sum /opt/300M.dd
0d97a9cd8bbd7ce75a2a76bb06258915 /opt/300M.dd

结论:可以重复加lun,都是可写可读的,未做保护

2.文件系统
160.1上的test001挂载/mnt/test001
160.2上的test001挂载/mnt/test002

进去160.1进行写发现卡住
进去160.2进行cd 发现卡住

3.虚机迁移(带数据盘) 100G数据盘
冷迁移:
nova migrate a0d8cbe7-07a4-4691-bb0b-8dd5b85d32ef xgto01n010244025044.sncloud.com
nova resize-confirm a0d8cbe7-07a4-4691-bb0b-8dd5b85d32ef

迁移前后md5值校验ok(验收报告有截图)


热迁前数据脚本准备一直写数据:
[root@snbs-boot-162 opt]# cat 1.sh
mkdir -p /opt/test
mkdir -p /mnt/snbs/test
j=0
for((i=0;i<=100;))
do
let j=j+1
cp /opt/1.txt /opt/test/${j}
cp /opt/1.txt /mnt/snbs/test/${j}
done

[root@snbs-boot-162 opt]# du -sh 1.txt
200M 1.txt




热迁:
nova live-migration a0d8cbe7-07a4-4691-bb0b-8dd5b85d32ef xgto01n010244025055.sncloud.com

迁移成功

热迁:nova live-migration vmUUID hostName 其中hostName查看命令和冷迁相同
疏散:nova host-evacuate --target_host newHostname oldHostname
疏散功能用于计算节点宕机后 将源节点的所有虚机疏散到目标节点【newHostname是目标节点 oldHostname是宕机节点】


扩容:
扩数据盘:
cinder extend 936e2c54-e1dc-4517-8d16-a2052b341806 200 该命令不区分是否处于挂载状态【非挂载状态下 就是冷的;挂载状态下 就是热的】
扩系统盘:
cinder extend 6f4e9b16-0dac-4a0a-bc25-2d1120d071c7 100


快照:【这版本没有集成快照回滚功能】
cinder snapshot-create --force true --name XXX(快照名字) --description XXX(描述)  volumeUUID 当卷处于挂载状态时 进行快照 需要添加--force参数

cinder snapshot-create --force true --name XXX(快照名字) --description XXX(描述)  volumeUUID

系统盘打快照:
cinder snapshot-create --force true --name 6f4e9b16-0dac-4a0a-bc25-2d1120d071c7-snap --description 162.202  6f4e9b16-0dac-4a0a-bc25-2d1120d071c7
96182d4a-167c-47b2-9a40-8595dc25005d


数据盘打快照:
cinder snapshot-create --force true --name 936e2c54-e1dc-4517-8d16-a2052b341806-snap --description 162.202  936e2c54-e1dc-4517-8d16-a2052b341806
11664a6a-b42c-4078-abd0-f8433c74d166

恢复快照:
curl -X POST "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=6f4e9b16-0dac-4a0a-bc25-2d1120d071c7&snapname=96182d4a-167c-47b2-9a40-8595dc25005d"
curl -X POST "http://127.0.0.1:8686/region/pool/vol/snapshot?volname=936e2c54-e1dc-4517-8d16-a2052b341806&snapname=11664a6a-b42c-4078-abd0-f8433c74d166"

启动虚机校验快照:
ok


一写多读测试完成:
1.裸卷可行,多tgtd加lun都可读可写
2.挂载文件系统出现,两边数据不能同步
3.openstack虚机冷热迁移、扩容、快照正常
4.openstack这版本没有集成快照回滚功能



1. 影响功能
openstack热迁移需要实现在迁移目标节点上的tgt上先无感的加LUN,完成迁移后在源节点上的tgt无感的删除LUN。原tgt实现增加/删除LUN方案存在以下几个问题:
1. 不删除源节点上LUN的情况下,在迁移目标节点上加LUN会失败
2. 加LUN时gateway上会清一次卷的元数据,导致热迁移过程中会出现短暂的IO挂起。
3. 卷切换gateway操作是由tgt独立判断和执行,在热迁移过程中,源节点卷发生切换gateway,导致源节点与目标节点上信息不同步。
4. 删除源节点上LUN时,会主动清理gateway上元数据,导致业务IO会出现短暂挂起
2. 测试建议
同步升级IscsiServer与tgtd到最新版本,并假设迁移源节点IP地址为A,目标节点IP地址为B
1. 在A上加LUN,通过tgtadm查询gateway信息,该LUN的switchable状态为1,并且gateway上会加载元数据
2. 在B上重复加LUN,A, B机器上分别通过tgtadm查询gateway信息,currentGW相同,且switchable同时为0,同时gateway上不会清理和重新加载元数据
3. 在A上删除LUN,B机器上通过tgtadm查询gateway信息,该LUN的switchable状态恢复1,gateway上不会清理元数据
Switchable开关测试:
1. 在上述第2步的基础上,
a) preferGW和currentGW不同,此时preferGW网络、功能正常,由于switchable为0,不会触发切回功能
b) preferGW和currentGW相同,此时preferGW进行kill掉,在A上进行一些读写操作,此时卷不会切换成其他gateway
2. 在上述第13步基础上,
a) preferGW和currentGW不同,此时preferGW网络、功能正常,由于switchable为1,会触发切回功能
b) preferGW和currentGW相同,此时preferGW进行kill掉,进行一些读写操作,由于switchable为1,此时卷会切换成其他gateway
3. 接口文档
1. 加LUN和删LUN的约定需要指定tgt的IP地址:
a) 加LUN http://127.0.0.1:8888/sys/iscsi?name=test1&ops=add_lun&tgt=10.37.2.19
b) 删LUN http://127.0.0.1:8888/sys/iscsi?name=test1&ops=del_lun&tgt=10.37.2.19
2. switchable开关接口(适用于异常情况、调试、测试):
a) 开启switchable http://127.0.0.1:8888/sys/iscsi?name=test1&ops=switchable_lun&flag=on
b) 关闭switchable http://127.0.0.1:8888/sys/iscsi?name=test1&ops=switchable_lun&flag=off
3. 查询卷状态接口变更:
restful查询 http://127.0.0.1:8888/tgtmaster/volume/status
tgtadm查询 tgtadm --lld iscsi --op gateway --mode target
在原有基础上,增加switchable字段:
1为可以触发切换、切回gateway操作
0为不会触发切换、切回gateway操作
4. 自测报告
根据测试建议操作,符合预期结果

006-tgtmaster调度iscsi命令:

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
1.将卷加入默认iqn
curl  "http://10.238.161.1:8888/sys/iscsi?name=vol-name&ops=add_lun"
返回解析
1200                                                                  -
2500及 {"error":"Error iscsi is nil"}                     
--失败.检查iscsiserver进程中的MasterIP

2.删lun
curl  "http://10.238.161.1:8888/sys/iscsi?name=vol-name&ops=del_lun"

指定节点删除lun:
curl  "http://10.238.161.1:8888/sys/iscsi?name=vol-name&ops=del_lun&tgt=tgtd-ip"

3.查询lun
curl  "http://10.242.180.207:8888/sys/iscsi?name=vol-name&ops=get_lun" 

4.查询所有卷的iqn及对应的tgt
curl "http://10.242.180.207:8888/sys/iscsi?name=vol-name&ops=show&pretty=y"

6.删除指定iqn
curl  "http://10.242.180.207:8888/sys/iscsi?iqn=iqn.2019-01.com.suning:storage.snbs.dev500&ops=del_iqn"   

7.将卷加入指定iqn(iqn已存在的情况下)
curl  "http://10.242.180.207:8888/sys/iscsi?name=dev600&ops=add_lun&iqn=iqn.2019-01.com.suning:storage.snbs.dev100"

8.将卷加入指定tgtd
curl  "http://10.242.180.207:8888/sys/iscsi?name=dev600&ops=add_lun&tgt=tgtd-ip"地址(不要端口号)"

9.将卷迁移到指定的iscsi.(可以在加指定的iqn) ---有bug
curl  "http://10.242.180.207:8888/sys/iscsi?name=dev500&ops=mov_lun&iscsi=10.37.2.19"

10.扩容卷
curl  "http://10.238.161.1:8888/sys/iscsi?name=vol-name&ops=expand_lun"

11.查询lun容量:
http://127.0.0.1:8888/sys/iscsi?name=xxx&ops=get_lun

006-tgt查询操作:

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
1.查询具体tgtserver详细信息:卷在哪个gateway上,卷在哪个tgtd上
curl -X PUT "http://10.238.161.1:8888/tgtmaster/detailtgt?tgt=10.238.160.1&pretty=y"
"Info": {
"IpPort": "10.238.160.1",
"VolumeCount": 114
},
"Volumes": [
{
"VolumeName": "b7d7ae66-9a23-4af9-b4f1-9998f234faf5",
"GateWay": "10.238.161.6:8585",
"TgtServer": "10.238.160.1"
}

2.查询某个卷在那个tgtserver和gateway上
 curl -X PUT "http://10.238.161.1:8888/tgtmaster/volume?volname=8deeb4ea-6a94-4f6a-b141-d3577c5bdbe9&pretty=y"
{
"VolumeName": "8deeb4ea-6a94-4f6a-b141-d3577c5bdbe9",
"GateWay": "10.238.161.6:8585",
"TgtServer": "10.238.160.1"
}

3.查询指定tgtd设备上的卷数量:
curl -X PUT "http://10.238.161.1:8888/tgtmaster/tgt?tgt=10.238.160.1&pretty=y"
{
"IpPort": "10.238.160.1",
"VolumeCount": 114
}

4.查询所有tgtd设备,以及它们上的卷数量
[root@xgto01n010244025044 ~]# curl -X PUT "http://10.238.161.1:8888/tgtmaster/tgtmap?pretty=y"
{
"ServerCount": 5,
"ServerInfos": [
{
"IpPort": "10.238.160.1",
"VolumeCount": 114
},
{
"IpPort": "10.238.160.2",
"VolumeCount": 100
},
{
"IpPort": "10.238.160.3",
"VolumeCount": 116
},
{
"IpPort": "10.238.161.5",
"VolumeCount": 10
},
{
"IpPort": "10.238.160.4",
"VolumeCount": 114
}
]
}

5.查看tgtd上所有卷的性能指标
curl "http://10.242.180.207:8888/tgtmaster/volume/status?pretty=y"
{
"volumeName": "6ac24310-d177-41ee-a2f8-4920cab729c9",
"perferGw": "10.242.180.211",
"currentGw": "10.242.180.211",
"status": "0",
"readError": "0",
"writeError": "0",
"ioCnt": "0",
"ioTotal": "51395",
"readIops": "0",
"readKBps": "0",
"readDelayAvg": "0",
"writeIops": "0",
"writeKBps": "1",
"writeDelayAvg": "7"
}


normal 0
fault 2
switch 3

007-gateway查询操作:

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
说明:
gateway异常后,有读写的卷立马切换到其他gateway,没有的读写的卷不切换。gateway恢复之后其他gateway需要2分钟左右才能恢复到原有gateway,不是立马切换。(gateway之间是有通信的)
1.查询所有gateway上的卷个数
[root@xgto01n010244025044 ~]# curl -X PUT "http://10.242.180.207:8888/tgtmaster/gatewaymap?pretty=y"
{
"ServerCount": 3,
"ServerInfos": [
{
"IpPort": "10.242.180.212:8585",
"VolumeCount": 3
},
{
"IpPort": "10.242.180.211:8585",
"VolumeCount": 5
},
{
"IpPort": "10.242.180.210:8585",
"VolumeCount": 3
}
]

2.查询具体某一个gateway上的卷个数
[root@xgto01n010244025044 ~]# curl -X PUT "http://10.242.180.207:8888/tgtmaster/gateway?gw=10.242.180.210:8585&pretty=y"
{
"IpPort": "10.242.180.210:8585",
"VolumeCount": 3
}

3.查询具体某一个gateway详细信息(打印详细卷名和tgtd地址)
[root@xgto01n010244025044 ~]# curl -X PUT "http://10.242.180.207:8888/tgtmaster/detailgateway?gw=10.242.180.210:8585&pretty=y"
{
"Info": {
"IpPort": "10.242.180.210:8585",
"VolumeCount": 3
},
"Volumes": [
{
"VolumeName": "23f6c766-fc09-4c71-b677-165af735fc09",
"GateWay": "10.242.180.210:8585",
"TgtServer": "10.27.244.148"
},
{
"VolumeName": "b31e79b8-fcba-4d44-957b-12a246708bff",
"GateWay": "10.242.180.210:8585",
"TgtServer": "10.27.244.153"
},
{
"VolumeName": "m1116t3",
"GateWay": "10.242.180.210:8585",
"TgtServer": "10.242.231.65"
}
]
}

008-查询所有卷的iqn及对应的tgt:

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
curl "http://10.242.180.207:8888/sys/iscsi?name=vol-name&ops=show&pretty=y"
{
  "Iscsi": [
    {
      "Ip": "10.27.244.153",
      "Status": 0, #0正常,1不在线
      "Names": [
    {
          "VolName": "d5077c65-4b2b-4a44-9a1f-8f26a7c13fed",
          "LunId": 1,
          "Iqn": "iqn.2019-01.com.suning:storage.snbs.d5077c65-4b2b-4a44-9a1f-8f26a7c13fed",
          "Tid": 1
        },
    {
          "VolName": "b31e79b8-fcba-4d44-957b-12a246708bff",
          "LunId": 1,
          "Iqn": "iqn.2019-01.com.suning:storage.snbs.b31e79b8-fcba-4d44-957b-12a246708bff",
          "Tid": 3
        },
    {
          "VolName": "6ac24310-d177-41ee-a2f8-4920cab729c9",
          "LunId": 1,
          "Iqn": "iqn.2019-01.com.suning:storage.snbs.6ac24310-d177-41ee-a2f8-4920cab729c9",
          "Tid": 4
        }
      ]
    },
  "Tgt": [
    {
      "mation": [
    {
          "ip": "IP Address: 10.27.244.153",
          "iqn": "Initiator: iqn.2008-11.org.linux-kvm:bd934d8f-0ccd-49db-899a-3b9ec01e614a alias: none"
        }
      ],
      "iqn": "iqn.2019-01.com.suning:storage.snbs.d5077c65-4b2b-4a44-9a1f-8f26a7c13fed"
    },
    {
      "mation": [
    {
          "ip": "IP Address: 10.27.244.153",
          "iqn": "Initiator: iqn.2008-11.org.linux-kvm:bd934d8f-0ccd-49db-899a-3b9ec01e614a alias: none"
        }
      ],
      "iqn": "iqn.2019-01.com.suning:storage.snbs.b31e79b8-fcba-4d44-957b-12a246708bff"
    }
  ]
}
赞赏一下吧~