Centos7 use the latest mysql self-pressure test tool mysqlslap

Source: Internet
Author: User
Tags mysql connect

Centos7 use the latest mysql self-pressure test tool mysqlslap

Mysqlslap -- help

1.1.1 remote connection test

Mysqlslap-a-h "10.10.10.92"-P3306

1.1.2 concurrency 50 and 100, total query 1000, iteration 5, local account and password connection test, output CPU Information

Mysqlslap-a -- concurrency = 50,100 -- number-of-queries 1000 -- iterations = 5 -- debug-info-uroot-p110120

1.1.3 view monitoring results by yourself

Mysqlslap-a -- concurrency = 50,100 -- number-of-queries 100000 -- iterations = 5 -- debug-info-uroot-p110120

1.3mysqlslap (some important parameters)

-Auto-generate-SQL,-

Automatically generate test tables and data

-Auto-generate-SQL-load-type = type

The type of the test statement. Optional values: read, key, write, update, and mixed (default ).

-Number-char-cols = N,-x N

The number of character columns in the automatically generated test table. The default value is 1.

-Number-int-cols = N,-y N

Number of columns in the automatically generated test table. The default value is 1.

-Number-of-queries = N

Total number of test queries (number of concurrent customers × number of queries per customer)

-Query = name,-q

Use a custom script to perform the test. For example, you can call a custom stored procedure or SQL statement to perform the test.

-Create-schema

The schema used for testing. The schema in MySQL is also the database.

-Commint = N

How many DML records are submitted once?

-Compress,-C

If both the server and client support compression, the compressed information is transmitted.

-Concurrency = N,-c N

Concurrency, that is, the number of clients that are simulated to execute the select statement at the same time. Multiple values can be specified. Use a comma or the value specified by the-delimiter parameter as the delimiter.

-Engine = engine_name,-e engine_name

The storage engine used to create a test table. You can specify multiple storage engines.

-Iterations = N,-I N

Test execution iterations

-Detach = N

Disconnect after executing N statements

-Debug-info,-T

Print memory and CPU Information

-Only-print

Print only test statements without actually executing them

1.4 common parameters (options:

-- Concurrency indicates the number of concurrent tasks. multiple concurrent tasks can be separated by commas. Example: -- concurrency = 50,200,500

-- Engines indicates the engine to be tested, which can be separated by separators. Example: -- engines = myisam, innodb, memory

-- Iterations indicates the number of times a test is run in different Concurrent Environments.

-- Auto-generate-SQL indicates that the SQL script generated by mysqlslap is used to test the concurrency pressure.

-- Auto-generate-SQL-add-auto-increment indicates that the auto_increment column is automatically added to the generated table, starting with version 5.1.18,

-- Auto-generate-SQL-load-type indicates whether the test environment is a combination of read, write, update, and mixed)

-- Number-of-queries indicates the total number of queries to be run.

-- Debug-info indicates the CPU and memory information to be output.

-- Number-int-cols indicates the number of INTEGER attributes in the example table.

-- Number-char-cols indicates the vachar type attributes in the example table.

-- Create-schema indicates the name of the custom test database.

-- Query indicates a custom test SQL script.

1.5 example

Single-threaded testing. Test what has been done

Mysqlslap-a-uroot-p110120

Multi-threaded testing. Use -- concurrency to simulate concurrent connections

Mysqlslap-a-c 100-uroot-p110120

Iterative testing. Used to obtain the average value after multiple tests.

Mysqlslap-a-I 10-uroot-p110120

Custom Test

Mysqlslap -- create-schema = test-q "select * from user"

1.6php massive data test mysql

Vi php-mysql.php

<? Php

// New the class instantiate the data construction class

$ Ds = new DataServ ();

// Set iptions for mysql connect

$ Ds-> sethost ("127.0.0.1"); // mysql server address

$ Ds-> setuser ("root"); // mysql user name

$ Ds-> setpasswd ("root"); // mysql user password

$ Ds-> setdb ("dbname"); // Database Password

$ Ds-> settable ("house_agency"); // table name

/** Set fields and value

* Rand int like array ("int", min, max)

* Rand string like array ("string", minlen, manlen)

* Increment int like array ("increment", minvalue, step) step default 1, minvalue default 0

* String like "admin"

* Int like 0

*/

/** Set fields and values

* Array ("int", min, max) min minimum random number, max maximum Random Number

* The minimum length of the random string array ("string", minlen, manlen) minlen string and the maximum length of the maxlen string

* The minimum value of minvalue of the auto-increment numeric type array ("increment", minvalue, step) is 1 by default, and the minimum value is 1. "" indicates auto-increment.

* String type "admin"

* Digit type 0

*/

$ Ds-> setfields (

Array ("agencyid" => array ("increment", 0, 2 ),

"Name" => array ("int", 20, 50 ),

"Address" => array ("string", 20, 50 ),

"Icon" => "icon ",

"Bgimg" => "bgimg ",

"Mainbusiness" => 1,

"Adminname" => "admin ",

"Isopen" => 1,

"Vieworder" => 1

)

);

// Create data file (start, end)

// Create 10 data records

$ Ds-> create (1,00000000 );

// Load data file into mysql

// Add data to the database

$ Ds-> loaddata ();

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.