In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to customize the Lua template of sysbench in MySQL stress testing". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Before the stress test, let's configure the environment and create a user and database.
Mysql > create user sysbench_test identified by 'mysql'
Query OK, 0 rows affected (0.08 sec)
Mysql > create database sysbench_db character set utf8
Query OK, 1 row affected (0.08 sec)
Mysql > grant all on sysbench_db.* to sysbench_test@'%'
Query OK, 0 rows affected (0.00 sec)
Then configure the simplest Lua template as follows:
#! / usr/bin/env sysbench
Function event ()
Db_query (
"SELECT 1"
)
End
At run time, configure execution permissions, chmod + x test1.lua, and then execute
. / test1.lua-mysql-user=sysbench_test-mysql-password=mysql-mysql-host=127.0.0.1-mysql-port=65535-mysql-db=sysbench_db run
The parameter-- mysql-user=sysbench_test-- mysql-password=mysql-- mysql-host=127.0.0.1-- mysql-port=65535 is for connection. It is even easier if you use the default configuration command of port 3306. The output is as follows:
In addition, we can verify the command options. We launched the second Lua template, test2.lua
Sysbench.cmdline.options = {
Tables = {"Number of tables", 1}
Table_size = {"Number of rows per table", 10000}
Create_secondary = {"Create a secondary key", true}
}
If the command option is wrong, it will be checked out.
Sysbench-tbales=8 test2.lua-mysql-user=sysbench_test-mysql-password=mysql-mysql-host=127.0.0.1-mysql-port=65535-mysql-db=sysbench_db run
Invalid option:-- tbales=8
If there is no problem, you can use help to get the initialized option value.
# sysbench test2.lua help
Sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Test2.lua options:
-- table_size=N Number of rows per table [10000]
-- tables=N Number of tables [1]
-- create_secondary [= on | off] Create a secondary key [on]
Next is the point, with regard to SQL API customization, there are actually rules to follow.
Let's take a look at the third Lua template, test3.lua
Function thread_init ()
Drv = sysbench.sql.driver ()
Con = drv:connect ()
End
Function event ()
Con:query ("SELECT 1"
)
End
Function thread_done ()
Con:disconnect ()
End
Use the command to complete the test.
Sysbench test3.lua-mysql-user=sysbench_test-mysql-password=mysql-mysql-host=127.0.0.1-mysql-port=65535-mysql-db=sysbench_db run
This is the end of "how to customize the Lua template of sysbench in MySQL stress testing". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.