Linux性能优化特性Tuned和ktune

性能优化是任何系统架构师和运维人员头疼且痴迷的问题。从数据库、服务器、存储、网络、应用系统等诸多系统层面,都存在进行优化的空间和探讨的余地。各种前辈也从系统开发过程流程、方法论、部署原则、监控测试和后期运维等诸多方面,进行了若干年的探讨。

在各种优化流派中,起码有一条是得到了广泛共识:系统优化工作绝对不存在“金手指”和“万灵药”。按照现在比较官方的说法:优化是一项涉及多领域、多学科,需要各方面人才合作才能做好的一项系统工程。

落实在数据库和Linux操作系统方面,这个问题就变的比较复杂。首先,无论是Linux还是运行其上的应用程序,CPU、网络、存储IO等多个方面共同配合。一个方面的短板就会造成整体的“木桶效应”。其次,根据系统用途的差异,每个应用系统优化的方面是不同的。比如:数据库服务器优化的重点就是IO读写速度;一些Web应用服务器优化的重点是提升吞吐量。最后,系统的各种优化方面是相互制约、相互协助的关系。单靠一方面强大的系统,整体是不会有很好的表现的。

1、Tuned优化

对一般新手而言,Linux应用环境优化是很困难的。领域多,范围广:CPU、存储、缓存策略、内存管理等涉及的参数。Linux内部虽然有默认设置值,可以应对大多数的情况场景,但是针对一些特殊场景,例如高性能、高并发和高可用的系统,就需要我们进行调整。这种工作对于初学者而言,是比较困难的。

红帽Linux针对这种情况,综合多年的性能优化分析经验,将若干典型的优化场景转化为优化Profile。普通用户借助tuned和ktune特性工具,可以自由切换系统到不同的Profile模式,应用优化参数模式。同时,一些高级用户可以以这些Profile作为一个工作起始点,修改或者添加一些优化功能点,构建适合自己特性的优化Profile。

另外,Profile的组织方式非常简单,以一个目录的形式进行组织。如果需要进行迁移,只要将目录转移到一个新服务器目录,就可以实现优化策略迁移。

目前,Tuned优化Profile提供了如下几种策略:

Profile名称

应用场景

default

desktop-powersave

server-powersave

laptop-ac-powersave

laptop-battery-powersave

throughput-performance

latency-performance

在/etc/tune-profiles目录中,我们可以找到对应的配置文件夹。

[root@SICS-MIGPC-DB tune-profiles]# ls -ltotal 68-rw-r–r– 1 root root 25 Apr 7 16:37 active-profiledrwxr-xr-x 2 root root 4096 Apr 3 13:11 defaultdrwxr-xr-x 2 root root 4096 Apr 3 13:11 desktop-powersavedrwxr-xr-x 2 root root 4096 Apr 3 13:11 enterprise-storagedrwxr-xr-x 2 root root 4096 Apr 3 13:42 enterprise-storage-no-thp-rw-r–r– 1 root root 9779 Jul 24 2013 functionsdrwxr-xr-x 2 root root 4096 Apr 3 13:11 laptop-ac-powersavedrwxr-xr-x 2 root root 4096 Apr 3 13:11 laptop-battery-powersavedrwxr-xr-x 2 root root 4096 Apr 3 13:11 latency-performancedrwxr-xr-x 2 root root 4096 Apr 3 13:11 sapdrwxr-xr-x 2 root root 4096 Apr 3 13:11 server-powersavedrwxr-xr-x 2 root root 4096 Apr 3 13:11 spindown-diskdrwxr-xr-x 2 root root 4096 Apr 3 13:11 throughput-performancedrwxr-xr-x 2 root root 4096 Apr 3 13:11 virtual-guestdrwxr-xr-x 2 root root 4096 Apr 3 13:11 virtual-host2、Tuned和Ktune服务结构

Tuned本质上是一个Linux环境中的后台进程,在运行过程中依据配置内容监控调整系统。监控程序会根据监控的配置内容,监控进程会持续监控结果反馈,调整优化策略。Ktune进程是在Red Hat 5.3引入的一项架构服务内容,为一些特定的用例场景来优化进程。

[root@SICS-MIGPC-DB ~]# ps -ef | grep tune

root 18878 18856 0 13:36 pts/0 00:00:00 grep tune

root 31656 1 0 Apr07 ? 00:00:00 /usr/bin/python /usr/sbin/tuned -d -c /etc/tuned.conf

tuned程序是后台运行的守护进程,-c参数用于指定当前的监控参数。

[root@SICS-MIGPC-DB tune-profiles]# cat /etc/tuned.conf# disable tuned[main][DiskMonitor]enabled=False[DiskTuning]enabled=False[NetMonitor]enabled=False[NetTuning]enabled=False[CPUMonitor]enabled=False[CPUTuning]enabled=False

作为后台的进程tuned命令,是可以通过chkconfig和service命令进行配置启动的。

[root@SICS-MIGPC-DB ~]# service tuned status

tuned (pid 31656) is running…

tuned-adm命令是管理tuned组件的主要接口。

[root@SICS-MIGPC-DB ~]# tuned-adm help

Usage: tuned-adm <command>

commands:

help show this help message and exit

list list all available and active profiles

active show current active profile

off switch off all tuning

profile <profile-name> switch to given profile

通过list命令,,可以查看当前应用和备选的所有Profile内容。

妩媚动人,让我感受到了大自然的神奇。

Linux性能优化特性Tuned和ktune

相关文章:

你感兴趣的文章:

标签云: