AI调优

命令功能

使用自研高性能AI调优方案,对数据库和大数据场景进行自动优化,自动调优后给予最优参数配置,提供复杂场景下参数配置的优化建议。

  • AI调优支持在CentOS 7.6、openEuler 20.03和openEuler 22.03 LTS版本操作系统上使用。
  • MySQL数据库免密配置请参见MySQL免密配置
  • 数据目录所在磁盘需预留足够磁盘空间供AI调优备份使用。

命令格式

devkit tuner aituner [-h] [-l {0,1,2,3}] [-r n] [-f <file>] [-o <dir>] [-a]

执行命令时,参数-f或参数-a至少输入一个,如果输入参数-f,则将按照应用配置文件的默认参数(未自定义时)开始调优;如果输入参数-a,将进入应用高级参数编辑模式。

参数说明

表1 参数说明

参数

参数选项

说明

-h/--help

-

获取帮助信息。

-l/--log-level

0/1/2/3

设置日志级别,默认为2。
  • 0:日志级别为DEBUG。
  • 1:日志级别为INFO。
  • 2:日志级别为WARNING。
  • 3:日志级别为ERROR。

-r/--round

-

指定调优迭代次数,默认为50次,数值需大于0,迭代次数越多,所需总耗时越长。

-f/--config-file-path

-

指定应用的配置文件路径,可从/usr/local/devkit/tuner/tools/aituner/config_file查看参数配置示例。

-o/--output

-

设置报告文件夹名称,默认在当前所在目录下,默认文件夹名称格式为aituner-YMD-HMS,报告文件夹中包含调优日志,调优历史数据和最优参数集。

-a/--advanced-param

-

设置应用高级参数。

说明:
  • 工具提供默认设置,一般无需使用-a参数;提供的默认参数配置文件/usr/local/devkit/tuner/tools/aituner/advanced_param/advanced_param.json(以RPM安装为例)。
  • 若有自定义参数需求,命令中使用-a参数,将进入高级参数设置模式;手动修改高级参数配置文件后,执行命令时将自行加载。

应用配置说明

RPM包安装时应用配置文件默认存放在/usr/local/devkit/tuner/tools/aituner/config_file路径下,数据库支持MySQL、openGauss、Vastbase和RocksDB,大数据支持Flink、Hive和Spark。

  • 若使用工具压缩包直接解压,文件路径为/home/DevKit-CLI-x.x.x-Linux-Kunpeng/tuner/tools/aituner/config_file,其中“/home”为解压目录。
  • Json文件由hsots_list、app、load和metric四部分组成。
  • hosts_list可包含多个节点信息,每个{}为一个节点信息,以“,”分隔。
  • openGauss和Vastbase的hosts_list需用户提供的是root账户。
表2 Json文件参数说明(共有部分)

第一层参数

第二层参数

示例值

说明

hosts_list

name

local

节点名称,可自定义。

ip

127.0.0.1

节点IP地址。

username

root

节点操作系统用户。

port

22

节点端口号。

app

host_name

["local"]

应用节点名称。与hosts_list的name参数对应,代表当前应用部署在该节点上。

表3 mysql_sysbench_config.json说明

第一层参数

第二层参数

第三层参数

示例值

说明

app

name

-

mysql

应用名称。

app_version

-

8.0.28

应用的版本号。MySQL支持的版本有:5.7.22~5.7.43和8.0.11~8.0.28,8.0.30~8.0.34。

app_configs

mysql_username

root

MySQL的用户名。

说明:

出于安全考虑,需要用户配置对应mysql用户免密,请参见MySQL免密配置

mysql_port

3306

MySQL的端口号。

mysql_exe_path

/usr/bin

mysql执行文件目录。

mysqld_exe_path

/usr/sbin

mysqld执行文件目录。

sock_path

/data/mysql/run/mysql.sock

mysql.sock文件路径。

说明:

也可输入:"",系统将自动从my.cnf文件中获取。

config_file_path

/etc/my.cnf

MySQL的配置文件路径。

load

name

-

mysql_sysbench

表示MySQL使用Sysbench作为压测工具,且仅支持Sysbench,不可修改。

host_name

-

["local"]

压测工具节点名称。

test_tool_path

-

/home/sysbench-0.5/sysbench/

压测工具路径。

test_tool_version

-

0.5

压测工具版本。

test_case_name

-

oltp_mix

测试用例名称。可选择:oltp_distinct、oltp_index、oltp_nonindex、oltp_order、oltp_point、oltp_simple、oltp_sum、oltp_delete和oltp_mix。

test_case_path

-

/home/sysbench-0.5/sysbench/tests/db/

测试用例路径。

thread_number

-

50

压测时使用Sysbench的线程数,范围为1~8192。

database_name

-

sysbench

压测时使用的数据库名。

oltp_tables_count

-

10

OLTP表数量。

oltp_table_size

-

1000

OLTP表大小。

exec_duration

-

600

压测执行时间。

metric

tune_metric

-

tps

调优的性能指标,可选tps和latency。

表4 opengauss_benchmarksql_config.json说明

第一层参数

第二层参数

第三层参数

示例值

说明

app

name

-

opengauss

应用名称。

app_version

-

5.0.1

应用的版本号。openGauss支持版本:3.0.0、3.0.3、3.0.5、5.0.0和5.0.1。

app_configs

system_username

omm

使用openGauss的操作系统用户。

data_node_path

/data/openGauss/install/data/dn

openGauss的数据节点路径。

load

name

-

opengauss_benchmarksql

表示openGauss使用BenchMarkSQL作为压测工具,不可修改。

test_tool_version

-

5.0

压测工具版本。

host_name

-

["local"]

压测工具节点名称。

config_path

-

/home/benchmarksql-5.0/run/props.openGauss.1000w

配置文件props路径。

script_path

-

/home/benchmarksql-5.0/run

压测脚本目录。

numa_bind

-

""

压测客户端绑核,如“1,2或2-5”。

metric

tune_metric

-

tpmC

调优的性能指标。

表5 vastbase_benchmarksql_config.json说明

第一层参数

第二层参数

第三层参数

示例值

说明

app

name

-

vastbase

应用名称。

app_version

-

G100

应用的版本号。Vastbase支持版本:G100。

app_configs

system_username

vastbase

Vastbase操作系统用户。

data_node_path

/home/vastbase/data/vastbase

Vastbase数据节点路径。

load

name

-

vastbase_benchmarksql

表示Vastbase使用BenchMarkSQL作为压测工具,不可修改。

test_tool_version

-

0.5

压测工具版本。

host_name

-

["local"]

压测工具节点名称。

config_path

-

/opt/benchmarksql/benchmarksql-5.0/run/props.vastbase.1000w

配置文件props路径。

script_path

-

/home/benchmarksql-5.0/run

压测脚本目录。

numa_bind

-

""

压测客户端绑核,如“1,2或2-5”。

metric

tune_metric

-

tpmC

调优的性能指标。

表6 rocksdb_benchmarksql_config.json说明

第一层参数

第二层参数

第三层参数

示例值

说明

app

name

-

rocksdb

应用名称。

app_version

-

7.9.2

应用的版本号。RocksDB支持版本:7.0.4、7.1.1、7.1.2、7.2.0、7.2.2、7.3.1、7.4.3-7.4.5、7.5.3、7.6.0、7.7.2、7.7.3、7.7.8、7.8.3和7.9.2。

app_configs

database_dir

/home/database/rocksdb/db1

RocksDB数据库路径。

load

name

-

rocksdb_dbbench

表示RocksDB使用db_bench作为压测工具,不可修改。

test_tool_version

-

7.9.2

压测工具版本。

host_name

-

["local"]

压测工具节点名称。

test_tool_path

-

/home/database/rocksdb/tools

压测工具路径。

benchmarks_list

-

[ "fillseq"]

测试用例,可选择:fillseq、fillsync、fillrandom、overwrite、readrandom、newiterator、newiteratorwhilewriting、seekrandom、seekrandomwhilewriting、readseq、readreverse、multireadrandom、mixgraph、readwhilewriting、readwhilescanning、readrandomwriterandom、updaterandom、xorupdaterandom、randomwithverify、fill 100K、crc32c、xxhash、compress、uncompress、acquireload、fillseekseq、randomtransaction、randomreplacekeys、timeseries和readtocache。

key_size

-

50

db_bench参数,取值范围1~2,147,483,647 (bytes)。

value_size

-

830

db_bench参数,取值范围1~2,147,483,647 (bytes)。

num

-

100

db_bench参数,取值范围1~9,223,372,036,854,775,807个。

thread_number

-

16

db_bench参数,压测使用的线程数。取值范围1~2,147,483,647个。

cache_size

-

16777216

db_bench参数,取值范围1~9,223,372,036,854,775,807 (bytes)。

exec_duration

-

0

压测执行时间,单位为秒,取值范围0~2,147,483,647。

metric

tune_metric

-

IOPS

调优的性能指标。

表7 flink_hibench_config.json说明

第一层参数

第二层参数

第三层参数

示例值

说明

app

name

-

flink

应用名称。

app_version

-

1.12

应用的版本号。Flink支持版本:1.12~1.15。

app_configs

app_exe_path

/home/hibench/flink/bin

应用执行文件路径。

master_type

standalone

部署模式,可选yarn和standalone。

startup_params

{}

应用启动参数。

load

name

-

flink_hibench

表示Flink使用Hibench作为压测工具,不可修改。

说明:

Hibench不支持压测Flink 1.15,请使用华为云HiBench

host_name

-

["local"]

压测工具节点名称。

test_case_name

-

identity

测试用例。可选identity、repartition和wordcount。

test_tool_version

-

7.0

压测工具版本。

exec_duration

-

180

压测执行时间,单位为秒

test_tool_path

-

/home/hibench/HiBench-7.0

压测工具路径。

hibench_datagen_throughput

-

600K

压测时用例的吞吐量。可选20K、40K、60K、80K、100K、200K、300K、400K、500K、600K、700K、800K、900K、1000K、2000K、4000K、6000K、8000K、10000K。

metric

tune_metric

-

latency

调优的性能指标。可选throughput、latency和throughput/latency。

表8 hive_tpcds_config.json说明

第一层参数

第二层参数

第三层参数

示例值

说明

app

name

-

hive

应用名称。

app_version

-

3.1.3

应用的版本号。Hive支持3.0.0和3.1.0~3.1.3。

app_configs

app_exe_path

/usr/local/hive/bin

应用执行文件路径。

load

name

-

hive_tpcds

表示Hive使用TPC-DS作为压测工具,不可修改。

test_tool_version

-

3.0

压测工具版本。

host_name

-

["local"]

压测工具节点名称。

tpcds_sql_index_list

-

[1,2]

测试用例,可选用例ID:1~99。

database_name

-

tpcds_bin_partitioned_orc_3

压测时使用的数据库名称。

exec_timeout

-

1000

压测超时时间,单位为秒。

sql_file_tmpdir

-

/tmp

临时存放测试用例的目录,压测结束后将自动删除。

metric

tune_metric

-

latency

调优的性能指标。

表9 spark_tpcds_config.json说明

第一层参数

第二层参数

第三层参数

示例值

说明

app

name

-

spark

应用名称。

app_version

-

3.3.1

应用的版本号。Spark支持2.3.0~2.3.2,2.4.1~2.4.7,3.0.0~3.0.3,3.1.0~3.1.2,3.2.1、3.2.2、3.3.0和3.3.1。

app_configs

app_exe_path

/home/bigdata/spark/bin

应用执行文件路径。

omni_home_dir

""

OmniOperator目录。

说明:

为""时表示不启用OmniOperator

master_type

yarn

应用的部署模式,可选yarn和standalone。

load

name

-

spark_tpcds

表示Spark使用TPC-DS作为压测工具,不可修改。

test_tool_version

-

3.0

压测工具版本。

host_name

-

["local"]

压测工具节点名称。

tpcds_sql_index_list

-

[1]

测试用例。可选用例ID:1~99,其中14,23,24,39用例有a和b两种,如14a和14b。

database_name

-

tpcds_bin_partitioned_orc_300

压测时使用的数据库名称。

exec_timeout

-

1000

压测超时时间,单位为秒。

sql_file_tmpdir

-

/tmp

临时存放测试用例的目录,压测结束后将自动删除。

metric

tune_metric

-

latency

调优的性能指标。

使用示例

devkit tuner aituner -r 10 -f /usr/local/devkit/tuner/tools/aituner/config_file/mysql_sysbench_config.json -o /home/mysql_20_tuner
  • 参数-r 10代表调优10轮,参数-f指定配置文件为/usr/local/devkit/tuner/tools/aituner/config_file/mysql_sysbench_config.json,参数-o /home/mysql_20_tuner表示生成报告的目录。
  • 示例的返回信息中应用信息过多,为便于展示已省略大部分内容,请以实际使用为准。

返回信息如下:

...
...
...
[MESSAGE]The baseline test is successful. The baseline performance result is 187463.0.
[MESSAGE]-- Tuning rounds: 1. The result of this round: 210.0, the current best tuning result is: 210.0
[MESSAGE]-- Tuning rounds: 2. The result of this round: 214422.0, the current best tuning result is: 214422.0
[MESSAGE]-- Tuning rounds: 3. The result of this round: 230803.0, the current best tuning result is: 230803.0
[MESSAGE]-- Tuning rounds: 4. The result of this round: 177219.0, the current best tuning result is: 230803.0
[MESSAGE]-- Tuning rounds: 5. The result of this round: 208.0, the current best tuning result is: 230803.0
[MESSAGE]-- Tuning rounds: 6. The result of this round: 210.0, the current best tuning result is: 230803.0
[MESSAGE]-- Tuning rounds: 7. The result of this round: 198.0, the current best tuning result is: 230803.0
[MESSAGE]-- Tuning rounds: 8. The result of this round: 207.0, the current best tuning result is: 230803.0
[MESSAGE]-- Tuning rounds: 9. The result of this round: 230353.0, the current best tuning result is: 230803.0
[MESSAGE]-- Tuning rounds: 10. The result of this round: 198912.0, the current best tuning result is: 230803.0
[MESSAGE]After 10 rounds of performance optimization, the optimal performance result is: 230803.0,Performance improved by 23.1%.
...
...
...