-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzfs_mirrors_performance.sh
executable file
·68 lines (54 loc) · 2.43 KB
/
zfs_mirrors_performance.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# ZFS pool performance testing. Performs several iterations of write and read using ramdisk.
# -------------------------------------------------------------------------------------------------
# Running this file may cause a potential data loss and assumes you accept that you know what
# you're doing. All actions with this script at your own risk.
# -------------------------------------------------------------------------------------------------
# This Source Code Form is subject to the terms of the BSD 3-Clause License. You can obtain one at:
# https://github.com/alexanderbazhenoff/scripts-pipelines-and-tiny-tools/blob/master/LICENSE
FILENAME="vm_image.qcow2"
RAMDISK_PATH="/mnt/ramdisk"
SOURCEFILE_PATH="/var/lib/libvirt/images"
RAMDISK_SIZE=62 # in gigabytes
ZFS_POOL_NAME="ssd"
POOL_PATH="/mnt/$ZFS_POOL_NAME"
BLOCK_DEVICES="/dev/sdc /dev/sde /dev/sdg /dev/sdi"
ZFS_POOL_TOPOLOGY="mirror sdc sde mirror sdg sdi"
ZFS_ATIME_OPTION="off" # off or on
ZFS_DEDUP_OPTION="off" # off or on
ZFS_COMPRESSION_OPTION="off" # on | off | lzjb | gzip | gzip-[1-9] | zle | lz4
NUMBER_OF_ITERATIONS=3 # total number of write/read iterations
# perform write-read with rsync
test_wr() {
# clean files from pool
for ((i=1; i <= NUMBER_OF_ITERATIONS; i++))
do
rm -f "${POOL_PATH}/${FILENAME}-${i}"
done
# write performance testing
rm -fv "${RAMDISK_PATH}/*"
cp "${SOURCEFILE_PATH}/$FILENAME" "${RAMDISK_PATH}/$FILENAME"
echo "write 3 copies:"
for ((i=1; i <= NUMBER_OF_ITERATIONS; i++))
do
rsync --info=progress2 "${POOL_PATH}/${FILENAME}-${i}" "${RAMDISK_PATH}/$FILENAME"
uptime | printf "\e[1A\t\t\t\t\t\t\t\t load %s\n" "$(uptime | sed 's/^.*average:/average:/')"
sync
echo 3 > /proc/sys/vm/drop_caches
rm -f "${RAMDISK_PATH}/$FILENAME"
done
}
mkdir $RAMDISK_PATH || true
mount -t tmpfs -o size="$RAMDISK_SIZE"g tmpfs $RAMDISK_PATH
umount $POOL_PATH || true
mkdir $POOL_PATH || true
wipefs --all "$BLOCK_DEVICES" > /dev/zero
zpool create $ZFS_POOL_NAME "$ZFS_POOL_TOPOLOGY" -f
zfs set mountpoint="$POOL_PATH" $ZFS_POOL_NAME
zfs set atime=$ZFS_ATIME_OPTION $ZFS_POOL_NAME
zfs set dedup=$ZFS_DEDUP_OPTION $ZFS_POOL_NAME
zfs set compression=$ZFS_COMPRESSION_OPTION $ZFS_POOL_NAME
printf "\n\nTesting zfs: dedup=%s, compress=%s, atime=%s | %s\n" "$ZFS_DEDUP_OPTION" "$ZFS_COMPRESSION_OPTION" \
"$ZFS_ATIME_OPTION" "$ZFS_POOL_TOPOLOGY"
test_wr
zpool destroy $ZFS_POOL_NAME