磁盘管理

raid

#!/bin/bash
# describe: use all free disk to create raid10
# 创建一个未使用磁盘的数组
ls_disk(){
    for disk in $(lsblk|awk '/disk/{print $1}');do
        mount|grep -q ${disk} &>/dev/null
        resout1=$?
        pvscan |grep -q ${disk} &>/dev/null
        resout2=$?
        if [ $resout1 -eq 1 ] &&  [ $resout2 -eq 1 ];then
            noUseDisk=(${noUseDisk[@]} /dev/$disk)
        fi
    done

    if [ ${#noUseDisk[@]} -lt 6 ];then
        echo "$(date "+%F %H:%M:%S")W! disk number enough!,current disk member is 【${noUseDisk[@]:-"null"}】"
        exit 23
    fi
}


# 做raid10
md_raid10() {
    echo "start create raid"
    mdadm -C /dev/md0 -R -a yes -l 10 -n 6 ${noUseDisk[@]}
    if [ $? -ne 0 ];then
        echo "$(date "+%F %H:%M:%S")E! command exec error 【mdadm -C /dev/md0 -R -a yes -l 10 -n 6 ${noUseDisk[@]}】! "
        exit 22
    fi
}

# main
ls_disk
md_raid10
lsblk|awk '/raid10/{print $1}'|grep -q md0 &>/dev/null
if [ $? -eq 0 ];then
    mdadm --detail --scan >>/dev/mdadm.conf
    echo "$(date "+%F %H:%M:%S")I!  mutil device 【${noUseDisk[@]}】raid10 to /dev/md0 successful !"
fi

io 测试

使用 Flexible I/O Tester (fio) 工具检查是否满足 Ansible Automation Platform PostgreSQL 数据库的最低要求。Fio 是一种用于对存储系统的写入/读取 IOPS 性能进行基准测试的工具。 https://prog.world/is-storage-speed-suitable-for-etcd-ask-fio/

先决条件

  • 您已安装 Flexible I/O Tester () 存储性能基准测试工具。fio

    要安装 ,请以 root 用户身份运行以下命令:fio

    # yum -y install fio
    
  • 您有足够的磁盘空间来存储测试数据日志文件。fio

    过程中显示的示例需要目录中至少 60GB 的磁盘空间:/tmp

    • numjobs设置命令运行的作业数。
    • size=10G设置每个作业生成的文件大小。
  • 您已调整参数的值。调整此值可减少测试数据量。size

程序

  1. 运行随机写入测试:

    $ fio --name=write_iops --directory=/tmp --numjobs=3 --size=10G \
    --time_based --runtime=60s --ramp_time=2s --ioengine=libaio --direct=1 \
    --verify=0 --bs=4K --iodepth=64 --rw=randwrite \
    --group_reporting=1 > /tmp/fio_benchmark_write_iops.log \
    2>> /tmp/fio_write_iops_error.log
    
  2. 运行随机读取测试:

    $ fio --name=read_iops --directory=/tmp \
    --numjobs=3 --size=10G --time_based --runtime=60s --ramp_time=2s \
    --ioengine=libaio --direct=1 --verify=0 --bs=4K --iodepth=64 --rw=randread \
    --group_reporting=1 > /tmp/fio_benchmark_read_iops.log \
    2>> /tmp/fio_read_iops_error.log
    
  3. 查看结果:

    在基准测试命令写入的日志文件中,搜索以 开头的行。此行显示测试的最小值、最大值和平均值。iops

    以下示例显示了随机读取测试的日志文件中的行:

    $ cat /tmp/fio_benchmark_read_iops.log
    read_iops: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64
    […]
       iops        : min=50879, max=61603, avg=56221.33, stdev=679.97, samples=360
    […]
    

    您必须根据自己的业务需求、应用程序工作负载和新需求查看、监视和重新访问日志文件。

posted @ 2024-04-25 12:29  mingtian是吧  阅读(5)  评论(0编辑  收藏  举报