ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

esrally(elasticsearch压测工具)介绍(一)

2022-06-14 20:35:47  阅读:103  来源: 互联网

标签:geonames esrally 压测 -- elasticsearch yangshujun rally


 

一、介绍

esrally是elastic search官方用于对ES集群集群进行压测的工具,可使用esrally构建不同版本集群、不同参数和数据进行压力测试,并且支持对结果进行比较。也支持对远程集群压测。 rally:(汽车,摩托车等)拉力赛,所以相关属于也与拉力赛相关。
  • track:赛道;指压测用到的样本数据和压测策略。
  • car: 赛车;指被压测不同类型的es实例(执行压测方案)。可通过:esrally list cars 查看
Available cars:

Name                     Type    Description
-----------------------  ------  --------------------------------------
16gheap                  car     Sets the Java heap to 16GB
1gheap                   car     Sets the Java heap to 1GB
24gheap                  car     Sets the Java heap to 24GB
2gheap                   car     Sets the Java heap to 2GB
4gheap                   car     Sets the Java heap to 4GB
8gheap                   car     Sets the Java heap to 8GB
defaults                 car     Sets the Java heap to 1GB
basic-license            mixin   Basic License
debug-non-safepoints     mixin   More accurate CPU profiles
ea                       mixin   Enables Java assertions
fp                       mixin   Preserves frame pointers
g1gc                     mixin   Enables the G1 garbage collector
parallelgc               mixin   Enables the Parallel garbage collector
trial-license            mixin   Trial License
unpooled                 mixin   Enables Netty's unpooled allocator
x-pack-ml                mixin   X-Pack Machine Learning
x-pack-monitoring-http   mixin   X-Pack Monitoring (HTTP exporter)
x-pack-monitoring-local  mixin   X-Pack Monitoring (local exporter)
x-pack-security          mixin   X-Pack Security
zgc                      mixin   Enables the ZGC garbage collector
  • pipline: 管道;可通过esrally list piplines 查看
Available pipelines:

Name                     Description
-----------------------  ---------------------------------------------------------------------------------------------
from-sources-complete    Builds and provisions Elasticsearch, runs a benchmark and reports results.
from-sources-skip-build  Provisions Elasticsearch (skips the build), runs a benchmark and reports results.
from-distribution        Downloads an Elasticsearch distribution, provisions it, runs a benchmark and reports results.
benchmark-only           Assumes an already running Elasticsearch instance, runs a benchmark and reports results
  • from-sources-complete :表示从源代码构建ES, --revision参数可以指定一个ES的修订版本,默认为最新版本。
  • rom-sources-skip-build :表示如果之前已经通过源码构建过一次相同版本的ES了,那么本次将不再进行构建,这样可以节省测试的时间
  • from-distribution:esrally将下载正式的ES发行版来进行测试, --distribution-version 参数可以指定ES版本,最低支持1.7.5
  • benchmark-only :将对已有的ES集群进行压测,--target-hosts参数可以指定ES集群地址
  • race:比赛记录;指每次压测记录,如果没有指定track,则默认使用geonames track进行测试
Recent races:

Race ID                               Race Timestamp    Track     Track Parameters    Challenge            Car       User Tags      Track Revision  Team Revision
------------------------------------  ----------------  --------  ------------------  -------------------  --------  -----------  ----------------  ---------------
5af141b9-c910-4021-b4fc-beb4c3fc16aa  20220614T072535Z  geonames                      append-no-conflicts  external
1415f9ca-1008-4307-8763-cdbc9640d304  20220614T072211Z  geonames                      append-no-conflicts  external                        6622623
5bfe97af-2c60-4a0f-a568-0e5f087f6b61  20220614T032008Z  geonames                      append-no-conflicts  external                        6622623
46ad39e9-0959-4813-804d-4f95407d886d  20220613T072708Z  geonames                      append-no-conflicts  external                        6622623
06324f7b-ab1c-4d81-b06b-45e537909374  20220613T070715Z  geonames                      append-no-conflicts  external                        6622623
  • 备注:可以根据不同race进行比较,例如:
esrally compare --baseline= 46ad39e9-0959-4813-804d-4f95407d886d --contender=06324f7b-ab1c-4d81-b06b-45e537909374

二、安装

  1. Python3环境:确保环境存在

  2. esrally安装:

    1. 安装虚拟环境:(后一个venv为虚拟环境文件夹)
python3 -m venv venv
  1. 安装esrally
source venv/bin/activate
(venv): pip install esrally
  1. 其他安装:

    1. 压测本地已经存在ES环境,即: --pipeline=benchmark-only --target-hosts=http://目标ES地址:目标端口,不需要安装java jdk环境
    2. 本地新建不同ES版本环境,即:piplines里其他三种pipline方式,安装java

三、配置

  1. 创建配置:

(venv): esrally configure
  • 备注:配置完成后,会覆盖写esrally配置文件 ~/.rally/rally.ini
  1. 压测数据于方案track介绍:

  • 所在目录(默认): ~/.rally/benchmarks/tracks/default/
  • esally自带的track:
(venv) [binger@test-node-21 .rally]$ ll  ~/.rally/benchmarks/tracks/default/
total 8
-rwxr-xr-x 1 yangshujun docker 2217 Jun 13 14:15 download.sh
drwxr-xr-x 2 yangshujun docker   91 Jun 14 11:20 eql
drwxr-xr-x 5 yangshujun docker  164 Jun 14 17:18 geonames
drwxr-xr-x 4 yangshujun docker  112 Jun 13 14:15 geopoint
drwxr-xr-x 5 yangshujun docker  126 Jun 13 14:15 geopointshape
drwxr-xr-x 5 yangshujun docker  126 Jun 14 11:20 geoshape
drwxr-xr-x 5 yangshujun docker  222 Jun 14 11:20 http_logs
drwxr-xr-x 4 yangshujun docker   95 Jun 14 11:20 metricbeat
drwxr-xr-x 4 yangshujun docker  180 Jun 13 14:15 nested
drwxr-xr-x 5 yangshujun docker  149 Jun 14 11:20 noaa
drwxr-xr-x 5 yangshujun docker  142 Jun 14 11:20 nyc_taxis
drwxr-xr-x 4 yangshujun docker  112 Jun 13 14:15 percolator
drwxr-xr-x 4 yangshujun docker  128 Jun 13 14:15 pmc
-rw-r--r-- 1 yangshujun docker 2896 Jun 13 14:15 README.md
drwxr-xr-x 4 yangshujun docker  144 Jun 13 14:15 so

         1. track组成(以default为例)

(venv) [binger@test-node-21 .rally]$ tree  ~/.rally/benchmarks/tracks/default/geonames/
/home/binger/.rally/benchmarks/tracks/default/geonames/
├── challenges
│   ├── default.json
├── files.txt
├── index.json
├── operations
│   └── default.json
├── README.md
├── terms.txt
├── track.json
└── track.py

         2. track.json定义压测方案相关

    • operations定义了压测操作细则,包含:索引数据、term查询,range查询,聚合查询...
    • challenges定义详细的压测方案

         3. 离线数据集下载:

在使用esrally进行比赛(压测)时,默认会根据赛道(track)配置 ~/.rally/benchmarks/tracks/default/geonames/track.json (如下)中“base-url”、“source-file”构建下载数据。下载数据较慢,可提前下载好,置于 ~/.rally/benchmarks/data/geonames 目录下。 或者:我们在elastic官网github上可以看到esrally的数据集相关描述 https://github.com/elastic/rally-tracks,通过rally-track/download.sh 中,下载
{% import "rally.helpers" as rally with context %}
{
  "version": 2,
  "description": "POIs from Geonames",
  "data-url": "http://benchmarks.elasticsearch.org.s3.amazonaws.com/corpora/geonames",
  "indices": [
    {
      "name": "geonames",
      "body": "index.json"
    }
  ],
  "corpora": [
    {
      "name": "geonames",
      "base-url": "https://rally-tracks.elastic.co/geonames",
      "documents": [
        {
          "source-file": "documents-2.json.bz2",
          "document-count": 11396503,
          "compressed-bytes": 265208777,
          "uncompressed-bytes": 3547613828
        }
      ]
    }
  ],
  "operations": [
    {{ rally.collect(parts="operations/*.json") }}
  ],
  "challenges": [
    {{ rally.collect(parts="challenges/*.json") }}
  ]
}

 

三、进行压测

  1. 压测命令:

esrally race --pipeline=benchmark-only --target-hosts=http://目标地址:目标端口 --track=geonames --challenge=append-no-conflicts --offline --include-tasks="type:bulk"
  • --pipline
  • --target-hosts: 目标集群地址
  • --track:赛道(默认geonames)
  • --challenge:track默认json配置中“challenges”包含:"append-no-conflicts"、"append-no-conflicts-index-only"、"append-fast-with-conflicts"和"significant-text"等,默认为:"append-no-conflicts"
  • --include-tasks:用户只运行 challenge 中的部分task
  • --cluster-health=yellow: 默认会检测集群状态,非green状态会直接退出,添加该参数可避免该状态
  • --test-model: 用测试数据运行,数据快
  • --client-options:指定一些客户端连接选项,比如用户名和密码。
  1. 总结报告:

    1. 通过日志查看每次输出的结果报告: ~/.rally/logs
    2. 通过json查看每次输出的结果报告:~/.rally/benchmarks/races
    3. 报告对比:
esrally compare --baseline= 46ad39e9-0959-4813-804d-4f95407d886d --contender=06324f7b-ab1c-4d81-b06b-45e537909374
  1. 参数介绍:Elasticsearch压测之Esrally压测标准 - 云+社区 - 腾讯云 (tencent.com)
   

四、参考:

标签:geonames,esrally,压测,--,elasticsearch,yangshujun,rally
来源: https://www.cnblogs.com/spaceapp/p/16376173.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有