|
0。背景 OpenStack 中的实例是不能持久化的,cinder服务重启,实例消失。如果需要挂载 volume,需要在 volume 中实现持久化。Cinder提供持久的块存储,目前仅供给虚拟机挂载使用。它并没有实现对块设备的管理和实际服务,而是为后端不同的存储结构提供了统一的接口,不同的块设备服务厂商在 Cinder 中实现其驱动支持以与 OpenStack 进行整合。它通过整合后端多种存储,用API接口为外界提供存储服务。主要核心是对卷的管理,允许都卷、类型和快照进行处理。 Cinder存储分为本地块存储、分布式块存储和SAN存储等多种后端存储类型:+ c% f O" ^( M) S
1. 本地存储: 默认通过LVM支持Linux
: k Q P9 F2 v) w2. SAN存储:1 r; t; F; b$ n( I6 T& H: e# H
(1)通过NFS协议支持NAS存储,比如Netapp
2 `+ {- r/ l9 p$ {; H: T8 C (2)通过添加不同厂商的制定driver来为了支持不同类型和型号的商业存储设备,比如EMC,IBM的存储。 在https://wiki.openstack.org/wiki/CinderSupportMatrix可以看到所支持的厂商存储列表。
$ r5 X4 o; g) r- z8 I' ?9 A7 V3. 分布式系统:支持sheepdog,ceph,和IBM的GPFS等 对于本地存储,cinder-volume 默认使用 LVM 驱动,该驱动当前的实现需要在主机上事先用 LVM 命令创建一个的卷组 , 当该主机接受到创建卷请求的时候,cinder-volume 在该卷组 上创建一个逻辑卷, 并且用 openiscsi 将这个卷当作一个 iscsi tgt 给输出.还可以将若干主机的本地存储用 sheepdog 虚拟成一个共享存储,然后使用 sheepdog 驱动。 1. Cinder LVM配置
. r. @9 x' w! f在cinder配置文件中,默认的backend lvmdriver是通过LVM来使用本地存储: [lvmdriver-1]7 J+ y; e4 @. ~4 P& J
volume_group = stack-volumes-lvmdriver-1% m4 K' G- O v% G" V
volume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver3 p3 u" {9 T3 J( e" {
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。+ X( n+ G' G: @& Q, t
- iSCSI的话,将其值设为 cinder.volume.drivers.lvm.LVMISCSIDriver;
- iSER的话,将其值设为 cinder.volume.drivers.lvm.LVMISERDriver。6 m) ]8 n) }0 U, Y2 d- P$ ]1 L
& ~( s" f/ E& o* h7 V. OLVM是cinder.volume.drivers.lvm.LVMISCSIDriver
2 B$ _3 d" q6 R3 ^ y' t: [6 ]* Z
- volume_backend_name 是backend name,在创建volume的时候可选择。
' a' r, L0 t: X5 t! n, q% D3 I
如果名字为stack-volumes-lvmdriver-1的volume group不存在,创建volume后其状态将为error,在cinder c-vol日志中可看到如下错误: Exception during message handling: Unexpected error while running command.
6 f0 u2 L9 U' D0 W( p* aCommand: None8 I+ t+ X& Q& c/ ?3 t' O3 Q* G
Exit code: -3 A' d. z! G. q5 L6 B% Z
Stdout: 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\''/ E; E( Z3 J: e! m7 c: H
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$ @0 f6 {; m7 l; M$ q% N+ c
--- Logical volume ---
2 } F# m, q& r4 S. QLV Name /dev/stack-volumes-lvmdriver-1/volume-02f986b0-418f-4f84-a5ec-7af61f5d5293
y! @, ~% f6 C rVG Name stack-volumes-lvmdriver-1" R2 r3 C v2 @
LV UUID 9oESr2-4V7f-qp22-F5te-hF2v-DWoy-EshtnN1 t* m! T3 {+ n
LV Write Access read/write
2 X k |0 Z$ T" a& l9 F9 Z, A0 U/ {LV Status available+ p0 v/ f: a6 w3 t
# open 07 K5 m. A V9 o+ Q, h. [
LV Size 1.00 GiB
# q3 V' G9 o8 @! W& wCurrent LE 256
5 ^) k4 I8 B2 F" U& S( j/ q& BSegments 1+ K/ X* _' I- g1 T% t% F) _
Allocation inherit
' W' i) g' I2 q- n) D3 g6 U# kRead ahead sectors auto
; a L+ n# w5 h4 Z/ S- currently set to 256
: w9 W5 H+ \$ I( e: i) [3 }Block device 252:0 4. 使用多个backend/添加新的LVM backend (1)创建新的volume group vg3 (1)修改cinder.conf,添加下面行:
5 ~$ J4 }( D0 G( E0 ~9 _7 aenabled_backends=lvmdriver-1,lvmdriver-2 . U% [0 [* n8 Q; }) J# [
[lvmdriver-2]: e, o9 F$ U) O& {' R
volume_group = vg3
. R) a# x, j6 G' s6 T& uvolume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver- A, {& R( q( F: O; m6 b( S* s
volume_backend_name = lvmdriver4vg3 注意: cinder-volume服务不监控该配置文件,除了在启动的时候读取该文件以外。因为在修改该文件后你需要重启该服务:`service cinder-volume restart`. (3)创建新的的volume type type-test s1@dev:~/devstack$ cinder type-create type-test/ D; e: u; a, h# S% y P! u) }, U
+--------------------------------------+---------------+
3 i+ K5 N5 C+ `: G6 z/ p& T| ID | Name |
, M5 O1 {7 _! L) y: ~6 C+--------------------------------------+---------------+; {3 w! A7 ?& }* ]. d
| 764480d1-7614-4a63-ba33-924d65765534 | type-test|
3 _" `( U; ?& Y* M+ O. _! {+--------------------------------------+---------------+ (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了。
7 T4 T3 r) g! l, N4 r) S
(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
6 ~0 @% Z" x( Z' D; `; A/ K7 `$ mSTRICT_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
3 a t- R6 u5 v1 b7 _# SBinary Host Zone Status State Updated At2 B8 @/ `; d1 P
cinder-scheduler dev nova enabled :-) 2014-12-12 16:11:54; I4 E, y5 o& `6 |% X+ i8 k
cinder-volume dev@lvmdriver-1 nova enabled :-) 2014-12-12 16:11:56
t6 p' ]( j8 d8 b+ T原因:cinder-volume的host少了一个对应第二个vg的一个。应该是添加第二个backend后配置没生效。" v; y0 I5 y& q8 s
解决:按照先后顺序重启 cinder-scheduler 和 cinder-volume 服务。创建volume错误消失。
, C; [* U3 X* g F(2) Volume一直处于creating状态。cinder-volume log中有如下错误:
* Z! }) u, E* p4 r, S$ g H5 nReturning exception create_volume() got an unexpected keyword argument 'source_replicaid' to caller 原因:controller上和storage node上cinder版本不一致。 [size=1em]1 9 b) c2 N/ {$ a, ^: U3 Y, q
| apt-get install package=version 命令。$ h& W+ [. E; \+ r! t5 k0 h: P+ f
3 x0 r$ p3 _* [1 c* O3 }; r, \+ @
|
; B7 G5 q& l2 y# M( l+ H+ @3 Z9 S) M4 o- M0 H2 q: w
. b6 s; ~1 N5 z. Q) S) V& `9 D
& a3 U( k' N6 T5 d9 q* d |