---
title: AI调优
description: "使用自研高性能AI调优方案，对数据库和大数据场景进行自动优化，自动调优后给予最优参数配置，提供复杂场景下参数配置的优化建议。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/devkit_24_rc3/cliuserguide/KunpengDevKitCli_0083.html
sourcePath: /source/zh/kunpengdevkithistory/devkit_24_rc3/cliuserguide/KunpengDevKitCli_0083.html
indexId: 2a8938ba95d22580e1d435fc68d4503eff6d70023d9d295e9bff09905f184a2285
---
# AI调优

#### 命令功能

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

- AI调优支持在CentOS 7.6、openEuler 20.03和openEuler 22.03 LTS版本操作系统上使用。
- MySQL数据库免密配置请参见  MySQL免密配置(https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/devkit_24_rc3/usermanual/kunpengoper_06_0031.html)
。
- 数据目录所在磁盘需预留足够磁盘空间供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 | 节点名称，可自定义。 |
| hosts\_list | ip | 127.0.0.1 | 节点IP地址。 |
| hosts\_list | username | root | 节点操作系统用户。 |
| hosts\_list | port | 22 | 节点端口号。 |
| app | host\_name | ["local"] | 应用节点名称。与hosts\_list的name参数对应，代表当前应用部署在该节点上。 |


**表3 mysql_sysbench_config.json说明**

| 第一层参数 | 第二层参数 | 第三层参数 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| app | name | \- | mysql | 应用名称。 |
| app | 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 | app\_configs | mysql\_username | root | MySQL的用户名。 说明： 出于安全考虑，需要用户配置对应mysql用户免密，请参见MySQL免密配置(https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/devkit\_24\_rc3/usermanual/kunpengoper\_06\_0031.html)。 |
| app | app\_configs | mysql\_port | 3306 | MySQL的端口号。 |
| app | app\_configs | mysql\_exe\_path | /usr/bin | mysql执行文件目录。 |
| app | app\_configs | mysqld\_exe\_path | /usr/sbin | mysqld执行文件目录。 |
| app | app\_configs | sock\_path | /data/mysql/run/mysql.sock | mysql.sock文件路径。 说明： 也可输入：""，系统将自动从my.cnf文件中获取。 |
| app | app\_configs | config\_file\_path | /etc/my.cnf | MySQL的配置文件路径。 |
| load | name | \- | mysql\_sysbench | 表示MySQL使用Sysbench作为压测工具，且仅支持Sysbench，不可修改。 |
| load | host\_name | \- | ["local"] | 压测工具节点名称。 |
| load | test\_tool\_path | \- | /home/sysbench\-0.5/sysbench/ | 压测工具路径。 |
| load | test\_tool\_version | \- | 0.5 | 压测工具版本。 |
| load | test\_case\_name | \- | oltp\_mix | 测试用例名称。可选择：oltp\_distinct、oltp\_index、oltp\_nonindex、oltp\_order、oltp\_point、oltp\_simple、oltp\_sum、oltp\_delete和oltp\_mix。 |
| load | test\_case\_path | \- | /home/sysbench\-0.5/sysbench/tests/db/ | 测试用例路径。 |
| load | thread\_number | \- | 50 | 压测时使用Sysbench的线程数，范围为1~8192。 |
| load | database\_name | \- | sysbench | 压测时使用的数据库名。 |
| load | oltp\_tables\_count | \- | 10 | OLTP表数量。 |
| load | oltp\_table\_size | \- | 1000 | OLTP表大小。 |
| load | exec\_duration | \- | 600 | 压测执行时间。 |
| metric | tune\_metric | \- | tps | 调优的性能指标，可选tps和latency。 |


**表4 opengauss_benchmarksql_config.json说明**

| 第一层参数 | 第二层参数 | 第三层参数 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| app | name | \- | opengauss | 应用名称。 |
| app | app\_version | \- | 5.0.1 | 应用的版本号。openGauss支持版本：3.0.0、3.0.3、3.0.5、5.0.0和5.0.1。 |
| app | app\_configs | system\_username | omm | 使用openGauss的操作系统用户。 |
| app | app\_configs | data\_node\_path | /data/openGauss/install/data/dn | openGauss的数据节点路径。 |
| load | name | \- | opengauss\_benchmarksql | 表示openGauss使用BenchMarkSQL作为压测工具，不可修改。 |
| load | test\_tool\_version | \- | 5.0 | 压测工具版本。 |
| load | host\_name | \- | ["local"] | 压测工具节点名称。 |
| load | config\_path | \- | /home/benchmarksql\-5.0/run/props.openGauss.1000w | 配置文件props路径。 |
| load | script\_path | \- | /home/benchmarksql\-5.0/run | 压测脚本目录。 |
| load | numa\_bind | \- | "" | 压测客户端绑核，如“1,2或2\-5”。 |
| metric | tune\_metric | \- | tpmC | 调优的性能指标。 |


**表5 vastbase_benchmarksql_config.json说明**

| 第一层参数 | 第二层参数 | 第三层参数 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| app | name | \- | vastbase | 应用名称。 |
| app | app\_version | \- | G100 | 应用的版本号。Vastbase支持版本：G100。 |
| app | app\_configs | system\_username | vastbase | Vastbase操作系统用户。 |
| app | app\_configs | data\_node\_path | /home/vastbase/data/vastbase | Vastbase数据节点路径。 |
| load | name | \- | vastbase\_benchmarksql | 表示Vastbase使用BenchMarkSQL作为压测工具，不可修改。 |
| load | test\_tool\_version | \- | 0.5 | 压测工具版本。 |
| load | host\_name | \- | ["local"] | 压测工具节点名称。 |
| load | config\_path | \- | /opt/benchmarksql/benchmarksql\-5.0/run/props.vastbase.1000w | 配置文件props路径。 |
| load | script\_path | \- | /home/benchmarksql\-5.0/run | 压测脚本目录。 |
| load | numa\_bind | \- | "" | 压测客户端绑核，如“1,2或2\-5”。 |
| metric | tune\_metric | \- | tpmC | 调优的性能指标。 |


**表6 rocksdb_benchmarksql_config.json说明**

| 第一层参数 | 第二层参数 | 第三层参数 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| app | name | \- | rocksdb | 应用名称。 |
| app | 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 | app\_configs | database\_dir | /home/database/rocksdb/db1 | RocksDB数据库路径。 |
| load | name | \- | rocksdb\_dbbench | 表示RocksDB使用db\_bench作为压测工具，不可修改。 |
| load | test\_tool\_version | \- | 7.9.2 | 压测工具版本。 |
| load | host\_name | \- | ["local"] | 压测工具节点名称。 |
| load | test\_tool\_path | \- | /home/database/rocksdb/tools | 压测工具路径。 |
| load | 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。 |
| load | key\_size | \- | 50 | db\_bench参数，取值范围1~2,147,483,647 (bytes)。 |
| load | value\_size | \- | 830 | db\_bench参数，取值范围1~2,147,483,647 (bytes)。 |
| load | num | \- | 100 | db\_bench参数，取值范围1~9,223,372,036,854,775,807个。 |
| load | thread\_number | \- | 16 | db\_bench参数，压测使用的线程数。取值范围1~2,147,483,647个。 |
| load | cache\_size | \- | 16777216 | db\_bench参数，取值范围1~9,223,372,036,854,775,807 (bytes)。 |
| load | exec\_duration | \- | 0 | 压测执行时间，单位为秒，取值范围0~2,147,483,647。 |
| metric | tune\_metric | \- | IOPS | 调优的性能指标。 |


**表7 flink_hibench_config.json说明**

| 第一层参数 | 第二层参数 | 第三层参数 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| app | name | \- | flink | 应用名称。 |
| app | app\_version | \- | 1.12 | 应用的版本号。Flink支持版本：1.12~1.15。 |
| app | app\_configs | app\_exe\_path | /home/hibench/flink/bin | 应用执行文件路径。 |
| app | app\_configs | master\_type | standalone | 部署模式，可选yarn和standalone。 |
| app | app\_configs | startup\_params | {} | 应用启动参数。 |
| load | name | \- | flink\_hibench | 表示Flink使用Hibench作为压测工具，不可修改。 说明： Hibench不支持压测Flink 1.15，请使用华为云HiBench(https://github.com/huaweicloud/huaweicloud\-mrs\-example/tree/performance\-tools/performance\-tools/Flink)。 |
| load | host\_name | \- | ["local"] | 压测工具节点名称。 |
| load | test\_case\_name | \- | identity | 测试用例。可选identity、repartition和wordcount。 |
| load | test\_tool\_version | \- | 7.0 | 压测工具版本。 |
| load | exec\_duration | \- | 180 | 压测执行时间，单位为秒 |
| load | test\_tool\_path | \- | /home/hibench/HiBench\-7.0 | 压测工具路径。 |
| load | 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 | app\_version | \- | 3.1.3 | 应用的版本号。Hive支持3.0.0和3.1.0~3.1.3。 |
| app | app\_configs | app\_exe\_path | /usr/local/hive/bin | 应用执行文件路径。 |
| load | name | \- | hive\_tpcds | 表示Hive使用TPC\-DS作为压测工具，不可修改。 |
| load | test\_tool\_version | \- | 3.0 | 压测工具版本。 |
| load | host\_name | \- | ["local"] | 压测工具节点名称。 |
| load | tpcds\_sql\_index\_list | \- | [1,2] | 测试用例，可选用例ID：1~99。 |
| load | database\_name | \- | tpcds\_bin\_partitioned\_orc\_3 | 压测时使用的数据库名称。 |
| load | exec\_timeout | \- | 1000 | 压测超时时间，单位为秒。 |
| load | sql\_file\_tmpdir | \- | /tmp | 临时存放测试用例的目录，压测结束后将自动删除。 |
| metric | tune\_metric | \- | latency | 调优的性能指标。 |


**表9 spark_tpcds_config.json说明**

| 第一层参数 | 第二层参数 | 第三层参数 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| app | name | \- | spark | 应用名称。 |
| app | 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 | app\_configs | app\_exe\_path | /home/bigdata/spark/bin | 应用执行文件路径。 |
| app | app\_configs | omni\_home\_dir | "" | OmniOperator目录。 说明： 为""时表示不启用OmniOperator。 |
| app | app\_configs | master\_type | yarn | 应用的部署模式，可选yarn和standalone。 |
| load | name | \- | spark\_tpcds | 表示Spark使用TPC\-DS作为压测工具，不可修改。 |
| load | test\_tool\_version | \- | 3.0 | 压测工具版本。 |
| load | host\_name | \- | ["local"] | 压测工具节点名称。 |
| load | tpcds\_sql\_index\_list | \- | [1] | 测试用例。可选用例ID：1~99，其中14，23，24，39用例有a和b两种，如14a和14b。 |
| load | database\_name | \- | tpcds\_bin\_partitioned\_orc\_300 | 压测时使用的数据库名称。 |
| load | exec\_timeout | \- | 1000 | 压测超时时间，单位为秒。 |
| load | 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%.
```
