環境准備
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