ES-esrally壓測工具

環境:

esrally 的文檔在這裏,這裏簡單說下安裝與運行。

esrally 對於軟件環境的要求如下:

  • Python 3.4+ 和 pip3 
  • bzip2-devel
  • JDK 8
  • git 1.9+ 以上

 

0、前置工作

esrally會用到bz2,需要先安裝bzip2-devel,然後再編譯python3

升級git 鏈接

1、安裝python3虛擬機環境:

Updata the python and pip at the latest version

python3 -m pip install --user --upgrade pip

python3 -m pip --version

 

Install the virtualenv

python3 -m pip install --user virtualenv

Note:If you are using Python 3.3 or newer the venv module is included in the Python standard library. This can also create and manage virtual environments, however, it only supports Python 3.

Creating a virtualenv

python3 -m virtualenv env

The second argument is the location to create the virtualenv. Generally, you can just create this in your project and call it env.

virtualenv will create a virtual Python installation in the env folder.

Activating a virtualenv

Before you can start installing or using packages in your virtualenv you’ll need to activate it. Activating a virtualenv will put the virtualenv-specific python and pip executables into your shell’s PATH.

source env/bin/activate

Leaving the virtualenv

If you want to switch projects or otherwise leave your virtualenv, simply run:

deactivate

 

2、安裝esrally

 

安裝方法爲:

pip3 install esrally

Tips: 

可以使用國內的pip源,比如豆瓣或者阿里的,這樣安裝會快很多。

安裝完畢後執行如下的配置命令,確認一些數據存放的路徑即可。

esrally configure

接下來就可以開跑了,比如下面這條命令是針對 es 5.0.0 版本進行壓力測試。

esrally --distribution-version=5.0.0

#這一步是下載es,安裝,壓測一條龍

運行結束後,會得到如下的結果。

對於第一次見到壓測結果的同學來說可能有些暈,這麼多數據,該怎麼看?!別急,一步步來!

Tips:

由於 esrally 的測試數據存儲在國外 aws 上,導致下載很慢甚至會超時失敗,從而導致整個壓測無法進行。後面我會把這些測試數據的壓縮包放到國內,大家可以下載後直接放到 esrally 的數據文件夾下面,保證壓測的正常進行。另外由於數據量過大,壓測的時間一般會很久,可能在1個小時左右,所以大家要有耐心哦~

如果你只是想體驗下,可以加上 --test-mode 的參數,此時只會下載1000條文檔進行測試。

 

 

 

3、測試已有集羣:

esrally race --pipeline=benchmark-only --target-hosts=127.0.0.1:9200 --track=nyc_taxis --challenge=append-no-conflicts

 

如果已有集羣設置了用戶名密碼,需要參照如下設置:

esrally race --pipeline=benchmark-only --target-hosts=es-cn-4591b51kf000f9ka4.elasticsearch.aliyuncs.com:9200 --track=nyc_taxis --challenge=append-no-conflicts --distribution-version=6.7.0 --client-options="use_ssl:false,basic_auth_user:'elastic',basic_auth_password:'Db9GQ6BKCQSid7NSBc51',verify_certs:false"

參數說明:

--pipeline benchmark-only 命令行參數將 Rally 指向現有的集羣

--target-host  實例url:port

--client-options 用於指定憑證

verify-certs:false,設置false,因爲 Rally 將會拒絕演示版證書

可以使用 esrally list tracks 命令來查看這些跑道

 

由於默認創建的索引是1shard,0replicas,因此要提前設置索引分片格式,然後再跑壓測進程

curl -XPUT -H 'Content-Type: application/json' -u elastic:Db9GQ6BKCQSid7NSBc51 http://es-cn-4591b51kf000f9ka4.elasticsearch.aliyuncs.com:9200/aliyunesrally -d '{  "settings": { "index": { "number_of_replicas": "2", "number_of_shards": "3" } } }'

 

參考:

git:https://www.cnblogs.com/kevingrace/p/8252517.htmln

esrally:https://segmentfault.com/a/1190000011174694 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章