Pcsd-nfs

Aus xinux.net
Zur Navigation springen Zur Suche springen

Vorraussetzungen

  • Eingerichteter HA-Cluster
  • Partitionierte Festplatte

DRBD erstellen

  • apt-get install drbd8-utils

DRBD konfigurieren

Die folgenden Anweißungen müssen auf beiden Nodes ausgeführt werden

  • vi /etc/drbd.d/nfs.res
resource nfs {
 protocol C;
 meta-disk internal;
 device /dev/drbd1;
 syncer {
  verify-alg sha1;
 }
 net {
  allow-two-primaries;
 }
 on mabel.xinux.lan {
  disk   /dev/sda1;
  address  198.19.250.1:7701;
 }
 on ryzen.xinux.lan {
  disk   /dev/sda1;
  address  198.19.250.2:7701;
 }
}

drbd-laufwerk erstellen

  • drbdadm create-md nfs
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.

drbd-Laufwerk hochfahren

  • modprobe drbd
  • drbdadm up nfs

Diesen Rechner als primär verwenden

Die folgenden Befehle müssen nur auf der Node ausgeführt werden, die später die primäre Node sein soll

  • drbdadm primary --force nfs

Dateisystem erstellen

  • mkfs.ext4 /dev/drbd1

Resourcen anlegen

in der Datei drbd_cfg zwischenspeichern

  • pcs cluster cib drbd_cfg

Die Resource für das Master/Slave-Setup erstellen

  • pcs -f drbd_cfg resource create nfs-drbd ocf:linbit:drbd drbd_resource=nfs op monitor interval=60s
  • pcs -f drbd_cfg resource master nfs-drbd-clone nfs-drbd master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true

Aus der Datei drbd_cfg in cib übernehmen

  • pcs cluster cib-push drbd_cfg

NFS erstellen

NFS Install

  • apt-get install nfs-kernel-server

Resource für NFS-IP erstellen

  • pcs resource create nfs-ip IPaddr2 ip=10.82.100.100 cidr_netmask=16

Resource für Mount erstellen

  • pcs resource create nfs-data Filesystem device="/dev/drbd1" directory="/mnt/misc/" fstype="ext4"

Resource für NFS-Server erstellen

  • pcs resource create nfs-Server systemd:nfs-kernel-server op monitor interval=”30s”

Abhängigkeiten und Reihenfolge anpassen

  • pcs constraint colocation add nfs-ip with master nfs-drbd-clone INFINITY
  • pcs constraint colocation add nfs-data with master nfs-drbd-clone INFINITY
  • pcs constraint colocation add nfs-server with master nfs-drbd-clone INFINITY
  • pcs constraint order promote nfs-drbd-clone then start nfs-ip
  • pcs constraint order start nfs-ip then start nfs-data
  • pcs constraint order start nfs-data then start nfs-server
  • pcs constraint show
Location Constraints:
Resource: nfs-drbd-clone
    Enabled on: mabel (score:INFINITY) (role: Master)
  Resource: nfs-ip
    Enabled on: mabel (score:INFINITY) (role: Started)
Ordering Constraints:
  promote nfs-drbd-clone then start nfs-ip (kind:Mandatory)
  start nfs-ip then start nfs-data (kind:Mandatory)
  start nfs-data then start nfs-server (kind:Mandatory)
Colocation Constraints:
  nfs-ip with nfs-drbd-clone (score:INFINITY) (with-rsc-role:Master)
  nfs-data with nfs-drbd-clone (score:INFINITY) (with-rsc-role:Master)
  nfs-server with nfs-drbd-clone (score:INFINITY) (with-rsc-role:Master)

Ergebnis

  • pcs status
Cluster name: kvm-cluster
Last updated: Thu Sep 21 09:48:09 2017		Last change: Wed Sep 20 19:31:16 2017 by root via crm_attribute on mabel
Stack: corosync
Current DC: ryzen (version 1.1.14-70404b0) - partition with quorum
2 nodes and 9 resources configured

Online: [ mabel ryzen ]

Full list of resources:

 Master/Slave Set: nfs-drbd-clone [nfs-drbd]
     Masters: [ mabel ]
     Slaves: [ ryzen ]
 nfs-ip	(ocf::heartbeat:IPaddr2):	Started mabel
 nfs-data	(ocf::heartbeat:Filesystem):	Started mabel
 nfs-server	(systemd:nfs-kernel-server):	Started mabel

PCSD Status:
  mabel: Online
  ryzen: Online

Daemon Status:
  corosync: active/disabled
  pacemaker: active/enabled
  pcsd: active/enabled