mysqlslap 負載模擬客戶端
mysqlslap是一種診斷程式用來模擬MySQL伺服器的客戶端負載並報告每個階段的時間。它模擬多個客戶端同時訪問MySQL服務。
mysqlslap語法如下:
Usage: mysqlslap [OPTIONS]
它有許多選項可以使用:
有些選項比如--create或--query能夠讓你指這一個字串包含一個SQL語句或一個檔案來包含SQL語句。如果你指定一個檔案,預設情況是它必須每行包含一個SQL語句(也就是說隱式語句分隔符是換行符)。使用--delimiter選項來指定不同的分隔符,它能讓你指定一個語句跨越多行或者將多個語句放入一行。在檔案中不能包含註釋,mysqlslap不能解析它們。
mysqlslap執行分為三個階段
1.建立方案,表和可選的任何儲存過程或用於測試的資料。這個階段使用單個客房端連線。
2.執行負載測試,這個階段可以使用多個客戶端連線。
3.清除(斷開連線,如果指定刪除表)。這個階段使用單個客戶端連線。
例如:
假設你建立和查詢SQL語句,而且想使用50個客戶端來執行查詢並且每個語句執行200次(在單行中輸入命令):
mysqlslap --delimiter=";" --create="create table a(b int);insert into a values(11)" --query="select * from a" --concurrency=50 --iterations=200
執行結果如下:
[mysql@localhost ~]$ mysqlslap -h192.168.1.250 -P33306 -uroot -p123456 mysql --delimiter=";" --create="create table a(b int);insert into a values(11)" --query="select * from a" --concurrency=50 --iterations=200 mysqlslap: [Warning] Using a password on the command line interface can be insecure. Benchmark Average number of seconds to run all queries: 0.268 seconds Minimum number of seconds to run all queries: 0.257 seconds Maximum number of seconds to run all queries: 0.370 seconds Number of clients running queries: 50 Average number of queries per client: 1
讓mysqlslap來使用一個有兩個INT列和三個varchar列的表來構建查詢SQL語句。使用五個客戶端每個客戶端查詢20次。不建立表或不插入資料(使用之前的測試方案和資料):
mysqlslap --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
執行結果如下:
[mysql@localhost ~]$ mysqlslap -h192.168.1.250 -P33306 -uroot -p123456 mysql --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql mysqlslap: [Warning] Using a password on the command line interface can be insecure. Benchmark Average number of seconds to run all queries: 0.247 seconds Minimum number of seconds to run all queries: 0.182 seconds Maximum number of seconds to run all queries: 0.361 seconds Number of clients running queries: 5 Average number of queries per client: 0
為了告訴程式從指定的檔案中載入建立,插入和查詢的SQL語句,這裡給--create選項指定create.sql檔案,它包含了由分號隔開的多個建立表的語句和多個插入語句。--query選項指定的query.sql檔案包含由分號隔開的多個查詢語句。執行所有載入的語句,然後使用五個客戶端執行查詢檔案中的所有查詢(每個執行五次):
mysqlslap --concurrency=5 --iterations=5 --query=query.sql --create=create.sql --delimiter=";"
執行結果如下:
[mysql@localhost ~]$ mysqlslap -h192.168.1.250 -P33306 -uroot -p123456 mysql --concurrency=5 --iterations=5 --query=query.sql --create=create.sql --delimiter=";" mysqlslap: [Warning] Using a password on the command line interface can be insecure. Benchmark Average number of seconds to run all queries: 0.035 seconds Minimum number of seconds to run all queries: 0.034 seconds Maximum number of seconds to run all queries: 0.038 seconds Number of clients running queries: 5 Average number of queries per client: 5
mysqlslap支援以下選項,可以在命令列指定或在選項檔案中透過[mysqlslap]和[client]組來指定
[mysql@localhost ~]$ mysqlslap --help mysqlslap Ver 1.0 Distrib 5.7.26, for Linux (x86_64) Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Run a query multiple times against the server. Usage: mysqlslap [OPTIONS] Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /mysqlsoft/mysql/etc/my.cnf /mysqlsoft/mysql/my.cnf ~/.my.cnf The following groups are read: mysqlslap client The following options may be given as the first argument: --print-defaults Print the program argument list and exit. --no-defaults Don't read default options from any option file, except for login file. --defaults-file=# Only read default options from the given file #. --defaults-extra-file=# Read this file after the global files are read. --defaults-group-suffix=# Also read groups with concat(group, suffix) --login-path=# Read this path from the login file. -?, --help Display this help and exit. -a, --auto-generate-sql Generate SQL where not supplied by file or command line. --auto-generate-sql-add-autoincrement Add an AUTO_INCREMENT column to auto-generated tables. --auto-generate-sql-execute-number=# Set this number to generate a set number of queries to run. --auto-generate-sql-guid-primary Add GUID based primary keys to auto-generated tables. --auto-generate-sql-load-type=name Specify test load type: mixed, update, write, key, or read; default is mixed. --auto-generate-sql-secondary-indexes=# Number of secondary indexes to add to auto-generated tables. --auto-generate-sql-unique-query-number=# Number of unique queries to generate for automatic tests. --auto-generate-sql-unique-write-number=# Number of unique queries to generate for auto-generate-sql-write-number. --auto-generate-sql-write-number=# Number of row inserts to perform for each thread (default is 100). --commit=# Commit records every X number of statements. -C, --compress Use compression in server/client protocol. -c, --concurrency=name Number of clients to simulate for query to run. --create=name File or string to use create tables. --create-schema=name Schema to run tests in. --csv[=name] Generate CSV output to named file or to stdout if no file is named. -#, --debug[=#] This is a non-debug version. Catch this and exit. --debug-check This is a non-debug version. Catch this and exit. -T, --debug-info This is a non-debug version. Catch this and exit. --default-auth=name Default authentication client-side plugin to use. -F, --delimiter=name Delimiter to use in SQL statements supplied in file or command line. --detach=# Detach (close and reopen) connections after X number of requests. --enable-cleartext-plugin Enable/disable the clear text authentication plugin. -e, --engine=name Storage engine to use for creating the table. -h, --host=name Connect to host. -i, --iterations=# Number of times to run the tests. --no-drop Do not drop the schema after the test. -x, --number-char-cols=name Number of VARCHAR columns to create in table if specifying --auto-generate-sql. -y, --number-int-cols=name Number of INT columns to create in table if specifying --auto-generate-sql. --number-of-queries=# Limit each client to this number of queries (this is not exact). --only-print Do not connect to the databases, but instead print out what would have been done. -p, --password[=name] Password to use when connecting to server. If password is not given it's asked from the tty. --plugin-dir=name Directory for client-side plugins. -P, --port=# Port number to use for connection. --post-query=name Query to run or file containing query to execute after tests have completed. --post-system=name system() string to execute after tests have completed. --pre-query=name Query to run or file containing query to execute before running tests. --pre-system=name system() string to execute before running tests. --protocol=name The protocol to use for connection (tcp, socket, pipe, memory). -q, --query=name Query to run or file containing query to run. --secure-auth Refuse client connecting to server if it uses old (pre-4.1.1) protocol. Deprecated. Always TRUE -s, --silent Run program in silent mode - no output. -S, --socket=name The socket file to use for connection. --sql-mode=name Specify sql-mode to run mysqlslap tool. --ssl-mode=name SSL connection mode. --ssl Deprecated. Use --ssl-mode instead. (Defaults to on; use --skip-ssl to disable.) --ssl-verify-server-cert Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead. --ssl-ca=name CA file in PEM format. --ssl-capath=name CA directory. --ssl-cert=name X509 cert in PEM format. --ssl-cipher=name SSL cipher to use. --ssl-key=name X509 key in PEM format. --ssl-crl=name Certificate revocation list. --ssl-crlpath=name Certificate revocation list path. --tls-version=name TLS version to use, permitted values are: TLSv1, TLSv1.1 -u, --user=name User for login if not current user. -v, --verbose More verbose output; you can use this multiple times to get even more verbose output. -V, --version Output version information and exit.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2871753/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- gRPC負載均衡(客戶端負載均衡)RPC負載客戶端
- SecureCRT\FX (終端模擬器\FTP客戶端)下載SecurecrtFTP客戶端
- SpringCloud客戶端負載均衡——RibbonSpringGCCloud客戶端負載
- SpringCloud 客戶端負載均衡:RibbonSpringGCCloud客戶端負載
- Spring Cloud Ribbon 客戶端負載均衡SpringCloud客戶端負載
- SecureCRT for Mac(終端模擬器/SSH客戶端)SecurecrtMac客戶端
- SpringCloud系列之客戶端負載均衡Netflix RibbonSpringGCCloud客戶端負載
- ③SpringCloud 實戰:使用 Ribbon 客戶端負載均衡SpringGCCloud客戶端負載
- 【Mac】Termius for mac(終端模擬器/SSH/SFTP客戶端)MacFTP客戶端
- Spring RestTemplate作為負載平衡器客戶端SpringREST負載客戶端
- Spring Cloud Netflix—客戶端負載平衡器:RibbonSpringCloud客戶端負載
- 微服務架構如何實現客戶端負載均衡微服務架構客戶端負載
- openGauss JDBC客戶端負載均衡與讀寫分離JDBC客戶端負載
- Spring Cloud入門教程-Ribbon實現客戶端負載均衡SpringCloud客戶端負載
- (23)go-micro微服務客戶端開發(使用負載均衡)Go微服務客戶端負載
- RocketMQ 客戶端負載均衡機制詳解及最佳實踐MQ客戶端負載
- spring cloud 上雲的情況下,Ribbon 客戶端負載均衡 與 ALB 服務端負載均衡的選擇SpringCloud客戶端負載服務端
- 使用fiddler和安卓模擬器抓取安卓客戶端資料包安卓客戶端
- 中文版vnc客戶端,中文版vnc客戶端下載,中文版vnc客戶端如何使用?VNC客戶端
- vnc windows客戶端,vnc windows客戶端下載,具體使用教程。VNCWindows客戶端
- 如何使用RunnerGo模擬使用者分流負載Go負載
- [轉載] 使用Redis的Java客戶端JedisRedisJava客戶端
- dubbo客戶端客戶端
- Pulsar客戶端客戶端
- mqtt 客戶端MQQT客戶端
- 微信客戶端團隊負責人技術訪談:如何著手客戶端效能監控和優化客戶端優化
- Linux 中模擬多種系統負載的方法Linux負載
- Oracle ORION模擬Database負載測試儲存效能OracleDatabase負載
- 客戶端安裝虛擬機器問題解答?客戶端虛擬機
- 服務端,客戶端服務端客戶端
- 客戶端,服務端客戶端服務端
- Nacos - 客戶端心跳續約及客戶端總結客戶端
- 物理DataGuard客戶端無縫切換--客戶端TAF 配置客戶端
- [Redis 客戶端整合] Java 中常用Redis客戶端比較Redis客戶端Java
- 模擬測試生成Apache Kafka負載的最佳工具:KLoadGenApacheKafka負載
- java B2B2C原始碼電子商務平臺 -----客戶端負載均衡策略Java原始碼客戶端負載
- java websocket 客戶端JavaWeb客戶端
- redis客戶端管理Redis客戶端