PostgreSQL DBA(90) - Linux(stress-ng簡介)

husthxd 發表於2019-09-11

本節簡單介紹了可用於Linux平臺下的壓力測試工具stress-ng.

安裝很簡單,在CentOS下,通過yum -y install stress-ng即可安裝此工具.
安裝成功後,執行man stress-ng可檢視該工具的幫助資訊.

NAME
       stress-ng - a tool to load and stress a computer system
       stress-ng是計算機系統進行壓力測試的工具.
SYNOPSIS
       stress-ng [OPTION [ARG]] ...
       使用方法:stress-ng [OPTION [ARG]] ...
DESCRIPTION
       stress-ng  will  stress  test a computer system in various selectable ways. It was
       designed to exercise various physical subsystems of a computer as well as the var‐
       ious  operating  system kernel interfaces.  stress-ng also has a wide range of CPU
       specific stress tests that exercise floating point, integer, bit manipulation  and
       control flow.
       stress-ng  was  originally  intended to make a machine work hard and trip hardware
       issues such as thermal overruns as well as operating system bugs that  only  occur
       when  a  system  is being thrashed hard. Use stress-ng with caution as some of the
       tests can make a system run hot on poorly designed hardware  and  also  can  cause
       excessive system thrashing which may be difficult to stop.
       stress-ng  can  also  measure test throughput rates; this can be useful to observe
       performance changes across different operating system releases or types  of  hard‐
       ware.  However,  it has never been intended to be used as a precise benchmark test
       suite, so do NOT use it in this manner.
       Running stress-ng with root privileges will adjust out of memory settings on Linux
       systems  to  make  the  stressors unkillable in low memory situations, so use this
       judiciously.  With the appropriate privilege, stress-ng can allow the ionice class
       and ionice levels to be adjusted, again, this should be used with care.
       One  can specify the number of processes to invoke per type of stress test; speci‐
       fying a negative or zero value will select the number of processors  available  as
       defined by sysconf(_SC_NPROCESSORS_CONF).
       stress-ng提供了N中途徑對系統進行測試.該工具可執行計算機的各種物理子系統(如CPU/記憶體/網路等)
       以及各種OS核心介面.stress-ng有大量的CPU壓力測試方法,包括測試浮點數/整數/位運算和控制流程等.
       stress-ng的最初目的是給機器加壓,通過使系統過載來發現OS的bug.要注意的是,stress-ng在設計不良
       的系統中執行可能會系統當機.
OPTIONS
       General stress-ng control options:
       ...
       詳細可參考stress-ng手冊.
EXAMPLES
       使用樣例
       stress-ng --vm 8 --vm-bytes 80% -t 1h
              run  8 virtual memory stressors that combined use 80% of the available mem‐
              ory for 1 hour. Thus each stressor uses 10% of the available memory.
              執行8個虛擬的記憶體壓測器,合計使用80%的可用記憶體,持續時間1小時,每個壓測器約10%的可用記憶體.
       stress-ng --cpu 4 --io 2 --vm 1 --vm-bytes 1G --timeout 60s
              runs for 60 seconds with 4 cpu stressors, 2 io stressors and 1 vm  stressor
              using 1GB of virtual memory.
       stress-ng --iomix 2 --iomix-bytes 10% -t 10m
              runs  2  instances  of  the mixed I/O stressors using a total of 10% of the
              available file system space for 10 minutes. Each stressor will  use  5%  of
              the available file system space.
       stress-ng --cpu 8 --cpu-ops 800000
              runs 8 cpu stressors and stops after 800000 bogo operations.
       stress-ng --sequential 2 --timeout 2m --metrics
              run  2 simultaneous instances of all the stressors sequentially one by one,
              each for 2 minutes and summarise with performance metrics at the end.
       stress-ng --cpu 4 --cpu-method fft --cpu-ops 10000 --metrics-brief
              run 4 FFT cpu stressors, stop after 10000 bogo  operations  and  produce  a
              summary just for the FFT results.
       stress-ng --cpu 0 --cpu-method all -t 1h
              run  cpu stressors on all online CPUs working through all the available CPU
              stressors for 1 hour.
       stress-ng --all 4 --timeout 5m
              run 4 instances of all the stressors for 5 minutes.
       stress-ng --random 64
              run 64 stressors that are randomly chosen from all the available stressors.
       stress-ng --cpu 64 --cpu-method all --verify -t 10m --metrics-brief
              run 64 instances of all the different cpu stressors  and  verify  that  the
              computations  are  correct for 10 minutes with a bogo operations summary at
              the end.
       stress-ng --sequential 0 -t 10m
              run all the stressors one by  one  for  10  minutes,  with  the  number  of
              instances of each stressor matching the number of online CPUs.
       stress-ng --sequential 8 --class io -t 5m --times
              run all the stressors in the io class one by one for 5 minutes each, with 8
              instances of each stressor running concurrently and show overall time util‐
              isation statistics at the end of the run.
       stress-ng --all 0 --maximize --aggressive
              run all the stressors (1 instance of each per CPU) simultaneously, maximize
              the settings (memory sizes, file allocations, etc.)  and  select  the  most
              demanding/aggressive options.
       stress-ng --random 32 -x numa,hdd,key
              run 32 randomly selected stressors and exclude the numa, hdd and key stres‐
              sors
       stress-ng --sequential 4 --class vm --exclude bigheap,brk,stack
              run 4 instances of the VM stressors one after  each  other,  excluding  the
              bigheap, brk and stack stressors
       stress-ng --taskset 0,2-3 --cpu 3
              run 3 instances of the CPU stressor and pin them to CPUs 0, 2 and 3.

參考資料
stress-ng
Stress Test CPU and Memory (VM) On a Linux / Unix With Stress-ng

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/6906/viewspace-2656712/,如需轉載,請註明出處,否則將追究法律責任。


相關文章

PostgreSQL

PostgreSQL DBA(96) - System Conf(client_min_messages)

PostgreSQL提供了引數client_min_messages用以控制返回給客戶的訊息級別,不同的級別返回的訊息大小不同,預設為NOTICE。在通常情況下,如果客戶端執行的SQL語句不頻繁的話,
PostgreSQL

PostgreSQL DBA(97) - System Conf(huge_pages)

PostgreSQL提供了引數huge_pages用以使用OS的huge pages,預設為try,即可用就用,用不了就不用。使用HUGE PAGE其中一個原因是因為HUGE PAGE是常駐記憶體的,
PostgreSQL

PostgreSQL DBA(98) - PG 12 Faster float conversion to text

PostgreSQL 12之前的版本浮點數是通過四捨五入到特定的數字來輸出的,由引數extra_float_digits控制。這種方法對於查詢有實數列或雙精度列的大表時的輸出速度較慢。在PG12中,十
Linux|PostgreSQL

PostgreSQL DBA(100) - Linux(Huge Pages)

PostgreSQL通過引數huge_pages設定是否啟用大頁,利用常駐記憶體用以提升效能,本節簡單介紹了Linux中Huge Pages的相關設定。Check if CPU supports Hu
Linux

Linux 中國徽標徵集活動進展彙報

自從 10 天前,我們發起了徽標徵集活動,得到了大家的踴躍支援。雖然有相當多朋友表示原來的徽標就挺好,是的修改下就可以,但是也有很多朋友給我們提交了新的徽標設計及其設計理念。以下,我將這些設計展示給大
Linux

主流發行版之前的那些最早的 Linux 發行版

在這篇回溯歷史的文章中,我們嘗試回顧一些最早的 Linux 發行版是如何演變的,並形成我們今天所知道的發行版的。在這裡,我們嘗試探討了第一個 Linux 核心問世後,諸如 Red Hat、Debian
Linux

用 Linux 命令顯示硬體資訊

通過命令列獲取計算機硬體詳細資訊。你可能會有很多的原因需要查清計算機硬體的詳細資訊。例如,你需要修復某些問題並在論壇上發出請求,人們可能會立即詢問你的計算機具體的資訊。或者當你想要升級計算機配置時,你
Linux

在 21 世紀該怎樣編譯 Linux 核心

也許你並不需要編譯 Linux 核心,但你能通過這篇教程快速上手。在計算機世界裡,核心kernel是處理硬體與一般系統之間通訊的低階軟體low-level software。除過一些燒錄進計算機主機板
Linux

在 Linux 上記錄和重放終端會話活動

通常,Linux 管理員們都使用 history 命令來跟蹤在先前的會話中執行過哪些命令,但是 history 命令的侷限性在於它不儲存命令的輸出。在某些情況下,我們要檢查上一個會話的命令輸出,並希望
Linux

現在你可以藉助 Insync 在 Linux 中原生使用 OneDrive

OneDrive 是微軟的一項雲端儲存服務,它為每個使用者提供 5GB 的免費儲存空間。它已與微軟帳戶整合,如果你使用 Windows,那麼已在其中預安裝了 OneDrive。OneDrive 無法在
PostgreSQL

PostgreSQL DBA(102) - pgAdmin(Row Level Security)

PostgreSQL提供了Row Level Security(RLS)來控制哪些行可以訪問或修改。一、簡介其標準的語法是:[[email protected] ~]$ psql -d testdbTimi
Linux

如何通過 SSH 在遠端 Linux 系統上執行命令

我們有時可能需要在遠端機器上執行一些命令。如果只是偶爾進行的操作,要實現這個目的,可以登入到遠端系統上直接執行命令。但是每次都這麼做的話,就有點煩人了。既然如此,有沒有擺脫這種麻煩操作的更佳方案?是的