• shell生成1到100个不同的随机数


    测试SMR HDD的时候,有一个需求是这样的。
    取100个连续的zone IO在zone间随机,zone内部有序。并记录性能
    其实就是选100个连续的zone ,随机打乱跑顺序写。脚本也很简单分两个步骤:第一生成100个1到100的随机数。第二步利用这个100个随机数作为zone的行号跑IO

    第一步生成1到100个不重复的随机数

    while true;do
    random_num=`echo $(( $RANDOM % 100 + 1))` 
    if [ -f "random_num.txt" ]
    then
    	  num_100=`cat random_num.txt|wc -l`
    	if [ $num_100 == 100 ]
    	then
    	      break 
    	else
             if [[ -z "$(cat random_num.txt|grep ^${random_num}$)" ]]
    	       then
                		echo $random_num >>random_num.txt
         	   fi  
    	fi 	
    else
    
    	echo $random_num >>random_num.txt
    fi
    done
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    第二步其实就是利用zbd工具取100个sma的zone跑IO了

    zbd report -i /dev/$1 |grep -i swr |sed -n  '6001,6100p'>${hdd}_smr_100.txt
    for num in `cat random_num.txt`;do
    ofst=`cat ${hdd}_smr_100.txt  |sed -n ${num}p |awk '{print $5}'|sed 's/,//g'`
    fio -filename=/dev/$hdd -direct=1 -zonemode=zbd --offset=$ofst -iodepth=8 -thread -rw=write --max_open_zones=128 -ioengine=libaio -bs=64k -numjobs=1 --size=1z -group_reporting -name=job_name --loops=1 >smr_${hdd}_${ofst}_write.txt
    done
    
    • 1
    • 2
    • 3
    • 4
    • 5

    完整脚本如下:

    while true;do
    random_num=`echo $(( $RANDOM % 100 + 1))` 
    if [ -f "random_num.txt" ]
    then
    	  num_100=`cat random_num.txt|wc -l`
    	if [ $num_100 == 100 ]
    	then
    	      break 
    	else
             if [[ -z "$(cat random_num.txt|grep ^${random_num}$)" ]]
    	       then
                		echo $random_num >>random_num.txt
         	   fi  
    	fi 	
    else
    
    	echo $random_num >>random_num.txt
    fi
    done
    zbd report -i /dev/$1 |grep -i swr |sed -n  '6001,6100p'>${hdd}_smr_100.txt
    for num in `cat random_num.txt`;do
    ofst=`cat ${hdd}_smr_100.txt  |sed -n ${num}p |awk '{print $5}'|sed 's/,//g'`
    fio -filename=/dev/$hdd -direct=1 -zonemode=zbd --offset=$ofst -iodepth=8 -thread -rw=write --max_open_zones=128 -ioengine=libaio -bs=64k -numjobs=1 --size=1z -group_reporting -name=job_name --loops=1 >smr_${hdd}_${ofst}_write.txt
    done
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    关于zbd的工具介绍 详情查看
    https://zonedstorage.io/docs/tools/libzbd

  • 相关阅读:
    论文阅读_对比学习_SimCLR
    k8s容器定时伸缩(CronHPA)
    win10添加回环网卡步骤
    静态工厂模式-反射工厂模式-注解工厂模式代码实现
    大厂频繁联手,NFT 与 GameFi 的融合能带来哪些新叙事?
    Web3.0世界知识体系分享-什么是Web3.0
    express学习33-多人管理25node.js—安装bcrypt出现错误的解决办法
    OceanBase 数据库入门知识
    面试官:Spring中都应用了哪些设计模式?
    VS code “import type“ 声明只能在 TypeScript 文件中使用
  • 原文地址:https://blog.csdn.net/weixin_43841091/article/details/132830949