美文网首页
Esrally性能测试步骤与调优

Esrally性能测试步骤与调优

作者: 朝朝Mumu | 来源:发表于2022-10-08 18:18 被阅读0次

    esrally一个对ElasticSearch做基准性能测试的工具,是 elastic 官方开源的一款基于 python3 实现的针对ES 的压测工具,ES官方也是基于 esrally 进行 es 的性能测试。

    安装部署

    python3.8安装

    使用root用户操作:

    yum install libffi-devel
    tar zxvf Python-3.8.0.tgz
    cd Python-3.8.0
    ./configure --prefix=/usr/local/python3
    make -j120
    make install
    rm -rf /usr/bin/python3
    ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
    

    可以自行查阅python官网:https://www.python.org/
    或者直接执行下载命令:
    wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

    git安装

    本环境已安装git version 2.23.0,如果git不满足要求,参考以下内容:

    git 源码可以通过下面的链接获取,有各种版本:

    https://mirrors.edge.kernel.org/pub/software/scm/git/

    卸载旧版本

    yum remove git

    编译安装

    tar -xzvf git-2.23.0.tar.gz 
    cd git-2.23.0
    ./configure --prefix=/usr/local/git --with-openssl=/usr/local/openssl
    sudo make && make install
    

    配置GIT的环境变量去修改 /etc/profile

    export GIT_HOME=/usr/local/git-2.23.0
    export PATH=\$PATH:\$GIT_HOME

    保存后执行source /etc/pfofile

    使用 git version 查看GIT版本。

    在线安装esrally

    pip3 install esrally==2.0.2 -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
    

    错误1

    ERROR: botocore 1.13.50 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.9 which is incompatible.

    解决办法:

    pip3 install urllib3==1.25
    重新执行安装命令,显示所有依赖均满足条件。

    错误2

    [root@worker1 opt]# esrally configure
    -bash: esrally:未找到命令

    不是安装失败,是因为esrally命令不会自动加入了环境变量!

    cd /usr/local/python3/bin

    ./esrally configure

    错误3

    最后一行报错ImportError: cannot import name ‘soft_unicode‘ from ‘markupsafe‘……
    查到弃用警告:“soft_unicode”已重命名为“soft_str”.旧名称将在 MarkupSafe 2.1 中删除,刚好这里已经是2.1.1版本了,看来需要回退低版本。
    解决办法:
    pip3 install markupsafe==2.0.1
    再次执行./esrally configure成功安装了!

    测试命令

    数据集下载

    这部分测试所需要的数据集可以在测试中下载,但数据集大且网络不稳定,因此预下载。

    如下操作:

    # downloads the script from Github
    curl -O https://raw.githubusercontent.com/elastic/rally-tracks/master/download.sh
    chmod u+x download.sh
    chown elasticsearch  download.sh
    # download all data for the geonames track
    su elasticsearch
    cd /usr/local/python3/bin/
    ./esrally configure
    cd ~
    ./download.sh geonames
    

    测试命令

    geonames测试实例:

    ./esrally --pipeline=benchmark-only --target-hosts=192.168.1.104:9200,192.168.1.106:9200,192.168.1.108:9200  --track=geonames --offline --track-params="number_of_shards:32,bulk_indexing_clients:128"  --report-file=/opt/report_geonames_32_128-numa.csv --report-format=csv
    

    性能调优

    ES参数

    1. ES的内存(heap size)
      堆内存配置文件 jvm.options设置(相同大小,不超过32g情况下尽可能大):
    -Xms16g
    -Xmx16g
    
    1. ES的thread_pool
      主要是不超过物理机的cpu核心数,一般越大越好。
      注意!这类参数现在不能动态设置了,必须直接修改es的配置文件保存然后重启ES集群。
    2. 关闭ES的监控(xpack),设置xpack.monitoring.collection.enabled 为false,提高稳定性。
    3. 调整ES的数据盘为多目录
      对ES读性能影响不大,可能略微对写ES性能有影响。

    esrally参数

    主要是分片数(shards)和客户端并发数需要调整!
    客户端并发数非常重要!客户端并发数非常重要!客户端并发数非常重要!
    如果不调大这个clients数其他参数基本白搭。

    踩坑2天……

    参考文档

    01:Elasticsearch压测之Esrally压测标准 - 腾讯云开发者社区-腾讯云
    02:esrally:Elasticsearch 官方压测工具及运用详解-阿里云开发者社区
    03:es7.3的性能参数调优_thread_pool.write.size

    相关文章

      网友评论

          本文标题:Esrally性能测试步骤与调优

          本文链接:https://www.haomeiwen.com/subject/fmdwartx.html