ceph luminous版本限制osd的内存使用

引言

ceph自从到了L版本以后,L版本的启用,对性能本身有了极大的提高,一直对这个比较不放心的就是内存的占用,刚开始的时候记得大量dd就可以把内存搞崩掉,这个应该是内部的设计逻辑需要更多的内存的占用

最近在做ARM版本的服务器的测试,机器为36盘位的机器,内存需要自然多,但是36盘位的机器,按之前想法是4G预留,那得需要144G内存了,这个还没有算迁移的时候的内存消耗,而很多时候,我们并不需要速度,只需要稳定就好

测试环境说明

测试环境比较简单,一台36盘位的arm机器,一台X86机器,通过万兆相连,设置集群为副本1,然后再X86上面通

限制前后对比

我们先按默认的来一组测试

用读取命令进行测试

rados  -p rbd  -t 64  bench 300  seq  --run-name  4Mt16
···
2019-09-03 15:19:20.478841 min lat: 0.188154 max lat: 0.658198 avg lat: 0.227437
  sec Cur ops   started  finished  avg MB/s  cur MB/s last lat(s)  avg lat(s)
   20      63      5620      5557   1111.24      1124    0.223682    0.227437
   21      63      5901      5838   1111.84      1124    0.232894      0.2274
   22      63      6179      6116   1111.84      1112    0.210126    0.227447
   23      63      6459      6396   1112.19      1120    0.209931    0.227353
   24      63      6742      6679   1113.01      1132    0.210041    0.227428
   25      63      7023      6960   1113.44      1124    0.447199    0.227417
   26      63      7302      7239   1113.54      1116    0.213757    0.227367
   27      63      7585      7522   1114.19      1132    0.222248    0.227416
   28      63      7870      7807   1115.08      1140    0.198665    0.227351
   29      63      8148      8085   1114.97      1112    0.222645    0.227402
   30      63      8430      8367    1115.4      1128    0.205243    0.227394
   31      63      8707      8644   1115.16      1108     0.22508    0.227397
   32      63      8987      8924   1115.31      1120    0.198234    0.227326
   33      63      9267      9204   1115.41      1120    0.232074    0.227447
   34      63      9551      9488   1115.99      1136    0.230373    0.227413
   35      63      9829      9766   1115.88      1112    0.214755    0.227405
   36      63     10107     10044   1115.77      1112    0.233391    0.227403
   37      63     10390     10327   1116.18      1132    0.223244    0.227412
   38      63     10673     10610    1116.6      1132    0.221128     0.22742
···

通过top看下内存占用

Tasks: 526 total,   1 running, 237 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.6 us,  1.5 sy,  0.0 ni, 95.3 id,  1.5 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem : 13316204+total, 31199616 free, 10079264+used,  1169792 buff/cache
KiB Swap:        0 total,        0 free,        0 used. 21086208 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                      
  43967 ceph      20   0 4176384   3.1g  26624 S   1.3  2.4   0:08.79 ceph-osd                     
  43890 ceph      20   0 4116992   3.0g  26688 S   1.0  2.4   0:08.69 ceph-osd                     
  43753 ceph      20   0 4091712   3.0g  26752 S   2.3  2.4   0:08.88 ceph-osd                     
  43873 ceph      20   0 4160000   3.0g  26688 S   2.0  2.4   0:08.77 ceph-osd                     
  43998 ceph      20   0 4275776   3.0g  26688 S   2.3  2.4   0:08.91 ceph-osd                     
  43716 ceph      20   0 4128960   3.0g  26688 S   2.3  2.3   0:08.95 ceph-osd                     
  43899 ceph      20   0 3911232   3.0g  26688 S   1.7  2.3   0:08.44 ceph-osd                     
  44022 ceph      20   0 4133120   3.0g  26752 S   2.0  2.3   0:09.29 ceph-osd                     
  43617 ceph      20   0 4100608   2.9g  26688 S   2.6  2.3   0:09.13 ceph-osd                     
  43868 ceph      20   0 4110016   2.9g  26688 S   2.6  2.3   0:08.70 ceph-osd                     
  43792 ceph      20   0 4095552   2.9g  26752 S   2.3  2.3   0:09.02 ceph-osd                     
  43985 ceph      20   0 4090368   2.9g  26624 S   2.3  2.3   0:08.84 ceph-osd                     
  43707 ceph      20   0 4177472   2.9g  26624 S   2.3  2.3   0:08.79 ceph-osd                     
  44028 ceph      20   0 4084288   2.9g  26624 S   2.3  2.3   0:08.93 ceph-osd                     
  43995 ceph      20   0 4092480   2.8g  26688 S   2.3  2.2   0:08.95 ceph-osd                     
  43852 ceph      20   0 4054528   2.8g  26752 S   3.6  2.2   0:08.75 ceph-osd                     
  44038 ceph      20   0 3966528   2.8g  26688 S   2.6  2.2   0:08.51 ceph-osd                     
  43755 ceph      20   0 4092096   2.8g  26752 S   3.0  2.2   0:09.10 ceph-osd                     
  43718 ceph      20   0 4045376   2.8g  26688 S   1.3  2.2   0:08.84 ceph-osd                     
  43901 ceph      20   0 3931648   2.7g  26688 S   1.7  2.2   0:08.67 ceph-osd                     
  43880 ceph      20   0 4028992   2.7g  26688 S   2.6  2.1   0:08.82 ceph-osd                     
  43897 ceph      20   0 3978752   2.7g  26624 S   2.3  2.1   0:08.59 ceph-osd                     
  43858 ceph      20   0 4019776   2.7g  26560 S   1.3  2.1   0:08.89 ceph-osd       

可以看到内存占用还是很可观的,我128G内存,基本要吃空了,内存需要的太大,还出现了无法分配内存的情况,我们限制下我们的内存

限制osd内存的参数
默认值为

osd_memory_target = 4294967296

我们限制到1G

osd_memory_target = 1073741824

设置好了后重启下所有的osd

再来一轮测试

同样的命令

2019-09-03 15:28:41.369259 min lat: 0.189981 max lat: 0.88615 avg lat: 0.227472
  sec Cur ops   started  finished  avg MB/s  cur MB/s last lat(s)  avg lat(s)
   40      63     11232     11169   1116.67      1116    0.221146    0.227472
   41      63     11513     11450   1116.85      1124     0.22655    0.227467
   42      63     11794     11731   1117.01      1124    0.213789    0.227451
   43      63     12073     12010   1116.98      1116     0.21521    0.227447
   44      63     12353     12290   1117.05      1120    0.232574    0.227455
   45      63     12632     12569   1117.02      1116    0.217199    0.227449
   46      63     12917     12854   1117.52      1140    0.211747    0.227425
   47      63     13194     13131   1117.31      1108    0.229418    0.227473
   48      63     13476     13413   1117.52      1128    0.229639    0.227456
   49      63     13756     13693   1117.57      1120    0.228479     0.22745
   50      63     14041     13978      1118      1140     0.21689    0.227463
   51      63     14316     14253   1117.64      1100     0.23947    0.227468
   52      63     14599     14536   1117.92      1132    0.215251    0.227452
   53      63     14880     14817   1118.03      1124    0.227617    0.227461
   54      63     15160     15097   1118.05      1120    0.224964    0.227449
   55      63     15442     15379   1118.22      1128    0.219148    0.227451
   56      63     15721     15658   1118.18      1116    0.223736    0.227459
   57      63     16001     15938   1118.21      1120     0.23183    0.227468
   58      63     16282     16219    1118.3      1124    0.217697    0.227465
   59      63     16566     16503    1118.6      1136    0.217804    0.227465

查看修改后的内存占用

top - 15:29:10 up  4:54,  6 users,  load average: 1.88, 2.74, 2.25
Tasks: 506 total,   1 running, 239 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.2 us,  0.9 sy,  0.0 ni, 97.4 id,  0.0 wa,  0.0 hi,  0.4 si,  0.0 st
KiB Mem : 13316204+total, 12275264+free,  9211264 used,  1198144 buff/cache
KiB Swap:        0 total,        0 free,        0 used. 11264793+avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                      
  48575 ceph      20   0  908544 262144  26688 S   2.0  0.2   0:09.71 ceph-osd                     
  48547 ceph      20   0  904448 252800  26752 S   1.0  0.2   0:09.36 ceph-osd                     
  48480 ceph      20   0  902336 247552  26624 S   1.3  0.2   0:09.11 ceph-osd                     
  48485 ceph      20   0  906048 242048  26688 S   1.7  0.2   0:09.38 ceph-osd                     
  48423 ceph      20   0  901312 241984  26688 S   1.3  0.2   0:09.62 ceph-osd                     
  48534 ceph      20   0  896576 234752  26688 S   1.3  0.2   0:09.22 ceph-osd                     
  48395 ceph      20   0  902656 231360  26688 S   2.0  0.2   0:08.96 ceph-osd                     
  48474 ceph      20   0  899584 225920  26624 S   1.3  0.2   0:09.07 ceph-osd                     
  48369 ceph      20   0  891456 223232  26688 S   1.3  0.2   0:09.31 ceph-osd                     
  48375 ceph      20   0  899648 222016  26624 S   1.7  0.2   0:08.72 ceph-osd                     
  48365 ceph      20   0  885312 220928  26688 S   1.3  0.2   0:09.06 ceph-osd                     
  48421 ceph      20   0  899200 218944  26688 S   1.7  0.2   0:09.31 ceph-osd                     
  48478 ceph      20   0  889344 218496  26880 S   1.3  0.2   0:09.46 ceph-osd                     
  48347 ceph      20   0  879104 218112  26688 S   1.7  0.2   0:08.52 ceph-osd                     
  48515 ceph      20   0  891456 215680  26688 S   2.0  0.2   0:09.21 ceph-osd                     
  48465 ceph      20   0  884224 214336  26688 S   1.7  0.2   0:08.82 ceph-osd                     
  48560 ceph      20   0  892480 214144  26624 S   1.3  0.2   0:08.87 ceph-osd                     
  48552 ceph      20   0  900992 213952  26752 S   1.7  0.2   0:09.32 ceph-osd                     
  48599 ceph      20   0  890432 213760  26624 S   2.0  0.2   0:09.19 ceph-osd                     
  48613 ceph      20   0  882176 213056  26752 S   1.0  0.2   0:09.12 ceph-osd                     
  48430 ceph      20   0  893440 212672  26688 S   1.7  0.2   0:09.18 ceph-osd                     
  48503 ceph      20   0  885312 211456  26688 S   2.3  0.2   0:09.52 ceph-osd                     
  48444 ceph      20   0  889408 211200  26752 S   2.0  0.2   0:09.60 ceph-osd                     
  48635 ceph      20   0  898624 210944  26688 S   2.0  0.2   0:09.26 ceph-osd                     
  48526 ceph      20   0  898624 210752  26816 S   2.6  0.2   0:09.20 ceph-osd                     
  48491 ceph      20   0  898368 210304  26816 S   2.3  0.2   0:09.57 ceph-osd     

可以看到内存控的好好的,并且在这个场景下面,我们的性能并没有太多的损失,基本一致的,因为我的环境是单万兆的,输出的网络带宽是小于底层磁盘可以提供的带宽的,这个情况下磁盘的占用也就没那么满

这个也是我在做配置的时候推荐的一点,各项资源不要打的那么满,对于带宽场景来说,多留几个磁盘的输出冗余,那么在出现一些异常的时候,底层也不会影响到那么大

总结

本篇通过一个参数的介绍,讲述了osd的内存的占用的控制,一般情况来说,默认的参数已经足够好了,当然你在很确定你修改的参数会影响什么的情况下,可以根据需要做一些调整,如果在你的IO模型下面,你调整了都看不到效果,那还是不动为好

我们手上有高性能的arm,就是上面的这款测试用到的,有32个processor,内存最大可以支持到

Maximum Capacity: 512 GB
Number Of Devices: 16

盘位的机箱我们有能力自己设计,也就是可以根据需要进行定制,有需要的可以找我

变更记录

Why Who When
创建 武汉-运维-磨渣 2018-09-03
原文地址:https://www.cnblogs.com/zphj1987/p/13575481.html