百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术资源 > 正文

ESRally离线安装与测试(easybuilderpro离线模拟)

off999 2024-10-04 00:31 28 浏览 0 评论

一、背景与介绍

(1)ESRally介绍:

ESrally是Elastic官方的,基于用户视角的对elasticsearch进行测试的工具。

术语:

  • rally:汽车拉力赛
  • track:赛道,压测方案。 在 Rally 中,每一次测试用的数据,都可以称之为 Track,不同的 Track 意味着不同的测试数据。
  • team/car: es instance,在 Rally 中,每一个参与测试的集群,都可以称之为 car ,不同的集群就是不同的 car,如果你是在选配置,则可以通过切换 car 来设置不同配置的测试。
  • race: 一场比赛,在 Rally 中,每一次测试都可以称之为 race
  • tournament: 锦标赛
  • challange:在 Rally 中,每一个 challange 意味着一个不同的测试场景,具体的场景则代表着 ElasticSearch 所执行的操作。

(2)测试背景与介绍

因为是生产环境,整个环境与互联网隔离。查看ESRally安装步骤,需要安装Python3、Git、JDK等,并且每个环境都有严格的版本要求,由于生产环境采用Centos7.9,Python3、Git、JDK均不符合版本要求,升级更新版本操作风险较高,故采用docker离线部署的方式。

二、测试步骤

(1)docker环境安装

1、Docker安装包下载:

https://download.docker.com/linux/static/stable/x86_64/

下载对应的安装包,此处可以使用最新安装包,我使用的版本是docker-20.10.9.tgz

2、准备docker.service 系统配置文件

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

3、准备安装脚本和卸载脚本

安装脚本 install.sh

#!/bin/sh
echo '解压tar包...'
tar -xvf $1

echo '将docker目录移到/usr/bin目录下...'
cp docker/* /usr/bin/

echo '将docker.service 移到/etc/systemd/system/ 目录...'
cp docker.service /etc/systemd/system/

echo '添加文件权限...'
chmod +x /etc/systemd/system/docker.service

echo '重新加载配置文件...'
systemctl daemon-reload

echo '启动docker...'
systemctl start docker

echo '设置开机自启...'
systemctl enable docker.service

echo 'docker安装成功...'
docker -v

卸载脚本 uninstall.sh

#!/bin/sh

echo '删除docker.service...'
rm -f /etc/systemd/system/docker.service

echo '删除docker文件...'
rm -rf /usr/bin/docker*

echo '重新加载配置文件'
systemctl daemon-reload

echo '卸载成功...'

4、安装

此时目录为:(只需要关注docker-20.10.9.tgz、docker.service、install.sh、uninstall.sh即可)

执行脚本 sh install.sh docker-20.10.9.tgz

查看docker 版本:docker -v

PS:如果需要卸载,操作如下:sh [uninstall.sh](<http://uninstall.sh/>)

(2) ESRally配置与安装

1、ESRally Docker image下载

(a)通过docker registry下载。

https://hub.docker.com/r/elastic/rally

在可以连通外网的docker环境上运行 docker pull elastic/rally 下载最新版本rally。

下载完成后,输入命令

docker save -o rally.docker elastic/rally

(b)作者已经构建好相关镜像,直接下载。

链接:https://pan.baidu.com/s/1FNs7dLbtE3aDZFbMlI_INQ 提取码:o2gh

2、镜像加载

docker load -i tensorflow_image.docker

3、ESRally配置

笔者尝试了网上很多方法,包括官网描述的offline安装步骤。

https://esrally.readthedocs.io/en/latest/install.html#offline-install

但是offline步骤也需要安装基础的环境,且通过docker环境进行volume绑定时,即使把benchmark相关的git工程下载下来,放到对应目录还是不行,因为整个过程中,rally会通过checkout命令获取对应的最新分支,而做checkout时,还是需要连接网络。

通过很多尝试,笔者使用了track-path的方式进行操作。具体步骤如下:

(A)下载对应测试数据集

http://benchmarks.elasticsearch.org.s3.amazonaws.com/corpora/geonames/documents-2.json.bz2

解压后,得到文件documents-2.json

(B)生成配置文件

生成 index.json 文件

{
  "settings": {
    "index.number_of_replicas": 0
  },
  "mappings": {
    "docs": {
      "dynamic": "strict",
      "properties": {
        "geonameid": {
          "type": "long"
        },
        "name": {
          "type": "text"
        },
        "latitude": {
          "type": "double"
        },
        "longitude": {
          "type": "double"
        },
        "country_code": {
          "type": "text"
        },
        "population": {
          "type": "long"
        }
      }
    }
  }
}

生成 track.json 文件

{
  "version": 2,
  "description": "Tutorial benchmark for Rally",
  "indices": [
    {
      "name": "geonames",
      "body": "index.json",
      "types": [ "docs" ]
    }
  ],
  "corpora": [
    {
      "name": "rally-tutorial",
      "documents": [
        {
          "source-file": "documents.json",
          "document-count": 11658903,
          "uncompressed-bytes": 1544799789
        }
      ]
    }
  ],
  "schedule": [
    {
      "operation": {
        "operation-type": "delete-index"
      }
    },
    {
      "operation": {
        "operation-type": "create-index"
      }
    },
    {
      "operation": {
        "operation-type": "cluster-health",
        "request-params": {
          "wait_for_status": "green"
        },
        "retry-until-success": true
      }
    },
    {
      "operation": {
        "operation-type": "bulk",
        "bulk-size": 5000
      },
      "warmup-time-period": 120,
      "clients": 8
    },
    {
      "operation": {
        "operation-type": "force-merge"
      }
    },
    {
      "operation": {
        "name": "query-match-all",
        "operation-type": "search",
        "body": {
          "query": {
            "match_all": {}
          }
        }
      },
      "clients": 8,
      "warmup-iterations": 1000,
      "iterations": 1000,
      "target-throughput": 100
    }
  ]
}

其中

{
          "source-file": "documents.json",
          "document-count": 11658903,
          "uncompressed-bytes": 1544799789
        }

需要按照情况生成,source-file为刚刚解压的文件名称,document-count使用wc -l documents.json 生成;uncompressed-bytes 如果为MacOS使用命令stat -f %z documents.json。如果是Linux系统,使用stat -f %z documents.json 得到。

将该文件夹打包后,放置在生产环境对应的目录下,笔者存放在 /home/test/rally/benchmarks/data/single

(C)运行名称查看track情况

docker run -v /home/test/rally/:/rally/.rally/ elastic/rally list tracks --track-path=/rally/.rally/benchmarks/data/single

(D)运行测试

docker run -v /home/test/rally:/rally/.rally elastic/rally race --pipeline=benchmark-only --target-hosts=10.142.3.6:9200 --track-path=/rally/.rally/benchmarks/data/rally-tutorial --client-options="basic_auth_user:'xxx',basic_auth_password:'xxx'" --offline  --report-format=csv --report-file=/rally/.rally/benchmarks/result.csv

Tips:

basic_auth_user:'xxx',basic_auth_password:'xxx':如果使用了认证,可以通过该参数

pipeline=benchmark-only: docker的esrally只能使用该模式进行测试。该模式表示当前存在集群,对该集群进行压力测试。

report-file : 对应的报告输出地址。

offline :采用离线方式测试。

测试结果如图所示:

三、后记

后续,笔者将测试用例打包至docker镜像中,只需执行命令即可。

参考文献:

https://esrally.readthedocs.io/en/stable/adding_tracks.html?highlight=track-path#creating-a-track-from-scratch

http://download.geonames.org/export/dump/allCountries.zip

http://esrally.lyremelody.org/zh_CN/latest/index.html

Tips:

1、Docker 绑定volume时报:permission not allow 可以对绑定账号赋权777

相关推荐

Python设计模式 第 13 章 中介者模式(Mediator Pattern)

在行为型模式中,中介者模式是解决“多对象间网状耦合”问题的核心模式。它就像“机场调度中心”——多个航班(对象)无需直接沟通起飞、降落时间,只需通过调度中心(中介者)协调,避免航班间的冲突与混乱...

1.3.1 python交互式模式的特点和用法

什么是Python交互模式Python交互模式,也叫Python交互式编程,是一种在Python解释器中运行的模式,它允许用户在解释器窗口中输入单个Python语句,并立即查看结果,而不需要编写整个程...

Python设计模式 第 8 章 装饰器模式(Decorator Pattern)

在结构型模式中,装饰器模式是实现“动态功能扩展”的核心模式。它就像“手机壳与手机的关系”——手机(原始对象)具备通话、上网等基础功能,手机壳(装饰器)可在不改变手机本身的前提下,为其新增保护、...

python设计模式 综合应用与实战指南

经过前面16章的学习,我们已系统掌握创建型模式(单例、工厂、建造者、原型)、结构型模式(适配器、桥接、组合、装饰器、外观、享元、代理)、行为型模式(责任链、命令、迭代器、中介者、观察者、状态、策略...

Python入门学习教程:第 16 章 图形用户界面(GUI)编程

16.1什么是GUI编程?图形用户界面(GraphicalUserInterface,简称GUI)是指通过窗口、按钮、菜单、文本框等可视化元素与用户交互的界面。与命令行界面(CLI)相比,...

Python 中 必须掌握的 20 个核心:str()

str()是Python中用于将对象转换为字符串表示的核心函数,它在字符串处理、输出格式化和对象序列化中扮演着关键角色。本文将全面解析str()函数的用法和特性。1.str()函数的基本用法1.1...

Python偏函数实战:用functools.partial减少50%重复代码的技巧

你是不是经常遇到这样的场景:写代码时同一个函数调用了几十次,每次都要重复传递相同的参数?比如处理文件时总要用encoding='utf-8',调用API时固定传Content-Type...

第2节.变量和数据类型【第29课-输出总结】

同学们,关于输出的知识点讲解完成之后,把重点性的知识点做一个总结回顾。·首先对于输出这一章节讲解的比如有格式化符号,格式化符号这里需要同学们额外去多留意的是不是百分号s格式化输出字符串。当然课上也说百...

AI最火语言python之json操作_python json.loads()

JSON(JavaScriptObjectNotation,JavaScript对象表示法)是一种开放标准的文件格式和数据交换格式,它易于人阅读和编写。JSON是一种常用的数据格式,比如对接各种第...

python中必须掌握的20个核心函数—split()详解

split()是Python字符串对象的方法,用于将字符串按照指定的分隔符拆分成列表。它是文本处理中最常用的函数之一。一、split()的基本用法1.1基本语法str.split(sep=None,...

实用方法分享:pdf文件分割方法 横向A3分割成纵向A4

今天在街上打印店给儿子打印试卷时,我在想:能不能,把它分割成A4在家中打印,这样就不需要跑到街上的打印店打印卷子了。原来,老师发的作业,是电子稿,pdf文件,A3格式的试卷。可是家中的打印机只能打印A...

20道常考Python面试题大总结_20道常考python面试题大总结免费

20道常考Python面试题大总结关于Python的面试经验一般来说,面试官会根据求职者在简历中填写的技术及相关细节来出面试题。一位拿了大厂技术岗SpecialOffer的网友分享了他总结的面试经...

Kotlin Data Classes 快速上手_kotlin快速入门

引言在日常开发中,我们常常需要创建一些只用来保存数据的类。问题是,这样的类往往需要写一堆模板化的方法:equals()、hashCode()、toString()……每次都重复,既枯燥又容易出错。//...

python自动化RobotFramework中Collections字典关键字使用(五)

前言介绍安装好robotframework库后,跟之前文章介绍的BuiltIn库一样BuiltIn库使用介绍,在“python安装目录\Lib\site-packages\robot\librarie...

Python中numpy数据分析库知识点总结

Python中numpy数据分析库知识点总结二、对已读取数据的处理②指定一个值,并对该值双边进行修改③指定两个值,并对第一个值的左侧和第二个值的右侧进行修改2.4数组的拼接和行列交换①竖直拼接(np...

取消回复欢迎 发表评论: