同步操作将从 openEuler/A-Tune 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
English | 简体中文
版权所有 © 2020 华为技术有限公司。
您对“本文档”的复制,使用,修改及分发受知识共享(Creative Commons)署名—相同方式共享4.0国际公共许可协议(以下简称“CC BY-SA 4.0”)的约束。为了方便用户理解,您可以通过访问https://creativecommons.org/licenses/by-sa/4.0/ 了解CC BY-SA 4.0的概要 (但不是替代)。CC BY-SA 4.0的完整协议内容您可以访问如下网址获取:https://creativecommons.org/licenses/by-sa/4.0/legalcode。
商标声明
A-Tune和其他华为商标均为华为技术有限公司的商标。本文档提及的其他所有商标或注册商标,由各自的所有人拥有。
免责声明
本文档仅作为使用指导,除非适用法强制规定或者双方有明确书面约定, 华为技术有限公司对本文档中的所有陈述、信息和建议不做任何明示或默示的声明或保证,包括但不限于不侵权,时效性或满足特定目的的担保。
本文档介绍openEuler系统性能自优化引擎A-Tune的安装部署和使用方法,以指导用户快速了解并使用A-Tune。
本文档适用于使用openEuler系统并希望了解和使用A-Tune的社区开发者、开源爱好者以及相关合作伙伴。使用人员需要具备基本的Linux操作系统知识。
操作系统作为衔接应用和硬件的基础软件,如何调整系统和应用配置,充分发挥软硬件能力,从而使业务性能达到最优,对用户至关重要。然而,运行在操作系统上的业务类型成百上千,应用形态千差万别,对资源的要求各不相同。当前硬件和基础软件组成的应用环境涉及高达7000多个配置对象,随着业务复杂度和调优对象的增加,调优所需的时间成本呈指数级增长,导致调优效率急剧下降,调优成为了一项极其复杂的工程,给用户带来巨大挑战。 其次,操作系统作为基础设施软件,提供了大量的软硬件管理能力,每种能力适用场景不尽相同,并非对所有的应用场景都通用有益,因此,不同的场景需要开启或关闭不同的能力,组合使用系统提供的各种能力,才能发挥应用程序的最佳性能; 另外,实际业务场景成千上万,计算、网络、存储等硬件配置也层出不穷,实验室无法遍历穷举所有的应用和业务场景,以及不同的硬件组合。 为了应对上述挑战,openEuler推出了A-Tune。
A-Tune是一款基于AI开发的系统性能优化引擎,它利用人工智能技术,对业务场景建立精准的系统画像,感知并推理出业务特征,进而做出智能决策,匹配并推荐最佳的系统参数配置组合,使业务处于最佳运行状态。
A-Tune核心技术架构如下图,主要包括智能决策、系统画像和交互系统三层。
A-Tune支持的主要特性、特性成熟度以及使用建议请参见表1。
表 1 特性成熟度
根据应用的负载特征,A-Tune将业务分为七大类,各类型的负载特征和A-Tune支持的应用请参见表2。
表 2 支持的业务类型和应用
本章介绍如何安装和部署A-Tune。
安装openEuler系统,安装方法参考《openEuler 1.0 安装指南》。
本章介绍A-Tune的安装模式和安装方法。
A-Tune支持单机模式和分布式模式安装:
单机模式
client和server安装到同一台机器上。
分布式模式
client和server分别安装在不同的机器上。
安装A-Tune的操作步骤如下:
挂载openEuler的iso文件。
# mount openEuler-1.0-aarch64-dvd.iso /mnt
配置本地yum源。
# vim /etc/yum.repos.d/local.repo
配置内容如下所示:
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1
安装A-Tune服务端。
说明:
本步骤会同时安装服务端和客户端软件包,对于单机部署模式,请跳过步骤4。
# yum install atune -y
安装A-Tune客户端。
# yum install atune-client -y
验证是否安装成功。
# rpm -qa | grep atune
atune-client-xxx
atune-db-xxx
atune-xxx
有如上回显信息表示安装成功。
本章介绍A-Tune的配置部署。
A-Tune配置文件/etc/atuned/atuned.cnf的配置项说明如下:
A-Tune服务启动配置
可根据需要进行修改。
system信息
system为系统执行相关的优化需要用到的参数信息,必须根据系统实际情况进行修改。
disk:执行analysis流程时需要采集的对应磁盘的信息或执行磁盘相关优化时需要指定的磁盘。
network:执行analysis时需要采集的对应的网卡的信息或执行网卡相关优化时需要指定的网卡。
user:执行ulimit相关优化时用到的用户名。目前只支持root用户。
tls:开启A-Tune的gRPC和http服务SSL/TLS证书校验,默认不开启。开启TLS后atune-adm命令在使用前需要设置以下环境变量方可与服务端进行通讯:
tlsservercertfile:gPRC服务端证书路径。
tlsserverkeyfile:gPRC服务端秘钥路径。
tlshttpcertfile:http服务端证书路径。
tlshttpkeyfile:http服务端秘钥路径。
tlshttpcacertfile:http服务端CA证书路径。
日志信息
根据情况修改日志的路径和级别,默认的日志信息在/var/log/message中。
monitor信息
为系统启动时默认采集的系统硬件信息。
#################################### server ###############################
# atuned config
[server]
# the protocol grpc server running on
# ranges: unix or tcp
protocol = unix
# the address that the grpc server to bind to
# default is unix socket /var/run/atuned/atuned.sock
# ranges: /var/run/atuned/atuned.sock or ip address
address = /var/run/atuned/atuned.sock
# the atuned grpc listening port
# the port can be set between 0 to 65535 which not be used
# port = 60001
# the rest service listening port, default is 8383
# the port can be set between 0 to 65535 which not be used
rest_port = 8383
# when run analysis command, the numbers of collected data.
# default is 20
sample_num = 20
# enable gRPC and http server authentication SSL/TLS
# default is false
# tls = true
# tlsservercertfile = /etc/atuned/server.pem
# tlsserverkeyfile = /etc/atuned/server.key
# tlshttpcertfile = /etc/atuned/http/server.pem
# tlshttpkeyfile = /etc/atuned/http/server.key
# tlshttpcacertfile = /etc/atuned/http/cacert.pem
#################################### log ###############################
[log]
# either "debug", "info", "warn", "error", "critical", default is "info"
level = info
#################################### monitor ###############################
[monitor]
# with the module and format of the MPI, the format is {module}_{purpose}
# the module is Either "mem", "net", "cpu", "storage"
# the purpose is "topo"
module = mem_topo, cpu_topo
#################################### system ###############################
# you can add arbitrary key-value here, just like key = value
# you can use the key in the profile
[system]
# the disk to be analysis
disk = sda
# the network to be analysis
network = enp189s0f0
user = root
A-Tune安装完成后,需要启动A-Tune服务才能使用。
启动atuned服务:
$ systemctl start atuned
查询atuned服务状态:
$ systemctl status atuned
若回显为如下,则服务启动成功。
用户可以通过调用A-Tune提供的命令行接口使用A-Tune提供的功能。本章介绍A-Tune命令行接口的功能和使用方式。
查询系统当前支持的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。
除了系统已定义的负载类型,A-Tune也支持用户定义新的workload_type及对应profile,并允许更新或删除自定义的workload_type。
用户也可以将“使用方法 > 自定义模型”中用户训练的自定义模型添加到A-Tune中。
添加用户自定义的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 it's 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
将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
删除用户自定义的workload_type。
atune-adm undefine <WORKLOAD_TYPE>
删除自定义的负载类型test_type。
$ atune-adm undefine test_type
A-Tune支持用户训练新的workload_type。训练方法非常简单,用户只要通过collection和train两条命令,即可完成新模型的训练。
采集业务运行时系统的全局资源使用情况以及OS的各项状态信息,并将收集的结果保存到csv格式的输出文件中,作为模型训练的输入数据集。
说明:
本命令依赖采样工具perf,mpstat,vmstat,iostat,sar。CPU型号目前仅支持鲲鹏920,可通过dmidecode -t processor检查CPU型号。
atune-adm collection <OPTIONS>
OPTIONS
$ atune-adm collection --filename name --interval 5 --duration 1200 --output_path /data --disk sda --network eth0 --workload_type test_type
使用采集的数据进行模型的训练。训练时至少采集两种workload_type的数据,否则会报错。
atune-adm train <OPTIONS>
使用data目录下的csv文件作为训练输入,生成的新模型new-model.m存放在model目录下。
$ atune-adm train --data_path ./data --output_file ./model/new-model.m
采集系统的实时统计数据进行负载类型识别,并进行自动优化。
atune-adm analysis [OPTIONS]
使用默认的模型进行分类识别
$ atune-adm analysis
使用自训练的模型进行识别
$ atune-adm analysis --model ./model/new-model.m
查看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
手动激活workload_type对应的profile,使得workload_type处于active状态。
atune-adm profile <WORKLOAD_TYPE>
WORKLOAD_TYPE 支持的类型参考list命令查询结果。
激活webserver对应的profile配置。
$ atune-adm profile webserver
回退当前的配置到系统的初始配置。
atune-adm rollback
$ atune-adm rollback
更新系统的数据库。
atune-adm upgrade <DB_FILE>
数据库更新为new_sqlite.db。
$ atune-adm upgrade ./new_sqlite.db
检查系统当前的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提供了最佳配置的自动搜索能力,免去人工反复做参数调整、性能评价的调优过程,极大地提升最优配置的搜寻效率。
使用指定的项目文件对参数进行动态空间的搜索,找到当前环境配置下的最优解。
atune-adm tuning [OPTIONS] <PROJECT_YAML>
说明:
在运行命令前,需要满足如下条件:
- 编辑好服务端yaml配置文件,且需要服务端管理员将该配置文件放到服务端的/etc/atuned/tuning/目录下。
- 编辑好客户端yaml配置文件并放在客户端任一目录。
PROJECT_YAML 客户端yaml配置文件
OPTIONS
表 1
服务端yaml文件配置说明
表 1 object项配置说明
客户端yaml文件配置说明
表 2 evaluations项配置说明
服务端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
$ atune-adm tuning example-client.yaml
$ atune-adm tuning --restore --project example
表 1 术语表
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。