動態優化Linux系統的tuned/tuned-adm工具使用簡介

RHEL/CentOS 在 6.3 版本之後引入了一套新的系統調優工具 tuned/tuned-adm,其中 tuned   是服務端程序,用來監控和收集系統各個組件的數據,並依據數據提供的信息動態調整系統設置,達到動態優化系統的目的;tuned-adm 是客戶端程序,用來和  tuned 打交道,用命令行的方式管理和配置 tuned,tuned-adm   提供了一些預先配置的優化方案可供直接使用,好比:筆記本、虛擬機、存儲服務器等。服務器

  若是你正在使用筆記本(電池電源),想優化系統、節約電源又不想知道太多這方面的細節,就能夠用 tuned/tuned-adm 這套工具並應用  laptop-battery-powersave 方案來調整和優化系統。固然不一樣的系統和應用場景有不一樣的優化方案,tuned-adm   預先配置的優化策略不是總能知足要求,這時候就須要定製,tuned-adm 容許用戶本身建立和定製新的調優方案。ide

  安裝和啓動 tuned:工具

  代碼以下:優化

  # yum update命令行

  # yum install tunedorm

  # service tuned startserver

  # chkconfig tuned on虛擬機

  # service ktune startit

  # chkconfig ktune onio

  查看當前優化方案:

  代碼以下:

  # tuned-adm active

  Current active profile: default

  Service tuned: enabled, running

  Service ktune: enabled, running

  查看預先配置好的優化方案:

  代碼以下:

  # tuned-adm list

  Available profiles:

  - laptop-battery-powersave

  - virtual-guest

  - desktop-powersave

  - sap

  - server-powersave

  - virtual-host

  - throughput-performance

  - enterprise-storage

  - laptop-ac-powersave

  - latency-performance

  - spindown-disk

  - default

  Current active profile: default

  若是服務器是虛擬機母機的話,能夠選用 virtual-host 方案優化。若是報錯 「kernel.sched_migration_cost」 is  an unknown key 能夠經過編輯 sysctl.ktune 這個文件解決。

  代碼以下:

  # tuned-adm profile virtual-host

  Reverting to saved sysctl settings: [ OK ]

  Calling '/etc/ktune.d/tunedadm.sh stop': [ OK ]

  Reverting to cfq elevator: sda sdb sdc sdd sde sdf sdg [ OK ]

  Stopping tuned: [ OK ]

  Switching to profile 'virtual-host'

  Applying deadline elevator: sda sdb sdc sdd sde sdf sdg [ OK ]

  Applying ktune sysctl settings:

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

  error: "kernel.sched_migration_cost" is an unknown key

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

  Applying sysctl settings from /etc/sysctl.conf

  Starting tuned: [ OK ]

  # vi /etc/tune-profiles/virtual-host/sysctl.ktune

  ...

  #kernel.sched_migration_cost = 5000000

  ...

  # tuned-adm profile virtual-host

  若是是企業存儲服務器的話,能夠用 enterprise-storage 方案:

  代碼以下:

  # tuned-adm profile enterprise-storage

  Stopping tuned: [ OK ]

  Switching to profile 'enterprise-storage'

  Applying deadline elevator: dm-0 sda sdb sdc sdd [ 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 ]

  上面預約的方案不是總能知足要求,若是有本身的需求能夠定製本身的方案。本身定製很容易,切換到優化方案的配置目錄,拷貝一個例子,而後編輯裏面的相關參數就能夠了,使用  tuned-adm list 命令會看到剛建立的新方案 my-virtual-host:

  代碼以下:

  # cd /etc/tune-profiles/

  # cp -r virtual-host my-virtual-host

  # vi my-virtual-host/*

  # tuned-adm list

  Available profiles:

  - laptop-battery-powersave

  - virtual-guest

  - desktop-powersave

  - sap

  - server-powersave

  - virtual-host

  - throughput-performance

  - enterprise-storage

  - laptop-ac-powersave

  - latency-performance

  - spindown-disk

  - default

  - my-virtual-host

  Current active profile: virtual-host

相關文章
相關標籤/搜索