Categories
Uncategorized

raid0 for varnish

To speed up varnish i choosen to cache data to a mdadm raid0 partition on half the drives (rest is raid1).

Create raid0 partitions (done twice)

(parted) print
Model: ATA ST2000NC001-1DY1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1001MB 1000MB primary boot, raid
2 1001MB 1009GB 1008GB primary raid

(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? xfs
Start? 1100GB
End? 1900GB

(parted) set 3 raid on
(parted) print
Model: ATA ST2000NC001-1DY1 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 1001MB 1000MB primary boot, raid
2 1001MB 1009GB 1008GB primary raid
3 1100GB 1900GB 800GB primary raid

mdadm raid0

mdadm -C /dev/md0 -l raid0 -n 2 /dev/sd[a-b]3
mkfs.xfs /dev/md0
mdadm --detail --scan >> /etc/mdadm.conf

fstab

To make sure this server can start evan if the raid0 partition fails, add nofail. noatime is added since atime is not needed for this drive.

/dev/md0  /var/lib/varnish/                     xfs     defaults,nofail,noatime 0 0

If it fails

If the drive fails varnish will crash, at a reboot varnish will not start (this is because the file varnish want to use dont fit within the root partition. to fix the raid0 partition, recreate all steps it and mount. dont forget to update /etc/mdadm.conf.