|
Tuned 介绍
tuned 是一个守护进程,用来动态调优系统中的相关参数(tuned 的同态调优默认情况下是全局禁用的)
[root@localhost ~]# systemctl status tuned
● tuned.service - Dynamic System Tuning Daemon
Loaded: loaded (/usr/lib/systemd/system/tuned.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-05-07 16:37:24 CST; 20min ago
Docs: man:tuned(8)
man:tuned.conf(5)
man:tuned-adm(8)
Main PID: 931 (tuned)
CGroup: /system.slice/tuned.service
└─931 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
May 07 16:37:23 localhost.localdomain systemd[1]: Starting Dynamic System Tuning Daemon...
May 07 16:37:24 localhost.localdomain systemd[1]: Started Dynamic System Tuning Daemon.
[root@localhost ~]
tuned 动态调优的工作架构
动态调优的场景
办公环境下,大多数时间,网卡是不活跃的(少数邮件进出,浏览网页),对于这种情况,网卡实际上不必一直全速运行;
tuned 会检测到这种低活跃度的情况,然后自动降低接口的速度; 如果接口活跃度在较长时间段内开始持续增长,则 tuned 会重新将接口速度设置为最大
这些原理也被应用在 CPU、内存、硬盘上; 对于服务器来说,稳定是大于一切的, 讲究的是组件都平稳运行,所以服务器上坚决不会启用"动态调优"
但是对于桌面环境,可以使用,打开方法如下:
[root@localhost ~]# vim /etc/tuned/tuned-main.conf
dynamic_tuning = 1
[root@localhost ~]# tuned-adm auto_profile
[root@localhost ~]# systemctl restart tune
对于服务器运维人员来说,我们要做的事就是选择一个正确的"调优配置文件"
列出所有调优配置文件以及当前应用的配置文件
[root@localhost ~]# tuned-adm list
Available profiles:
- balanced - General non-specialized tuned profile
- desktop - Optimize for the desktop use-case
- hpc-compute - Optimize for HPC compute workloads
- latency-performance - Optimize for deterministic performance at the cost of increased power consumption
- network-latency - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency
network performance
- network-throughput - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- powersave - Optimize for low power consumption
- throughput-performance - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest - Optimize for running inside a virtual guest
- virtual-host - Optimize for running KVM guests
Current active profile: virtual-guest
[root@localhost ~]#
man tuned-profiles
hpc-compute 针对 high-performance computing 高性能计算机进行调优,基于 latency-performance
latency-performance 延迟性能优化
network-latency 网络延迟优化
network-throughput 网络吞吐量优化
throughput-performance 吞吐性能优化
virtual-guest 虚拟机优化
virtual-host 虚拟机宿主机优化
吞吐量和延迟的关系
吞吐量=一次处理数据的大小(单位时间内能处理的任务数); 延迟=处理数据的速度(通常指往返延迟,来回的速度)
是否经常听到: "低延迟高吞吐(延迟越低吞吐越高)" 这样的话?答案是否定的,让我们看一篇故事:
银行ATM机的故事
原文链接(可能需要真正的互联网):
http://techdiscuss.wordpress.com ... ughput-and-latency/
某银行有一台 ATM 取款机,每个人从取钱开始到结束需要用时 60 秒才能完成; 即延迟=60秒,吞吐量=1人/60秒;
后来银行升级了取款流程,仅需30秒即可完成取款操作; 即延迟=30秒,吞吐量=1人/30秒; (这里就是大部分人所说的: 低延迟高吞吐)
再后来银行增加了1台ATM机,一共有2台ATM机; 现在延迟=30秒不变,吞吐量=4人/60秒; (此时吞吐量变大了,但延迟并没有变)
最后,银行决定取款后要在旁边完成一个问卷调查,用时也是30秒,也就是说对用户而言又变成了60秒; 即延迟=60秒,但ATM的吞吐量呢?依旧是 4人/60秒(此时延迟增加,但
吞吐不变)
作者表达的核心: 延迟是"每个客户感受到的时间长短(应用程序)",吞吐是"整个银行的处理效率(操作系统)"
吞吐与延迟是2个独立的指标,应当分别考量; 操作系统应尽量让网络吞吐量大,还要让应用程序发送数据的延迟尽量小,这是两个不同的目标
第三方的tuned配置文件
[root@localhost ~]# yum search tuned-profiles
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* epel: hkg.mirror.rackspace.com
* extras: mirror.lzu.edu.cn
* updates: mirror.lzu.edu.cn
============================================ N/S matched: tuned-profiles ============================================
tuned-profiles-atomic.noarch : Additional tuned profile(s) targeted to Atomic
tuned-profiles-compat.noarch : Additional tuned profiles mainly for backward compatibility with tuned 1.0
tuned-profiles-cpu-partitioning.noarch : Additional tuned profile(s) optimized for CPU partitioning
tuned-profiles-mssql.noarch : Additional tuned profile(s) for MS SQL Server
tuned-profiles-oracle.noarch : Additional tuned profile(s) targeted to Oracle loads
Name and summary matches only, use "search all" for everything.
[root@localhost ~]# yum -y install tuned-profiles-oracle
应用 tuned 的配置文件
可以同时应用多个 profiles 文件(用空格分隔多个profiles),但不建议,可能会有冲突,通常来说应用一个即可;
相关命令:
tuned-adm profile 用于配置 profile 生效
tuned-adm active 用于查看当前生效的是哪个 profile
[root@localhost ~]# tuned-adm profile throughput-performance
[root@localhost ~]# tuned-adm active
Current active profile: throughput-performance
[root@localhost ~]#
如果你不知道如何选择 profile 文件,你可以使用自带的系统推荐功能,系统会根据环境帮你选择一个 profile, 命令 tuned-adm recommend
[root@localhost ~]# tuned-adm recommend
virtual-guest
如果你想关闭系统调优,可以执行
[root@localhost ~]# tuned-adm off
[root@localhost ~]# tuned-adm active
No current active profile.
原因是我这台单网卡的软路由,经常莫名其妙的dnsmasq卡死 查看top发现是tuned在占用CPU 然后就搜了这个教程
只需要最后一个命令就行了 但是我不确定重启系统以后是否还会重新恢复
https://access.redhat.com/docume ... ization_guide-tuned
这个教程有永久关闭方法
tuned-adm off; systemctl disable tuned
最后我发现不是这个的问题,是dnsmasq的问题
yum安装的dnsmasq貌似有问题 我把文件替换为我手动编译的2.89的文件 好像就没这个问题了
最终发现是把网卡加入到了防火墙的trusted区 导致这种问题 把网卡重新改为默认的public区然后放行需要的就好了
也不知道redhat怎么设置的trusted 看来这种all allow式的防火墙设置应该是永远不要使用
|
|