找回密码
 注册
查看: 4459|回复: 1

Openstack对接两套Ceph

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2020-11-28 19:52:37 | 显示全部楼层 |阅读模式
环境说明* M7 v, a! C; B( K1 H
openpstack-Pike对接cephRBD单集群,配置简单,可参考openstack官网或者ceph官网;
6 X7 D0 k2 z& p8 g1.Openstack官网参考配置:
7 g+ P/ ?: a9 Mhttps://docs.openstack.org/cinder/train/configuration/block-storage/drivers/ceph-rbd-volume-driver.html
: m+ Q/ a$ T9 g8 K% Y' N1 j2.Ceph官网参考配置:
/ W1 Z( a5 k5 p1 S; n' g  p1 @https://docs.ceph.com/docs/master/install/install-ceph-deploy/7 q4 B; N4 w6 r, X6 z, x  u6 |) b/ N
由于物理环境和业务需求变更,当前配置云计算环境要求一套openstack对接后台两套不同版本的cephRBD存储集群;4 w$ m% u* g  j7 R/ F
此处以现有以下正常运行环境展开配置;( T% z5 p) V0 x( q+ E
1)openstack-Pike
, J9 K2 Z) `. Y* H; K; ]7 _2 C2)Ceph Luminous 12.2.5
4 K  Q; u: Z& }1 \& r5 s9 G: n3)Ceph Nautilus 14.2.7/ m% P# q: O# z5 o7 \
其中,openstack对接ceph Luminous配置完成,且正常运行。现在此套openstack+ceph环境基础上,新增一套ceph Nautilus存储集群,使openstack能够同时调用两套存储资源。& t5 j  J4 n6 e" }" V% ?7 q

配置步骤
0 ~0 X/ Y3 B' ~# K4 [; c1.拷贝配置文件
9 U$ f. |, X0 }4 _#拷贝配置文件、cinder账户key到openstack的cinder节点5 M, ?$ K# D( a: k; \% K  z
/etc/ceph/ceph2.conf7 e  E( E% w$ B; i( ~
/etc/ceph/ceph.client.cinder2.keyring
& K7 {$ P2 l0 r#此处使用cinder账户,仅拷贝cinder2账户的key即可

2.创建存储池2 d2 C: `$ ?3 r/ G) g0 a6 I- c- _3 @
#OSD添加完成后,创建存储池,指定存储池pg/pgp数,配置其对应功能模式
; l& L4 o* Q4 L+ w1 e7 S# \2 c( Z% rceph osd pool create volumes 512 512
; j0 I0 J, l4 a! \; bceph osd pool create backups 128 1282 l( l$ @4 b5 [4 c- \  a7 }& R! ?
ceph osd pool create vms 512 512. R* U: ^1 E/ d5 A+ L3 g
ceph osd pool create images 128 128

ceph osd pool application enable volumes rbd
- Y5 ~1 \, ?( {- L( f! q! U% `7 tceph osd pool application enable backups rbd# s7 ^' ]* h; M1 ?) k6 O/ G
ceph osd pool application enable vms rbd 6 N- n; ?' e8 i6 a5 l+ p9 N
ceph osd pool application enable images rbd

3.创建集群访问账户
$ ^, r9 W) C7 H* Y8 _; Nceph auth get-or-create client.cinder2 mon ‘allow r‘ osd ‘allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rwx pool=vms, allow rx pool=images‘; Z  D; H. j8 W5 F
ceph auth get-or-create client.cinder2-backup mon ‘allow r‘ osd ‘allow class-read object_prefix rbd_children, allow rwx pool=backups‘
; V1 ?2 m+ Y) T" q) Uceph auth get-or-create client.glance mon ‘allow r‘ osd ‘allow class-read object_prefix rbd_children, allow rwx pool=images‘

4.查看进程信息
! F( M& f' O3 G: E#查看当前openstack的cinder组件服务进程
# ]' S1 z5 m  E! e! X5 G! T/ csource /root/keystonerc.admin6 u& v9 S) g& X  @
cinder service-list

5.修改配置文件
& y1 a. s9 z8 Z% B8 d$ B#修改cinder配置文件
$ ]3 @0 p( y# q: }% f[DEFAULT]) Z, G. B( q9 q' ^
enabled_backends = ceph1,ceph2

[ceph1]
( H, s- r' M' T+ S( J: Xvolume_driver = cinder.volume.drivers.rbd.RBDDriver8 n0 P& }, f2 z; E3 l1 L, C
volume_backend_name = ceph1
; V' l- l$ ]. p1 hrbd_pool = volumes1- y" u: g  F0 Z7 y7 {8 d
rbd_ceph_conf = /etc/ceph1/ceph1.conf
# L+ F7 |  z! c- ?4 f* Qrbd_flatten_volume_from_snapshot = false; s0 @3 Q5 j1 e9 W/ A, R) C
rbd_max_clone_depth = 5$ L5 }: e& M2 e  V' _2 S7 ]) Y8 p
rados_connect_timeout = -1) c6 k9 u! U+ O5 b6 h
glance_api_version = 2
3 `$ \0 a" d& P/ ]rbd_user = cinder1$ m1 I+ Z/ t" K* J* e9 T' W4 S" {
rbd_secret_uuid = **

[ceph2]
- Y' K+ n& l6 Y% d, m* [) l7 bvolume_driver = cinder.volume.drivers.rbd.RBDDriver! L; S+ V7 D. M8 N
volume_backend_name = ceph2
1 [1 W% y6 c  H5 p, `: ~rbd_pool = volumes2: }, \( W: ]# q6 A) b
rbd_ceph_conf = /etc/ceph/ceph2/ceph2.conf
; J1 m5 y/ g# l( orbd_flatten_volume_from_snapshot = false
( Y2 w9 ~. V/ A0 yrbd_max_clone_depth = 5# @+ z( P# _4 r! w% }2 L- u: ?
rados_connect_timeout = -10 e- `6 ^$ R) F- E, _
glance_api_version = 2& T, s9 S. }5 h
rbd_user = cinder24 G* U) K# L1 `- ]7 y! n
rbd_secret_uuid = **

6.重启服务
2 v6 v" |) {2 q/ P7 N2 n#重启cinder-volume服务1 R0 d5 \3 U) P1 m
service openstack-cinder-volume restart Redirecting to /bin/systemctl restart openstack-cinder-volume.service
1 n) R9 ^: U( n1 S* k( v2 Dservice openstack-cinder-scheduler restart Redirecting to /bin/systemctl restart openstack-cinder-scheduler.service

7.查看进程
! {- T& o- q+ q6 H- S8 Fcinder service-list

8.创建卷测试3 ]4 q6 l- h2 W$ Y5 V
#卷类型绑定
0 t: j0 |* ^+ [; W8 i: |1 l  ycinder type-create ceph16 U! \; n/ p* t% q  ?
cinder type-key ceph1 set volume_backend_name=ceph16 P# N0 l  |" [; @9 A$ J5 p
cinder type-create ceph2
" V. K' h  U! q) ]5 ^/ Ocinder type-key ceph2 set volume_backend_name=ceph2

9.查看绑定结果, {+ I5 f4 u9 i  ^% Q
cinder create --volume-type ceph1 --display_name {volume-name}{volume-size}
9 p$ C, t, s! B/ W% t& j8 hcinder create --volume-type ceph2 --display_name {volume-name}{volume-size}

配置libvirt
5 K) b8 e& M, }$ p$ F7 A; G, C! D1.将第二套ceph的密钥添加到nova-compute节点的libvirt& B2 r; I/ W& Q- L( P) \" e
#为了使VM可以访问到第二套cephRBD云盘,需要在nova-compute节点上将第二套ceph的cinder用户的密钥添加到libvirt+ I/ L; }' G' i, c1 i5 T
ceph -c /etc/ceph2/ceph2/ceph2.conf -k /etc/ceph2/ceph.client.cinder2.keyring auth get-key client.cinder2 |tee client.cinder2.key

#绑定之前cinder.conf中第二个ceph集群的uuid. g& A2 P. x7 r$ d
cat > secret2.xml <<EOF8 [. z* y# ^; s9 X% f
<secret ephemeral=‘no‘ private=‘no‘>$ P4 q$ k) u2 T$ S, t
<uuid>***</uuid>1 ?$ |- B) E/ `5 N
<usage type=‘ceph‘>8 c% `7 j) H6 J& d- I$ G3 a4 g1 O
<name>client.cinder2 secret</name>
, r) _+ X: ^( Q</usage>
% d5 I# s1 l) o7 X' F2 w</secret>
3 y$ I* r4 B9 l3 R2 f3 ]7 t#以上整段拷贝执行即可,替换uuid值

sudo virsh secret-define --file secret2.xml

sudo virsh secret-set-value --secret ***** --base64 $(cat client.cinder2.key) rm client.cinder2.key secret2.xml' C" o( ?' d( K; L  b
#删除提示信息,输入Y即可

2.验证配置是否生效- v8 W  f+ Y3 [* E) N0 ~# L" m
#通过之前创建的两个类型的云盘挂载到openstack的VM验证配置
2 ~- _" H) K( w- L1 E" n. T3 S7 |/ \nova volume-attach {instance-id}{volume1-id}7 Z1 @- r. ]4 K" S
nova volume-attach {instance-id}{volume2-id}

参考资料:# _9 i" j. M- z6 O; g: ^
《ceph设计原理与实现》---谢型果
- j- n' N0 H$ N; M红帽官网
' K: F9 u2 z4 k" _https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/3/html/ceph_block_device_to_openstack_guide/installing_and_configuring_ceph_clients5 K  ?0 y% ]$ l
ceph官网
  v, k7 M$ P4 m% b! whttps://docs.ceph.com/docs/master/install/install-ceph-deploy/

; R0 E$ r# G2 f  N

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2020-11-28 20:44:58 | 显示全部楼层
The nova-compute, cinder-backup and on the cinder-volume node require both the Python bindings and the client command line tools:
; s4 e& ^' k  p) Z; \1 X% h
+ i" V1 s+ |) D4 B! `! ]8 @# yum install python-rbd0 R5 i$ q% |# D$ o
# yum install ceph-common
3 }5 l& U' l6 d3 rThe glance-api node requires the Python bindings for librbd:/ p1 W- i( i  ~6 Z; g, ~

. ~* l) y6 q% n) P8 f8 k: ]# yum install python-rbd
) t. t; X0 [2 s# D2.1. Copying Ceph Configuration File to OpenStack Nodes; p) K1 C! c2 ^: g2 ~
The nodes running glance-api, cinder-volume, nova-compute and cinder-backup act as Ceph clients. Each requires the Ceph configuration file. Copy the Ceph configuration file from the monitor node to the OSP nodes.+ s) ~! y1 Q0 H

, b" Y3 ^; l- v5 l# scp /etc/ceph/ceph.conf osp:/etc/ceph. U4 K+ c; d! O( S, J, ]. K
2.2. Setting Up Ceph Client Authentication
# Q% q& ^( V, v: CFrom a Ceph monitor node, create new users for Cinder, Cinder Backup and Glance.8 x* U+ j9 z, N

# c" Z* x2 \; s; I( u! L# ceph auth get-or-create client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rwx pool=vms, allow rx pool=images'$ P. G4 C2 S/ {0 N+ t0 S7 z4 y; X

# l: i8 f4 L: e* _. Z6 \+ Q6 e# ceph auth get-or-create client.cinder-backup mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=backups'7 F% r9 U* I, v7 F; O
- Z( f% E: g  q8 W- i9 w
# ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'- r4 ^! T" i$ I- @: @
Add the keyrings for client.cinder, client.cinder-backup and client.glance to the appropriate nodes and change their ownership:
' R4 S2 P: k) n0 F# G$ O) E+ D5 p# }5 e/ X9 O" }
# ceph auth get-or-create client.cinder | ssh {your-volume-server} sudo tee /etc/ceph/ceph.client.cinder.keyring
/ F8 n8 J! i4 G3 v. N( }# ssh {your-cinder-volume-server} chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring, U" B  y: ]8 G# x8 H8 c2 J
6 @; |8 b4 p6 P4 q0 l
# ceph auth get-or-create client.cinder-backup | ssh {your-cinder-backup-server} tee /etc/ceph/ceph.client.cinder-backup.keyring
0 x3 ^' a2 C& Z5 ]# ssh {your-cinder-backup-server} chown cinder:cinder /etc/ceph/ceph.client.cinder-backup.keyring
  X3 `. R9 ~0 @4 N4 I9 u! a5 i- c$ y0 G
# ceph auth get-or-create client.glance | ssh {your-glance-api-server} sudo tee /etc/ceph/ceph.client.glance.keyring
( A/ [" t+ P) w6 Y7 d% d. e' P9 ?# ssh {your-glance-api-server} chown glance:glance /etc/ceph/ceph.client.glance.keyring) m! ?' p0 s9 V) k6 d9 g
Nodes running nova-compute need the keyring file for the nova-compute process:
! Q7 b8 b+ ~! w1 B& E# {) ]
* l" b$ |: Z3 X  v0 E+ b! B2 V# ceph auth get-or-create client.cinder | ssh {your-nova-compute-server} tee /etc/ceph/ceph.client.cinder.keyring7 B9 n" j5 c9 `, J+ M5 N2 X
Nodes running nova-compute also need to store the secret key of the client.cinder user in libvirt. The libvirt process needs it to access the cluster while attaching a block device from Cinder. Create a temporary copy of the secret key on the nodes running nova-compute:
+ j" z3 u. Y6 _; h% d; j
) i# r7 U6 d# u) E7 I6 [# ceph auth get-key client.cinder | ssh {your-compute-node} tee client.cinder.key
) a0 W7 t" g: E! s* DIf the storage cluster contains Ceph Block Device images that use the exclusive-lock feature, ensure that all Ceph Block Device users have permissions to blacklist clients:
4 J' `, \% A0 s  k5 S
6 d3 y  v* }/ _$ z# ceph auth caps client.{ID} mon 'allow r, allow command "osd blacklist"' osd '{existing-OSD-user-capabilities}', `4 t) @3 k! j
Return to the compute node.
' ?1 X! L' d% M3 y: n
" P* N( m! S8 F* |# F# ssh {your-compute-node}% U2 q: A' ^" t# x5 X
Generate a UUID for the secret, and save the UUID of the secret for configuring nova-compute later.$ L% K+ q$ N# C& d
- m" i" T1 B4 w: ~% v2 u
# uuidgen > uuid-secret.txt' m% P) m- \! V7 S3 w- M) }2 }
NOTE% ?& G2 l$ d+ Y+ B% Y2 ^
You don’t necessarily need the UUID on all the compute nodes. However from a platform consistency perspective, it’s better to keep the same UUID.
" I5 |- B6 a/ t6 |& m7 Z2 r+ \+ Z' P7 s8 B1 B4 n+ n* l
Then, on the compute nodes, add the secret key to libvirt and remove the temporary copy of the key:$ T- V& i5 a' w: z# r
6 [1 J& Z4 e) a* r# L, e" T
cat > secret.xml <<EOF" r/ G4 N. H# ?5 B: ^
<secret ephemeral='no' private='no'>  x6 L8 v' N5 w
  <uuid>`cat uuid-secret.txt`</uuid>3 a" x" x. a$ m7 @; d
  <usage type='ceph'>( l  i5 N" O. _# F
    <name>client.cinder secret</name>+ E. a8 F& ?0 T" p* M
  </usage>
3 L, [( z, Y: W3 _9 ]</secret>3 I3 c" l* ~2 y& M" ^: ~. H$ v
EOF
6 L4 ~$ w! t( e6 {# virsh secret-define --file secret.xml
0 i- ?1 r" A5 o. }' d+ g# virsh secret-set-value --secret $(cat uuid-secret.txt) --base64 $(cat client.cinder.key) && rm client.cinder.key secret.xml
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:05 , Processed in 0.015882 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表