2016년 11월 7일 월요일

리눅스 ( Tuned 데몬을 이용한 OS 튜닝) 튜닝

tuned 패키지 대해 알아보겠습니다. 

  • Tuned 시스템 모듈로서 시스템 사용에 대한 데이터를 모니터링 하고, 수집하여 데이터를 기반으로 동적으로 시스템 설정을 조절하기 위한 데몬입니다보통 CPU 전력 소비 비활성화를 Disable 하거나, CPU/네트웍/디스크 등의 설정을 조정하기 위해 사용하며, Profile 패키지로 묶여있어, 리눅스 튜닝에 대해 잘모르는 분들이 쉽게 튜닝하도록 만들어진 모듈이라고 볼수 있습니다.

  • 설치
[root@blade01 ~]# rpm -qa |grep tuned
tuned-0.2.19-6.el6.noarch
tuned-utils-0.2.19-6.el6.noarch

Rpm 으로 설치하거나 Yum 통해 설치를 하면 됩니다
$> yum install tuned

  • Tuned-adm Profile 종류
    • 위에 설명과 같이 tuned-adm 통해 몇가지 패키지화된 Profile 제공하고 있으며 프로파일을 통해 가볍게 적용할 있습니다.

  • Tuned-adm list 확인 방법
[root@blade01 ~]# tuned-adm list
Available profiles:
- desktop-powersave
- latency-performance
- laptop-battery-powersave
- server-powersave
- spindown-disk
- default
- laptop-ac-powersave
- throughput-performance
- enterprise-storage
Current active profile: latency-performance

  • Tuned-adm 설명
    • 중요하게 사용되는 몇가지 알아 봅니다. 만약 DBMS 경우 Latency-performance 것을 권장합니다.
Default
기본적인 절전 프로파일. 디스크 CPU 플러그인만 활성화함.
latency-performance
지연성능 튜닝용. 절전 매커니즘을 비활성화하고, CPU Polling C0 활성화함
CPU 절전에 들어가지 않는다고 보면됨. I/O 스케줄러는 모두 Deadline 으로 변경되고,
전원관리의 cpu_dma_latency 0으로 등록됨
( 여기서 cpu C-0 활성화하는 옵션이 cpu_dma_latency 입니다. )
이값이 200이상으로 설정하면 C-6
20~199 경우 C-3
1~19 경우 C-1
0 경우 C-0 활성화 됩니다.
throughput-performance
처리량 성능튜닝용 . 절전 매커니즘을 비활성화시스템에 엔터프라이즈급 스토리지가 없는 경우 권장
Latency-performance 동일하나 아래와 같은 차이점이 있다.
kernel.sched_min_granularity_ns = 4000000  -> 10000
kernel.sched_wakeup_granularity_ns = 4000000 -> 15000
vm.dirty_ratio = 20 -> 40 
THP 활성화
enterprise-storage
엔터프라이즈급 스토리지가 있는 경우( 백업 컨트롤러 캐쉬, 디스크 내장 캐시가 있는) 서버에 권장
Throughput-performance 동일하지만 파일 시스템이 barrier=0 으로 Mount .  

여기서 파일시스템 mount 옵션을 barrier 바꾸는 것은 간단히 설명하면 파일시스템의 무결성과
일관성을 위한 옵션으로 볼수 있다.  Ext4, XFS 파일 시스템은 기본적으로 활성화 되어 있고,
데이터가 저장장치에 기록이 되면 디스크캐시에 존재하는 데이터를 물리적 저장장치에 기록을 보장하는 것이다만약 배터리가 있는  RAID 컨트롤러 캐시를 사용한다면 시스템 전력이 나가더라도, RAID 컨트롤러에서  fsync() 해주므로, 불필요한 Fsync() 작업을 barrier=0 통해 Disable 있다.


  • Tuned 데몬 start
    • [root@blade01 ~]# service tuned start

  • Tuned Latency 모드로 활성화 방법
    • [root@blade01 ~]# tuned-adm profile latency-performance


  • CPU 활성화 모니터링 (powertop 통해 모니터링 가능)
    • [root@blade01 ~]#powertop

  • Tuned-adm Profile 쓰지 않고 CPU 전력 활성화와 CPU C-State 올리는 방법
    • Cpu_dma_latency 값만 조절하면 된다.
    • 다만 Tuned 에서 사용하는 파이썬 파일을 활용하는 것이 편리하므로 , Tuned Yum 으로 설치하고 아래와 같이 cpu_dma_latency 값만 수정한다.
      • Cpu_dma_latency 값에 따른 CPU C-State 활성화
# /usr/libexec/tuned/pmqos-static.py cpu_dma_latency=0
pk cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
100.00 2.93 2.67 0.00 0.00 0.00 0.00 0.00

/usr/libexec/tuned/pmqos-static.py cpu_dma_latency=200
pk cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
0.04 2.19 2.67 0.04 0.26 99.66 0.91 91.91
Set it to anything in between 20 and 199, and you get into C3:

# /usr/libexec/tuned/pmqos-static.py cpu_dma_latency=199
pk cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
0.03 2.28 2.67 0.03 99.94 0.00 89.65 0.00
Set it to anything in between 1 and 19, and you get into C1:

# /usr/libexec/tuned/pmqos-static.py cpu_dma_latency=19
pk cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
0.02 2.18 2.67 99.98 0.00 0.00 0.00 0.00
Set it to 0 and you get into C0. This is what latency-performance
profile does.

# /usr/libexec/tuned/pmqos-static.py cpu_dma_latency=0
pk cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
100.00 2.93 2.67 0.00 0.00 0.00 0.00 0.00


댓글 없음:

댓글 쓰기