|
0。背景 OpenStack 中的实例是不能持久化的,cinder服务重启,实例消失。如果需要挂载 volume,需要在 volume 中实现持久化。Cinder提供持久的块存储,目前仅供给虚拟机挂载使用。它并没有实现对块设备的管理和实际服务,而是为后端不同的存储结构提供了统一的接口,不同的块设备服务厂商在 Cinder 中实现其驱动支持以与 OpenStack 进行整合。它通过整合后端多种存储,用API接口为外界提供存储服务。主要核心是对卷的管理,允许都卷、类型和快照进行处理。 Cinder存储分为本地块存储、分布式块存储和SAN存储等多种后端存储类型:
. z, l" `% Q8 q5 ?2 Z0 P1. 本地存储: 默认通过LVM支持Linux, C3 `" T5 e' i& R3 }; y& G
2. SAN存储:# R1 V: _1 E8 `6 N* ]
(1)通过NFS协议支持NAS存储,比如Netapp; o# S6 s: T! b9 m6 T& L0 C& ]
(2)通过添加不同厂商的制定driver来为了支持不同类型和型号的商业存储设备,比如EMC,IBM的存储。 在https://wiki.openstack.org/wiki/CinderSupportMatrix可以看到所支持的厂商存储列表。
, ^3 g. g0 A+ u3. 分布式系统:支持sheepdog,ceph,和IBM的GPFS等 对于本地存储,cinder-volume 默认使用 LVM 驱动,该驱动当前的实现需要在主机上事先用 LVM 命令创建一个的卷组 , 当该主机接受到创建卷请求的时候,cinder-volume 在该卷组 上创建一个逻辑卷, 并且用 openiscsi 将这个卷当作一个 iscsi tgt 给输出.还可以将若干主机的本地存储用 sheepdog 虚拟成一个共享存储,然后使用 sheepdog 驱动。 1. Cinder LVM配置+ t( b/ I, q% m; L& r0 ~# x
在cinder配置文件中,默认的backend lvmdriver是通过LVM来使用本地存储: [lvmdriver-1]
7 @' R5 o! n% ~4 I hvolume_group = stack-volumes-lvmdriver-1
6 _! i4 ]9 U0 C* \0 M, Pvolume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver5 {7 @3 U+ R* W: S7 Z+ Z
volume_backend_name = lvmdriver-1 - volume_group 指定Cinder使用的 volume group。在devstack默认安装时其名称是stack-volumes-lvmdriver-1;在实际部署cinder的时候其默认名称是cinder-volumes。
- volume_driver 指定driver类型. Cinder目前支持两种传输协议, iSCSI and iSER。 g# n7 @, M4 f d) ]5 g- m& Z
- iSCSI的话,将其值设为 cinder.volume.drivers.lvm.LVMISCSIDriver;
- iSER的话,将其值设为 cinder.volume.drivers.lvm.LVMISERDriver。0 D r) K6 m- M: @9 [
5 w+ F8 Z! G) z, f* b3 _
LVM是cinder.volume.drivers.lvm.LVMISCSIDriver
) h5 s4 |2 \" v3 l) a* I3 r9 x
- volume_backend_name 是backend name,在创建volume的时候可选择。
2 M+ [7 E$ [7 a O) q3 B
如果名字为stack-volumes-lvmdriver-1的volume group不存在,创建volume后其状态将为error,在cinder c-vol日志中可看到如下错误: Exception during message handling: Unexpected error while running command.! H: B8 r8 M1 N# v: y: O% @( c
Command: None
5 m1 r0 @! B2 k5 ~5 {Exit code: -
- U5 D, t, q8 rStdout: u'Unexpected error while running command.\nCommand: sudo cinder-rootwrap /etc/cinder/rootwrap.conf lvcreate -n volume-f3aef3b9-1a71-41d4-956e-a00044544b74 stack-volumes-lvmdriver-1 -L 1g\nExit code: 5\nStdout: u\'\'\nStderr: u\' Volume group "stack-volumes-lvmdriver-1" not found\\n\''
b& G- I( v7 I7 M4 `Stderr: None 3. Cinder使用LVM 成功创建一个Cinder volume后,可以在VG中看到新创建的logical volume: root@dev:/home/s1# lvdisplay /dev/stack-volumes-lvmdriver-1/volume-02f986b0-418f-4f84-a5ec-7af61f5d5293+ N: c. y' H5 A
--- Logical volume ---
2 z4 t. k# G& H! `3 e7 f+ l. oLV Name /dev/stack-volumes-lvmdriver-1/volume-02f986b0-418f-4f84-a5ec-7af61f5d5293
p; D# R! y: o- p9 E$ a! K% JVG Name stack-volumes-lvmdriver-1* D( m& p, l: p6 t4 q0 ?) ?
LV UUID 9oESr2-4V7f-qp22-F5te-hF2v-DWoy-EshtnN
" q. i0 k; d* H, |. P/ Q7 Y/ D- ]' nLV Write Access read/write+ @# Q W8 {3 m
LV Status available5 i8 i' y6 s: P' U/ _0 q
# open 0
/ B/ z- d( R# I1 d4 Y$ j# nLV Size 1.00 GiB' [9 x; d5 M1 X0 n4 l! {
Current LE 256& R3 O) }( _% b1 X
Segments 1. c6 L& o+ b* d2 Z
Allocation inherit
5 K$ c2 I% `3 L6 w; ^! \Read ahead sectors auto
2 d$ J/ g, v/ y0 F& {9 B- currently set to 256
3 Y4 G Y. ?- W/ j# T: u& FBlock device 252:0 4. 使用多个backend/添加新的LVM backend (1)创建新的volume group vg3 (1)修改cinder.conf,添加下面行: 6 }/ y) z1 y i) V) I
enabled_backends=lvmdriver-1,lvmdriver-2 4 O6 R5 x7 H* W1 G9 N
[lvmdriver-2]) B* }" ^& i4 _; m( n
volume_group = vg3
' Q; G# \" {' s1 [' ivolume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver
3 p2 i: Q. x; C9 B$ K) ^/ |5 V6 L2 ]9 Jvolume_backend_name = lvmdriver4vg3 注意: cinder-volume服务不监控该配置文件,除了在启动的时候读取该文件以外。因为在修改该文件后你需要重启该服务:`service cinder-volume restart`. (3)创建新的的volume type type-test s1@dev:~/devstack$ cinder type-create type-test5 C1 p" \ A' W" Z' k, i
+--------------------------------------+---------------+/ h& B4 y, B) T& ~6 q8 O
| ID | Name |
2 v8 B8 Y+ ~# h) W+--------------------------------------+---------------+4 h! L/ R% K' }5 L2 ~; U
| 764480d1-7614-4a63-ba33-924d65765534 | type-test|7 i" M% l7 K# w* A7 ~
+--------------------------------------+---------------+ (4) 设置volume type的backend name cinder type-key type-test set volume_backend_name=lvmdriver4vg3 注意: - 只有一个backend的时候,除了配置volume group外,不需要添加别的配置信息,创建volume的时候也不需要选择volume type。
- 当有多个backend的时候,你需要使用volume-type来将volume创建到指定的backend中。一个volume-type可以有几个backend,这时候 the capacity scheduler 会自动选择合适的backend来创建volume。
- 如果定义了volume type,但是cinder.conf中没有定义volume backend,那么cinder scheduler将找不到有效的host来创建volume了。9 `: v* E: i* a+ D
(5)可以在Horizen中选择新的type type-test来创建volume了 5. 遇到的问题: (1) 在选择一个volume type创建volume时失败, 症状:日志中有 No valid host was found. No weighed hosts available 错误 分析:查看volume host: s1@dev:~/devstack$ cinder-manage service list: R! {3 o# W6 y. z6 Q# c" |
STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION from (pid=4488) _check_effective_sql_mode /usr/local/lib/python2.7/dist-packages/oslo/db/sqlalchemy/session.py:5098 e$ O( j- E# o$ h$ d8 i I
Binary Host Zone Status State Updated At
7 e! }1 o" n; @- x) q- [+ rcinder-scheduler dev nova enabled :-) 2014-12-12 16:11:544 \$ o% M3 D1 p# j) j& d
cinder-volume dev@lvmdriver-1 nova enabled :-) 2014-12-12 16:11:560 M, l+ F G" Q; U- r, L
原因:cinder-volume的host少了一个对应第二个vg的一个。应该是添加第二个backend后配置没生效。
+ ?. L O# t6 A5 E6 E3 a, V; }解决:按照先后顺序重启 cinder-scheduler 和 cinder-volume 服务。创建volume错误消失。
3 `1 Y A U1 o# C(2) Volume一直处于creating状态。cinder-volume log中有如下错误:9 Z2 f# n7 q( @( ]& w9 g& ^: z
Returning exception create_volume() got an unexpected keyword argument 'source_replicaid' to caller 原因:controller上和storage node上cinder版本不一致。 [size=1em] | apt-get install package=version 命令。
1 G3 \/ Y7 e& y
! k Y$ b) n) K3 Q9 o) t# z |
6 K( d8 ?. F7 z- w* Y. x0 i
^" T2 i9 {# y( N, X* n2 \- s/ ~( \% b$ c
) I' V# W/ V; B q7 s2 I1 u8 x |