首先可以看一下/sysbench/sysbench/tests/db目录下的脚本: ./ |-- common.lua # 是一个通用脚本 会有初始化相关参数 |-- delete.lua |-- insert.lua |-- Makefile |-- Makefile.am |-- Makefile.in |-- oltp.lua # oltp场景经常使用到的,包含读写 |-- oltp_simple.lua |-- parallel_prepare.lua |-- select.lua |-- select_random_points.lua |-- select_random_ranges.lua |-- update_index.lua `-- update_non_index.lua
今天要改动的其实很简单,只需要改动common.lua中的初始化参数即可修改之前:
oltp_table_size = oltp_table_size or 10000 oltp_range_size = oltp_range_size or 100 oltp_tables_count = oltp_tables_count or 1 oltp_point_selects = oltp_point_selects or 10 #如果未设置该参数,默认执行10次 oltp_simple_ranges = oltp_simple_ranges or 1 oltp_sum_ranges = oltp_sum_ranges or 1 oltp_order_ranges = oltp_order_ranges or 1 oltp_distinct_ranges = oltp_distinct_ranges or 1 oltp_index_updates = oltp_index_updates or 1 oltp_non_index_updates = oltp_non_index_updates or 1
function set_vars() oltp_table_size = oltp_table_size or 10000 oltp_range_size = oltp_range_size or 100 oltp_tables_count = oltp_tables_count or 1 oltp_point_selects = oltp_point_selects or 0 oltp_simple_ranges = oltp_simple_ranges or 0 oltp_sum_ranges = oltp_sum_ranges or 0 oltp_order_ranges = oltp_order_ranges or 0 oltp_distinct_ranges = oltp_distinct_ranges or 0 oltp_index_updates = oltp_index_updates or 1 oltp_non_index_updates = oltp_non_index_updates or 1
所以 如果直接使用olpt.lua测试读写场景的话,注意读写比例: 10+1+1+1+1:4=14:4=7:2的比例,这个对于有些需要只写或者对写影响更大的一些变更测试是很不方便的,所以只需要小小改动一下,我们就可以实现只写了。
