阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

在红帽Linux上部署Automatic System Tuning

109次阅读
没有评论

共计 5762 个字符,预计需要花费 15 分钟才能阅读完成。

随着开放式平台的推广应用,以 Linux 为代表的开放式操作系统平台越来越成为系统架构选择的优选。作为一款成熟的操作系统,系统监控调优是 Linux 平台必不可少的工具组件。历经多个版本的 Linux,已经发展出很成熟的操作系统优化配置策略。

本篇主要介绍红帽 Linux 环境中的 Automatic System Tuning 组件包。针对 Linux 系统不同的实际场景,采用不同的应用配置文件 Profile 策略。

1、环境介绍

笔者操作系统环境为 Red Hate 6.4。目前的 Linux 操作系统,已经可以支撑小到个人版本桌面服务器,大到大型系统集群环境的多种类型系统。例如:企业存储服务器、高网络吞吐量服务器等等。

[root@SICS-MIGPC-DB ~]# cat /etc/RedHat-release

Red Hat Enterprise Linux Server release 6.4 (Santiago)

2、Tuned 安装

首先可以利用 yum 安装 Automatic System Tuning 包的程序。Yum 可以自动帮助我们解决诸如包依赖、版本选择等诸多问题,是进行安装配置的有限选项。

对 Linux 的不同发行版本来说,yum 是有不同选项的。Red Hat Linux 要求的比较严格,只有注册了官方服务支持之后才能得到从网站下载最新 rpm 包的服务。对 CentOS 等开源版本来说,yum 工具限制比较少。笔者通常的做法,是建立本地的 yum 资源库,将 Linux 安装盘中的 rpm 包放在资源库中,根据需要进行安装。

[root@SICS-MIGPC-DB ~]# yum install tuned

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

localyum                                                | 2.9 kB    00:00 …

Setting up Install Process

Resolving Dependencies

–> Running transaction check

—> Package tuned.noarch 0:0.2.19-13.el6 will be installed

–> Finished Dependency Resolution

Dependencies Resolved

================================================================================

Package        Arch            Version                Repository        Size

================================================================================

Installing:

tuned          noarch          0.2.19-13.el6          localyum          94 k

Transaction Summary

================================================================================

Install      1 Package(s)

Total download size: 94 k

Installed size: 222 k

Is this ok [y/N]: yes

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : tuned-0.2.19-13.el6.noarch                                  1/1

Verifying  : tuned-0.2.19-13.el6.noarch                                  1/1

Installed:

tuned.noarch 0:0.2.19-13.el6

Complete!

安装之后,tuned 以系统服务的形式被配置入系统。

[root@SICS-MIGPC-DB ~]# chkconfig –list | grep tuned

tuned          0:off  1:off  2:off  3:off  4:off  5:off  6:off

[root@SICS-MIGPC-DB ~]# chkconfig tuned on

[root@SICS-MIGPC-DB ~]# chkconfig –list | grep tuned

tuned          0:off  1:off  2:on    3:on    4:on    5:on    6:off

3、tuned 配置使用

通过 service 命令,可以查看 tuned 服务的状态和启动关闭。

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

tuned is stopped

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

Starting tuned: [OK]

在 /etc/tune-profiles 目录中,我们可以找到各种预设的 Profile 文件。

[root@SICS-MIGPC-DB tune-profiles]# cd /etc/tune-profiles/

[root@SICS-MIGPC-DB tune-profiles]# ls -l

total 64

-rw-r–r– 1 root root    7 Jul 24  2013 active-profile

drwxr-xr-x 2 root root 4096 Apr  3 13:11 default

drwxr-xr-x 2 root root 4096 Apr  3 13:11 desktop-powersave

drwxr-xr-x 2 root root 4096 Apr  3 13:11 enterprise-storage

-rw-r–r– 1 root root 9779 Jul 24  2013 functions

drwxr-xr-x 2 root root 4096 Apr  3 13:11 laptop-ac-powersave

drwxr-xr-x 2 root root 4096 Apr  3 13:11 laptop-battery-powersave

drwxr-xr-x 2 root root 4096 Apr  3 13:11 latency-performance

drwxr-xr-x 2 root root 4096 Apr  3 13:11 sap

drwxr-xr-x 2 root root 4096 Apr  3 13:11 server-powersave

drwxr-xr-x 2 root root 4096 Apr  3 13:11 spindown-disk

drwxr-xr-x 2 root root 4096 Apr  3 13:11 throughput-performance

drwxr-xr-x 2 root root 4096 Apr  3 13:11 virtual-guest

drwxr-xr-x 2 root root 4096 Apr  3 13:11 virtual-host

其中包括诸如节能笔记本、SAP 系统、虚拟主机等内容,都是 Linux 提供的预定义模板。

下面可以依据现有的配置模板,修改成实际需要的版本。笔者准备配置出不使用 Linux Huge Page 特性的配置文件 Profile。

[root@SICS-MIGPC-DB tune-profiles]# ls -l | grep enter

drwxr-xr-x 2 root root 4096 Apr  3 13:11 enterprise-storage

drwxr-xr-x 2 root root 4096 Apr  3 13:37 enterprise-storage-no-thp

进入目录:

[root@SICS-MIGPC-DB tune-profiles]# cd enterprise-storage-no-thp/

[root@SICS-MIGPC-DB enterprise-storage-no-thp]# ls -l

total 16

-rwxr-xr-x 1 root root  314 Apr  3 13:37 ktune.sh

-rw-r–r– 1 root root 1239 Apr  3 13:37 ktune.sysconfig

-rw-r–r– 1 root root 1562 Apr  3 13:37 sysctl.ktune

-rw-r–r– 1 root root  191 Apr  3 13:37 tuned.conf

修改配置内容:

[root@SICS-MIGPC-DB enterprise-storage-no-thp]# sed -ie ‘s,set_transparent_hugepages always,set_transparent_hugepages never’, /etc/tune-profiles/enterprise-storage-no-thp/ktune.sh

[root@SICS-MIGPC-DB enterprise-storage-no-thp]# grep set_transparent_hugepages ktune.sh

set_transparent_hugepages never

激活设置好的 Profile,应用设定。

[root@SICS-MIGPC-DB enterprise-storage-no-thp]# tuned-adm profile enterprise-storage-no-thp

Stopping tuned: [OK]

Switching to profile ‘enterprise-storage-no-thp’

Applying deadline elevator: dm-0 dm-1 dm-2 sda [OK]

Applying ktune sysctl settings:

/etc/ktune.d/tunedadm.conf: [OK]

Calling ‘/etc/ktune.d/tunedadm.sh start’: [OK]

Applying sysctl settings from /etc/sysctl.conf

Starting tuned: [OK]

[root@SICS-MIGPC-DB enterprise-storage-no-thp]#

判断不使用 Huge Page 参数设置。

[root@SICS-MIGPC-DB enterprise-storage-no-thp]# cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

always [never]

如果需要恢复默认的设置,只需要将 tuned 服务关闭即可。

[root@SICS-MIGPC-DB etc]# service –status-all | grep tun

Current ktune sysctl settings:

tuned (pid  32429) is running…

从 ps –ef 命令中,可以看到使用的后台进程和参数情况。

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

root      322 32642  0 14:05 pts/0    00:00:00 grep tun

root    32429    1  0 13:46 ?        00:00:00 /usr/bin/python /usr/sbin/tuned -d -c /etc/tuned.conf

从 tuned 执行使用的参数文件 /etc/tuned.conf 上,可以看出该工具带有监控功能。

[root@SICS-MIGPC-DB etc]# cat tuned.conf

# disable tuned

[main]

[DiskMonitor]

enabled=False

[DiskTuning]

enabled=False

[NetMonitor]

enabled=False

[NetTuning]

enabled=False

[CPUMonitor]

enabled=False

[CPUTuning]

enabled=False

tuned-adm 工具用户配置和启用 Profile 文件和信息。

[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

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

Available profiles:

– laptop-battery-powersave

– virtual-guest

– enterprise-storage

– desktop-powersave

– default

– throughput-performance

– spindown-disk

– sap

– enterprise-storage-no-thp

– laptop-ac-powersave

– virtual-host

– server-powersave

– latency-performance

Current active profile: enterprise-storage-no-thp

4、结论

在当前环境中,从运行维护角度已经有很多现成的工具和手段。掌握适当的方法论和工具,在正确的场合应用正确的工具,是我们运维人员应当具备的一种能力。

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-04/115943.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计5762字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中