2016-01-12 15:00:22 +03:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# This script does the following:
|
|
|
|
|
# 1. Prepares the RAID with all the data disks attached
|
|
|
|
|
# 2. Places an entry for the created RAID in /etc/fstab.
|
|
|
|
|
# 3. Keep the sysbench test script in the startup for IO performance test.
|
|
|
|
|
#
|
|
|
|
|
# Author: Srikanth M
|
|
|
|
|
# Email : v-srm@microsoft.com
|
|
|
|
|
#
|
|
|
|
|
#####
|
2016-02-26 23:19:20 +03:00
|
|
|
|
if [[ $# == 2 ]]
|
|
|
|
|
then
|
|
|
|
|
username=$1
|
|
|
|
|
test_type=$2
|
|
|
|
|
else
|
|
|
|
|
echo "Usage: bash $0 <vm_loginuser> <LVM / RAID>"
|
|
|
|
|
exit -1
|
|
|
|
|
fi
|
2016-02-10 21:45:38 +03:00
|
|
|
|
|
2016-01-12 15:00:22 +03:00
|
|
|
|
mountdir="/dataIOtest"
|
|
|
|
|
code_path="/home/$username/code"
|
2016-02-26 23:19:20 +03:00
|
|
|
|
code_path="/home/$username/code/"
|
|
|
|
|
. $code_path/azuremodules.sh
|
|
|
|
|
|
2016-01-12 15:00:22 +03:00
|
|
|
|
LOGFILE="${code_path}/iotest.log.txt"
|
2016-02-10 21:45:38 +03:00
|
|
|
|
[ -d $mountdir ] && umount $mountdir && rm -rf $mountdir
|
|
|
|
|
mkdir $mountdir
|
|
|
|
|
echo "IO test setup started.." > $LOGFILE
|
2016-01-12 15:00:22 +03:00
|
|
|
|
list=(`fdisk -l | grep 'Disk.*/dev/sd[a-z]' |awk '{print $2}' | sed s/://| sort| grep -v "/dev/sd[ab]$" `)
|
|
|
|
|
|
|
|
|
|
lsblk >> $LOGFILE
|
|
|
|
|
|
2016-02-10 21:45:38 +03:00
|
|
|
|
if [ "$test_type" == "LVM" ]; then
|
2016-02-26 23:19:20 +03:00
|
|
|
|
|
|
|
|
|
install_package lvm2
|
|
|
|
|
|
2016-02-10 21:45:38 +03:00
|
|
|
|
deviceName="/dev/vg1/lv1"
|
|
|
|
|
echo "--- LVM $deviceName creation started ---" >> $LOGFILE
|
2016-01-12 15:00:22 +03:00
|
|
|
|
|
2016-02-10 21:45:38 +03:00
|
|
|
|
yes | pvcreate ${list[@]} >> $LOGFILE
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "pvcreate: Failed" >> $LOGFILE
|
|
|
|
|
exit 80
|
|
|
|
|
fi
|
|
|
|
|
echo "pvcreate: Success" >> $LOGFILE
|
|
|
|
|
|
|
|
|
|
vgcreate vg1 ${list[@]} >> $LOGFILE
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "vgcreate : Failed" >> $LOGFILE
|
|
|
|
|
exit 80
|
|
|
|
|
fi
|
|
|
|
|
echo "vgcreate : Success" >> $LOGFILE
|
|
|
|
|
|
|
|
|
|
lvcreate -l 100%FREE -i 32 -I 64 vg1 -n lv1
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "lvcreate: Failed" >> $LOGFILE
|
|
|
|
|
exit 80
|
|
|
|
|
fi
|
|
|
|
|
echo "lvcreate : Success" >> $LOGFILE
|
|
|
|
|
|
|
|
|
|
time mkfs.ext4 $deviceName >> $LOGFILE
|
|
|
|
|
|
|
|
|
|
mount -o barrier=0 $deviceName $mountdir
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "$deviceName LVM mount: Failed" >> $LOGFILE
|
|
|
|
|
exit 80
|
|
|
|
|
fi
|
|
|
|
|
echo "$deviceName LVM mount: Success on $mountdir" >> $LOGFILE
|
|
|
|
|
uuid=`blkid $deviceName| sed "s/.*UUID=\"//"| sed "s/\".*\"//"`
|
|
|
|
|
echo $uuid
|
|
|
|
|
echo "UUID=$uuid $mountdir ext4 defaults,barrier=0 0 2" >> /etc/fstab
|
|
|
|
|
|
|
|
|
|
elif [ "$test_type" == "RAID" ]; then
|
2016-02-26 23:19:20 +03:00
|
|
|
|
install_package mdadm
|
2016-02-10 21:45:38 +03:00
|
|
|
|
count=0
|
|
|
|
|
while [ "x${list[count]}" != "x" ]
|
|
|
|
|
do
|
|
|
|
|
echo ${list[$count]} >> $LOGFILE
|
|
|
|
|
(echo n; echo p; echo 2; echo; echo; echo t; echo fd; echo w;) | fdisk ${list[$count]} >> $LOGFILE
|
|
|
|
|
count=$(( $count + 1 ))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
deviceName="/dev/md1"
|
|
|
|
|
echo "--- Raid $deviceName creation started ---" >> $LOGFILE
|
|
|
|
|
(echo y)| mdadm --create $deviceName --level 0 --raid-devices ${#list[@]} ${list[@]} >> $LOGFILE
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "$deviceName Raid creation: Failed" >> $LOGFILE
|
|
|
|
|
exit 80
|
|
|
|
|
fi
|
|
|
|
|
echo "$deviceName Raid creation: Success" >> $LOGFILE
|
|
|
|
|
|
|
|
|
|
time mkfs.ext4 $deviceName >> $LOGFILE
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "$deviceName Raid format: Failed" >> $LOGFILE
|
|
|
|
|
exit 80
|
|
|
|
|
fi
|
|
|
|
|
echo "$deviceName Raid format: Success" >> $LOGFILE
|
|
|
|
|
|
|
|
|
|
mount -o nobarrier $deviceName $mountdir
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "$deviceName Raid mount: Failed" >> $LOGFILE
|
|
|
|
|
exit 80
|
|
|
|
|
fi
|
|
|
|
|
echo "$deviceName Raid mount: Success on $mountdir" >> $LOGFILE
|
|
|
|
|
uuid=`blkid $deviceName| sed "s/.*UUID=\"//"| sed "s/\".*\"//"`
|
|
|
|
|
echo $uuid
|
|
|
|
|
echo "UUID=$uuid $mountdir ext4 defaults,barrier=0 0 2" >> /etc/fstab
|
|
|
|
|
else
|
|
|
|
|
echo "Unknown DiskType $test_type: Aborted" >> $LOGFILE
|
2016-01-12 15:00:22 +03:00
|
|
|
|
fi
|
2016-02-10 21:45:38 +03:00
|
|
|
|
|
2016-01-12 15:00:22 +03:00
|
|
|
|
df -hT >> $LOGFILE
|
|
|
|
|
cp $code_path/sysbench-full-io-test.sh $mountdir
|
|
|
|
|
bash $code_path/keep_cmds_in_startup.sh "cd $mountdir ; bash $mountdir/sysbench-full-io-test.sh $username &"
|