esrally for es on cfs

esrally for es on cfs

简介

esrally 是 elastic 官方开源的一款基于 python3 实现的针对 es 的压测工具,主要功能如下:

  • 自动创建、压测和销毁 es 集群
  • 可分 es 版本管理压测数据和方案
  • 完善的压测数据展示,支持不同压测之间的数据对比分析,也可以将数据存储到指定的es中进行二次分析
  • 支持收集 JVM 详细信息,比如内存、GC等数据来定位性能问题

安装测试

测试环境

节点类型节点数CPU内存存储网络备注
管理节点33232 GB120 GB SSD10 Gb/s
元数据节点103232 GB16 x 1TB SSD10 Gb/s混合部署
数据节点103232 GB16 x 1TB SSD10 Gb/s混合部署

cfs配置

  • 创建cfs vol
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/bin/sh
# ./create_vol.sh

VolNames=estest
leader=10.194.139.42:8080  #cfs master leader节点的ip
Capacity=1024  #unit GB
Owner=es01
DpCount=500

# 创建vol
curl "http://$leader/admin/createVol?name=$VolName&replicas=3&type=extent&capacity=$Capacity&owner=$Owner&followerRead=true"

# 创建dp
curl "http://$leader/dataPartition/create?count=$DpCount&name=$VolName&type=extent"
  • 挂载cfs vol:

    在es运行节点运行cfs-client,挂载cfs vol到指定目录:/mnt/cfs

1
2
$ cd $CFS_ROOT
$ bin/cfs-client -c conf/cfs-client.json

cfs client 配置文件:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// cfs-client.json
{
        "mountPoint": "/mnt/cfs",
        "volName": "estest",
        "owner": "es01",
        "masterAddr": "10.194.139.42:8080,10.194.139.44:8080,10.194.139.45:8080",
        "logDir": "/export/Logs/cfs",
        "warnLogDir": "/export/Logs/cfs",
        "logLevel": "debug",
        "consulAddr": "http://cbconsul-cfs01.cbmonitor.svc.ht7.n.jd.local",
        "exporterPort": 9613,
        "profPort": "11094"
}

es配置

修改es配置文件elasticsearch.yml中配置项path.data为cfs挂载目录:

1
2
3
4
# elasticsearch.yml
#...
path.data: /mnt/cfs/es/<HOST_NAME>   ## HOST_NAME为节点主机名,如果节点运行多个es,每个es需配置不同的目录
#...

esrally

  • centos7
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$ yum install -y python3 python3-devel
# install git
$ yum install -y http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm
$ yum install -y git
$ pip3 install esrally

$ target_hosts=10.194.132.2:20000,10.194.132.5:20000,10.194.132.71:20000,10.194.134.196:20000
$ esrally --track=pmc \
    --target-hosts=$target_hosts \
    --pipeline=benchmark-only

$ esrally --pipeline=benchmark-only \
 --track=http_logs \
 --target-hosts=$target_hosts \
 --report-file=/tmp/report_http_logs.md

# 指定集群,运行测试,test-mode参数只会运行1000条文档 es集群必须处理green状态,否则会被禁止race
# 去掉--offline --test-mode可以让其把相关文件夹创建,然后结束掉
esrally --pipeline=benchmark-only --target-hosts=127.0.0.1:9200 --offline --test-mode --client-options="basic_auth_user:'elastic',basic_auth_password:'your_password'"

esrally race --track=geonames --challenge=append-no-conflicts --user-tag="car:1g" --car=1gheap --pipeline=benchmark-only --target-hosts=127.0.0.1:9200 --offline --test-mode --client-options="basic_auth_user:'elastic',basic_auth_password:'your_password'"

esrally race --track=geonames --challenge=append-no-conflicts --user-tag="car:2g" --car=2gheap --pipeline=benchmark-only --target-hosts=127.0.0.1:9200 --offline --test-mode --client-options="basic_auth_user:'elastic',basic_auth_password:'your_password'"

# 对比2次的测试结果,根据esrally list races显示的时间戳当参数值,如果报错就使用Race ID
esrally compare --baseline='Race ID' --contender='Race ID'

# 修改集群的分片数和副本数
vim /home/esrally/.rally/benchmarks/tracks/default/geonames/index.json
vim /home/esrally/.rally/benchmarks/tracks/default/geonames/challenges/default.json

# 常用命令
esrally list tracks
esrally list cars
esrally list races
esrally list pipelines

$ esrally list races
$ esrally compare --baseline 30889a15-66d3-4336-b6cb-0304834d853a  --contender 1d1d5a98-54cb-486d-8339-98fe72ff054c

测试结果

metriclocal-r0local-r1local-r2cfs-r0cfs-r1cfs-r2
Cumulative indexing time of primary
shards
48.195650.121453.698161.51460.687461.6843
Cumulative merge time of primary shards19.373419.75916.344620.775315.17025.61673
Cumulative refresh time of primary shard6.521285.994135.6194812.798410.68249.8606
Cumulative flush time of primary shards0.0051301.67E-050.00280.01473330.03075

  • local-r0、local-r1, local-r2: 分别表示es    path.data使用本地磁盘,replica分别为0,1,2时的数据;

  • cfs-r0,cfs-r1, cfs-r2分别表示es path.data使用cfs 卷,replica分别为0,1,2时esrally的数据;

参考

  1. https://esrally.readthedocs.io/en/latest/summary_report.html
  2. https://www.jianshu.com/p/c89975b50447
  3. 快速入门 — Rally 0.9.0 文档
updatedupdated2024-05-152024-05-15