合 Linux下如何快速消耗CPU、内存、IO、磁盘等(压测)
Tags: LinuxOS总结压测stresssysbenchfallocate
CPU
可以参考:https://www.dbaup.com/dbbao66linuxxiaruherangnidecpubaochizai90yishang.html#xiang_guan_wen_zhang
1 2 3 4 5 6 7 8 9 | -- cpu for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do cat /dev/urandom | md5sum & done for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do dd if=/dev/zero of=/dev/null & done sysbench --threads=100 --events=80000 cpu --cpu-max-prime=8000000 run stress --cpu 8 --timeout 600 |
内存
1 2 3 4 5 6 | -- 内存(消耗90%内存) stress --vm-bytes $(awk '/MemFree/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 1 -- 慎用(这将启动10个并发的stress进程,从而消耗更多的内存) for i in {1..10}; do stress --vm-bytes $(awk '/MemFree/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 1 & done |
磁盘IO
1 2 3 4 5 6 7 | fio -filename=/tmp/read_write.dat -direct=1 -iodepth=1 -rw=randrw -rwmixread=70 \ -ioengine=psync -bs=32k -size=6G -numjobs=12 -runtime=180 -group_reporting -name=randrw_70read_32k dd if=/dev/zero of=/tmp/a.dat bs=8k count=1M oflag=direct stress-ng -i 4 --hdd 1 --timeout 600 |