一、stress工具安裝:
1、獲取stress源碼安裝包(stress-1.0.4.tar.gz)
3、解壓並安裝
[root@localhost /]#cd /tmp/ [root@localhost tmp]#tar –zxvf stress-1.0.4.tar.gz
4、進入stress-1.0.4文件夾下,編譯並安裝stress
[root@localhost tmp]#cd /tmp/stress-1.0.4/ [root@localhost stress-1.0.4]#./configure [root@localhost stress-1.0.4]# make [root@localhost stress-1.0.4]#make install
默認安裝在:/usr/local/bin/stress
二、stress工具使用:
命令:taskset –c 邏輯CPU索引號 stress --timeout 持續時間 --cpu 1
參數說明:
-c 服務器邏輯CPU的索引號
--timeout 對CPU施加壓力的持續時間
--cpu stress進程數,若值為2,每個stress進程所有消耗的邏輯CPU資源平分
如:對索引為0的邏輯cpu施加壓力, 持續30秒
taskset -c 0 stress --timeout 30 --cpu 1
通過top 1可以查看到索引為0的CPU的利用率