elasticsearch系列(二) esrally压测

环境准备

  linux centOS(工作环境)

  python3.4及以上

  pip3

  JDK8

  git1.9及以上

  gradle2.13及以上

 准备过程中的坑

  这些环境准备没什么太大问题,都是wget下来安装就行,唯一有一个python3安装的坑。

  由于本人安装的是python3.6.1,pip3和setupTools都是集成在python安装包里的,比python2时代方便许多,当一切都井井有条后,pip3 install esrally,报出如下错误

  Could not fetch URL https://pypi.python.org/simple/esrally/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. – skipping

  这是因为pip3默认采用https协议获取资源,而ssl模块有点问题,最后找到的解决方法

  1.治标

  通过在~/.pip/pip.conf文件中加入

  trusted-host = 你要信任的url

  不采用https协议获取资源

  2.治本

  把当前的openssl-devel卸载了,然后重新安装一个

  yum remove openssl-devel

  yum install openssl-devel

  在python3.6中的/Modules/Setup 修改了启动配置

#修改结果如下:
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c 
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl 
-L$(SSL)/lib -lssl -lcrypto

  然后重新编译

esrally使用

通过esrally configure配置,根据提示来就行,如下图所示

使用本地es集群测试

--pipeline=benchmark-only

es官网下载

--pipeline=from-distribution

测试数据集,默认是geonames

--track=geonames

使用离线的数据集

--offline

常用命令组合

//第一次压测需要从远端下载数据集

esrally --pipeline=benchmark-only --target-hosts=host:9200 --distribution-version=5.2.2(本人用的5.2.2)

//之后数据集不变的话,直接使用本地数据集

esrally --pipeline=benchmark-only --target-hosts=host:9200 --distribution-version=5.2.2 --offline

注意

es集群必须处理green状态,否则会被禁止race

 

默认的压测数据的压测配置在 /root/.rally/benchmarks/tracks/default/geonames/track.json

默认压测的内容比较多,可以自定义压测内容,比如数据导入,数据搜索,统计搜索等,都是些es支持的命令

也有类似jmeter的压测配置,比如并发量,迭代次数,额定吞吐量,调度时间等

下图是esrally的压测的部分结果

 

总结

esrally是官方做压测的开源工具,权威程度不言而喻,但是有点复杂,相当于又学了一个部署复杂版的jmeter。所以如果单单只是想测试ES搜索性能的话,建议使用jmeter。

 

参考资料

//官网的rally教程

https://esrally.readthedocs.io/en/latest/

//官网的rally教程,关于压测内容的详细说明

http://esrally.readthedocs.io/en/0.5.3/track.html#search

//网友对rally的总结

http://m.blog.csdn.net/article/details?id=56291834

新博客地址 http://ixiaosi.art/ 欢迎来访 : )
原文地址:https://www.cnblogs.com/ulysses-you/p/6834127.html