九月份偷了下懒,补上一篇
注释:shell脚本,需要fio工具,实时监控磁盘的读写性能
#!/bin/bash DATE=$(date +%m-%d) IOSTATLOG=/var/log/iostat${DATE}.log FIOLOG=/var/log/fio${DATE}.log /bin/ps -ef |grep "iostat -dk 5" | grep -v grep > /dev/null if [ $? == 0 ] then echo "Disk monitor already running" exit 1 else /usr/bin/iostat -dk 5 >>$IOSTATLOG & pid=$! fi while true do echo "-------------`date`--------">>$FIOLOG echo "--------------fio test---------------------">>$FIOLOG ######随机读: echo "-------------随机读s----------------">>$FIOLOG fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=4k -size=4096M -numjobs=10 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=128k -size=4096M -numjobs=10 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=1M -size=4096M -numjobs=10 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 #####顺序读: echo "-------------顺序读----------------">>$FIOLOG fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=4k -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=128k -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=1M -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 #####随机写: echo "-------------随机写----------------">>$FIOLOG fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=4k -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=128k -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=1M -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 #####顺序写: echo "-------------顺序写----------------">>$FIOLOG fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=4k -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=128k -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=1M -size=4096M -numjobs=30 -runtime=1000 -group_reporting -name=mytest >>$FIOLOG 2>&1 #####混合随机读写: echo "-------------混合随机读写----------------">>$FIOLOG #######4k fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=4k -size=4096M -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop >>$FIOLOG 2>&1 #######128k fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=128k -size=4096M -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop >>$FIOLOG 2>&1 #######1M fio -filename=/dev/sda1 -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=1M -size=4096M -numjobs=30 -runtime=100 -group_reporting -name=mytest -ioscheduler=noop >>$FIOLOG 2>&1 sleep 60 done
本文出自 “DanielQu” 博客,请务必保留此出处http://qujunorz.blog.51cto.com/6378776/1859968
原文地址:http://qujunorz.blog.51cto.com/6378776/1859968