将设为首页浏览此站
开启辅助访问 天气与日历 收藏本站联系我们切换到窄版

易陆发现论坛

 找回密码
 开始注册
查看: 256|回复: 1
收起左侧

ceph集群与openstack对接

[复制链接]
发表于 2021-7-19 11:06:38 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?开始注册

x

创建cinder并设置权限

[root@controller ceph]# 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'

设置密钥

[root@controller ceph]# ceph auth get-or-create client.cinder | tee /etc/ceph/ceph.client.cinder.keyring
7 v' E& b8 X; y9 I
* v' S% d8 Q+ ^2 d: D& M4 B/ T( V#传送密钥到computer+ c5 Q: @# W- E3 S! m0 w
7 X2 S" y, }! [4 N% m4 w+ j9 w
[root@controller ~]# ceph auth get-key client.cinder > client.cinder.key( ?8 r# l% S. J9 W, q" Q# D. g9 j- v
+ a. `3 N" C, ]$ h6 d
[root@controller ~]# scp client.cinder.key computer:/root/1 V. n0 r7 U" Q4 y3 K
8 B$ B0 D2 S) t/ k
#修改权限
) Z& l* n& W" m# e) I+ R1 k* l- G5 K8 q1 K5 J$ e8 I
[root@controller ceph]# chown  cinder.cinder /etc/ceph/ceph.client.cinder.keyring* v! [) `, V0 L7 l0 i7 U3 S

设置密钥

#computer生成uuid- z9 A% d6 G2 v+ z+ }' B
' C- _" f1 S/ ]
[root@computer ~]#uuidgen
) O+ r4 Q9 _) v, G- Y0 V4 j
9 c0 L( C1 Y& W7 d" ^6 m1fad1f90-63fb-4c15-bfc3-366c6559c1fe #创建密钥文件
$ @- r, d% r- l" N( f+ Z1 ^, `* C. H2 r1 Q
[root@computer ~]# vi secret.xml( l' q$ ?8 j! C
  1fad1f90-63fb-4c15-bfc3-366c6559c1fe   client.cinder secret: E. \2 q9 s; k2 D$ ^! K

- F7 F8 n1 N2 z+ C0 r/ S$ l

% ^+ ^" M0 Q8 E. J  O) z#定义密钥
( E; B8 v( K" ]0 ^/ B: z  X5 Wvirsh secret-define --file secret.xml
! S- W; S. k) \  a* A! D& |# g: F2 u( q' ?; B) [& [5 G; e' l

) v. ^4 f* C; U6 s5 F, d% F& Y#设置密钥
3 A4 N5 f( [! z
2 T9 `: v; s7 q
. T5 Y$ k7 G- {# M& {
virsh secret-set-value --secret 1fad1f90-63fb-4c15-bfc3-366c6559c1fe  --base64 $(cat client.cinder.key) && rm -rf client.cinder.key secret.xml
4 P7 s" N9 ^  q7 e! c1 R
" \1 j. E8 k4 Y! ?( B' |3 t
5 o3 R( F! m! b7 b6 I$ F) u
设置对接cinder模块) t0 B( y/ X0 R# g; Q

修改配置文件

[root@controller ~]# vi /etc/cinder/cinder.conf
( u0 s) p: m2 l/ H9 B% P- y5 @% p( ~4 G
[default]1 P/ Q/ k6 X, J/ d; L. T0 j

4 v$ R9 ?7 l( f! k' T4 }& h" crpc_backend = rabbit& m# U4 n, \5 y  |8 k9 ]8 R2 @7 t
  a/ q/ o1 \$ F; f7 t: G- D
auth_strategy = keystone
6 F- s2 L& {) Q/ J
1 W; T1 L1 B! Ymy_ip = 192.168.8.65( T/ `, i4 d" Y! b/ _' q

( f6 p2 [$ S# Henabled_backends = ceph-1
9 O8 z; S0 X. v) ]! _" s/ d& [, A; j' D
[ceph-1]" M/ H6 Q; V% t* Y& |

8 _' g; L/ k* j8 \) Jdefault_volume_type= ceph-1' g' X: d  X$ K  G

% [) Y) [& t1 l# g. Qglance_api_version = 2  
' w1 o* e- ~4 p: _. e2 }% M) f) L" b) }- r
volume_driver = cinder.volume.drivers.rbd.RBDDriver
- B4 |9 c, G3 n! D9 }
! C/ d: n3 |' y" `+ e- F  K" P1 P+ A" nvolume_backend_name = ceph-1
6 y; U7 ~# C: o8 t7 T2 Z0 M) @& a# o' h: ^. |8 A
rbd_pool = volumes
" n5 t; ]0 U" n% {* h2 Y8 ]9 `/ Q0 _( U- H4 X+ L/ ]+ Z
rbd_ceph_conf = /etc/ceph/ceph.conf
) F* m- G) @% G! w, `8 d* D( h! Y* W
+ k5 \# y$ b. r* O5 s9 erbd_flatten_volume_from_snapshot = false0 H9 g* o. K# K4 H

& C! x  U$ Z' ?0 k. \$ G, Irbd_max_clone_depth = 5# F* {7 K; M8 J# D

' V& R3 Q' t1 U% y1 Jrbd_store_chunk_size = 4
+ V( t' Q( |. l" s5 s7 K1 s8 Q
# w& E* I& T& R9 p. n+ q  Erados_connect_timeout = -1" X3 V/ w$ R4 {

6 g" m' V" k/ o) ^4 ?( W' drbd_user = cinder
: y6 O9 U* j9 m! z' {2 L
, C5 X0 y7 u( G# r3 |" b#对应computer创建的uuid8 X8 A' e3 t, {5 _

+ l5 v9 m  v( s$ A' }  H2 Z+ grbd_secret_uuid = 1fad1f90-63fb-4c15-bfc3-366c6559c1fe
" v" \4 O+ R! Q

同步数据库

#若已经有数据库,对数据库进行删除并重新创建和同步
) W. G7 X2 h* u: B
1 X+ g0 a7 N% V5 R& U2 ~& N( T[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder; D5 {6 |& c6 H- C; x

重启服务

[root@controller ~]# systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service openstack-cinder-volume.service

设置ceph的类型和存储类型

[root@controller ~]# source admin-openrc / P- C- X: b; y2 T$ y- N, |
+ Z# h/ u% T0 O* G2 N% O3 k
[root@controller ~]# cinder type-create  ceph-1
: S! k% G, ~, _$ ?) y! A  m1 Y
8 [5 x$ f. E8 G* }! }4 N7 g8 G' Q[root@controller ~]# cinder type-key ceph set volume_backend_name=ceph-1
9 W9 d; U7 a/ N6 ~0 U
# g: z# Z4 T& t9 {, @; M7 k对接nova-compute模块  k' {. _0 p6 f( T3 l8 f

computer结点修改配置文件

[root@computer ~]# vi /etc.nova/nova.conf5 ?3 _. T, b4 M! w8 j
9 F- r5 ]7 o# `: J, N: `; i
[libvirt]
8 r# ?: y  S2 ]( D4 D8 v# u- t; D5 D0 X8 k% \
virt_type = qemu, P& F* A. R) A$ F

* s8 l- l% h( \inject_password = true
3 T  z! K2 A2 }" Z  x
1 d- h' g+ y8 s6 o+ _inject_partition = -18 u" d4 b: @; z. F& ^4 y4 V
/ k. j" U; z# X
images_type = rbd
' N+ e- l9 u3 N! p
5 h; Q0 ~3 M0 R$ G& P7 limages_rbd_pool = vms( X9 d/ c% j# C& m. p6 p

) f% e1 y4 v7 U# Z; ~0 nimages_rbd_ceph_conf = /etc/ceph/ceph.conf
, S+ w" d# ?! X7 b
# O. L" w; a/ O, l6 R9 J) trbd_user = cinder
, B& B+ T+ ^) P( V+ |+ n4 V* b
) d6 S4 _1 c  P+ Y. {rbd_secret_uuid = 1fad1f90-63fb-4c15-bfc3-366c6559c1fe
; K6 t; \' |" _0 f2 G: r7 g
# P  A" S3 ]6 m/ O' W( Hdisk_cachemodes = "network=writeback"( H- I  Y1 f2 t7 w

% L" U' M: {! N8 L% p0 }live_migration_flag = "VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"2 ~. a& M/ w+ `% n7 D
$ T$ E4 H. Q* {9 a" b3 h
hw_disk_discard = unmap  
; {7 l. x$ u/ ~3 b% z$ H! f/ v, V$ Z- Y: `
[root@computer ~]# vi /etc/ceph/ceph.conf % U: W+ Q+ L4 _  }6 U/ J

/ J. t; [2 G; w% M7 |. g, x[client]
8 m# p, q7 @- o1 M1 d( L4 j! P4 ^" L! }$ w! b
rbd cache=true
4 H1 f# {# D; q  ?: Q! o# H0 H7 d  F3 c/ W8 K8 d. c: L% ^( e
rbd cache writethrough until flush=true2 @/ t( O5 y0 ]- l- ?

& D5 n2 J9 I! X( g, C# \admin socket = /var/run/ceph/guests/$cluster-$type.$id.$pid.$cctid.asok& P' ~2 v1 ]1 w# w
5 d) A9 m7 W1 W" x$ M" G1 X" v
log file = /var/log/qemu/qemu-guest-$pid.log) S6 L: @5 u8 p' @' w5 U" Y
# \: Z: t& W7 X
rbd concurrent management ops = 209 i2 ^/ ?& j% S+ F

创建日志目录

[root@computer ~]# mkdir -p /var/run/ceph/guests/ /var/log/qemu/
& g# ]' A. ]' y( C2 q+ E/ X
8 g3 }( q' ?2 M% U/ K8 ~[root@computer ~]# chown 777 -R /var/run/ceph/guests/ /var/log/qemu/* l8 F: t" [1 g1 g& S/ b- t, Q

controller下发密钥

[root@controller ~]# cd /etc/ceph5 l. [  M4 ]2 `+ R: Z

$ P+ K4 s6 ^. f. t) y* @1 d[root@controller ~]# scp ceph.client.cinder.keyring root@compute01:/etc/ceph2 u3 Q; E: `* I+ b: B# @7 M" G

重启服务

[root@computer ~]# systemctl stop libvirtd openstack-nova-compute
& m9 Z9 M; m. g6 J& H/ F6 C6 [, c. g9 ?# R: N
[root@computer ~]# systemctl start libvirtd openstack-nova-compute- E' ^1 p+ O& D- }2 F

* R" d" Z, g) p5 i; K# t
; ^* }) t* @% U8 l
 楼主| 发表于 2021-7-19 11:13:12 | 显示全部楼层
创建cinder并设置权限2 z) H  S! T6 C5 z+ B/ h
' [9 P2 v$ o" ?" o$ ]3 t
[root@controller ceph]# 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'
) C7 J2 d; w  j7 u+ }. n' U设置密钥
" U+ {! J, P$ W: `
+ H9 e- ?8 o# \* L# u1 I[root@controller ceph]# ceph auth get-or-create client.cinder | tee /etc/ceph/ceph.client.cinder.keyring# d+ k) d' p5 Q

/ ]$ Y0 O, L: I#传送密钥到computer
8 n( T$ T, P. Y9 v; N, W[root@controller ~]# ceph auth get-key client.cinder > client.cinder.key
3 k% D% ?2 T  {& h8 G% n' g[root@controller ~]# scp client.cinder.key computer:/root/+ `# k# E, K  s4 W/ S

, G- ^& z4 q* Z& \9 B7 _#修改权限
! B3 y  q1 |% L8 U3 L! a1 Y[root@controller ceph]# chown  cinder.cinder /etc/ceph/ceph.client.cinder.keyring3 l; g2 d- I8 _/ m# d
设置密钥  t, t/ K8 U- c2 L% T4 Z# C
- o5 S9 \# ^: ]1 F8 k
#computer生成uuid" ]1 O( `% u! D/ l' l' O6 X: a3 M
[root@computer ~]#uuidgen
7 O# \. u& ?" M1fad1f90-63fb-4c15-bfc3-366c6559c1fe
* W$ @+ V) }6 q1 q# [4 o# ~+ d0 |+ D6 R$ ~1 B
#创建密钥文件
. D0 R! e+ V3 X1 `[root@computer ~]# vi secret.xml: J& V$ |3 }" r4 m9 L- |
  1fad1f90-63fb-4c15-bfc3-366c6559c1fe   client.cinder secret) ?0 a3 g* }: s- |" Q4 W
#定义密钥
2 w" `1 B  k7 f) tvirsh secret-define --file secret.xml" P6 C# i+ T3 n( D  W& ~$ m8 w
+ m! @( T& i. s
#设置密钥
5 o0 W. X# P2 svirsh secret-set-value --secret 1fad1f90-63fb-4c15-bfc3-366c6559c1fe  --base64 $(cat client.cinder.key) && rm -rf client.cinder.key secret.xml# i/ x8 x" ?1 p* @
设置对接cinder模块+ {$ [5 M- l4 J/ ~# T5 @* V+ Q) }3 W* p
修改配置文件
$ b1 k' ^: B. s/ D- m  U9 H1 `
( r8 X( m0 e) m( t+ U3 l) `[root@controller ~]# vi /etc/cinder/cinder.conf
% n& f1 @: }. `, l8 v( V[default]
2 P/ s# g) L! ~! V" _rpc_backend = rabbit
  o/ _$ n, V4 ^: gauth_strategy = keystone
0 j7 B$ C0 l. m* q; H5 L! p" wmy_ip = 192.168.29.148+ H) r/ S6 H0 _; T' _
enabled_backends = ceph
# K1 W; w9 D9 v1 R  d3 e
/ o4 A- ]7 L+ C( x7 w; h" o1 l[ceph]
+ z( M' b9 U* gdefault_volume_type= ceph
1 I0 [! K7 R  `1 |+ zglance_api_version = 2  $ O. G% n7 G$ g" k% T; Y
volume_driver = cinder.volume.drivers.rbd.RBDDriver
$ w8 A: S' N0 Q! B: n( e1 @7 tvolume_backend_name = ceph1 Y9 J5 h% q" E* o( {
rbd_pool = volumes
+ c) t* y' \+ H# i0 r! qrbd_ceph_conf = /etc/ceph/ceph.conf
: G; R7 ~, H4 O/ f* ?rbd_flatten_volume_from_snapshot = false8 @+ T& H$ F! }4 g. i2 }9 T2 S4 t
rbd_max_clone_depth = 5) v) _: O3 ~! g
rbd_store_chunk_size = 4
, I0 l* t; [: Irados_connect_timeout = -1
+ G4 m* v1 Z4 e* g9 g9 J8 q# ~rbd_user = cinder
) I2 t$ W  Z, H+ }, J9 Y# Y5 L#对应computer创建的uuid
4 E5 p/ c& D# b6 b  rrbd_secret_uuid = 1fad1f90-63fb-4c15-bfc3-366c6559c1fe 0 D5 c3 ]4 a' M# ~8 }, z- I+ ^
同步数据库
3 D9 [4 U2 s1 j1 j; u: F# w  @* n0 z& ~" Z1 ?. n$ A, f' `
#若已经有数据库,对数据库进行删除并重新创建和同步5 R( z, m* w  O. i
[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
- A& Y4 I8 \$ g; |重启服务
# E7 H  f6 ?- Q. D9 j9 r1 ]" z6 R" b. P) r4 p' h
[root@controller ~]# systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service openstack-cinder-volume.service
1 S8 h" ]: i5 [5 G% z6 s设置ceph的类型和存储类型
6 `% {* K% W. Q/ C  G# |# p7 z/ ^0 l' I0 r( L
[root@controller ~]# source admin-openrc
- [) g- {7 \- {[root@controller ~]# cinder type-create  ceph
6 p7 G4 r: x; c& A[root@controller ~]# cinder type-key ceph set volume_backend_name=ceph; R5 z# a* ?% G4 N, N; Q% C
对接nova-compute模块# r9 V" V2 Y* |
computer结点修改配置文件
& y' E/ H6 L% W/ ~+ {$ Z, @, M) a/ a! K7 t) e
[root@computer ~]# vi /etc.nova/nova.conf
$ [+ o% E4 ?( a# J6 W[libvirt]  @, `( o+ s5 N0 g& X1 ]1 d( K9 D. ~
virt_type = qemu; I8 K+ y$ b; j; B: y$ S" W
inject_password = true
7 ^2 Q+ _9 I3 e& @0 m! {8 }6 Kinject_partition = -1
; Z; d0 D1 d6 I; f- Gimages_type = rbd) b# I0 G" [4 G1 ]7 ]4 T% ?
images_rbd_pool = vms
$ a7 c& q6 t/ E* F1 v$ l: T  fimages_rbd_ceph_conf = /etc/ceph/ceph.conf
: o' T( j' F+ C+ r, g- V5 I$ H8 ~rbd_user = cinder
) }! `0 W/ ^! Q* W4 t& Orbd_secret_uuid = 1fad1f90-63fb-4c15-bfc3-366c6559c1fe
% X3 y. K4 ]& {" r7 n8 Odisk_cachemodes = "network=writeback"
; j  \' ^# b& j' k& k) i0 O1 nlive_migration_flag = "VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"# }4 ^# C. S0 n* c4 x* o1 G
hw_disk_discard = unmap
2 B2 Y3 H2 v& k% Z$ @! [0 f8 V" R[root@computer ~]# vi /etc/ceph/ceph.conf
4 a) V8 a. B, j. a: Y1 |8 x  G[client]+ l1 K0 z, G$ ?+ F; M: I! M) @
rbd cache=true
# w& b# o# l+ Y: O% Wrbd cache writethrough until flush=true$ t' f$ t4 z) s$ q. }) R, y* f8 l
admin socket = /var/run/ceph/guests/$cluster-$type.$id.$pid.$cctid.asok( L; E1 V. S- G8 f/ B* y. f
log file = /var/log/qemu/qemu-guest-$pid.log
3 C  e# v6 n  ]- v$ O9 V- ?rbd concurrent management ops = 20& [* ~$ U  S3 X7 E
创建日志目录
( ?0 n& H8 c0 x% ]5 A& ^
3 \2 t# o$ q* h# g! A$ d8 [4 e[root@computer ~]# mkdir -p /var/run/ceph/guests/ /var/log/qemu/
- }4 b% f5 |$ F1 u[root@computer ~]# chown 777 -R /var/run/ceph/guests/ /var/log/qemu/0 U: g. U. Q5 Q  V
controller下发密钥
1 x5 h4 F  R) w2 G9 w* j  O$ S' v
[root@controller ~]# cd /etc/ceph) g1 P. P; b7 |. Q* h% m: h5 M7 w
[root@controller ~]# scp ceph.client.cinder.keyring root@computer:/etc/ceph1 G5 h9 y$ v3 I! _$ V+ ]+ d/ w- E3 S( g
重启服务# B8 D4 }2 }3 Z5 _& O
0 w9 K+ I6 T6 G% Q$ y
[root@computer ~]# systemctl stop libvirtd openstack-nova-compute
% ~+ [; ?( y* F, z2 ?+ g* h! |[root@computer ~]# systemctl start libvirtd openstack-nova-compute
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

如有购买积分卡请联系497906712

QQ|返回首页|Archiver|手机版|小黑屋|易陆发现 点击这里给我发消息

GMT+8, 2021-9-27 02:06 , Processed in 0.072932 second(s), 24 queries .

Powered by LR.LINUX.cloud bbs168x X3.2 Licensed

© 2012-2022 Comsenz Inc.

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