Mysql stress test shell script

Source: Internet
Author: User

Mysql stress test shell script Mysql comes with the stress test tool mysqlslap, so we don't have to write our own program to test the pressure on Mysql reading. The stress test shell script is as follows: www.2cto.com [plain] #! /Bin/sh while true do mysqlslap -- concurrency = 100 -- iterations = 10 -- create-schema = 'test' -- query = "insert into test (c1, c2, c3, c4) values (1, 1, 'A ') "-- number-of-queries = 200 -- debug-info-uroot-p123456 usleep 100 done www.2cto.com the script above indicates doing this cyclically every 100 MS: Simulating mysql clients, perform 200 inserts (number-of-queries = concurrency *) on the test table of the database test. Therefore, the number of queries per mysql client is twice ), iterations: 10. -- Debug-info: prints information about memory and CPU. Then we can write a shell script to output the number of mysql operations within the specified time interval (for example, 1 second). The shell script is as follows: [plain] #! /Bin/sh lastTimes = "0" while true do currentTimes = $ (mysql-uroot-p '000000'-e "show global status like 'com _ insert'" | sed' 1d '| awk' {print $2 }') times = $ (expr $ {currentTimes}-$ {lastTimes}) lastTimes = "$ {currentTimes}" echo "$ {times}" sleep 1 done views the number of mysql operations, you can view the variables starting with 'com _ 'in global status, which are mysql operation commands. For example, Com_insert is the INSERT command and Com_update is the update command, for more information, see the document description. Subtract the number of adjacent two times to obtain the number of executions within the interval. PS: In addition to commands such as iostat, you can also use the top command to view the io load (see the percentage of wait. If it is greater than or equal to the number of 1/cpu cores, it indicates that the hard disk IO is faulty ). Please refer to the English article: Understanding Disk I/O-when shoshould you be worried? Source http://blog.csdn.net/skyman_2001

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.