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 

 

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