|
0。背景 OpenStack 中的实例是不能持久化的,cinder服务重启,实例消失。如果需要挂载 volume,需要在 volume 中实现持久化。Cinder提供持久的块存储,目前仅供给虚拟机挂载使用。它并没有实现对块设备的管理和实际服务,而是为后端不同的存储结构提供了统一的接口,不同的块设备服务厂商在 Cinder 中实现其驱动支持以与 OpenStack 进行整合。它通过整合后端多种存储,用API接口为外界提供存储服务。主要核心是对卷的管理,允许都卷、类型和快照进行处理。 Cinder存储分为本地块存储、分布式块存储和SAN存储等多种后端存储类型:' T9 `- O! V: Y5 x" T& j) I
1. 本地存储: 默认通过LVM支持Linux7 P3 W( @' L1 x6 Z; L& K- D
2. SAN存储:
& Q" J+ G1 g& O" O (1)通过NFS协议支持NAS存储,比如Netapp' j: m: W, ]# P( o& _$ J
(2)通过添加不同厂商的制定driver来为了支持不同类型和型号的商业存储设备,比如EMC,IBM的存储。 在https://wiki.openstack.org/wiki/CinderSupportMatrix可以看到所支持的厂商存储列表。# k l% @$ \) \; T' a: ]; t: X
3. 分布式系统:支持sheepdog,ceph,和IBM的GPFS等 对于本地存储,cinder-volume 默认使用 LVM 驱动,该驱动当前的实现需要在主机上事先用 LVM 命令创建一个的卷组 , 当该主机接受到创建卷请求的时候,cinder-volume 在该卷组 上创建一个逻辑卷, 并且用 openiscsi 将这个卷当作一个 iscsi tgt 给输出.还可以将若干主机的本地存储用 sheepdog 虚拟成一个共享存储,然后使用 sheepdog 驱动。 1. Cinder LVM配置
# k B% F0 L3 k) A; M' T在cinder配置文件中,默认的backend lvmdriver是通过LVM来使用本地存储: [lvmdriver-1]
% C# _- |2 T! k, Ivolume_group = stack-volumes-lvmdriver-1
G* ^3 r. w8 Uvolume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver
. w) @) b8 C1 v4 I7 N7 Dvolume_backend_name = lvmdriver-1 - volume_group 指定Cinder使用的 volume group。在devstack默认安装时其名称是stack-volumes-lvmdriver-1;在实际部署cinder的时候其默认名称是cinder-volumes。
- volume_driver 指定driver类型. Cinder目前支持两种传输协议, iSCSI and iSER。& }2 S% K' A I4 Q: A' v. L3 M! N
- iSCSI的话,将其值设为 cinder.volume.drivers.lvm.LVMISCSIDriver;
- iSER的话,将其值设为 cinder.volume.drivers.lvm.LVMISERDriver。
- @6 D$ X0 z) X
7 V Q& K0 q$ L1 P- RLVM是cinder.volume.drivers.lvm.LVMISCSIDriver
3 N6 c4 {! P7 S3 O" b4 X* b0 q
- volume_backend_name 是backend name,在创建volume的时候可选择。
0 V9 c; G8 v0 | r$ k+ s% J
如果名字为stack-volumes-lvmdriver-1的volume group不存在,创建volume后其状态将为error,在cinder c-vol日志中可看到如下错误: Exception during message handling: Unexpected error while running command.
) B# ^: ?% l/ O& v% w; L: t2 L: }Command: None5 C) l/ M6 `. K2 X! H" ?
Exit code: -
1 D8 @9 ]% ^! h* c0 F1 R- y# Z( MStdout: 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\''
: M1 G/ P: }7 n$ M8 \/ G- TStderr: 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: V. o7 A: E5 x
--- Logical volume ---
3 U6 q0 a7 @" l# dLV Name /dev/stack-volumes-lvmdriver-1/volume-02f986b0-418f-4f84-a5ec-7af61f5d5293
3 J& J" q* T( S o- l! B( U" r: oVG Name stack-volumes-lvmdriver-1) D+ u, x6 b5 E8 q, ?
LV UUID 9oESr2-4V7f-qp22-F5te-hF2v-DWoy-EshtnN. ]6 W: I5 F# b' M
LV Write Access read/write
. a) v4 T3 z. \8 V$ iLV Status available
: `9 ? | X7 `' h: ~# W4 Z7 i# open 0
% L* Z* l8 `2 R |' a8 O* ELV Size 1.00 GiB
3 n$ ]' `, @! r( P* FCurrent LE 256" J. s9 J. G1 I. g
Segments 12 f6 {& g7 O7 l9 N
Allocation inherit
1 t# \% f! v' H5 jRead ahead sectors auto
# Z# b$ {6 f' [ n& A- ^( e2 v- currently set to 256
! B/ O: H+ K# U7 ?" y, \2 [: jBlock device 252:0 4. 使用多个backend/添加新的LVM backend (1)创建新的volume group vg3 (1)修改cinder.conf,添加下面行:
0 n4 ?, v8 [* M& d: p! J2 nenabled_backends=lvmdriver-1,lvmdriver-2
; Y9 x/ [- U1 j. k[lvmdriver-2]+ I: f/ g# [3 }5 T
volume_group = vg31 W; r# [- E# A3 _
volume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver* @0 U, P- Z: o
volume_backend_name = lvmdriver4vg3 注意: cinder-volume服务不监控该配置文件,除了在启动的时候读取该文件以外。因为在修改该文件后你需要重启该服务:`service cinder-volume restart`. (3)创建新的的volume type type-test s1@dev:~/devstack$ cinder type-create type-test
7 N, S- V- U4 v5 K) W9 H+--------------------------------------+---------------+
' R9 K$ Y2 W0 V" ^. I1 q3 w5 r| ID | Name |9 h* y% I' K1 b+ E! ~& ~4 w
+--------------------------------------+---------------+
2 n* K; b* D- V4 K| 764480d1-7614-4a63-ba33-924d65765534 | type-test|5 W3 t( r+ Y; i9 j% l
+--------------------------------------+---------------+ (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了。+ j6 \6 y2 l7 m8 b5 O' V
(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
. k1 w; i0 J2 L3 y6 j3 q {+ b) JSTRICT_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:509& [7 V9 E) I( x) ~3 i& ?
Binary Host Zone Status State Updated At
' ^- ~0 K0 E* E' Q# _, {* bcinder-scheduler dev nova enabled :-) 2014-12-12 16:11:541 X8 N- R0 g/ F; B
cinder-volume dev@lvmdriver-1 nova enabled :-) 2014-12-12 16:11:56# M; k% W0 {7 V, S3 o
原因:cinder-volume的host少了一个对应第二个vg的一个。应该是添加第二个backend后配置没生效。
$ V2 n: r/ |+ s( O解决:按照先后顺序重启 cinder-scheduler 和 cinder-volume 服务。创建volume错误消失。
9 q0 V* w) H5 I# _(2) Volume一直处于creating状态。cinder-volume log中有如下错误:# R( _% s: l# j
Returning exception create_volume() got an unexpected keyword argument 'source_replicaid' to caller 原因:controller上和storage node上cinder版本不一致。 [size=1em] | apt-get install package=version 命令。
' E. c- Y7 m% J4 w4 F0 b. F& L/ ]6 M8 Q7 z) o9 l% T
| 6 l8 ^' b [0 ~! |# J
0 c+ s/ S; B/ X2 t! V* ?1 \( Y: s. B3 H
4 }* B, \( M- G) r! |2 l- u
4 q7 F) U) s1 M |