192.168.0.1 node1 192.168.0.2 node2
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum install -y kmod-drbd84 drbd84-utils
modprobe drbd echo drbd > /etc/modules-load.d/drbd.conf
resource r0 { protocol C; device /dev/drbd0; meta-disk internal; disk /dev/sdb; net { allow-two-primaries; } disk { fencing resource-and-stonith; } handlers { fence-peer "/usr/lib/drbd/crm-fence-peer.sh"; after-resync-target "/usr/lib/drbd/crm-unfence-peer.sh"; } on node1 { address 192.168.0.1:7788; } on node2 { address 192.168.0.2:7788; }
systemctl disable drbd drbdadm create-md r0 drbdadm up r0
drbdadm primary --force r0
yum install -y pacemaker pcs resource-agents
echo CHANGEME | passwd --stdin hacluster
systemctl enable pcsd systemctl start pcsd
pcs cluster auth node1 node2 -u hacluster
pcs cluster setup --force --name samba_cluster node1 node2
pcs cluster enable --all pcs cluster start --all
pcs property set stonith-enabled=false pcs property set no-quorum-policy=ignore
pcs resource create virtual_ip ocf:heartbeat:IPaddr2 ip=192.168.0.10 cidr_netmask=24 op monitor interval=60s
pcs cluster cib drbd_cfg pcs -f drbd_cfg resource create DRBD ocf:linbit:drbd drbd_resource=r0 op monitor interval=60s pcs -f drbd_cfg resource master DRBDClone DRBD master-max=2 master-node-max=1 clone-node-max=1 clone-max=2 notify=true interleave=true pcs cluster cib-push drbd_cfg
yum install -y lvm2-cluster gfs2-utils /sbin/lvmconf --enable-cluster
pcs resource create dlm ocf:pacemaker:controld op monitor interval=30s on-fail=fence clone interleave=true ordered=true pcs resource create clvmd ocf:heartbeat:clvm op monitor interval=30s on-fail=fence clone interleave=true ordered=true pcs constraint colocation add clvmd-clone with dlm-clone
pcs constraint order start DRBDClone then dlm-clone pcs constraint order start dlm-clone then clvmd-clone
sed -i 's/write_cache_state = 1/write_cache_state = 0/' /etc/lvm/lvm.conf rm /etc/lvm/cache/*
# This configuration option has an automatic default value. # filter = [ "a|.*/|" ] filter = [ "r|^/dev/sdb$|" ]
$ vgcreate -Ay -cy cl_vg /dev/drbd0 Physical volume "/dev/drbd0" successfully created. Clustered volume group "cl_vg" successfully created $ lvcreate -l100%FREE -n r0 cl_vg Logical volume "r0" created.
mkfs.gfs2 -j2 -p lock_dlm -t drbd-gfs2:r0 /dev/cl_vg/r0
pcs resource create fs ocf:heartbeat:Filesystem device="/dev/cl_vg/r0" directory="/mnt/" fstype="gfs2" --clone pcs constraint order start clvmd-clone then fs-clone
yum install -y samba ctdb cifs-utils
CTDB_RECOVERY_LOCK="/mnt/ctdb/.ctdb.lock" CTDB_NODES=/etc/ctdb/nodes CTDB_MANAGES_SAMBA=yes CTDB_LOGGING=file:/var/log/ctdb.log CTDB_DEBUGLEVEL=NOTICE
cat /etc/ctdb/nodes 192.168.0.1 192.168.0.2
[global] clustering = yes private dir = /mnt/ctdb lock directory = /mnt/ctdb idmap backend = tdb2 passdb backend = tdbsam [test] comment = Cluster Share path = /mnt browseable = yes writable = yes
pcs constraint order start fs-clone then samba
vgchage -ay pcs resource refresh
Source: https://habr.com/ru/post/435906/
All Articles