组件压测

压力测试Mysql

安装sysbench

wget https://github.com/akopytov/sysbench/archive/1.0.zip -O "sysbench-1.0.zip"
unzip sysbench-1.0.zip
cd sysbench-1.0
yum install automake libtool –y
./autogen.sh

./configure  
#如果出现:configure: error: mysql_config executable not found,需要安装:mariadb-devel (yum install mariadb-devel 安装mysql_config) 可能还要安装mariadb-server包,yum install mariadb-server,但是我没有遇到。


export LD_LIBRARY_PATH=/usr/local/mysql8/include  
#这里要换成自己的mysql路径下的include,可以用:which mysql命令查看mysql位置。
make && make install

sysbench --version  
#如果报错 error while loading shared libraries: libmysqlclient.so.21: cannot open shared object file: No such file or directory
#添加环境变量
export LD_LIBRARY_PATH=/usr/local/mysql8/lib:$LD_LIBRARY_PATH

压测方法

#创建库
CREATE DATABASE testdb;

#测试1张表1000万数据
time sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=192.168.1.179 --mysql-port=3308 --mysql-user=root --mysql-password='11223344!!' --mysql-db=testdb --table-size=10000000 --tables=1 prepare

#测试10张表100万数据
time sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=192.168.1.179 --mysql-port=3308 --mysql-user=root --mysql-password='11223344!!' --mysql-db=testdb --table-size=1000000 --tables=10 prepare


#4个进程 测试60秒1张表1000万数据的读写操作
time sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=192.168.1.179 --mysql-port=3308 --mysql-user=root --mysql-password='11223344!!' --mysql-db=testdb --table-size=10000000 --tables=1 --threads=4 --time=60 run

#测试删除数据1张表1000万数据
time sysbench /usr/local/share/sysbench/oltp_read_write.lua --mysql-host=192.168.1.179 --mysql-port=3308 --mysql-user=root --mysql-password='11223344!!' --mysql-db=testdb --table-size=10000000 --tables=1 cleanup

压力测试ES

安装esrally

pip3 install esrally
#创建软连接
ln -s /usr/local/python3/bin/esrally /usr/bin/esrally
#执行命令 验证有没有成功
esrally list tracks

    ____        ____
   / __ \____ _/ / /_  __
  / /_/ / __ `/ / / / / /
 / _, _/ /_/ / / / /_/ /
/_/ |_|\__,_/_/_/\__, /
                /____/

Available tracks:

Name                     Description                                                                       Documents    Compressed Size    Uncompressed Size    Default Challenge                               All Challenges
-----------------------  --------------------------------------------------------------------------------  -----------  -----------------  -------------------  ----------------------------------------------  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cohere_vector            Benchmark for vector search with Cohere Wikipedia data                            32,893,221   186.9 GB           507.0 GB             index-and-search                                index-and-search
dense_vector             Benchmark for dense vector indexing and search                                    10,000,000   7.2 GB             19.5 GB              index-and-search                                index-and-search
elastic/apm              Elastic APM benchmark for Rally                                                   19,557       N/A                52.4 MB              default                                         default
elastic/endpoint         Endpoint track                                                                    0            0 bytes            0 bytes              default                                         default
elastic/logs             Track for simulating logging workloads                                            16,469,078   N/A                N/A                  logging-indexing                                cross-clusters-search-and-replication,cross-clusters-search-and-snapshot,logging-disk-usage,logging-indexing-querying,logging-indexing,logging-querying-concurrent-stress,logging-querying,logging-snapshot-mount,logging-snapshot-restore,logging-snapshot,many-shards-quantitative,many-shards-snapshots
elastic/security         Track for simulating Elastic Security workloads                                   77,513,777   N/A                N/A                  security-querying                               generate-alerts-source-events,security-indexing-querying,security-indexing,security-querying
elser-ingest-speedtest   Benchmark weighted terms queries on ELSER tokens on the MS MARCO passage dataset  1,050,000    N/A                2.0 GB               ELSER-V2                                        ELSER-V1,ELSER-V2-PlatformSpecific,ELSER-V2,ELSER-Min-Latency-Multi-Doc-Multi-Parametric-Ingest,ELSER-Size-Search-Multi-Doc-Multi-Parametric-Ingest,ELSER-Multi-Doc-Multi-Parametric-Ingest,ELSER-Multi-Parametric-Ingest
eql                      EQL benchmarks based on endgame index of SIEM demo cluster                        60,782,211   4.5 GB             109.2 GB             default                                         default,index-sorting
geonames                 POIs from Geonames                                                                11,396,503   252.9 MB           3.3 GB               append-no-conflicts                             append-no-conflicts,append-no-conflicts-index-only,append-fast-with-conflicts,significant-text
geopoint                 Point coordinates from PlanetOSM                                                  60,844,404   482.1 MB           2.3 GB               append-no-conflicts                             append-no-conflicts,append-no-conflicts-index-only,append-fast-with-conflicts
geopointshape            Point coordinates from PlanetOSM indexed as geoshapes                             60,844,404   470.8 MB           2.6 GB               append-no-conflicts                             append-no-conflicts,append-no-conflicts-index-only,append-fast-with-conflicts
geoshape                 Shapes from PlanetOSM                                                             84,220,567   17.0 GB            58.7 GB              append-no-conflicts                             append-no-conflicts,append-no-conflicts-big
http_logs                HTTP server log data                                                              247,249,096  1.2 GB             31.1 GB              append-no-conflicts                             append-no-conflicts,runtime-fields,append-no-conflicts-index-only,append-sorted-no-conflicts,append-index-only-with-ingest-pipeline,update,append-no-conflicts-index-reindex-only
k8s_metrics              Index refresh benchmarks with a Kubernetes pod metrics dataset                    8,642,016    2.1 GB             86.1 GB              append-no-conflicts-metrics-index-with-refresh  append-no-conflicts-metrics-index-with-refresh,append-no-conflicts-metrics-index-with-intermittent-refresh,append-no-conflicts-metrics-index-only,append-no-conflicts-metrics-with-fast-refresh,fast-refresh-index-only,fast-refresh-index-with-search
metricbeat               Metricbeat data                                                                   1,079,600    87.7 MB            1.2 GB               append-no-conflicts                             append-no-conflicts
msmarco-passage-ranking  Benchmark bm25, semantic and hybrid search on the MS MARCO passage dataset        8,841,823    16.3 GB            53.6 GB              msmarco-passage-ranking                         msmarco-passage-ranking
msmarco-v2-vector        Benchmark for vector search with msmarco-v2 passage data                          138,364,198  1045.0 GB          2980.0 GB            index-and-search                                index-and-search
nested                   StackOverflow Q&A stored as nested docs                                           11,203,029   663.3 MB           3.4 GB               nested-search-challenge                         nested-search-challenge,index-only
noaa                     Global daily weather measurements from NOAA                                       33,659,481   949.4 MB           9.0 GB               append-no-conflicts                             append-no-conflicts,append-no-conflicts-index-only,aggs,filter-aggs
nyc_taxis                Taxi rides in New York in 2015                                                    165,346,708  4.5 GB             74.3 GB              append-no-conflicts                             append-no-conflicts,append-no-conflicts-index-only,append-sorted-no-conflicts-index-only,update,update-only,append-ml,aggs,esql,update-aggs-only,autoscale,autoscale-v2
openai_vector            Benchmark for vector search using the OpenAI text-embedding-ada-002 model         2,680,961    31.0 GB            87.3 GB              index-and-search                                index-and-search
percolator               Percolator benchmark based on AOL queries                                         2,000,000    121.1 kB           104.9 MB             append-no-conflicts                             append-no-conflicts
pmc                      Full text benchmark with academic papers from PMC                                 574,199      5.5 GB             21.7 GB              append-no-conflicts                             append-no-conflicts,append-no-conflicts-index-only,append-sorted-no-conflicts,append-fast-with-conflicts,indexing-querying
random_vector            Benchmarking filtered search on random vectors                                    0            0 bytes            0 bytes              index-and-search                                index-and-search
so                       Indexing benchmark using up to questions and answers from StackOverflow           36,062,278   8.9 GB             33.1 GB              append-no-conflicts                             append-no-conflicts,transform,frequent-items
so_vector                Benchmark for vector search with StackOverflow data                               2,000,000    12.3 GB            32.2 GB              index-and-search                                index-and-search
sql                      SQL query performance based on NOAA Weather data                                  33,659,481   949.4 MB           9.0 GB               sql                                             sql
tsdb                     metricbeat information for elastic-app k8s cluster                                116,633,698  N/A                123.0 GB             append-no-conflicts                             append-no-conflicts,downsample
tsdb_k8s_queries         metricbeat information for elastic-app k8s cluster                                17,280,000   N/A                60.3 GB              append-no-conflicts                             append-no-conflicts-rampup,append-no-conflicts,append-no-conflicts-index-only,esql
wikipedia                Benchmark for search with Wikipedia data                                          22,986,185   17.9 GB            76.7 GB              index-and-search                                index-and-search

--------------------------------
[INFO] SUCCESS (took 44 seconds)
--------------------------------


#测试ES  中间会去github上面下载东西 翻墙问题自己解决  我使用的是proxychains4命令 可以看我之前的文档
#注:那个下载文件报错 不用管也行 测试是继续进行的
esrally race --track=geonames --target-hosts=ES地址:9200 --pipeline=benchmark-only --kill-running-processes

压力测试Redis

压测方法

#进入到redis的安装目录bin下
测试一个客户端 1000万数据量 
./redis-benchmark -h 127.0.0.1 -p 6379 -c 1 -n 10000000
最后修改:2024 年 03 月 22 日
如果觉得我的文章对你有用,请随意赞赏