暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openEuler A-Tune用户指南 使用方法

原创 openeuler 2021-07-10
662

用户可以通过命令行客户端atune-adm使用A-Tune提供的功能。本章介绍A-Tune客户端包含的功能和使用方法。

总体说明

  • 使用A-Tune需要使用root权限。
  • atune-adm支持的命令可以通过 atune-adm help/--help/-h 查询。
  • 使用方法中所有命令的使用举例都是在单机部署模式下,如果是在分布式部署模式下,需要指定服务器IP和端口号,例如:

    ```

    atune-adm -a 192.168.3.196 -p 60001 list

    ```

  • define、update、undefine、collection、train、upgrade不支持远程执行。

  • 命令格式中,[ ] 表示参数可选,<> 表示参数必选,具体参数由实际情况确定。
  • 命令格式中,各命令含义如下:
    • WORKLOAD_TYPE:用户自定义负载类型的名称,负载支持的类型参考list命令查询结果。
    • PROFILE_NAME:用户自定义profile的名称
    • PROFILE_PATH:用户自定义profile的路径

查询负载类型

list

功能描述

查询系统当前支持的workload_type和对应的profile,以及当前处于active状态的profile。

命令格式

atune-adm list

使用示例

```

atune-adm list

Support WorkloadTypes: +-----------------------------------+------------------------+-----------+ | WorkloadType | ProfileName | Active | +===================================+========================+===========+ | default | default | true | +-----------------------------------+------------------------+-----------+ | webserver | ssl_webserver | false | +-----------------------------------+------------------------+-----------+ | big_database | database | false | +-----------------------------------+------------------------+-----------+ | big_data | big_data | false | +-----------------------------------+------------------------+-----------+ | in-memory_computing | in-memory_computing | false | +-----------------------------------+------------------------+-----------+ | in-memory_database | in-memory_database | false | +-----------------------------------+------------------------+-----------+ | single_computer_intensive_jobs | compute-intensive | false | +-----------------------------------+------------------------+-----------+ | communication | rpc_communication | false | +-----------------------------------+------------------------+-----------+ | idle | default | false | +-----------------------------------+------------------------+-----------+

```

说明:
Active为true表示当前激活的profile,示例表示当前激活的是default类型对应的profile。

分析负载类型并自优化

analysis

功能描述

采集系统的实时统计数据进行负载类型识别,并进行自动优化。

命令格式

atune-adm analysis [OPTIONS]

参数说明

  • OPTIONS

    参数

    描述

    --model, -m

    用户自训练产生的新模型

使用示例

  • 使用默认的模型进行分类识别

    ```

    atune-adm analysis

    ```

  • 使用自训练的模型进行识别

    ```

    atune-adm analysis --model /usr/libexec/atuned/analysis/models/new-model.m

    ```

自定义模型

A-Tune支持用户定义并学习新模型。定义新模型的操作流程如下:

  1. 用define命令定义workload_type和profile
  2. 用collection命令收集workload_type对应的画像数据
  3. 用train命令训练得到模型

define

功能描述

添加用户自定义的workload_type,及对应的profile优化项。

命令格式

atune-adm define <WORKLOAD_TYPE> <PROFILE_NAME> <PROFILE_PATH>

使用示例

新增一个workload type,workload type的名称为test_type,profile name的名称为test_name,优化项的配置文件为example.conf。

```

atune-adm define test_type test_name ./example.conf

```

example.conf 可以参考如下方式书写(以下各优化项非必填,仅供参考),也可通过atune-adm info查看已有的profile是如何书写的。

``` [main]

list its parent profile

[tip]

the recommended optimization, which should be performed manunaly

[check]

check the environment

[affinity.irq]

to change the affinity of irqs

[affinity.task]

to change the affinity of tasks

[bios]

to change the bios config

[bootloader.grub2]

to change the grub2 config

[kernel_config]

to change the kernel config

[script]

the script extention of cpi

[sysctl]

to change the /proc/sys/* config

[sysfs]

to change the /sys/* config

[systemctl]

to change the system service config

[ulimit]

to change the resources limit of user

```

collection

功能描述

采集业务运行时系统的全局资源使用情况以及OS的各项状态信息,并将收集的结果保存到csv格式的输出文件中,作为模型训练的输入数据集。

说明:
- 本命令依赖采样工具perf,mpstat,vmstat,iostat,sar。
- CPU型号目前仅支持鲲鹏920,可通过dmidecode -t processor检查CPU型号。

命令格式

atune-adm collection <OPTIONS>

参数说明

  • OPTIONS

    参数

    描述

    --filename, -f

    生成的用于训练的csv文件名:名称-时间戳.csv

    --output_path, -o

    生成的csv文件的存放路径,需提供绝对路径

    --disk, -b

    业务运行时实际使用的磁盘,如/dev/sda

    --network, -n

    业务运行时使用的网络接口,如eth0

    --workload_type, -t

    标记业务的负载类型,作为训练时使用的标签

    --duration, -d

    业务运行时采集数据的时间,单位秒,默认采集时间1200秒

    --interval,-i

    采集数据的时间间隔,单位秒,默认采集间隔5秒

使用示例

```

atune-adm collection --filename name --interval 5 --duration 1200 --output_path /home/data --disk sda --network eth0 --workload_type test_type

```

train

功能描述

使用采集的数据进行模型的训练。训练时至少采集两种workload_type的数据,否则训练会出错。

命令格式

atune-adm train <OPTIONS>

参数说明

  • OPTIONS

    参数

    描述

    --data_path, -d

    存放模型训练所需的csv文件的目录

    --output_file, -o

    训练生成的新模型

使用示例

使用data目录下的csv文件作为训练输入,生成的新模型new-model.m存放在model目录下。

```

atune-adm train --data_path /home/data --output_file /usr/libexec/atuned/analysis/models/new-model.m

```

undefine

功能描述

删除用户自定义的workload_type。

命令格式

atune-adm undefine <WORKLOAD_TYPE>

使用示例

删除自定义的负载类型test_type。

```

atune-adm undefine test_type

```

查询profile

info

功能描述

查看workload_type对应的profile内容。

命令格式

atune-adm info <WORKLOAD_TYPE_>_

使用示例

查看webserver的profile内容:

```

atune-adm info webserver

*** ssl_webserver:

webserver tuned configuration

[main]

TODO CONFIG

[kernel_config]

TODO CONFIG

[bios]

TODO CONFIG

[sysfs]

TODO CONFIG

[sysctl] fs.file-max=6553600 fs.suid_dumpable = 1 fs.aio-max-nr = 1048576 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_syncookies = 1 net.ipv4.ip_local_port_range = 1024 65500 net.ipv4.tcp_max_tw_buckets = 5000 net.core.somaxconn = 65535 net.core.netdev_max_backlog = 262144 net.ipv4.tcp_max_orphans = 262144 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 60 net.ipv4.tcp_mem = 362619 483495 725238 net.ipv4.tcp_rmem = 4096 87380 6291456 net.ipv4.tcp_wmem = 4096 16384 4194304 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216

[systemctl] sysmonitor=stop irqbalance=stop

[bootloader.grub2] selinux=0 iommu.passthrough=1

[tip] bind your master process to the CPU near the network = affinity bind your network interrupt to the CPU that has this network = affinity relogin into the system to enable limits setting = OS

[script] openssl_hpre = 0 prefetch = off

[ulimit] {user}.hard.nofile = 102400 {user}.soft.nofile = 102400

[affinity.task]

TODO CONFIG

[affinity.irq]

TODO CONFIG

[check]

TODO CONFIG

```

更新profile

用户根据需要更新已有profile。

update

功能描述

将workload_type原来的优化项更新为new.conf中的内容。

命令格式

atune-adm update <WORKLOAD_TYPE> <PROFILE_NAME> <PROFILE_FILE>

使用示例

更新负载类型为test_type,优化项名称为test_name的优化项为new.conf。

```

atune-adm update test_type test_name ./new.conf

```

激活profile

profile

功能描述

手动激活workload_type对应的profile,使得workload_type处于active状态。

命令格式

atune-adm profile <_WORKLOAD_TYPE>_

参数说明

WORKLOAD_TYPE支持的类型参考list命令查询结果。

使用示例

激活webserver对应的profile配置。

```

atune-adm profile webserver

```

回滚profile

rollback

功能描述

回退当前的配置到系统的初始配置。

命令格式

atune-adm rollback

使用示例

```

atune-adm rollback

```

更新数据库

upgrade

功能描述

更新系统的数据库。

命令格式

atune-adm upgrade <DB_FILE>

参数说明

  • DB_FILE

    新的数据库文件路径

使用示例

数据库更新为new_sqlite.db。

```

atune-adm upgrade ./new_sqlite.db

```

系统信息查询

check

功能描述

检查系统当前的cpu、bios、os、网卡等信息。

命令格式

atune-adm check

使用示例

```

atune-adm check

cpu information: cpu:0 version: Kunpeng 920-6426 speed: 2600000000 HZ cores: 64 cpu:1 version: Kunpeng 920-6426 speed: 2600000000 HZ cores: 64 system information: DMIBIOSVersion: 0.59 OSRelease: 4.19.36-vhulk1906.3.0.h356.eulerosv2r8.aarch64 network information: name: eth0 product: HNS GE/10GE/25GE RDMA Network Controller name: eth1 product: HNS GE/10GE/25GE Network Controller name: eth2 product: HNS GE/10GE/25GE RDMA Network Controller name: eth3 product: HNS GE/10GE/25GE Network Controller name: eth4 product: HNS GE/10GE/25GE RDMA Network Controller name: eth5 product: HNS GE/10GE/25GE Network Controller name: eth6 product: HNS GE/10GE/25GE RDMA Network Controller name: eth7 product: HNS GE/10GE/25GE Network Controller name: docker0 product: ```

参数自调优

A-Tune提供了最佳配置的自动搜索能力,免去人工反复做参数调整、性能评价的调优过程,极大地提升最优配置的搜寻效率。

tuning

功能描述

使用指定的项目文件对参数进行动态空间的搜索,找到当前环境配置下的最优解。

命令格式

说明:
在运行命令前,需要满足如下条件:
1. 编辑好服务端yaml配置文件,且需要服务端管理员将该配置文件放到服务端的/etc/atuned/tuning/目录下。
2. 编辑好客户端yaml配置文件并放在客户端任一目录。

atune-adm tuning [OPTIONS] <PROJECT_YAML>

参数说明

  • OPTIONS

    参数

    描述

    --restore, -r

    恢复tuning优化前的初始配置

    --project, -p

    指定需要恢复的yaml文件中的项目名称

    说明:
    当使用参数时,上述两个参数需要同时使用,且-p参数后需要跟具体的项目名称。

  • PROJECT_YAML:客户端yaml配置文件。

配置说明

表 1 服务端yaml文件

配置名称

配置说明

参数类型

取值范围

project

项目名称。

字符串

-

startworkload

待调优服务的启动脚本。

字符串

-

stopworkload

待调优服务的停止脚本。

字符串

-

maxiterations

最大调优迭代次数,用于限制客户端的迭代次数。一般来说,调优迭代次数越多,优化效果越好,但所需时间越长。用户必须根据实际的业务场景进行配置。

整型

>10

object

需要调节的参数项及信息。

object 配置项请参见表2

-

-

表 2 object项配置说明

配置名称

配置说明

参数类型

取值范围

name

待调参数名称

字符串

-

desc

待调参数描述

字符串

-

get

查询参数值的脚本

-

-

set

设置参数值的脚本

-

-

needrestart

参数生效是否需要重启业务

枚举

"true", "false"

type

参数的类型,目前支持discrete, continuous两种类型,对应离散型、连续型参数

枚举

"discrete", "continuous"

dtype

该参数仅在type为discrete类型时配置,目前支持int和string两种类型

枚举

int, string

scope

参数设置范围,仅在type为discrete且dtype为int时或者type为continuous时生效

整型

用户自定义,取值在该参数的合法范围

step

参数值步长,dtype为int时使用

整型

用户自定义

items

参数值在scope定义范围之外的枚举值,dtype为int时使用

整型

用户自定义,取值在该参数的合法范围

options

参数值的枚举范围,dtype为string时使用

字符串

用户自定义,取值在该参数的合法范围

ref

参数的推荐初始值

整型或字符串

用户自定义,取值在该参数的合法范围

表 3 客户端yaml文件配置说明

配置名称

配置说明

参数类型

取值范围

project

项目名称,需要与服务端对应配置文件中的project匹配

字符串

-

iterations

调优迭代次数

整型

>=10

benchmark

性能测试脚本

-

-

evaluations

性能测试评估指标

evaluations 配置项请参见表4

-

-

表 4 evaluations项配置说明

配置名称

配置说明

参数类型

取值范围

name

评价指标名称

字符串

-

get

获取性能评估结果的脚本

-

-

type

评估结果的正负类型,positive代表最小化性能值,negative代表最大化对应性能值

枚举

"positive","negative"

weight

该指标的权重百分比,0-100

整型

0-100

threshold

该指标的最低性能要求

整型

用户指定

配置示例

服务端yaml文件配置示例:

``` project: "example" maxiterations: 10 startworkload: "" stopworkload: "" object : - name : "vm.swappiness" info : desc : "the vm.swappiness" get : "sysctl -a | grep vm.swappiness" set : "sysctl -w vm.swappiness=$value" needrestart: "false" type : "continuous" scope : - 0 - 10 ref : 1 - name : "irqbalance" info : desc : "system irqbalance" get : "systemctl status irqbalance" set : "systemctl $value sysmonitor;systemctl $value irqbalance" needrestart: "false" type : "discrete" options: - "start" - "stop" dtype : "string" ref : "start" - name : "net.tcp_min_tso_segs" info : desc : "the minimum tso number" get : "cat /proc/sys/net/ipv4/tcp_min_tso_segs" set : "echo $value > /proc/sys/net/ipv4/tcp_min_tso_segs" needrestart: "false" type : "continuous" scope: - 1 - 16 ref : 2 - name : "prefetcher" info : desc : "" get : "cat /sys/class/misc/prefetch/policy" set : "echo $value > /sys/class/misc/prefetch/policy" needrestart: "false" type : "discrete" options: - "0" - "15" dtype : "string" ref : "15" - name : "kernel.sched_min_granularity_ns" info : desc : "Minimal preemption granularity for CPU-bound tasks" get : "sysctl kernel.sched_min_granularity_ns" set : "sysctl -w kernel.sched_min_granularity_ns=$value" needrestart: "false" type : "continuous" scope: - 5000000 - 50000000 ref : 10000000 - name : "kernel.sched_latency_ns" info : desc : "" get : "sysctl kernel.sched_latency_ns" set : "sysctl -w kernel.sched_latency_ns=$value" needrestart: "false" type : "continuous" scope: - 10000000 - 100000000 ref : 16000000

```

客户端yaml文件配置示例:

project: "example" iterations : 10 benchmark : "sh /home/Benchmarks/mysql/tunning_mysql.sh" evaluations : - name: "tps" info: get: "echo -e '$out' |grep 'transactions:' |awk '{print $3}' | cut -c 2-" type: "negative" weight: 100 threshold: 100

使用示例

  • 进行tuning调优

    ```

    atune-adm tuning example-client.yaml

    ```

  • 恢复tuning调优前的初始配置,example为yaml文件中的项目名称

    ```

    atune-adm tuning --restore --project example

    ```

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论