马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
0。背景 openstack 中的实例是不能持久化的,cinder服务重启,实例消失。如果需要挂载 volume,需要在 volume 中实现持久化。Cinder提供持久的块存储,目前仅供给虚拟机挂载使用。它并没有实现对块设备的管理和实际服务,而是为后端不同的存储结构提供了统一的接口,不同的块设备服务厂商在 Cinder 中实现其驱动支持以与 OpenStack 进行整合。它通过整合后端多种存储,用API接口为外界提供存储服务。主要核心是对卷的管理,允许都卷、类型和快照进行处理。 Cinder存储分为本地块存储、分布式块存储和SAN存储等多种后端存储类型:' I+ v9 x V/ r4 x
1. 本地存储: 默认通过LVM支持Linux+ R; O. b3 D- C+ R* C; c& j
2. SAN存储:
- K0 i6 J( `5 j5 v$ ]% ^' e7 G; } (1)通过NFS协议支持NAS存储,比如Netapp
/ w5 O e" _3 ` r" I ] (2)通过添加不同厂商的制定driver来为了支持不同类型和型号的商业存储设备,比如EMC,IBM的存储。 在https://wiki.openstack.org/wiki/CinderSupportMatrix可以看到所支持的厂商存储列表。
* U( C6 L, I/ _0 ^" R3. 分布式系统:支持sheepdog,ceph,和IBM的GPFS等 对于本地存储,cinder-volume 默认使用 LVM 驱动,该驱动当前的实现需要在主机上事先用 LVM 命令创建一个的卷组 , 当该主机接受到创建卷请求的时候,cinder-volume 在该卷组 上创建一个逻辑卷, 并且用 openiscsi 将这个卷当作一个 iscsi tgt 给输出.还可以将若干主机的本地存储用 sheepdog 虚拟成一个共享存储,然后使用 sheepdog 驱动。 1. Cinder LVM配置7 P' I: Z! o+ z$ z2 G- P5 o6 E
在cinder配置文件中,默认的backend lvmdriver是通过LVM来使用本地存储: [lvmdriver-1]$ _5 p0 a1 O: e7 X5 y# o. D$ C1 S( C
volume_group = stack-volumes-lvmdriver-1
4 K6 R; \) Q: h0 v/ {volume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver7 J' \2 M* k: e7 M! c$ [
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。4 C# s& a7 A; S! t9 b0 J
- iSCSI的话,将其值设为 cinder.volume.drivers.lvm.LVMISCSIDriver;
- iSER的话,将其值设为 cinder.volume.drivers.lvm.LVMISERDriver。# _ F4 Z. T: t& K% N) P2 N8 w
d3 e1 o- ?, c0 f/ `9 r
LVM是cinder.volume.drivers.lvm.LVMISCSIDriver
/ O% c8 ?- W/ J; x$ B- A* e
- volume_backend_name 是backend name,在创建volume的时候可选择。4 c& U6 y6 ~3 [5 @* w3 E6 B3 U
如果名字为stack-volumes-lvmdriver-1的volume group不存在,创建volume后其状态将为error,在cinder c-vol日志中可看到如下错误: Exception during message handling: Unexpected error while running command.' K( J, }; a9 h X5 x
Command: None
5 s( C P f; j! z- O: lExit code: -
' D' o* Z1 ^- p7 ]4 r+ k3 M$ tStdout: 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\''9 p4 ?% |) ~9 V3 l- A9 J. \
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! k0 u: Y+ Z4 b# ]: H/ H
--- Logical volume ---& ~( v1 M3 `& l/ ]
LV Name /dev/stack-volumes-lvmdriver-1/volume-02f986b0-418f-4f84-a5ec-7af61f5d5293
' s1 L3 V5 w2 {& E L0 rVG Name stack-volumes-lvmdriver-1: N* t* {: W: {% |
LV UUID 9oESr2-4V7f-qp22-F5te-hF2v-DWoy-EshtnN8 E2 v) R" d. ~4 B
LV Write Access read/write
0 v$ a9 M7 K, K4 Q. Y6 MLV Status available( r) V) G* G. N3 o1 u3 b0 y
# open 0; M& ^1 A7 g+ W d8 |- I4 W
LV Size 1.00 GiB6 W, q$ b! k; s- V6 y( A _
Current LE 2562 {+ \* B' U0 q. m
Segments 1
5 F8 s/ X- ]' L: Y4 k3 A" V hAllocation inherit+ q9 R3 R9 _/ ]4 E
Read ahead sectors auto
' v; r/ l! V9 }. F' D# m: P5 u- currently set to 256
4 M% ~: P1 V5 r( `4 MBlock device 252:0 4. 使用多个backend/添加新的LVM backend (1)创建新的volume group vg3 (1)修改cinder.conf,添加下面行: 6 y; r; i2 H z
enabled_backends=lvmdriver-1,lvmdriver-2
/ B% }& D9 b, h R7 [' |, e# `[lvmdriver-2]
* H# a+ R' T( n) Bvolume_group = vg34 r4 J" W" W3 ]9 d8 K; a0 ~
volume_driver = cinder.volume.drivers.lvm.LVMISCSIDriver( ]+ ?- m, I# ?; q2 F. q
volume_backend_name = lvmdriver4vg3 注意: cinder-volume服务不监控该配置文件,除了在启动的时候读取该文件以外。因为在修改该文件后你需要重启该服务:`service cinder-volume restart`. (3)创建新的的volume type type-test s1@dev:~/devstack$ cinder type-create type-test7 N7 s4 |, w" f, ^7 J7 \( O
+--------------------------------------+---------------+
. e' Y4 z8 W! R- x" P| ID | Name |
5 o6 d4 ^+ {" w: R1 S1 n+--------------------------------------+---------------+9 O7 N0 c- u% T' x9 x: ^
| 764480d1-7614-4a63-ba33-924d65765534 | type-test|
2 Q' `* n( Z4 e& P+--------------------------------------+---------------+ (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 A" Y5 A* ~$ U; D# O
(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
7 R+ R t7 ~ P' Q* A; tSTRICT_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
}, H$ s: H3 p/ K7 Z" wBinary Host Zone Status State Updated At5 k& c; c5 ]- J- y# R7 {
cinder-scheduler dev nova enabled :-) 2014-12-12 16:11:54" w& z7 V& }$ b/ M3 x
cinder-volume dev@lvmdriver-1 nova enabled :-) 2014-12-12 16:11:56
- ]) G+ @) \" P+ u原因:cinder-volume的host少了一个对应第二个vg的一个。应该是添加第二个backend后配置没生效。
1 P! `, v; k' j( e Z* [7 r+ J! r解决:按照先后顺序重启 cinder-scheduler 和 cinder-volume 服务。创建volume错误消失。0 n# c/ b6 @9 Y6 y/ H9 z+ v/ z8 w
(2) Volume一直处于creating状态。cinder-volume log中有如下错误:
# |- Q. O: K9 {! t0 ?- |& B- j. yReturning exception create_volume() got an unexpected keyword argument 'source_replicaid' to caller 原因:controller上和storage node上cinder版本不一致。 [size=1em]1 ' C8 n E- w; m5 l' p5 A H8 a
| apt-get install package=version 命令。
! ~) h; k) Q) V3 ~ C* q, B5 n% F+ o2 K4 |6 d
| ; O$ a7 q0 `' Q9 j& X' S: d5 l
& W ^: x- n5 z2 g
& y- a& ?4 }8 }1 l
# z& ~+ K7 R7 H% i
|