通过docker运行

rally可以通过docker镜像运行

局限性

使用Docker镜像时,不支持以下Rally功能:

  1. 分发负载测试驱动程序以应用多台计算机的测试。
  2. 使用benchmark-only测试以外的其他 pipelines

快速开始

您可以通过一个简单的命令列出可用的tracks来测试Rally Docker镜像

  1. $ docker run elastic/rally list tracks
  2. ____ ____
  3. / __ \____ _/ / /_ __
  4. / /_/ / __ `/ / / / / /
  5. / _, _/ /_/ / / / /_/ /
  6. /_/ |_|\__,_/_/_/\__, /
  7. /____/
  8. Available tracks:
  9. Name Description Documents Compressed Size Uncompressed Size Default Challenge All Challenges
  10. ------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------- ----------------- ------------------- ----------------------- ---------------------------------------------------------------------------------------------------------------------------
  11. geopoint Point coordinates from PlanetOSM 60,844,404 481.9 MB 2.3 GB append-no-conflicts append-no-conflicts,append-no-conflicts-index-only,append-fast-with-conflicts
  12. eventdata This benchmark indexes HTTP access logs generated based sample logs from the elastic.co website using the generator available in https://github.com/elastic/rally-eventdata-track 20,000,000 755.1 MB 15.3 GB append-no-conflicts append-no-conflicts
  13. nested StackOverflow Q&A stored as nested docs 11,203,029 663.1 MB 3.4 GB nested-search-challenge nested-search-challenge,index-only
  14. so Indexing benchmark using up to questions and answers from StackOverflow 36,062,278 8.9 GB 33.1 GB append-no-conflicts append-no-conflicts
  15. geoshape Shapes from PlanetOSM 60,523,283 13.4 GB 45.4 GB append-no-conflicts append-no-conflicts
  16. http_logs HTTP server log data 247,249,096 1.2 GB 31.1 GB append-no-conflicts append-no-conflicts,append-no-conflicts-index-only,append-sorted-no-conflicts,append-index-only-with-ingest-pipeline,update
  17. geonames POIs from Geonames 11,396,505 252.4 MB 3.3 GB append-no-conflicts append-no-conflicts,append-no-conflicts-index-only,append-sorted-no-conflicts,append-fast-with-conflicts
  18. noaa Global daily weather measurements from NOAA 33,659,481 947.3 MB 9.0 GB append-no-conflicts append-no-conflicts,append-no-conflicts-index-only
  19. percolator Percolator benchmark based on AOL queries 2,000,000 102.7 kB 104.9 MB append-no-conflicts append-no-conflicts
  20. nyc_taxis Taxi rides in New York in 2015 165,346,692 4.5 GB 74.3 GB append-no-conflicts append-no-conflicts,append-no-conflicts-index-only,append-sorted-no-conflicts-index-only,update,append-ml
  21. geopointshape Point coordinates from PlanetOSM indexed as geoshapes 60,844,404 470.5 MB 2.6 GB append-no-conflicts append-no-conflicts,append-no-conflicts-index-only,append-fast-with-conflicts
  22. metricbeat Metricbeat data 1,079,600 87.6 MB 1.2 GB append-no-conflicts append-no-conflicts
  23. pmc Full text benchmark with academic papers from PMC 574,199 5.5 GB 21.7 GB append-no-conflicts append-no-conflicts,append-no-conflicts-index-only,append-sorted-no-conflicts,append-fast-with-conflicts
  24. -------------------------------
  25. [INFO] SUCCESS (took 3 seconds)
  26. -------------------------------

下一步,我们假设Elasticsearch在es01:9200上运行,并且可以从运行Rally Docker运行的主机上访问 使用以下命令在test-mode下运行nyc_taxis的tracks:

  1. $ docker run elastic/rally --track=nyc_taxis --test-mode --pipeline=benchmark-only --target-hosts=es01:9200

``` note:: 我们不需要像通常的命令行调用中那样显式指定esrally。 Docker镜像中的entrypoint会自动执行此操作。

  1. 现在,考虑到上述限制,您就可以使用所有常规的Rally命令。
  2. ## 配置
  3. Docker镜像的配置文件在`/rally/.rally/rally.ini`下,我们可以创建自己的配置文件并挂载使用:

docker run -v /home//custom_rally.ini:/rally/.rally/rally.ini elastic/rally …

  1. ## 持久化
  2. 强烈建议将容器的`/rally/.rally`挂载出来,这将确保您在调用之间具有持久性,并且下载和提取的任何tracks都可以重用,从而减少了启动时间。
  3. 您需要确保UID1000(尤其在OpenShift中,GID0),以便Rally可以写入挂载的目录。
  4. 如果您的挂载文件中不包含`rally.ini`,则容器会在首次运行时为您创建一个。
  5. 例子:

mkdir myrally sudo chgrp 0 myrally

First run will generate the rally.ini

docker run —rm -v $PWD/myrally:/rally/.rally elastic/rally —track=nyc_taxis —test-mode —pipeline=benchmark-only —target-hosts=es01:9200

  1. ____ ____

/ __ / / / / /_/ / `/ / / / / / / , / // / / / // / // ||_,///_, / /_/

Running simple configuration. Run the advanced configuration with:

esrally configure —advanced-config

  • Setting up benchmark root directory in /rally/.rally/benchmarks
  • Setting up benchmark source directory in /rally/.rally/benchmarks/src/elasticsearch

Configuration successfully written to /rally/.rally/rally.ini. Happy benchmarking!

More info about Rally:

now run our benchmark

docker run —rm -v $PWD/myrally:/rally/.rally elastic/rally —track=nyc_taxis —test-mode —pipeline=benchmark-only —target-hosts=es01:9200

inspect results

$ tree myrally/benchmarks/races/ myrally/benchmarks/races/ └── 1d81930a-4ebe-4640-a09b-3055174bce43 └── race.json

1 directory, 1 file

  1. 万一您忘记挂载目录,Rally Docker镜像将为/rally/.rally创建一个匿名卷,以确保即使容器终止后日志和结果也能持久保存。
  2. 例如,执行我们之前的快速入门示例:

docker run elastic/rally —track=nyc_taxis —test-mode —pipeline=benchmark-only —target-hosts=es01:9200 docker volume ls DRIVER VOLUME NAME local 96256462c3a1f61120443e6d69d9cb0091b28a02234318bdabc52b6801972199

  1. 为了进一步检查内容,我们可以将其绑定到另一个镜像中,例如:

$ docker run —rm -i -v=96256462c3a1f61120443e6d69d9cb0091b28a02234318bdabc52b6801972199:/rallyvolume -ti python:3.7.3-slim /bin/bash root@9a7dd7b3d8df:/# cd /rallyvolume/ root@9a7dd7b3d8df:/rallyvolume# ls root@9a7dd7b3d8df:/rallyvolume/.rally# ls benchmarks logging.json logs rally.ini

head -4 benchmarks/races/1d81930a-4ebe-4640-a09b-3055174bce43/race.json

{ “rally-version”: “1.2.1.dev0”, “environment”: “local”, “race-id”: “1d81930a-4ebe-4640-a09b-3055174bce43”,

  1. ## 一些细节
  2. Rally以用户1000的身份运行,其文件使用uidgid 10000进行安装(以支持[任意用户ID](https://docs.openshift.com/enterprise/3.1/creating_images/guidelines.html))。
  3. ## 扩展
  4. 您还可以在现有映像之上创建自己的自定义Docker映像。以下示例显示了如何入门:

FROM elastic/rally:1.2.1 COPY —chown=1000:0 rally.ini /rally/.rally/

  1. 然后,您可以使用以下命令构建和测试镜像:

docker build —tag=custom-rally . docker run -ti custom-rally list tracks ```