Changes between Version 1 and Version 2 of ssd


Ignore:
Timestamp:
Sep 25, 2016, 3:24:19 PM (5 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ssd

    v1 v2  
    2626Due to limitations of SSD, the operating system must communicate to the disk which sectors are free for writing (trim/discards), we have to configure all the disk layers specifically to pass these "disard" messages.
    2727
    28 
     28== Technical Details ==
     29
     30Following are the steps for adding a solid state drive to both a host and a guest
     31
     32=== Adding solid state drives to a host ===
     33
     34First, order the disks (see [ticket:11870#comment:7 previous SSDs we have purchased] and order the cables and cages needed to install them (see [ticket:11870#comment:10 previous cables we have ordered]).
     35
     36Once installed, the should show up via `cat /proc/partitions` as something like /dev/sda and /dev/sdb.
     37
     38Next, modify the physical servers .pp file in puppet, changing the call to m_physical server to be:
     39
     40{{{
     41class { "mayfirst::m_physical":
     42  ssd => true
     43}
     44}}}
     45
     46Once you push, it should change /etc/lvm/lvm.conf to have: `issue_discards = 1`
     47
     48Next, create a single partition on each device, e.g.:
     49
     50{{{
     510 wiwa:/etc/lvm# parted /dev/sdb
     52GNU Parted 3.2
     53Using /dev/sdb
     54Welcome to GNU Parted! Type 'help' to view a list of commands.
     55(parted) mklabel gpt
     56(parted) unit s mkpart main 8192 -196608                                       
     57(parted) p                                                               
     58Model: ATA SAMSUNG MZ7KM480 (scsi)
     59Disk /dev/sdb: 937703088s
     60Sector size (logical/physical): 512B/512B
     61Partition Table: gpt
     62Disk Flags:
     63
     64Number  Start  End         Size        File system  Name  Flags
     65 1      8192s  937506480s  937498289s               main
     66
     67(parted)
     68}}}
     69
     70Then a RAID 1 array:
     71
     72{{{
     73mdadm --create --raid-devices=2 --level=1 --metadata=1.0 --verbose /dev/md2 /dev/sda1 /dev/sdb1
     74}}}
     75
     76Scan your RAID devices:
     77
     78{{{
     79mdadm --examine --scan
     80}}}
     81
     82And based on the output, edit /etc/mdadm/mdam.conf to add a line for your new RAID (something like: `ARRAY /dev/md/2  metadata=1.0 UUID=70345fc6:661e67ce:715261cf:84112f10 name=wiwa:2`
     83
     84Now, setup encryption and be sure to enable `--allow-discards`:
     85
     86{{{
     870 wiwa:/etc/lvm# cryptsetup luksFormat /dev/md2
     88
     89WARNING!
     90========
     91This will overwrite data on /dev/md2 irrevocably.
     92
     93Are you sure? (Type uppercase yes): YES
     94Enter passphrase:
     95Verify passphrase:
     960 wiwa:/etc/lvm# cryptsetup --allow-discards luksOpen /dev/md2 md2_crypt
     97Enter passphrase for /dev/md2:
     980 wiwa:/etc/lvm# blkid /dev/md2
     99/dev/md2: UUID="b360ef4f-84ea-457c-8f86-a7f94b1f9277" TYPE="crypto_LUKS"
     1000 wiwa:/etc/lvm# echo md2_crypt UUID=b360ef4f-84ea-457c-8f86-a7f94b1f9277 none luks,discard >> /etc/crypttab
     1010 wiwa:/etc/lvm# cat /etc/crypttab
     102# <target name> <source device>         <key file>      <options>
     103md1_crypt UUID=ae7a55a5-cc91-4064-8e5f-06eb293188a2 none luks
     104md2_crypt UUID=b360ef4f-84ea-457c-8f86-a7f94b1f9277 none luks,discard
     1050 wiwa:/etc/lvm#  pvcreate /dev/mapper/md2_crypt
     106  Physical volume "/dev/mapper/md2_crypt" successfully created
     1070 wiwa:/etc/lvm# vgcreate vg_wiwa1 /dev/mapper/md2_crypt
     108  Volume group "vg_wiwa1" successfully created
     1090 wiwa:/etc/lvm#
     110}}}
     111
     112=== Adding solid state drives to a guest ===
     113
     114On the host, create a logical volume for your given host, e.g.:
     115
     116{{{
     1170 wiwa:/etc/lvm# lvcreate --size 10GB --name jacobs vg_wiwa1
     118  Logical volume "jacobs" created
     1190 wiwa:/etc/lvm#
     120}}}
     121
     122Change the group ownership to match the user the guests runs as:
     123
     124{{{
     1251 wiwa:/etc/sv/kvm/jacobs# ls -l /dev/mapper/vg_wiwa1-jacobs
     126lrwxrwxrwx 1 root root 8 Sep 23 15:16 /dev/mapper/vg_wiwa1-jacobs -> ../dm-28
     1270 wiwa:/etc/sv/kvm/jacobs# chgrp jacobs /dev/dm-28
     1280 wiwa:/etc/sv/kvm/jacobs#
     129}}}
     130
     131Reboot the guest.
     132
     133From the guest...
     134
     135Look for the new block device (/dev/sdb below):
     136
     137{{{
     1380 jacobs:~# cat /proc/partitions
     139major minor  #blocks  name
     140
     141   8       16   10485760 sdb
     142   8        0  524288000 sda
     143   8        1     248832 sda1
     144   8        2  524037120 sda2
     145 254        0    3997696 dm-0
     146 254        1     499712 dm-1
     147 254        2     999424 dm-2
     148 254        3    4997120 dm-3
     149 254        4    4997120 dm-4
     150 254        5   20971520 dm-5
     1510 jacobs:~#
     152}}}
     153
     154Create a single partition:
     155
     156{{{
     1570 jacobs:~# parted /dev/sdb
     158GNU Parted 3.2
     159Using /dev/sdb
     160Welcome to GNU Parted! Type 'help' to view a list of commands.
     161(parted) mklabel gpt                                                     
     162(parted) unit s mkpart main 8192 -196608                                 
     163(parted) p                                                               
     164Model: QEMU QEMU HARDDISK (scsi)
     165Disk /dev/sdb: 20971520s
     166Sector size (logical/physical): 512B/512B
     167Partition Table: gpt
     168Disk Flags:
     169
     170Number  Start  End        Size       File system  Name  Flags
     171 1      8192s  20774912s  20766721s               main
     172
     173(parted) quit                                                             
     174Information: You may need to update /etc/fstab.
     175
     1760 jacobs:~#
     177}}}
     178
     179Create a filesystem:
     180
     181{{{
     182mkfs -t ext4 /dev/sdb1
     183}}}
     184
     185==== Replacing MySQL partition ====
     186
     187If you are using this partition to replace MySQL...
     188
     189Stop mysql:
     190
     191{{{
     192systemctl stop mysql
     193}}}
     194
     195Unmount /var/lib/mysql:
     196
     197{{{
     198umount /var/lib/mysql
     199}}}
     200
     201Edit /etc/fstab, change the line for mounting /var/lib/mysql to match /dev/sdb1 instead of the existing logical volume.
     202
     203Mount the old logical volume on /mnt:
     204
     205{{{
     206mount /dev/mapper/vg_jacobs0-var+lib+mysql /mnt
     207}}}
     208
     209Mount the new partition:
     210
     211{{{
     212mount /var/lib/mysql
     213}}}
     214
     215Move the data:
     216
     217{{{
     218mv /mnt/* /var/lib/mysql
     219}}}
     220
     221Umount /mnt and remove the logical volume:
     222
     223{{{
     224umount /mnt
     225lvremove /dev/mapper/vg_jacobs0-var+lib+mysql
     226}}}
     227
     228Retart mysql:
     229
     230{{{
     231systemctl start mysql
     232}}}