ES 是近乎線性擴(kuò)展的分布式系統(tǒng),所以可以總結(jié)成同一個(gè)測(cè)試模式:
1.使用和線上集群相同硬件配置的服務(wù)器搭建一個(gè)單節(jié)點(diǎn)集群。
2.使用和線上集群相同的映射創(chuàng)建一個(gè) 0 副本,1 分片的測(cè)試索引。
3.使用和線上集群相同的數(shù)據(jù)寫入進(jìn)行壓測(cè)。
4.觀察寫入性能,或者運(yùn)行查詢請(qǐng)求觀察搜索聚合性能。
5.持續(xù)壓測(cè)數(shù)小時(shí),使用監(jiān)控系統(tǒng)記錄 eps、requesttime、fielddata cache、GC count 等關(guān)鍵數(shù)據(jù)。
測(cè)試完成后,根據(jù)監(jiān)控系統(tǒng)數(shù)據(jù),確定單分片的性能拐點(diǎn),或者適合自己預(yù)期值的臨界點(diǎn)。這個(gè)數(shù)據(jù),就是一個(gè)基準(zhǔn)數(shù)據(jù)。之后的擴(kuò)容計(jì)劃,都可以以這個(gè)基準(zhǔn)單位進(jìn)行。
需要注意的是,測(cè)試是以分片為單位的,在實(shí)際使用中,因?yàn)橹鞣制透北痉制际窃诟髯怨?jié)點(diǎn)做 indexing 和 merge 操作,需要消耗同樣的寫入性能。所以,實(shí)際集群的容量預(yù)估中,要考慮副本數(shù)的影響。也就是說,假如你在基準(zhǔn)測(cè)試中得到單機(jī)寫入性能在 10000 eps,那么開啟一個(gè)副本后所能達(dá)到的 eps 就只有 5000 了。還想寫入 10000 eps 的話,就需要加一倍機(jī)器。
因?yàn)閑srally 需要使用 pip3
一、PIP 3安裝說明
1、下載安裝
登陸服務(wù)器
[server]$ cd ~
[server]$ mkdir tmp
[server]$ cd tmp
[server]$ wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
[server]$ tar zxvf Python-3.6.2.tgz
[server]$ cd Python-3.6.2
[server]$ ./configure --prefix=$HOME/opt/python-3.6.2
[server]$ make
[server]$ make install
修改profile
[server]$ vim /etc/profile
在文件尾部加入配置
export PATH=$HOME/opt/python-3.6.2/bin:$PATH
[server]$ source /etc/profile
驗(yàn)證信息
[server]$ which python3
/root/opt/python-3.6.2/bin/python3
[server]$ python3 --version
Python 3.6.2
安裝完畢
二 、 安裝 esrally
官方文檔有介紹
Install Python 3.5+ including pip3, git 1.9+ and an appropriate JDK to run Elasticsearch Be sure that JAVA_HOME points to that JDK. Then run the following command, optionally prefixed by sudoif necessary:
python 3.5+
git 1.9+
JAVA_HOME 必須配置了JDK
[server]$ pip3 install esrally
如果第一步有任何問題 ,看文檔 https://esrally.readthedocs.io/en/stable/install.html
[server]$ esrally configure //首次配置 檢測(cè)環(huán)境,官方詳細(xì)配置 https://esrally.readthedocs.io/en/stable/configuration.html
____ ____
/ __ \____ _/ / /_ __
/ /_/ / __ `/ / / / / /
/ _, _/ /_/ / / / /_/ /
/_/ |_|\__,_/_/_/\__, /
/____/
Running simple configuration. Run the advanced configuration with:
esrally configure --advanced-config
* Setting up benchmark root directory in /root/.rally/benchmarks
* Setting up benchmark source directory in /root/.rally/benchmarks/src/elasticsearch
Configuration successfully written to /root/.rally/rally.ini. Happy benchmarking!
More info about Rally:
* Type esrally --help
* Read the documentation at https://esrally.readthedocs.io/en/1.2.1/
* Ask a question on the forum at https://discuss.elastic.co/c/elasticsearch/rally
我這里的需求很簡(jiǎn)單,需要測(cè)試的是現(xiàn)有集群,所以使用pipeline方式,官方自帶的數(shù)據(jù)樣本必須要安裝git ,然后下載,而且下載巨慢,可以考慮自己生成數(shù)據(jù)。
esrally --track=percolator --target-hosts=192.168.81.101:39202,192.168.81.102:39202,192.168.81.103:39202 --pipeline=benchmark-only
esrally --pipeline=benchmark-only --target-hosts=192.168.41.4:9200,192.168.41.5:9200,192.168.41.6:9200,192.168.41.7:9200,192.168.41.8:9200,192.168.41.9:9200
因 數(shù)據(jù)文件太大所以這里需要進(jìn)行自定義數(shù)據(jù)集和自定義腳本進(jìn)行測(cè)試(編寫中)