RHEL/CentOS 在 6.3 版本以后引入了一套新的系统调优工具 tuned/tuned-adm,其中 tuned 是服务端程序,用来监控和收集系统各个组件的数据,并依据数据提供的信息动态调整系统设置,达到动态优化系统的目的;tuned-adm 是客户端程序,用来和 tuned 打交道,用命令行的方式管理和配置 tuned,tuned-adm 提供了一些预先配置的优化方案可供直接使用,比如:笔记本、虚拟机、存储服务器等。
如果你正在使用笔记本(电池电源),想优化系统、节约电源又不想知道太多这方面的细节,就可以用 tuned/tuned-adm 这套工具并应用 laptop-battery-powersave 方案来调整和优化系统。当然不同的系统和应用场景有不同的优化方案,tuned-adm 预先配置的优化策略不是总能满足要求,这时候就需要定制,tuned-adm 允许用户自己创建和定制新的调优方案。
[root@1st-kvm tuned]# rpm -qa|grep tun
tuned-2.5.1-4.el7.noarch
[root@1st-kvm tuned]# less /var/log/tuned/tuned.log
[root@1st-kvm ~]# tuned-adm list
Available profiles:
- balanced
- desktop
- latency-performance
- network-latency
- network-throughput
- powersave
- throughput-performance
- virtual-guest
- virtual-host
Current active profile: balanced
[root@1st-kvm ~]# tuned-adm active
Current active profile: balanced
[root@1st-kvm ~]# tuned-adm profile virtual-host
[root@1st-kvm ~]# tuned-adm active
Current active profile: virtual-host
如果是企业存储服务器的话,可以用 enterprise-storage 方案:
tuned-adm profile enterprise-storage
上面预定的方案不是总能满足要求,如果有自己的需求可以定制自己的方案。自己定制很容易,切换到优化方案的配置目录,拷贝一个例子,然后编辑里面的相关参数就可以了,使用 tuned-adm list 命令会看到刚创建的新方案 my-virtual-host:
[root@1st-kvm tuned]# ll
total 16
drwxr-xr-x. 2 root root 23 Jul 24 14:59 balanced
drwxr-xr-x. 2 root root 23 Jul 24 14:59 desktop
-rw-r--r--. 1 root root 12260 May 19 2015 functions
drwxr-xr-x. 2 root root 23 Jul 24 14:59 latency-performance
drwxr-xr-x. 2 root root 23 Jul 24 14:59 network-latency
drwxr-xr-x. 2 root root 23 Jul 24 14:59 network-throughput
drwxr-xr-x. 2 root root 39 Jul 24 14:59 powersave
-rw-r--r--. 1 root root 1288 Aug 1 2015 recommend.conf
drwxr-xr-x. 2 root root 23 Jul 24 14:59 throughput-performance
drwxr-xr-x. 2 root root 23 Jul 24 14:59 virtual-guest
drwxr-xr-x. 2 root root 23 Jul 24 14:59 virtual-host
[root@1st-kvm tuned]# pwd
/usr/lib/tuned
在这个目录下,新建一个目录,修改里面的tuned.conf来配置参数,最后用tuned-adm active来选择这个定制的方案
[root@test tuned]# ls -R
.:
balanced desktop functions latency-performance network-latency network-throughput powersave recommend.d throughput-performance virtual-guest virtual-host
./balanced:
tuned.conf
./desktop:
tuned.conf
./latency-performance:
tuned.conf
./network-latency:
tuned.conf
./network-throughput:
tuned.conf
./powersave:
script.sh tuned.conf
./recommend.d:
50-tuned.conf
./throughput-performance:
tuned.conf
./virtual-guest:
tuned.conf
./virtual-host:
tuned.conf
[root@test tuned]# pwd
/usr/lib/tuned
[root@test tuned]# cd network-throughput/
[root@test network-throughput]# cat tuned.conf
#
# tuned configuration
#
[main]
summary=Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
include=throughput-performance
[sysctl]
# Increase kernel buffer size maximums. Currently this seems only necessary at 40Gb speeds.
#
# The buffer tuning values below do not account for any potential hugepage allocation.
# Ensure that you do not oversubscribe system memory.
net.ipv4.tcp_rmem="4096 87380 16777216"
net.ipv4.tcp_wmem="4096 16384 16777216"
net.ipv4.udp_mem="3145728 4194304 16777216"