找回密码
 注册
查看: 2848|回复: 0

Ceph主要配置参数详解,ceph优化

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-7-9 13:27:27 | 显示全部楼层 |阅读模式
概述
9 k4 o. M+ z( s) h* D, o3 R/ r0 RCeph的配置参数很多,从网上也能搜索到一大批的调优参数,但这些参数为什么这么设置?设置为这样是否合理?解释的并不多, m5 v1 ~! `. C- V  _
本文从当前我们的ceph.conf文件入手,解释其中的每一项配置,做为以后参数调优和新人学习的依据;
  c2 @( f& s2 w# q) p7 I参数详解! J6 |- Y1 F% V* h" M
1,一些固定配置参数
. h* A0 f: y% x% A2 }2 m! T8 |; b  E/ w) N1 N1 U
fsid = 6d529c3d-5745-4fa5-be5f-3962a8e8687c
# L1 {- [# a" b& Y6 ?mon_initial_members = mon1, mon2, mon3
& l5 [; L8 Z' u1 z: emon_host = 10.10.40.67,10.10.40.68,10.10.40.69
" @( x, W, O; I以上通常是通过ceph-deploy生成的,都是ceph monitor相关的参数,不用修改;1 @) G  z3 T( P
2,网络配置参数/ N+ Q9 p) o+ ^
2 v- x9 i. o; o. D2 K5 I8 H3 K3 H
public_network = 10.10.40.0/24    默认值 ""+ E/ p: a" D, k0 @7 a& N
cluster_network = 10.10.41.0/24  默认值 """ k7 a" q0 O: O* r
public network:monitor与osd,client与monitor,client与osd通信的网络,最好配置为带宽较高的万兆网络;
3 N5 B) o/ D9 g" o2 }cluster network:OSD之间通信的网络,一般配置为带宽较高的万兆网络;# B$ B' e6 F8 u* L: b! S4 s
参考:
) U  O* [3 P% b4 K( ghttp://docs.ceph.com/docs/master/rados/configuration/network-config-ref/' h% B' ]/ I0 ?5 T. B9 x; C# k& N
3,pool size配置参数+ k* [" p/ b$ j

) r, A8 s* t  @osd_pool_default_size = 3       默认值 3
& Y; k* W0 t! i# @6 v! |osd_pool_default_min_size = 1  默认值 0 // 0 means no specific default; ceph will use size-size/2
! D- x% f4 h4 C' r& f0 u这两个是创建ceph pool的时候的默认size参数,一般配置为3和1,3副本能足够保证数据的可靠性;
. U1 T) r4 U: i/ W& z4,认证配置参数8 |$ B0 G! S% X5 @6 g/ h
" ~+ j& s0 N' I) D
auth_service_required = none    默认值 "cephx"- A& e( s* W% F
auth_client_required = none     默认值 "cephx, none"0 G. |6 U/ f7 T# x& ~1 `
auth_cluster_required = none   默认值 "cephx"4 {) U8 X& _5 i7 E  c+ T
以上是Ceph authentication的配置参数,默认值为开启ceph认证;+ [0 B+ [) g$ F3 m  v: p. Z
在内部使用的ceph集群中一般配置为none,即不使用认证,这样能适当加快ceph集群访问速度;
% ?1 Q9 C1 e+ z) Q- T$ l5,osd down out配置参数
+ \; V; y* ]) N# T, w% X4 g
% u+ e9 {  n' y9 Emon_osd_down_out_interval = 864000  默认值 300 // seconds
+ e/ j- [( _6 r( e2 U0 u$ Z+ Umon_osd_min_down_reporters = 2      默认值 2
$ ]9 \" K7 i; G# p/ C2 h3 T& Kmon_osd_report_timeout = 900        默认值 900
: o, l% Y! e; ?8 w: mosd_heartbeat_interval = 15         默认值 6. ~9 _: e& T" ~& D* J$ h3 H
osd_heartbeat_grace = 60            默认值 208 v0 w* k2 B& e
mon_osd_down_out_interval:ceph标记一个osd为down and out的最大时间间隔
2 B- ^' t" p1 t3 bmon_osd_min_down_reporters:mon标记一个osd为down的最小reporters个数(报告该osd为down的其他osd为一个reporter)
1 ?  J  R( |+ hmon_osd_report_timeout:mon标记一个osd为down的最长等待时间
( W  x& _0 d% h8 Zosd_heartbeat_interval:osd发送heartbeat给其他osd的间隔时间(同一PG之间的osd才会有heartbeat)
9 O+ ?+ v1 M3 p! K( G% ?0 r0 m$ }% ^' Sosd_heartbeat_grace:osd报告其他osd为down的最大时间间隔,grace调大,也有副作用,如果某个osd异常退出,等待其他osd上报的时间必须为grace,在这段时间段内,这个osd负责的pg的io会hang住,所以尽量不要将grace调的太大。4 I% v  f. {7 m: q2 Y. w2 u- b8 D
基于实际情况合理配置上述参数,能减少或及时发现osd变为down(降低IO hang住的时间和概率),延长osd变为down and out的时间(防止网络抖动造成的数据recovery);
7 e* `. j# Q2 o参考:
: W5 a4 O4 F& T( d" Rhttp://docs.ceph.com/docs/master/rados/configuration/mon-osd-interaction/
9 W- P, ~$ R+ ]2 thttp://blog.wjin.org/posts/ceph-osd-heartbeat.html8 a) C( {- `1 B9 L7 A! y* H8 D
6,objecter配置参数
: ^; L  N& L2 Q! F$ b( x
  I$ L5 Z) o& d7 u/ D7 t6 D( Pobjecter_inflight_ops = 10240               默认值 1024  |& q. f1 F; h$ Q1 v) Q* J. o
objecter_inflight_op_bytes = 1048576000     默认值 100M; u- ]6 k+ H! o, ]5 Q8 j% x
osd client端objecter的throttle配置,它的配置会影响librbd,RGW端的性能;
+ A6 Z, n: c* w/ X( _8 Y& \配置建议:
, @  e4 D) F/ |6 s0 C5 r调大这两个值
2 j) Q! A  I4 p4 q; O7 N! b6 A: f7,ceph rgw配置参数
: R0 ~  z) |+ @, ^3 m* c4 [
3 y7 ]" a9 t0 r7 t* jrgw_frontends = "civetweb port=10080 num_threads=2000"  默认值 "fastcgi, civetweb port=7480"% [. |) F8 l: \7 v
rgw_thread_pool_size = 512                              默认值 100
# t5 L+ F) I6 G4 [, Vrgw_override_bucket_index_max_shards = 20               默认值 05 F& f+ P2 s& v
/ U1 t+ ?/ t3 t  H8 p* r; _0 L; o
rgw_max_chunk_size = 1048576                            默认值 512 * 1024# t8 w$ W' `# b/ V
rgw_cache_lru_size = 1000000                            默认值 10000 // num of entries in rgw cache
6 x- T- Q! O7 e; C6 Drgw_bucket_default_quota_max_objects = 10000000         默认值 -1 // number of objects allowed
; E$ y- Y  p/ U  8 I9 A+ `  [* _; R  ~1 E
rgw_dns_name = object-storage.ffan.com                  默认值
5 y4 A( `6 q9 D$ |% S6 `1 Vrgw_swift_url = http://object-storage.ffan.com          默认值/ @6 `9 l& h. t% S% S7 ?
rgw_frontends:rgw的前端配置,一般配置为使用轻量级的civetweb;prot为访问rgw的端口,根据实际情况配置;num_threads为civetweb的线程数;( W+ l; _* K' H) h" m
rgw_thread_pool_size:rgw前端web的线程数,与rgw_frontends中的num_threads含义一致,但num_threads 优于rgw_thread_pool_size的配置,两个只需要配置一个即可;
% H2 ]" E$ r& r& {( O0 |/ a4 Rrgw_override_bucket_index_max_shards:rgw bucket index object的最大shards数,增大这个值能减少bucket index object的访问时间,但也会加大bucket的ls时间;
: ]0 S. ?8 K3 |8 z4 |% urgw_max_chunk_size:rgw最大chunk size,针对大文件的对象存储场景可以把这个值调大;+ b- x( i! y' r0 I: r# q' u0 D
rgw_cache_lru_size:rgw的lru cache size,对于读较多的应用场景,调大这个值能加快rgw的响应速度;2 f. t" ]) g. o% {2 O
rgw_bucket_default_quota_max_objects:配合该参数限制一个bucket的最大objects个数;
4 u  I# e5 I; Q  @/ A. d参考:/ G& U( H) u# K; r5 L; v2 U5 w
http://docs.ceph.com/docs/jewel/install/install-ceph-gateway/
$ x# l! f' H* N5 F3 f  w9 shttp://ceph-users.ceph.narkive.com/mdB90g7R/rgw-increase-the-first-chunk-size$ M* u. x! f: b2 n4 u
https://access.redhat.com/solutions/2122231* I( A3 ~  {7 u; L! k# {
8,debug配置参数
) T- ]. n7 j; g) Q7 b9 {; d/ ]: x& O* ~5 N8 l* z3 e3 V
debug_lockdep = 0/0% o/ M1 K, z- Y% ~' b- B* i9 ?
debug_context = 0/0: ], b% y; ^+ m: ^) b
debug_crush = 0/0# B7 y8 H# {1 n# x; s9 }$ H. p
debug_buffer = 0/0* G' K2 p" o* Z1 `4 }
debug_timer = 0/0+ d" s" Q+ n6 J0 C, c; F! t2 M& s
debug_filer = 0/0
9 a. [/ G- z  z8 Z6 \& B+ D; x" @* Kdebug_objecter = 0/0
# G4 s- m6 L! S1 X+ {2 d$ Gdebug_rados = 0/0
8 O. p6 d6 {8 ddebug_rbd = 0/0
# L+ B" ^% _% }- Idebug_journaler = 0/08 A, n1 R1 l3 ~/ R4 p7 [
debug_objectcatcher = 0/06 [  n1 ?( R5 U2 u0 k7 a, B
debug_client = 0/08 [* C' D  [2 o7 w# q
debug_osd = 0/00 K& n6 ^* W7 F% s0 {
debug_optracker = 0/0
; s4 R" Q( `& e$ Hdebug_objclass = 0/0
- m2 Z" J% }# J1 n: D/ f# C* _debug_filestore = 0/00 A$ V. J8 ^9 @2 ?$ _' `5 i
debug_journal = 0/0" a9 c+ m, h+ k, r+ S5 k0 S: z0 S
debug_ms = 0/0
# o6 \+ T2 t! }* j/ V+ ldebug_mon = 0/0/ E: t; A8 S6 W/ x) ~8 ]0 k
debug_monc = 0/0
4 g- m3 W& u* K* a# R* S% pdebug_tp = 0/0
1 H% `: h' R* tdebug_auth = 0/0
+ U, F( U  @& G! q$ Sdebug_finisher = 0/06 \/ E' O: g1 ~8 Y6 ^% o
debug_heartbeatmap = 0/0
8 b' @8 v. T. H) H) C: b, ndebug_perfcounter = 0/0" z4 m7 }5 |0 e3 A4 n
debug_asok = 0/0& H2 X  G9 s6 A* f5 I& G; i- \
debug_throttle = 0/0, A9 `# m. G8 `% M5 A$ _1 A+ G9 d
debug_paxos = 0/0/ g8 I( @- M5 l: B3 {
debug_rgw = 0/0
) O+ b8 b% u: U# f& ]/ e- f关闭了所有的debug信息,能一定程度加快ceph集群速度,但也会丢失一些关键log,出问题的时候不好分析;3 }( Q' s: M0 z; d& D% F
参考:5 r. q/ ?' ~4 D  O1 R1 p6 f
http://www.10tiao.com/html/362/201609/2654062487/1.html3 [# b2 w) v) ~! M5 r6 Q
9,osd op配置参数  A0 C1 C, [/ l8 U( a4 L. f

; n2 \: j  N! I& J! a& Bosd_enable_op_tracker = false       默认值 true5 w4 o- R+ T$ k* r4 f* F
osd_num_op_tracker_shard = 32       默认值 32* j) N2 E& X: B$ w) Z; i% t# q0 W/ N
osd_op_threads = 10                 默认值 2
+ P  h; I( @! H& B: I4 m( K  qosd_disk_threads = 1                默认值 1% |* h5 P* X( _' o, O9 W* o3 E
osd_op_num_shards = 32                 默认值 5
# t7 j9 x2 b; x$ h% U8 posd_op_num_threads_per_shard = 2    默认值 2
5 H3 \% e+ O6 d/ I2 }' B; losd_enable_op_tracker:追踪osd op状态的配置参数,默认为true;不建议关闭,关闭后osd的 slow_request,ops_in_flight,historic_ops 无法正常统计;' ~) M1 a- w; Q1 p
; I; R$ R3 z8 V
# ceph daemon /var/run/ceph/ceph-osd.0.asok dump_ops_in_flight
. p# c6 ^; |" Z8 h* a, iop_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck.  Please enable "osd_enable_op_tracker", and the tracker will start to track new ops received afterwards.$ [6 B3 B3 N. j& ^9 w0 g
# ceph daemon /var/run/ceph/ceph-osd.0.asok dump_historic_ops, ?6 p; k) x/ _+ i2 r
op_tracker tracking is not enabled now, so no ops are tracked currently, even those get stuck.  Please enable "osd_enable_op_tracker", and the tracker will start to track new ops received afterwards.
' G* U& p: i2 \. R+ O( N打开op tracker后,若集群iops很高,osd_num_op_tracker_shard可以适当调大,因为每个shard都有个独立的mutex锁;
* Z8 O4 V+ |7 o& ]$ w+ h. l% [7 `: Y; l$ O

( d, @/ A( i2 u8 B3 x1 `class OpTracker {
. A! Q% s) b$ _0 d# {* A..." l- z0 q# I3 H, S
    struct ShardedTrackingData {/ g5 p9 J8 R4 L- u) t. R
        Mutex ops_in_flight_lock_sharded;* _! D! x0 [+ f( _
        xlist<TrackedOp *> ops_in_flight_sharded;
* `  k' ^9 W/ \. {8 f        explicit ShardedTrackingData(string lock_name):
. [3 Y8 g$ b2 Y1 Z9 R* R            ops_in_flight_lock_sharded(lock_name.c_str()) {}3 S" v4 k8 D% S% Y  z' n* l
    };
+ G% ?& V( o. e' @3 E2 D# g2 C& b    vector<ShardedTrackingData*> sharded_in_flight_list;5 d) X7 V/ G& A9 V5 B# W5 r( E
    uint32_t num_optracker_shards;
' N4 Q9 k, Q9 W2 z...
9 P% z4 Q: R4 I};& n' O) d8 B2 X$ d
osd_op_threads:对应的work queue有peering_wq(osd peering请求),recovery_gen_wq(PG recovery请求);+ b" U7 I! T. x0 A# Q
osd_disk_threads:对应的work queue为 remove_wq(PG remove请求);
& |  L2 `9 {6 i  M# zosd_op_num_shards和osd_op_num_threads_per_shard:对应的thread pool为osd_op_tp,work queue为op_shardedwq;. v1 ^, Z: t4 D& n9 _7 l
处理的请求包括:. p3 \9 K5 n1 Z: J
OpRequestRef8 d  h2 P0 ~. ]
PGSnapTrim  w: n* @. a6 I( i) ?
PGScrub3 n, X' L) K- |- [. x
调大osd_op_num_shards可以增大osd ops的处理线程数,增大并发性,提升OSD性能;
: N/ v: k2 A' q5 Q" o10,osd client message配置参数
7 ^8 ^/ H* k* t1 E1
+ l* S5 f+ W: j7 c: ~& Z2
9 U& G8 t/ v. rosd_client_message_size_cap = 1048576000    默认值 500*1024L*1024L     // client data allowed in-memory (in bytes)
' L" m7 u2 h; ^+ l: C6 ?6 a( kosd_client_message_cap = 10000              默认值 100     // num client messages allowed in-memory" {* w0 G" b. s1 ~! L& b* S
这个是osd端收到client messages的capacity配置,配置大的话能提升osd的处理能力,但会占用较多的系统内存;& c* f' q9 Q" E3 n3 C
配置建议:
6 K; x# }3 i2 ?服务器内存足够大的时候,适当增大这两个值; v6 F$ f7 K7 ]+ v3 v6 j( ^, \
11,osd scrub配置参数
, o7 q' g4 j0 r0 k4 a$ M
' V' N2 _$ K& mosd_scrub_begin_hour = 2                默认值 0" {! S5 i# {' y
osd_scrub_end_hour = 6                   默认值 24
4 R* w" E* M- A3 n
6 o, v- {! n: `7 k% W& Y// The time in seconds that scrubbing sleeps between two consecutive scrubs
8 p6 F, b8 [; e( I% s0 X# Yosd_scrub_sleep = 2                       默认值 0        // sleep between [deep]scrub ops1 y; y. m& u8 B/ \$ Q3 Q1 ]
) T7 ?! A: u, [
osd_scrub_load_threshold = 5            默认值 0.57 G' a6 f* Q4 N! n9 l# _
  ' z9 ?5 z4 E+ w4 R
// chunky scrub配置的最小/最大objects数,以下是默认值
4 ]% x3 S2 [  \0 `2 V% fosd_scrub_chunk_min = 5; ]2 q) A2 I6 b9 n, _+ M' ~$ o1 W
osd_scrub_chunk_max = 25
. q' u/ x# B4 F  u9 s% O  BCeph osd scrub是保证ceph数据一致性的机制,scrub以PG为单位,但每次scrub回获取PG lock,所以它可能会影响PG正常的IO;; K6 k4 R3 z4 g/ u+ `; n. x
Ceph后来引入了chunky的scrub模式,每次scrub只会选取PG的一部分objects,完成后释放PG lock,并把下一次的PG scrub加入队列;这样能很好的减少PG scrub时候占用PG lock的时间,避免过多影响PG正常的IO;
  G9 E1 w  b, I9 ]; B* q6 U2 C同理,引入的osd_scrub_sleep参数会让线程在每次scrub前释放PG lock,然后睡眠一段时间,也能很好的减少scrub对PG正常IO的影响;
6 @: E! B: M# A$ V配置建议:
+ t( f6 I4 b# C* A# v2 ^( qosd_scrub_begin_hour和osd_scrub_end_hour:OSD Scrub的开始结束时间,根据具体业务指定;
2 n; y0 x3 r/ r- dosd_scrub_sleep:osd在每次执行scrub时的睡眠时间;有个bug跟这个配置有关,建议关闭;6 O/ L, u: {! K# B
osd_scrub_load_threshold:osd开启scrub的系统load阈值,根据系统的load average值配置该参数;1 k. [# G( L2 ?! D0 l4 r6 s  e
osd_scrub_chunk_min和osd_scrub_chunk_max:根据PG中object的个数配置;针对RGW全是小文件的情况,这两个值需要调大;
9 @! j4 t- d8 K& k6 Q参考:& L4 f4 [0 }. \, p; Y
http://www.jianshu.com/p/ea2296e1555c3 \) Y' M% }4 J# a9 L
http://tracker.ceph.com/issues/19497
1 p% A6 ~9 B- U4 P; J+ V. \12,osd thread timeout配置参数
7 O8 [0 v2 ~+ h" W$ V$ W+ W0 k8 N; I! P) J3 Y
osd_op_thread_timeout = 580               默认值 15
; U5 x, ]% V0 F# L) [( d4 Posd_op_thread_suicide_timeout = 600         默认值 150
; F3 H) ~( x  K/ ?' n( c' j3 U ) Y3 m* }% H) [$ \9 ~
osd_recovery_thread_timeout = 580           默认值 30
8 S. }: {8 m# ^osd_recovery_thread_suicide_timeout = 600   默认值 3007 N: U/ a3 A9 E
osd_op_thread_timeout和osd_op_thread_suicide_timeout关联的work queue为:& H- q3 l% m: ]- `  [; ]
op_shardedwq - 关联的请求为:OpRequestRef,PGSnapTrim,PGScrub+ `. d1 A' E* L7 }
peering_wq - 关联的请求为:osd peering
% D. H" c$ i7 S: Uosd_recovery_thread_timeout和osd_recovery_thread_suicide_timeout关联的work queue为:
+ y# \7 `" P# h  ]& {, O( Irecovery_wq - 关联的请求为:PG recovery; G7 C; M4 M1 u& M4 |$ g5 U7 J- q- d
Ceph的work queue都有个基类WorkQueue_,定义如下:
6 ?9 z3 G1 m7 Y3 Y6 I* U# y% m, y3 F) O
/// Pool of threads that share work submitted to multiple work queues.* [, D* ]7 O6 c; |
class ThreadPool : public md_config_obs_t {
& }& [; P6 d3 G* R0 X  ?.... i& m1 a: e7 b1 S& m
    /// Basic interface to a work queue used by the worker threads.
1 j( D0 X4 X; a) B! ~+ _- [' V9 S    struct WorkQueue_ {, J2 t) Y) O( v! S
        string name;
2 ]; |& L' |! C; S0 T) X        time_t timeout_interval, suicide_interval;
/ |9 h5 P6 y7 a6 J        WorkQueue_(string n, time_t ti, time_t sti)
4 _" z9 e# a# I. D            : name(n), timeout_interval(ti), suicide_interval(sti)9 p" X2 V0 _( f7 {( W# l8 J
        { }0 S5 [, V2 _1 b6 |7 I# R
...
0 S0 K$ y( f+ k8 w+ s" |这里的timeout_interval和suicide_interval分别对应上面所述的配置timeout和suicide_timeout;
' Q8 x0 P2 p* s  B当thread处理work queue中的一个请求时,会受到这两个timeout时间的限制:
& T9 p! S2 e$ ~$ \timeout_interval - 到时间后设置m_unhealthy_workers+17 T: W8 T! `2 r4 `# T5 D
suicide_interval - 到时间后调用assert,OSD进程crush  d! f3 ^  e* d3 r7 b: p; c
对应的处理函数为:. m, N% B) N8 c! \  ?

' X) Z% j- }$ Q1 Mbool HeartbeatMap::_check(const heartbeat_handle_d *h, const char *who, time_t now)% P9 U8 y# k6 M) j- T- Q( o
{
' }8 E+ V# ?& S6 @% c    bool healthy = true;0 ^! q+ L/ x- k) \; N5 Y
    time_t was;. ?4 Q! l. W2 l+ K' L9 L0 x
    was = h->timeout.read();
# z0 W6 J$ C9 f7 \9 l    if (was && was < now) {2 E# Y% `0 _+ t, k  j6 \2 w; u( D
        ldout(m_cct, 1) << who << " '" << h->name << "'"; B  S9 |7 w/ P7 W! Z+ k9 f5 {
                        << " had timed out after " << h->grace << dendl;
" V1 p1 V" q$ x' T        healthy = false;0 Y8 x5 F) g4 h  z/ H! u) |$ V
    }
7 v: V* R1 ]0 z    was = h->suicide_timeout.read();
- r: @5 s5 o/ K8 a, s& j! I0 i7 @$ j7 e    if (was && was < now) {/ O/ y6 f8 E9 ]) J. w3 J9 i+ M
        ldout(m_cct, 1) << who << " '" << h->name << "'"+ j+ p2 @2 c" o; Z
                        << " had suicide timed out after " << h->suicide_grace << dendl;
3 N3 s* x* T* X! A$ k        assert(0 == "hit suicide timeout");  r) u* b6 I6 `' w
    }5 s% J0 o, [9 m* M) H
    return healthy;6 U4 y* v6 i) F' f
}
* N% K+ g$ M2 W+ p: A当前仅有RGW添加了worker的perfcounter,所以也只有RGW可以通过perf dump查看total/unhealthy的worker信息:1 B. Q  y0 \+ I2 f+ J; G/ v( B
# g1 r7 J. {8 C3 Z6 M
[root@ yangguanjun]# ceph daemon /var/run/ceph/ceph-client.rgw.rgwdaemon.asok perf dump | grep worker/ `1 J7 @/ o+ C  N1 b5 `* ?
        "total_workers": 32,4 a: }9 d1 v+ Q+ d7 _3 u8 {: j
        "unhealthy_workers": 0- B& R9 X5 w1 D$ r/ E
对应的配置项为:' [/ X  D3 O9 z' `: R
0 \' p5 @0 L  D; r0 `8 ]
OPTION(rgw_num_async_rados_threads, OPT_INT, 32) // num of threads to use for async rados operations
8 ]" z1 b  d% T% J9 p5 c2 L6 a```
* B! L) e2 [' W2 q, Z7 ~; y5 I**配置建议:**
# L3 O. g! u5 g, v- `*_thread_timeout`:这个值配置越小越能及时发现处理慢的请求,所以不建议配置很大;特别是针对速度快的设备,建议调小该值;, n) |$ T: F3 f3 K9 f1 ]
- `*_thread_suicide_timeout`:这个值配置小了会导致超时后的OSD crush,所以建议调大;特别是在对应的throttle调大后,更应该调大该值;6 M8 f8 V8 V9 d/ `, Q" P& m  N5 \
### 13,fielstore op thread配置参数2 r9 q) K. m8 w+ D% R+ p0 T
```sh
1 Q: T$ z7 a8 I/ |' {1 vfilestore_op_threads = 10                   默认值 2- J- Z3 v$ I9 A: s1 a" Z! q! }
filestore_op_thread_timeout = 580           默认值 60
; j7 ?  h: d1 f, J# u' tfilestore_op_thread_suicide_timeout = 600   默认值 1805 H9 H( D  G& i
filestore_op_threads:对应的thread pool为op_tp,对应的work queue为op_wq;filestore的所有请求都经过op_wq处理;
7 x( [5 h" v! o) o6 {增大该参数能提升filestore的处理能力,提升filestore的性能;配合filestore的throttle一起调整;1 x% d. e5 F2 K7 e
filestore_op_thread_timeout和filestore_op_thread_suicide_timeout关联的work queue为:op_wq- l. ^0 p3 n: ?! _& T! n
配置的含义与上一节中的thread_timeout/thread_suicide_timeout保持一致;' Y5 r. _% E/ N# K! s
13,filestore merge/split配置参数
6 x8 V! _4 X3 M0 k, o( m$ T! E* D7 s' b% a: p
filestore_merge_threshold = -1       默认值 10; p# ^6 w0 x+ G" T! a
filestore_split_multiple = 16000      默认值 24 f8 F+ Q. p9 r: k& S
这两个参数是管理filestore的目录分裂/合并的,filestore的每个目录允许的最大文件数为:
4 ]0 q$ a) f6 W0 m7 ^filestore_split_multiple * abs(filestore_merge_threshold) * 167 m1 a2 @+ h$ d
在RGW的小文件应用场景,会很容易达到默认配置的文件数(320),若在写的过程中触发了filestore的分裂,则会非常影响filestore的性能;
! g4 B( r) f1 W) g1 s& W/ Y0 \每次filestore的目录分裂,会依据如下规则分裂为多层目录,最底层16个子目录:
8 J& I* K- a5 j! ]例如PG 31.4C0, hash结尾是4C0,若该目录分裂,会分裂为 DIR_0/DIR_C/DIR_4/{DIR_0, DIR_F};
' e5 }5 H1 M) ~# Y8 j原始目录下的object会根据规则放到不同的子目录里,object的名称格式为: *__head_xxxxX4C0_*,分裂时候X是几,就放进子目录DIR_X里。比如object:*__head_xxxxA4C0_*, 就放进子目录 DIR_0/DIR_C/DIR_4/DIR_A 里;
% q! D. E  Z1 s7 r! Q9 o0 N解决办法:
6 v" |" j* K5 N+ G% t; M: x5 n增大merge/split配置参数的值,使单个目录容纳更多的文件;) b. k6 k; a- N+ ]: |7 B. U: K
filestore_merge_threshold配置为负数;这样会提前触发目录的预分裂,避免目录在某一时间段的集中分裂,详细机制没有调研;6 w% s+ \; O& Q: `4 z
创建pool时指定expected-num-objects;这样会依据目录分裂规则,在创建pool的时候就创建分裂的子目录,避免了目录分裂对filestore性能的影响;
: C0 \: U$ k+ u+ s2 m参考:
4 y/ K! A7 y. yhttp://docs.ceph.com/docs/master/rados/configuration/filestore-config-ref/6 O: G: ?. a0 Y3 s& `5 B1 e
http://docs.ceph.com/docs/jewel/rados/operations/pools/#create-a-pool
: H, G( S4 o, B& xhttp://blog.csdn.net/for_tech/article/details/512519369 G! O, L$ L/ ?+ o: L) S+ m3 u
http://ivanjobs.github.io/page3/- h) O" I9 K! |. f5 F! ?' {* W
14,filestore fd cache配置参数
" N& U9 f6 c2 e/ I  Y( V7 {( B( J! f! K: H, O
filestore_fd_cache_shards =  32     默认值 16     // FD number of shards8 @; T1 d; m  t9 {3 e# L4 @9 J% n
filestore_fd_cache_size = 32768     默认值 128  // FD lru size
: ^5 m- W* c. ~1 ~filestore的fd cache是加速访问filestore里的file的,在非一次性写入的应用场景,增大配置可以很明显的提升filestore的性能;
6 @  E& S3 I! ^' L% j15,filestore sync配置参数+ [8 z  k: t: T* B& s) N9 N

" S! q5 p( K- P; N; d0 Y& ^( ~filestore_wbthrottle_enable = false    默认值 true        SSD的时候建议关闭7 a7 d+ U" ^9 g3 |
filestore_min_sync_interval = 5           默认值 0.01 s     最小同步间隔秒数,sync fs的数据到disk,FileStore::sync_entry()
' N$ ~2 b; j: z; F5 @filestore_max_sync_interval = 10         默认值 5 s       最大同步间隔秒数,sync fs的数据到disk,FileStore::sync_entry()
  ]0 P+ j$ x# Cfilestore_commit_timeout = 3000         默认值 600 s       FileStore::sync_entry() 里 new SyncEntryTimeout(m_filestore_commit_timeout)
( ], `5 b2 O2 D6 V5 k4 _filestore_wbthrottle_enable的配置是关于filestore writeback throttle的,即我们说的filestore处理workqueue op_wq的数据量阈值;默认值是true,开启后XFS相关的配置参数有:5 s+ H9 A% T/ M* z

& C+ @) _' i  ]; G4 [OPTION(filestore_wbthrottle_xfs_bytes_start_flusher, OPT_U64, 41943040)
. X, K+ y( D. ?; DOPTION(filestore_wbthrottle_xfs_bytes_hard_limit, OPT_U64, 419430400)/ z7 N* a# j  F) f3 R  `
OPTION(filestore_wbthrottle_xfs_ios_start_flusher, OPT_U64, 500)) m; k1 g( {% V: I
OPTION(filestore_wbthrottle_xfs_ios_hard_limit, OPT_U64, 5000)8 Z# R; w$ r9 t
OPTION(filestore_wbthrottle_xfs_inodes_start_flusher, OPT_U64, 500)
# p- g" }6 L) q3 Z( l3 sOPTION(filestore_wbthrottle_xfs_inodes_hard_limit, OPT_U64, 5000)
$ t4 ?" B- }9 f3 V0 }( k* F* N若使用普通HDD,可以保持其为true;针对SSD,建议将其关闭,不开启writeback throttle;
+ D; L* r4 T( U7 ~6 @filestore_min_sync_interval和filestore_max_sync_interval是配置filestore flush outstanding IO到disk的时间间隔的;增大配置可以让系统做尽可能多的IO merge,减少filestore写磁盘的压力,但也会增大page cache占用内存的开销,增大数据丢失的可能性;8 o2 B6 E+ F7 Y( W
filestore_commit_timeout是配置filestore sync entry到disk的超时时间,在filestore压力很大时,调大这个值能尽量避免IO超时导致OSD crush;, j- p/ E5 g6 W7 g: S
16,filestore throttle配置参数! Y6 t$ Y0 S1 ?3 ^4 y! R5 S% V/ ~) A
4 @+ O8 K9 j/ F; i. v3 _
filestore_expected_throughput_bytes =  536870912       默认值 200MB    /// Expected filestore throughput in B/s0 U( o3 H0 `1 ^, E0 \" a! `
filestore_expected_throughput_ops = 2500                默认值 200      /// Expected filestore throughput in ops/s
6 @6 _) s4 ]7 `3 c" P) H" x5 ?filestore_queue_max_bytes= 1048576000                   默认值 100MB
* A  U2 t# m9 K7 ]filestore_queue_max_ops = 5000                          默认值 50
3 j3 j8 {* F' U9 p8 B8 {
# z5 [8 L( S. i: j. Q+ w- Q/// Use above to inject delays intended to keep the op queue between low and high2 s7 l* Y& e; W" ]( p
filestore_queue_low_threshhold = 0.6                    默认值 0.3) a2 T* S8 G, a, p0 n0 H6 o8 }
filestore_queue_high_threshhold = 0.9                   默认值 0.9
3 r  b% {; }' b9 o- }% Z
7 h  R  X% t* d- W$ T& bfilestore_queue_high_delay_multiple = 2                    默认值 0    /// Filestore high delay multiple.  Defaults to 0 (disabled)
7 r" q, C2 y: `filestore_queue_max_delay_multiple = 10                 默认值 0    /// Filestore max delay multiple.  Defaults to 0 (disabled)
* Y! d3 B4 J3 h# ?  D# H在jewel版本里,引入了dynamic throttle,来平滑普通throttle带来的长尾效应问题;8 |- R3 j/ T/ M) q
一般在使用普通磁盘时,之前的throttle机制即可很好的工作,所以这里默认filestore_queue_high_delay_multiple和filestore_queue_max_delay_multiple都为0;& d$ b' r, k2 a" A# A/ R
针对高速磁盘,需要在部署之前,通过小工具ceph_smalliobenchfs来测试下,获取合适的配置参数;
2 F8 Z7 ]) @; m& H: c, Q5 j
* a7 l8 r+ M, w  _0 |( r6 H- F: b5 gBackoffThrottle的介绍如下:
1 @  r; s* y! ]/**4 V  z. K+ L) T; ?
* BackoffThrottle
7 Q- Q# v- u/ a! i# M, j, Y** J3 y. e3 \( H2 D, y
* Creates a throttle which gradually induces delays when get() is called! r+ H6 Y9 k/ `2 s/ x8 {3 r$ j" c
* based on params low_threshhold, high_threshhold, expected_throughput,
( i6 l' a1 R6 @) f' Q6 B" U) t* high_multiple, and max_multiple.4 v  s3 D3 `, @6 x
*& g. U* U& K2 ^
* In [0, low_threshhold), we want no delay.! W+ r2 P  j$ J. i6 O# _
*
; X# r2 f0 Q5 W; \9 m8 x* In [low_threshhold, high_threshhold), delays should be injected based
5 e2 o2 e" X  y' C/ L: n* on a line from 0 at low_threshhold to
4 Y3 m" C3 r3 t, I* high_multiple * (1/expected_throughput) at high_threshhold.2 x, V3 u* }4 k
*
; N1 @3 S2 e* U, Y+ }* In [high_threshhold, 1), we want delays injected based on a line from0 [" q: r+ }  Z: B/ G' }; F8 D, P3 N
* (high_multiple * (1/expected_throughput)) at high_threshhold to
4 F2 f' h- [  c9 Z7 q* (high_multiple * (1/expected_throughput)) +' D& ]6 P, a+ c# ]* L6 r
* (max_multiple * (1/expected_throughput)) at 1.
% q) b" ?+ a4 G*) H( @0 G6 d+ X1 M
* Let the current throttle ratio (current/max) be r, low_threshhold be l,2 P  u. Y9 ^8 Z4 I: [! T% s3 Q
* high_threshhold be h, high_delay (high_multiple / expected_throughput) be e,
- J/ h; _$ O# D- s0 ]* and max_delay (max_muliple / expected_throughput) be m.6 H. E4 h; V1 x2 u  F& P
*
& d2 `+ e9 X' S+ w# m# `* delay = 0, r \in [0, l). K# f) ~, N) I/ K6 {
* delay = (r - l) * (e / (h - l)), r \in [l, h)& e' f1 u' m9 f, O* }7 p! E
* delay = h + (r - h)((m - e)/(1 - h))+ R, W9 V; p" G# x; g  b
*/
+ a1 [* P* Z- t" O参考:
/ M0 V2 f7 ^9 [$ ]( Q9 ]% a0 Qhttp://docs.ceph.com/docs/jewel/dev/osd_internals/osd_throttles/+ C. E! g6 {( }: {; O+ }- _
http://blog.wjin.org/posts/ceph-dynamic-throttle.html' ]- w( m3 ]8 f2 H, ]. Q
https://github.com/ceph/ceph/blob/master/src/doc/dynamic-throttle.txt
/ Z4 V6 d6 j% lCeph BackoffThrottle分析
8 d5 Q# x# u- t; w: w) j. Y2 \. v17,filestore finisher threads配置参数
8 U# F7 `) `2 E1+ h) k- B3 Z7 S, g8 z6 m
2
1 P" [3 i; L8 z( s: v5 n4 ^filestore_ondisk_finisher_threads = 2   默认值 1
8 P4 F, _" I1 Ufilestore_apply_finisher_threads = 2   默认值 18 `  C2 y6 \* h
这两个参数定义filestore commit/apply的finisher处理线程数,默认都为1,任何IO commit/apply完成后,都需要经过对应的ondisk/apply finisher thread处理;: r% l1 K7 {+ |' {
在使用普通HDD时,磁盘性能是瓶颈,单个finisher thread就能处理好;3 R) z. d+ v3 C) z. R$ Y* j
但在使用高速磁盘的时候,IO完成比较快,单个finisher thread不能处理这么多的IO commit/apply reply,它会成为瓶颈;所以在jewel版本里引入了finisher thread pool的配置,这里一般配置为2即可;1 }$ [2 s. Q" t( e
18,journal配置参数
2 c# C, k5 Z' _0 Z5 s9 O- H( `9 c" n" Z+ \2 l
journal_max_write_bytes=1048576000          默认值 10M    / [  a: _4 X  {
journal_max_write_entries=5000                默认值 100
. X* U' V) A; M; V% Q1 i% f6 j 2 y2 _9 r+ p5 b- s
journal_throttle_high_multiple = 2          默认值 0    /// Multiple over expected at high_threshhold. Defaults to 0 (disabled).3 p8 b2 q$ X! E. ^! ^8 ~0 [- e
journal_throttle_max_multiple = 10          默认值 0    /// Multiple over expected at max.  Defaults to 0 (disabled).
9 z% F9 P& _# y* ~. E3 J: B/// Target range for journal fullness
6 p- z7 D+ l' ^; yOPTION(journal_throttle_low_threshhold, OPT_DOUBLE, 0.6)
, z& F5 T6 x5 _' _OPTION(journal_throttle_high_threshhold, OPT_DOUBLE, 0.9)9 ^$ \9 E, s0 W2 D3 j
journal_max_write_bytes和journal_max_write_entries是journal一次write的数据量和entries限制;
' D' A! s2 b! E6 l# l& M针对SSD分区做journal的情况,这两个值要增大,这样能增大journal的吞吐量;
. g5 f) _$ L6 A6 M( Zjournal_throttle_high_multiple和journal_throttle_max_multiple是JournalThrottle的配置参数,JournalThrottle是BackoffThrottle的封装类,所以JournalThrottle与我们在filestore throttle介绍的dynamic throttle工作原理一样;
% H% G4 J# X  Q5 O8 z; d5 v# R; T4 X5 `1 o% n+ w" n
int FileJournal::set_throttle_params()) Z6 {5 X0 p1 ?2 s0 x
{
' W- ?2 _4 R6 ?: k6 B7 ^+ C( P    stringstream ss;% F: e: Q" |6 y) ~' e6 _! d+ \
    bool valid = throttle.set_params(9 E7 }: H( M! V* a* L" u) t& _# v- ~
                     g_conf->journal_throttle_low_threshhold,# U, i/ I4 O8 F1 R2 V- ?- d: z
                     g_conf->journal_throttle_high_threshhold,
; V4 ?6 B4 a5 p( W) X; q" R                     g_conf->filestore_expected_throughput_bytes,
8 u  w- q) r- D# E* G                     g_conf->journal_throttle_high_multiple,; j( b% f4 P% L6 c  A  R) ?# c% W
                     g_conf->journal_throttle_max_multiple,
) n, w$ `' z& t; C0 I* }                     header.max_size - get_top(),
; U" `+ l) \  X, U                     &ss);  v/ |" H5 X+ L0 ^
..., X- V5 W9 f; R7 u; a1 I
}; r3 L1 V9 C" S( {
从上述代码中看出相关的配置参数有:$ q6 p, I- V" H
journal_throttle_low_threshhold
; q. {6 d  d9 q+ N5 ~! H0 ]journal_throttle_high_threshhold
, C4 f7 ^; h3 L( q; V/ hfilestore_expected_throughput_bytes1 m8 o( F8 h2 a, ]3 U
19,rbd cache配置参数
+ P% R& ^! X' m, D8 b' Z; W
* R( N9 {7 V1 I* l1 S[client]
6 W" ^; m& D$ N* qrbd_cache_size = 134217728                  默认值 32M // cache size in bytes8 x4 E2 D+ v1 O( Z
rbd_cache_max_dirty = 100663296             默认值 24M // dirty limit in bytes - set to 0 for write-through caching
3 F% j1 \+ V) {( k3 brbd_cache_target_dirty = 67108864           默认值 16M // target dirty limit in bytes, k3 x5 o. X* I4 i6 ]
rbd_cache_writethrough_until_flush = true   默认值 true    // whether to make writeback caching writethrough until flush is called, to be sure the user of librbd will send flushs so that writeback is safe" R7 a! }$ U% H5 c% z. |
rbd_cache_max_dirty_age = 5                 默认值 1.0     // seconds in cache before writeback starts
2 h% z* U1 \8 H/ C  n! Arbd_cache_size:client端每个rbd image的cache size,不需要太大,可以调整为64M,不然会比较占client端内存;7 `4 X/ w* ~# o6 B4 b9 e
参照默认值,根据rbd_cache_size的大小调整rbd_cache_max_dirty和rbd_cache_target_dirty;: \& C  W1 T0 m& ^) ~( |
rbd_cache_max_dirty:在writeback模式下cache的最大bytes数,默认是24MB;当该值为0时,表示使用writethrough模式;
6 W7 R* V1 f& `! Z+ ^rbd_cache_target_dirty:在writeback模式下cache向ceph集群写入的bytes阀值,默认16MB;注意该值一定要小于rbd_cache_max_dirty值
# {, E5 f- I2 l6 W* t9 J1 |rbd_cache_writethrough_until_flush:在内核触发flush cache到ceph集群前rbd cache一直是writethrough模式,直到flush后rbd cache变成writeback模式;+ R1 J: I' Q9 Y# D
rbd_cache_max_dirty_age:标记OSDC端ObjectCacher中entry在cache中的最长时间;* R" G6 n7 j0 U+ z0 b  @: r
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 00:09 , Processed in 0.020786 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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