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

Openstack对接两套Ceph

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2020-11-28 19:52:37 | 显示全部楼层 |阅读模式
环境说明8 g- L. c( w  j' @6 r
openpstack-Pike对接cephRBD单集群,配置简单,可参考openstack官网或者ceph官网;
3 B7 n. ?4 p. g8 p' \# @1.Openstack官网参考配置:
) }: g5 I' p' Khttps://docs.openstack.org/cinder/train/configuration/block-storage/drivers/ceph-rbd-volume-driver.html9 w& w1 p. P8 c( G5 [0 U
2.Ceph官网参考配置:6 M5 o# K- c; |+ z3 m" R
https://docs.ceph.com/docs/master/install/install-ceph-deploy/. t7 G4 F& e0 r0 Y% E" `
由于物理环境和业务需求变更,当前配置云计算环境要求一套openstack对接后台两套不同版本的cephRBD存储集群;7 p) r& C8 c: J5 q. z6 O
此处以现有以下正常运行环境展开配置;
! h; j/ P- F& _; ?6 S5 C1)openstack-Pike! y0 s1 }* J+ C& ?
2)Ceph Luminous 12.2.5
" I/ f. R$ n& j$ p" ^3)Ceph Nautilus 14.2.7. r( e7 ^* V9 ]" n! @
其中,openstack对接ceph Luminous配置完成,且正常运行。现在此套openstack+ceph环境基础上,新增一套ceph Nautilus存储集群,使openstack能够同时调用两套存储资源。6 B7 a* T* z  L& D9 S% ~/ L

配置步骤
; R/ u! I/ x4 u# c! p  ]1.拷贝配置文件/ L4 h' N+ i  U; u  h
#拷贝配置文件、cinder账户key到openstack的cinder节点7 l7 `# S$ K5 l
/etc/ceph/ceph2.conf* V1 W2 w6 i. s" g# `6 g
/etc/ceph/ceph.client.cinder2.keyring5 M4 z0 e% ^4 L/ v2 d: g8 Q
#此处使用cinder账户,仅拷贝cinder2账户的key即可

2.创建存储池
- D$ c( P3 f1 q! A#OSD添加完成后,创建存储池,指定存储池pg/pgp数,配置其对应功能模式
* l5 w7 q# ]3 t1 d3 F- Fceph osd pool create volumes 512 512
, T4 t( F' ~2 B5 i4 Rceph osd pool create backups 128 128, \7 I$ d& H+ z0 E; A: X) j
ceph osd pool create vms 512 512
: Y( J! t. \. w3 \ceph osd pool create images 128 128

ceph osd pool application enable volumes rbd) n& D5 Q( s7 }3 ]: T, n
ceph osd pool application enable backups rbd
! x1 a; V' X0 w/ c' uceph osd pool application enable vms rbd 7 Y: ^# L  V$ A- I! g% j
ceph osd pool application enable images rbd

3.创建集群访问账户) q- W& b0 G5 V( `* V$ B: P
ceph 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‘
$ H! A4 f" o$ o. a$ Nceph auth get-or-create client.cinder2-backup mon ‘allow r‘ osd ‘allow class-read object_prefix rbd_children, allow rwx pool=backups‘! r/ P* [) T; L; V8 l2 n1 S
ceph auth get-or-create client.glance mon ‘allow r‘ osd ‘allow class-read object_prefix rbd_children, allow rwx pool=images‘

4.查看进程信息$ ]' @$ E2 k4 e6 k
#查看当前openstack的cinder组件服务进程! {" a/ d/ m$ j. V6 ?% }  ~! ~
source /root/keystonerc.admin
9 Q8 Q& O( m' }  mcinder service-list

5.修改配置文件9 I5 s* `4 K% j% A1 X* [
#修改cinder配置文件
* u& [# I; e8 _9 g[DEFAULT]1 w: _: P  F# F+ @
enabled_backends = ceph1,ceph2

[ceph1]
: \# x$ F+ m- h+ L- z7 p. Rvolume_driver = cinder.volume.drivers.rbd.RBDDriver
  C; G0 i# P( a4 ?. ~1 b& M4 kvolume_backend_name = ceph15 `* N- X& m( c- I1 C" ^) T
rbd_pool = volumes14 P1 s/ ]' O4 v* L9 a" C0 U5 j
rbd_ceph_conf = /etc/ceph1/ceph1.conf
% Y) D2 F* k3 g/ O7 V2 Lrbd_flatten_volume_from_snapshot = false
0 h7 E" p. F' Yrbd_max_clone_depth = 5
' V' s8 d; b1 F  I) l" Irados_connect_timeout = -1, o5 P' [: k, N4 I: y/ H
glance_api_version = 2
1 ?# [' w0 W- O8 s# Brbd_user = cinder1, N" y( P# ~$ z: L
rbd_secret_uuid = **

[ceph2], v& t( K, `4 a/ t% a1 Y  c2 D0 i
volume_driver = cinder.volume.drivers.rbd.RBDDriver
; h' i6 B' S+ i3 z( ?! V7 svolume_backend_name = ceph2
2 G4 f) a9 s! Qrbd_pool = volumes2) \2 ], S8 P# F! O: F+ d- w# k2 b& L
rbd_ceph_conf = /etc/ceph/ceph2/ceph2.conf
# Q# N# p* m$ R9 D! ^rbd_flatten_volume_from_snapshot = false
! Z8 S( N5 z( U, Srbd_max_clone_depth = 5
; r4 o8 y9 s7 H* l/ {rados_connect_timeout = -1
7 b* G" h5 x" w4 {( cglance_api_version = 2
3 U0 N9 T- N2 q' W, ~; {8 n8 S2 crbd_user = cinder2
% k4 [5 l& ]& ~5 B" j: e1 c) Brbd_secret_uuid = **

6.重启服务
( W( k- W% S+ Y2 `9 B( y8 ]6 x( V; T#重启cinder-volume服务
* W. g, t( i2 D+ i( lservice openstack-cinder-volume restart Redirecting to /bin/systemctl restart openstack-cinder-volume.service
4 A) q" o& G3 }6 R9 @service openstack-cinder-scheduler restart Redirecting to /bin/systemctl restart openstack-cinder-scheduler.service

7.查看进程& h8 a2 o( U7 H7 Z1 O  t$ s
cinder service-list

8.创建卷测试# m$ O9 h+ P8 K+ P
#卷类型绑定
6 f" O/ R7 }$ q& {3 ^cinder type-create ceph1
. M" e2 Y' ^/ m1 I8 A( Gcinder type-key ceph1 set volume_backend_name=ceph13 J9 Z. C0 B5 @7 p+ M
cinder type-create ceph2
! _3 U7 @* H( |: b! ~cinder type-key ceph2 set volume_backend_name=ceph2

9.查看绑定结果
9 N2 R* i% y! h( c' ycinder create --volume-type ceph1 --display_name {volume-name}{volume-size}
" d' Z1 W# h  d2 j. _% L0 T0 w1 Kcinder create --volume-type ceph2 --display_name {volume-name}{volume-size}

配置libvirt; @! c$ W* ]7 G! {' N
1.将第二套ceph的密钥添加到nova-compute节点的libvirt
9 e* u, \- V# s; L& R2 D- L#为了使VM可以访问到第二套cephRBD云盘,需要在nova-compute节点上将第二套ceph的cinder用户的密钥添加到libvirt9 D5 u$ L0 V- R/ l/ V
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
+ v2 v, e# R5 E/ Mcat > secret2.xml <<EOF0 F' i" V4 K. c& r- F" Z- z: T
<secret ephemeral=‘no‘ private=‘no‘>
8 {8 K' C) {. O<uuid>***</uuid>
! Y% `1 y3 `# \0 @: a  g5 T<usage type=‘ceph‘>0 y9 `$ [/ R" d4 ]& M5 v1 G( |
<name>client.cinder2 secret</name>
/ P' ~: }$ O* k) V/ }# y, u1 G</usage>( A  l! _, A0 O4 v) O
</secret>
/ ~* f; x% g( z1 ?0 @. K#以上整段拷贝执行即可,替换uuid值

sudo virsh secret-define --file secret2.xml

sudo virsh secret-set-value --secret ***** --base64 $(cat client.cinder2.key) rm client.cinder2.key secret2.xml4 `+ y& s! V# Q, I1 w7 Y3 m
#删除提示信息,输入Y即可

2.验证配置是否生效: M5 N$ V% n9 \! p, z( \# g) y+ m
#通过之前创建的两个类型的云盘挂载到openstack的VM验证配置
' Z; g! k0 a% Bnova volume-attach {instance-id}{volume1-id}
; P- ?4 t' s9 D9 `nova volume-attach {instance-id}{volume2-id}

参考资料:
  n0 J. h% \( U( }6 `《ceph设计原理与实现》---谢型果! a$ A$ v+ k5 [( o' R8 S, r
红帽官网
) F7 [6 n* K' A$ }https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/3/html/ceph_block_device_to_openstack_guide/installing_and_configuring_ceph_clients
6 O( V( y' m; |% i4 a( zceph官网+ g3 j$ T- }# A9 s7 C7 y
https://docs.ceph.com/docs/master/install/install-ceph-deploy/


6 d& q, _, E4 v8 c1 ^7 ~9 c- T

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:. y$ C1 z  A: A) h1 z8 D& s
2 z  u4 T& N9 B* a8 r7 e8 P
# yum install python-rbd
  ?, l! a2 s* t! m  d; ?0 `# yum install ceph-common0 |4 Z6 U( m9 d) y" O! m
The glance-api node requires the Python bindings for librbd:) t% a5 {% }+ ~0 b/ f( ^
$ `" ]2 D6 S& r( Y% S
# yum install python-rbd1 n6 K7 W' w3 }& f; v
2.1. Copying Ceph Configuration File to OpenStack Nodes
: ~2 L) j! ]- ~* ^5 v: G$ `* |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.
$ T% r! C/ M! o7 z
$ Y+ d7 T7 R) A2 X# D0 ~# scp /etc/ceph/ceph.conf osp:/etc/ceph
7 o4 N& Z! u0 m3 o3 I2.2. Setting Up Ceph Client Authentication  |  A: t" h! K% p
From a Ceph monitor node, create new users for Cinder, Cinder Backup and Glance.
) n6 f  T/ `! B* O8 J7 n, }2 C# `) D* r, @
# 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'
2 ?. v, B6 j" {5 u" {
. L- }4 j9 g$ ?+ {+ a1 E$ I# ceph auth get-or-create client.cinder-backup mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=backups'! ^$ g$ F; G3 h6 P; P3 `8 n$ S# B6 v
: u* Y6 s4 [! i: m& I3 G
# ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'
" x8 B9 f$ t$ X$ B( k8 QAdd the keyrings for client.cinder, client.cinder-backup and client.glance to the appropriate nodes and change their ownership:
1 ?0 ?, \! [1 W( b$ ~$ j( g& p: [) [% I& o) p9 w, C
# ceph auth get-or-create client.cinder | ssh {your-volume-server} sudo tee /etc/ceph/ceph.client.cinder.keyring
! b- l, B% P. C; @6 ?6 ^" b# ssh {your-cinder-volume-server} chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring( R- n2 b. Z- N2 r
& @3 h0 O1 m* j( r7 p+ q/ V& x- x$ Q
# ceph auth get-or-create client.cinder-backup | ssh {your-cinder-backup-server} tee /etc/ceph/ceph.client.cinder-backup.keyring
" m; ?. j% Q2 S: W# ssh {your-cinder-backup-server} chown cinder:cinder /etc/ceph/ceph.client.cinder-backup.keyring
/ T0 L9 A+ i( @4 \2 n, @. F* f5 H$ ?( D$ C0 R& U
# ceph auth get-or-create client.glance | ssh {your-glance-api-server} sudo tee /etc/ceph/ceph.client.glance.keyring
' d4 V* D0 `$ V1 E! v# ssh {your-glance-api-server} chown glance:glance /etc/ceph/ceph.client.glance.keyring
  Z8 x, ], H5 Q  t2 DNodes running nova-compute need the keyring file for the nova-compute process:! A0 a4 {. p! [' o# |7 `
- W* x  O5 G3 d' F, F
# ceph auth get-or-create client.cinder | ssh {your-nova-compute-server} tee /etc/ceph/ceph.client.cinder.keyring
0 N4 }6 I( s2 T% s3 [- o( LNodes 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:
: R$ ?5 z" e; f* v! ^4 L7 O8 q5 p) I2 g, w
# ceph auth get-key client.cinder | ssh {your-compute-node} tee client.cinder.key) w% E7 H& u1 R
If 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:
8 v6 d; L% R  q- D( S$ J/ @; h3 _& ]- q
# ceph auth caps client.{ID} mon 'allow r, allow command "osd blacklist"' osd '{existing-OSD-user-capabilities}'
" w# p7 e8 y' b( X6 Q( zReturn to the compute node.
/ n( e  M% N; r2 m  Z" d0 l6 a
# ssh {your-compute-node}! m. {& |) v7 j2 l, G  k6 @
Generate a UUID for the secret, and save the UUID of the secret for configuring nova-compute later.
1 N# a7 c9 I' x0 I' y. y
. p, J  I$ K$ @$ @0 q' G# uuidgen > uuid-secret.txt
0 L! F; Q! S- v+ J2 H3 yNOTE( O+ D* n* u5 l1 j4 R* ^! Y' [
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.9 u( p7 T2 l/ r) @
/ K; i. ]% V0 ~2 M7 Z1 V
Then, on the compute nodes, add the secret key to libvirt and remove the temporary copy of the key:
: T5 F, A* t. l  X1 p. F  N, f2 J5 D% Z$ k) i
cat > secret.xml <<EOF
4 y; T* ]2 n0 ?5 g- J8 }<secret ephemeral='no' private='no'>
) Z" P5 K3 e- t% z( s  <uuid>`cat uuid-secret.txt`</uuid>5 U, N& _( F( Q' s+ s0 K; _4 v
  <usage type='ceph'>
- P5 ~6 [2 [4 H5 b- _8 Y    <name>client.cinder secret</name>+ {9 D: Z1 ?" ]+ ~& K) ?. h7 C
  </usage>
0 Q# W( U6 t+ b2 v. ^# ^</secret>0 s' y, B* I8 V
EOF# q6 G- @0 ?3 l$ d
# virsh secret-define --file secret.xml
' o- A! P: Z* ^3 P: K# 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 02:03 , Processed in 0.019194 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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