其他分享
首页 > 其他分享> > esrally(elasticsearch压测工具)介绍(一)

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

作者:互联网

 

一、介绍

esrally是elastic search官方用于对ES集群集群进行压测的工具,可使用esrally构建不同版本集群、不同参数和数据进行压力测试,并且支持对结果进行比较。也支持对远程集群压测。 rally:(汽车,摩托车等)拉力赛,所以相关属于也与拉力赛相关。
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
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
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
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
  1. 压测数据于方案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定义压测方案相关

         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"
  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