proxmox5にdrbd9モジュールを有効にする

## 参考

https://github.com/LINBIT/drbdmanage-proxmox

[Linbit Docs – Docs LINBIT](http://docs.linbit.com/docs/users-guide-9.0/#ch-proxmox)

## パッケージのインストール

```rb:drbdmanage-proxmoxのインストール
wget -O- https://packages.linbit.com/package-signing-pubkey.asc | apt-key add -

PVERS=5 && echo "deb http://packages.linbit.com/proxmox/ proxmox-$PVERS drbd-9.0" > \
	/etc/apt/sources.list.d/linbit.list

echo "deb http://download.proxmox.com/debian stretch pve-no-subscription" > \
	/etc/apt/sources.list.d/pve-enterprise.list

apt update

apt dist-upgrade -y
reboot

# drbd9カーネルモジュールを作成する
apt install -y drbd-dkms pve-headers drbdmanage-proxmox
```

## カーネルモジュール作成

```sh:drbd9対応カーネルモジュール作成
# dpkg-reconfigure drbd-dkms

-------- Uninstall Beginning --------
Module:  drbd
Version: 9.0.9+linbit-1
Kernel:  4.13.8-3-pve (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

drbd.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.13.8-3-pve/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


drbd_transport_tcp.ko:
 - Uninstallation
   - Deleting from: /lib/modules/4.13.8-3-pve/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod...

DKMS: uninstall completed.

------------------------------
Deleting module version: 9.0.9+linbit-1
completely from the DKMS tree.
------------------------------
Done.
Loading new drbd-9.0.9+linbit-1 DKMS files...
Building for 4.13.8-3-pve
Building initial module for 4.13.8-3-pve
Done.

drbd:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/4.13.8-3-pve/updates/dkms/

drbd_transport_tcp.ko:
Running module version sanity check.
 - Original module
 - Installation
   - Installing to /lib/modules/4.13.8-3-pve/updates/dkms/

depmod...

DKMS: install completed.

# find /lib/modules/4.13.8-3-pve/updates/dkms/
/lib/modules/4.13.8-3-pve/updates/dkms/
/lib/modules/4.13.8-3-pve/updates/dkms/drbd.ko
/lib/modules/4.13.8-3-pve/updates/dkms/drbd_transport_tcp.ko

# modinfo /lib/modules/4.13.8-3-pve/updates/dkms/drbd.ko
filename:       /lib/modules/4.13.8-3-pve/updates/dkms/drbd.ko
alias:          block-major-147-*
license:        GPL
version:        9.0.9-1
description:    drbd - Distributed Replicated Block Device v9.0.9-1
author:         Philipp Reisner <phil@linbit.com>, Lars Ellenberg <lars@linbit.com>
srcversion:     0BCD9EBE15ECBA6B05269A7
depends:        libcrc32c
name:           drbd
vermagic:       4.13.8-3-pve SMP mod_unload modversions 
parm:           minor_count:Approximate number of drbd devices (1-255) (uint)
parm:           disable_sendpage:bool
parm:           allow_oos:DONT USE! (bool)
parm:           enable_faults:int
parm:           fault_rate:int
parm:           fault_count:int
parm:           fault_devs:int
parm:           two_phase_commit_fail:int
parm:           usermode_helper:string
```

## drbdpoolの作成

```sh:
fdisk /dev/vdb
# n p Enter Enter Enter
# t 8e
# w

vgcreate drbdpool /dev/vdb1
```

## drbdmanage init

```sh:
# drbdmanage init 192.168.100.55

You are going to initialize a new drbdmanage cluster.
CAUTION! Note that:
  * Any previous drbdmanage cluster information may be removed
  * Any remaining resources managed by a previous drbdmanage installation
    that still exist on this system will no longer be managed by drbdmanage

Confirm:

  yes/no: yes
Empty drbdmanage control volume initialized on '/dev/drbd0'.
Empty drbdmanage control volume initialized on '/dev/drbd1'.
Waiting for server: .
Operation completed successfully
```

```sh:UpToDateであることを確認
# drbdadm status
.drbdctrl role:Primary
  volume:0 disk:UpToDate
  volume:1 disk:UpToDate
```

## ノードの追加

```sh:
# drbdmanage add-node proxmox56 192.168.100.56
Operation completed successfully
Operation completed successfully
Host key verification failed.
Give leader time to contact the new node
Operation completed successfully
Operation completed successfully

Join command for node proxmox56:
drbdmanage join -p 6999 192.168.100.56 1 proxmox55 192.168.100.55 0 xxxxxxxxxxxxxxxxxxxx
```

```sh:
# drbdmanage nodes
+----------------------------------------------------------------------------------------------------------+
| Name      | Pool Size | Pool Free |   |                                                            State |
|----------------------------------------------------------------------------------------------------------|
| proxmox55 |   unknown |   unknown |   |                                       online/quorum vote ignored |
| proxmox56 |   unknown |   unknown |   | offline/quorum vote ignored, pending actions: adjust connections |
+----------------------------------------------------------------------------------------------------------+
```

これはうまくいってなさそう。`drbdmanage resume-all`しても変わらない


----


## LVM

```sh:現状
# lvs
  LV   VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  data pve twi-aotz-- 156.64g             0.00   0.43                            
  root pve -wi-ao----  58.00g                                                    
  swap pve -wi-ao----   2.00g
```

```sh:lvmボリュームの削除
# lvremove pve/drbdpool
Do you really want to remove and DISCARD active logical volume pve/drbdpool? [y/n]: y
  Logical volume "drbdpool" successfully removed
```

```sh:pvを縮小
# pvs
  PV         VG  Fmt  Attr PSize   PFree  
  /dev/sda3  pve lvm2 a--  232.63g 172.63g

# pvresize --setphysicalvolumesize 100G /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

# pvs
  PV         VG  Fmt  Attr PSize   PFree 
  /dev/sda3  pve lvm2 a--  100.00g 40.00g
```

```sh:(参考まで)lvmボリュームの作成方法
# lvcreate -n drbdpool pve -L 4G
```

```sh:(参考まで)dataをdrbdpoolにリネーム
# lvrename pve data drbdpool
  Renamed "data" to "drbdpool" in volume group "pve"

# lvs
  LV       VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  drbdpool pve twi-aotz-- 156.64g             0.00   0.43                            
  root     pve -wi-ao----  58.00g                                                    
  swap     pve -wi-ao----   2.00g
```