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

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

off999 2024-10-04 00:31 22 浏览 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

相关推荐

SPC相关的计算用excel和python实现【源码下载】

做SPC分析涉及到很多计算,比如CPK、PPK、概率图、PPM等等,网上很多公式,但具体实现却不是那么容易的。我们整理了这些用excel和python实现的代码。包括但不限于以下的内容:SPC分析中的...

Python学不会来打我(34)python函数爬取百度图片_附源码

随着人工智能和大数据的发展,图像数据的获取变得越来越重要。作为Python初学者,掌握如何从网页中抓取图片并保存到本地是一项非常实用的技能。本文将手把手教你使用Python函数编写一个简单的百度图片...

django python数据中心、客户、机柜、设备资源管理平台源码分享

先转发后关注,私信“资源”即可免费获取源码下载链接!本项目一个开源的倾向于数据中心运营商而开发的,拥有数据中心、客户、机柜、设备、跳线、物品、测试、文档等一些列模块的资源管理平台,解决各类资源集中管理...

熬夜也值得学习练手的108个Python项目(附源码),太实用了!

现在学编程的人越来越多,Python因为简单好上手、功能又强大,成了很多人的首选。不管是做数据分析、人工智能,还是写网络程序、自动化脚本,Python都能派上用场。而且它诞生的时间比网页还早,作为...

这五个办公室常用自动化工具python源码,复制代码就能用

办公室自动化现在能看这文章的恐怕大部分都是办公室久坐工作者,很多都有腰肌劳损、肩周炎等职业病,难道就不能有个工具缓解一下工作量吗?那么恭喜你点进了这篇文章,这篇文章将使用python直接实现五个常...

将python源代码封装成window可执行程序教程

将python源代码封装成window可执行程序教程点击键盘win+r打开运行框在运行框中输入cmd,进入到命令行。在命令行中输入piplist去查看当前电脑中所有的库检查是否有pyinstall...

Python 爬虫如何爬取网页源码?(爬虫获取网页源代码)

下面教大家用几行代码轻松爬取百度首页源码。什么是urllib?urllib库是Python内置的HTTP请求库,它可以看做是处理URL的组件集合。urllib库包含了四大模块,具体如下:urllib....

Python RPC 之 Thrift(python是做什么的)

thrift-0.12.0python3.4.3Thrift简介:Thrift是一款高性能、开源的RPC框架,产自Facebook后贡献给了Apache,Thrift囊括了整个RP...

用Python编写FPGA以太网MAC(附源码下载方式)

来源:EETOP作者:ccpp123略作了解后发现,MyHDL不是高层次综合,它实际上是用Python的一些功能实现了一个Verilog仿真器,能对用Python写的仿Verilog语言进行仿...

python爬虫常用工具库总结(python爬虫工具下载)

说起爬虫,大家可能第一时间想到的是python,今天就简单为大家介绍下pyhton常用的一些库。请求库:实现基础Http操作urllib:python内置基本库,实现了一系列用于操作url的功能。...

手把手教你使用scrapy框架来爬取北京新发地价格行情(理论篇)

来源:Python爬虫与数据挖掘作者:霖hero大家好!我是霖hero。上个月的时候,我写了一篇关于IP代理的文章,手把手教你使用XPath爬取免费代理IP,今天在这里分享我的第二篇文章,希望大家可以...

2025年Python爬虫学习路线:第1阶段 爬虫基础入门开始

这个阶段的目标是让你熟悉Python的基础知识、了解HTTP请求和HTML是如何工作的,并最终完成你的第一个爬虫小项目——抓取名言!按照计划,我们首先要打好Python基础。Python就像是我们要...

如何入门 Python 爬虫?(python零基础爬虫)

1.很多人一上来就要爬虫,其实没有弄明白要用爬虫做什么,最后学完了却用不上。大多数人其实是不需要去学习爬虫的,因为工作所在的公司里有自己的数据库,里面就有数据来帮助你完成业务分析。什么时候要用到爬虫呢...

突破爬虫瓶颈:Python爬虫核心能力提升与案例实操

技术控必看!Python爬虫高手进阶全攻略,解锁数据处理高阶玩法在数字化时代,Python爬虫早已成为数据探索者手中的得力工具。从基础的网页抓取到复杂的数据处理,每一次技术升级都能带来新的突破。本文将...

网络爬虫开源框架(网络爬虫的框架)

目前开源爬虫下载框架是百花齐放,各个编程语言都有,以下主要介绍其中重要的几个:1)python:scrapy,pyspider,gcrawler2)Java:webmagic,WebCollector...

取消回复欢迎 发表评论: