mysqlslap is a diagnostic program designed to emulate client load for a MySQL server and to report the timing of each stage. It works as if multiple clients are accessing the server.
Invoke mysqlslap like this:
shell> mysqlslap [options]
Some options such as --create or --query enable you to specify a string containing an SQL statement or a file containing statements. If you specify a file, by default it must contain one statement per line. (That is, the implicit statement delimiter is the newline character.) Use the --delimiter option to specify a different delimiter, which enables you to specify statements that span multiple lines or place multiple statements on a single line. You cannot include comments in a file; mysqlslap does not understand them.
mysqlslap runs in three stages:
- Create schema, table, and optionally any stored programs or data to use for the test. This stage uses a single client connection.
- Run the load test. This stage can use many client connections.
- Clean up (disconnect, drop table if specified). This stage uses a single client connection.
Examples:
Supply your own create and query SQL statements, with 50 clients querying and 200 selects for each (enter the command on a single line):
mysqlslap --delimiter=";"
--create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)"
--query="SELECT * FROM a" --concurrency=50 --iterations=200
Let mysqlslap build the query SQL statement with a table of two INT columns and three VARCHAR columns. Use five clients querying 20 times each. Do not create the table or insert the data (that is, use the previous test's schema and data):
mysqlslap --concurrency=5 --iterations=20
--number-int-cols=2 --number-char-cols=3
--auto-generate-sql
Tell the program to load the create, insert, and query SQL statements from the specified files, where the create.sql file has multiple table creation statements delimited by ';' and multiple insert statements delimited by ';'. The --query file will have multiple queries delimited by ';'. Run all the load statements, then run all the queries in the query file with five clients (five times each):
mysqlslap --concurrency=5
--iterations=5 --query=query.sql --create=create.sql
--delimiter=";"
Options
- --auto-generate-sql, -a
Generate SQL statements automatically when they are not supplied in files or using command options. - --auto-generate-sql-add-autoincrement
Add an AUTO_INCREMENT column to automatically generated tables. - --auto-generate-sql-execute-number=N
Specify how many queries to generate automatically. - --auto-generate-sql-guid-primary
Add a GUID-based primary key to automatically generated tables. - --auto-generate-sql-load-type=type
Specify the test load type. The permissible values are read (scan tables), write (insert into tables), key (read primary keys), update (update primary keys), or mixed (half inserts, half scanning selects). The default is mixed. - --auto-generate-sql-secondary-indexes=N
Specify how many secondary indexes to add to automatically generated tables. By default, none are added. - --auto-generate-sql-unique-query-number=N
How many different queries to generate for automatic tests. For example, if you run a key test that performs 1000 selects, you can use this option with a value of 1000 to run 1000 unique queries, or with a value of 50 to perform 50 different selects. The default is 10. - --auto-generate-sql-unique-write-number=N
How many different queries to generate for --auto-generate-sql-write-number. The default is 10. - --auto-generate-sql-write-number=N
How many row inserts to perform. The default is 100. - --commit=N
How many statements to execute before committing. The default is 0 (no commits are done). - --compress, -C
Compress all information sent between the client and the server if both support compression. - --concurrency=N, -c N
The number of parallel clients to simulate. - --create=value
The file or string containing the statement to use for creating the table. - --create-schema=value
The schema in which to run the tests. -
Generate output in comma-separated values format. The output goes to the named file, or to the standard output if no file is given.
- --enable-cleartext-plugin
Enable the mysql_clear_password cleartext authentication plugin. (See Section 6.5.1.7, “The Cleartext Client-Side Authentication Plugin”.) This option was added in MySQL 5.6.7. - --engine=engine_name, -e engine_name
The storage engine to use for creating tables. - --no-drop
Prevent mysqlslap from dropping any schema it creates during the test run. This option was added in MySQL 5.6.3. -
Do not connect to databases. mysqlslap only prints what it would have done.
- The file or string containing the statement to execute after the tests have completed. This execution is not counted for timing purposes.
- --post-system=str
The string to execute using system() after the tests have completed. This execution is not counted for timing purposes. - --pre-query=value
The file or string containing the statement to execute before running the tests. This execution is not counted for timing purposes. - --pre-system=str
The string to execute using system() before running the tests. This execution is not counted for timing purposes. - --print-defaults
Print the program name and all options that it gets from option files. - --protocol={TCP|SOCKET|PIPE|MEMORY}
The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the permissible values, see Section 4.2.2, “Connecting to the MySQL Server”. - --query=value, -q value
The file or string containing the SELECT statement to use for retrieving data.
댓글 없음:
댓글 쓰기