前言
哦对!这篇文章会使用Markdown来编辑(终于),所以观感上应该会好很多,也很方便我编辑。但遗憾的是表情包貌似用不了了呜呜呜呜呜呜(之后再找个替代方案罢)
本笔记是通过学习Red Hat System Administration II 9.0记下的,因此Linux版本基于Red Hat Enterprise Linux。
调整调优配置集
静态调优
tuned守护进程会在服务启动时选择新的调优配置集。静态则会集中在tuned运行时预定义的kernel参数进行调优操作。因此对于静态调优而言,tuned守护进程是针对整体性能的预期来进行配置的,而不是随着活跃度变化来灵活调整。说人话就是你已经对调优效果有预知了,根据预知来调整参数。
动态调优
tuned守护进程会监视系统活动,并根据运行时的变化来调整调优配置。当然这不是指一开始就能达到目标调优配置,而是随着监视系统的活动来不断适应当前的工作负载。举个例子来说,如果你只是看看网页刷刷邮件,并没有很高的活动,此时tuned则会降低设置值。tuned附带了三个不同的监控插件,分别是:
disk
:根据每个磁盘设备的 IO 操作数监控磁盘负载net
:根据每个网卡传输的数据包数量监控网络负载load
:监控每个CPU的负载
tuned 配置
在使用Red Hat Linux时其实已经包含了最低限度安装的tuned软件包,但如果没有的话可以使用以下命令来手动安装和启用软件包。
[japerz@linux ~]$ dnf install tuned
..[省略]..
[japerz@linux ~]$ systemctl enable --now tuned
Created symlink /etc/systemd/system/multi-user.target.wants/tuned.service → /usr/lib/systemd/system/tuned.service.
tuned 应用提供的配置集分为以下几个类别:
- 节能型配置集
- 性能提升型配置集
性能提升型配置集中包括侧重于以下方面的配置集:
- 存储和网络的低延迟
- 存储和网络的高吞吐量
- 虚拟机性能
- 虚拟化主机性能
tuned 应用将调优配置集存储在 /usr/lib/tuned
和 /etc/tuned
目录下。每个配置集都有一个单独的目录,目录中包含 tuned.conf
主配置文件以及其他可选文件。
virtual-guest
的tuned.conf
默认配置文件如下:
[japerz@linux tuned]$ cat virtual-guest/tuned.conf
#
# tuned configuration
#
[main]
summary=Optimize for running inside a virtual guest
include=throughput-performance
[sysctl]
# If a workload mostly uses anonymous memory and it hits this limit, the entire
# working set is buffered for I/O, and any more write buffering would require
# swapping, so it's time to throttle writes until I/O can catch up. Workloads
# that mostly use file mappings may be able to use even higher values.
#
# The generator of dirty data starts writeback at this percentage (system default
# is 20%)
vm.dirty_ratio = 30
# Filesystem I/O is usually much more efficient than swapping, so try to keep
# swapping low. It's usually safe to go even lower than this on systems with
# server-grade storage.
vm.swappiness = 30
除了virtual-guest以外,还有很多调优集,以下是调优集列表:
调优集 | 作用 |
---|---|
balanced | 适合兼顾节能和性能的系统 |
powersave | 最大程度实现节能 |
throughput-performance | 最大程度提高吞吐量 |
accelerator-performance | 调优方式和上面一样,但是会将延迟缩短到100ms以下 |
latency-proformance | 适合需要牺牲能耗来换取低延迟的服务器系统 |
network-throughput | 从 throughput-performance 调优集衍生,旨在获得最大网络吞吐量 |
network-latency | 从 latency-performance 配置集衍生,拥有额外的网络调优参数,获得低网络延迟 |
desktop | 从 balanced 配置集衍生,但对桌面式交互的响应速度有所优化 |
hpc-compute | 从 latency-performance 配置集衍生,适合高性能运算 |
virtual-guest | 对在虚拟机上运行的系统进行调优,以获得最高性能 |
virtual-host | 对宿主机的系统进行调优,以获得最高性能 |
intel-sst | 针对采用 Intel Speed Select Technology 配置的系统进行了优化。可以当作其他调优集的覆盖层来用 |
optimize-serial-console | 提高控制台的响应能力。可以当作其他调优集的覆盖层来用 |
其实仔细一看,大多数都调好了草!
警告
从控制台管理调优集
使用 tuned-adm
命令来更改 tuned 守护进程的设置。tuned-adm
命令会检查当前的设置,列出可用的配置集,为系统推荐调优配置集,直接更改配置集或关闭调优。
我们可以使用以下指令来查看当前使用的调优集:
[japerz@linux ~]$ tuned-adm active
Current active profile: virtual-guest
我们可以使用以下指令来查看可用的调优集列表:
[japerz@linux ~]$ tuned-adm list
Available profiles:
- accelerator-performance - Throughput performance based tuning with ...
- balanced - General non-specialized tuned profile
- desktop - Optimize for the desktop use-case
- hpc-compute - Optimize for HPC compute workloads
- intel-sst - Configure for Intel Speed Select Base Frequency
- latency-performance - Optimize for deterministic performance at ...
- network-latency - Optimize for deterministic performance at ...
..[省略]..
Current active profile: virtual-guest
我们可以使用以下指令来切换当前的调优集:
[japerz@linux ~]$ tuned-adm profile throughput-performance
[japerz@linux ~]$ tuned-adm active
Current active profile: throughput-performance
注意:上面的throughput-performance可以换成你期望更换的调优集!
以及,我们可以使用以下指令来让tuned推荐调优集:
[japerz@linux ~]$ tuned-adm recommend
virtual-guest
注意:tuned-adm recommend
命令的建议基于各种系统特征,包括系统是否为虚拟机以及在系统安装期间选择的其他预定义类别。
要想恢复当前调优集所应用的设置更改,可以切换到另外一个调优集或者停止tuned守护进程。以下是相关指令:
[japerz@linux ~]$ tuned-adm off
[japerz@linux ~]$ tuned-adm active
No current active profile.