安裝
Python 3.8+ including pip3, git 1.9+html
pip3 install esrallypython
高級配置
esrally configure --advanced-config (可屢次執行)git
Enter the benchmark root directory (default: /home/apps/.rally/benchmarks): Using default value '/home/apps/.rally/benchmarks' Enter your Elasticsearch project directory: (default: /home/apps/.rally/benchmarks/src/elasticsearch): Using default value '/home/apps/.rally/benchmarks/src/elasticsearch' Where should metrics be kept? (1) In memory (simpler but less options for analysis) (2) Elasticsearch (requires a separate ES instance, keeps all raw samples for analysis) (default: 1): 2 Enter the host name of the ES metrics store (default: localhost): Using default value 'localhost' Enter the port of the ES metrics store: 9200 Use secure connection (True, False) (default: False): Username for basic authentication (empty if not needed) (default: ): Password for basic authentication (empty if not needed) (default: ): Enter a descriptive name for this benchmark environment (ASCII, no spaces) (default: local): rally_demo Do you want Rally to keep the Elasticsearch benchmark candidate installation including the index (will use several GB per trial run)? (default: False): Configuration successfully written to /home/apps/.rally/rally.ini. Happy benchmarking!
- rally-metrics-*:記錄race中全部的採樣數據(性能報告數據都是基於採樣數據彙總得出的結果),能夠經過採樣數據看到具體抖動狀況進行具體分析
- rally-results-*:基於上面的採樣數據進行詳細的數據彙總,針對每一個指標進行彙總,能夠針對每一個指標進行最終的結果展現
- rally-races-:把最終性能壓測結果(即咱們看到的輸出數據)展現出來,一個文檔就是一次race壓測
將測試結果放入開啓x_pack集羣中須要配置github
vim .rally/rally.inijson
[reporting]vim
#datastore.ssl.verification_mode = nonebash
datastore.ssl.certificate_authorities = /home/elasticsearch/client-ca.cerapp
使用
配置代理下載trackless
export http_proxy=http://proxy.acme.org:8888/
elasticsearch
/root/.rally/logs/rally.log將記錄
Rally connects via proxy URL [http://proxy.acme.org:3128/] to the Internet (picked up from the environment variable [http_proxy]).
esrally list tracks
相似於賽道的意思
nested 嵌套文檔 percolator 過濾查詢 eventdata geoshape geopoint 地理查詢 so geopointshape noaa metricbeat nyc_taxis 高度數據化結構 http_logs pmc 全文搜索 geonames 結構化數據
對現有集羣進行基準測試
esrally --track=pmc --target-hosts=10.5.5.10:9243,10.5.5.11:9243,10.5.5.12:9243 --pipeline=benchmark-only --client-options="use_ssl:true,verify_certs:true,basic_auth_user:'elastic',basic_auth_password:'changeme'" --user-tag="intention:baseline_github_1234" --report-file=result.csv --report-format=csv
rally能夠組成分佈式集羣,並能夠根據配置文件進行測試,由於沒有試過,這裏再也不贅述
esrally list races 對比兩場比賽
esrally compare --baseline=0bfd4542-3821-4c79-81a2-0858636068ce --contender=beb154e4-0a05-4f45-ad9f-e34f9a9e51f7
建立track
mkdir .rally/benchmarks/data/XXX
- 獲取數據 allCountries.txt
- 轉換爲json格式
vim toJSON.py import json cols = (("geonameid", "int", True), ("name", "string", True), ("asciiname", "string", False), ("alternatenames", "string", False), ("latitude", "double", True), ("longitude", "double", True), ("feature_class", "string", False), ("feature_code", "string", False), ("country_code", "string", True), ("cc2", "string", False), ("admin1_code", "string", False), ("admin2_code", "string", False), ("admin3_code", "string", False), ("admin4_code", "string", False), ("population", "long", True), ("elevation", "int", False), ("dem", "string", False), ("timezone", "string", False)) def main(): with open("allCountries.txt", "rt", encoding="UTF-8") as f: for line in f: tup = line.strip().split("\t") record = {} for i in range(len(cols)): name, type, include = cols[i] if tup[i] != "" and include: if type in ("int", "long"): record[name] = int(tup[i]) elif type == "double": record[name] = float(tup[i]) elif type == "string": record[name] = tup[i] print(json.dumps(record, ensure_ascii=False)) if __name__ == "__main__": main()
python3 toJSON.py > documents.json
-
編寫track.json
-
檢查是否可用
esrally info --track-path=~/rally-tracks/tutorial
track解剖
{% set index_count = 2 %} #設置循環次數 { "version": 2, "description": "Tutorial benchmark for Rally", "indices": [ { "name": "geonames", #要操做索引的名稱 "body": "index.json" } ], "corpora": [ #此軌道使用的全部文檔語料庫 { "name": "rally-tutorial", "documents": [ { "source-file": "documents.json", "document-count": 11658903, "uncompressed-bytes": 1544799789 } ] } ], "schedule": [ #具體執行的操做 { "operation": { "operation-type": "delete-index" #操做類型 } }, { "operation": { "operation-type": "create-index" } }, { "operation": { "operation-type": "cluster-health", "request-params": { "wait_for_status": "green" } } }, { "operation": { "operation-type": "bulk", "bulk-size": 5000 }, "warmup-time-period": 120, "clients": 8 }, { "operation": { "operation-type": "force-merge" } }, { "operation": { "name": "query-match-all", "operation-type": "search", "body": { "query": { "match_all": {} } } }, "clients": 8, #發起請求客戶端數量 "warmup-iterations": 1000, #預熱,不顯示在測量結果中 "iterations": 1000, #執行次數 "target-throughput": 100 #儘量慢地運行任務,target-throughput/clients/s qps } ] }
配置parallel實現並行執行語句
https://esrally.readthedocs.io/en/latest/track.html