DRBD-Cookbook
How to create your own cluster solution, without SAN or NAS!
1. Edition
1 Introduction1.1 Syntax of that book1.2 Built-in bugs1.3 Hostnames2 Installation2.1 Software2.2 Requirements3 Preliminary considerations3.1 Disk drive – physically vs. LVM3.2 Filesystem on the disk device3.2.1 UFS / ext23.2.2 ext3 / ext43.2.3 xfs3.2.4 BtrFS3.2.5 OCFS23.2.6 Conclusion4 Configuration-Basics on a two-node-cluster-array4.1 SSH-Configuration4.1.1 SSH-Key-Types4.1.2 Recipe: Generate and distribute SSH keys4.2 Configuration of the locale Disk devices4.2.1 Recipe: Create LVM volume via YaST4.2.2 Recipe: Create a LVM-Volume via shell4.3 DRBD configuration4.3.1 Performance4.3.2 /etc/drbd.conf4.3.3 /etc/drbd.d/global_common.conf4.3.4 Resourceconfiguration4.3.5 Resource Description:4.3.6 Alternative notation4.3.7 Ports4.3.8 Recipe: Command sequence for the basic configuration5 Data transmission in the backbone LAN5.1 Recipe: Backbone LAN in the DRBD configuration6 Multi-node cluster6.1 Stacking-Device6.1.1 Recipe: Commissioning a stacking device with DRBD8 under SLES11 SP46.1.2 Recipe: Commissioning a stacking device with DRBD9 under OpenSuSE 15.16.2 RAID1 over at least three nodes7 Hardened cluster7.1 Detecting the state of the firewall7.2 Firewallzones7.3 Build a new firewall-service7.4 Build a new zone7.5 Basics of a two-stage hardening concept7.5.1 Hardening with the firewall7.5.2 Hardening with the Secure-Shell-Options8 Increase / decrease the size of the DRBD device8.1 Unofficial method8.1.1 Concept8.1.2 Command sequence8.2 The official way9 Program your own cluster solution9.1 Configuration file9.1.1 Content of the configuration file9.2 Virtual IP-address9.2.1 Script explanation for my_virt_ip.pl:9.3 Make database switchable9.3.1 Script explanation for my_dev_switch.pl:9.4 Communication between cluster nodes - the Horcher9.4.1 Script explanation for my_horcher.pl:9.5 Controlscript9.5.1 Script explanation for my_control.pl:9.6 Service control scripts for systemd9.6.1 Explanation for mycluster_horcher.service:9.6.2 Explanation for mycluster_control.service:9.7 Initialization script for the cluster controller9.7.1 Explanation for my_service.pl:9.8 Maintenance9.9 General information about the scripts10 Include DRBD in Veritas Cluster10.1 Include DRBD as Veritas-Agent10.2 Increase or decrease a DRBD-Device, which is included in the Veritas-Cluster11 DRBD and Docker11.1 Preparation and first start of the container11.2 Work with the container12 Win-DRBD13 SSH-Configuration on SLE 15 / OpenSuSE Leap 15.x14 Creating a LVM-Volume-Group14.1 YaST14.2 Shell15 Stop, start, enable and disable services - a little tutorial15.1 Copying servicefiles15.2 Use services via YaST15.3 Operate services with systemctl16 Sources and disclaimer16.1 Sources16.1.1 Internet16.1.2 Books16.2 Disclaimer:17 About…17.1 …the book…17.2 …the author…17.3 Legal notice:
If you want to build a cluster, sooner or later you face the problem that the data must be usable on all participating servers. This problem can be solved by transporting the data once per minute from the active cluster node to the passive cluster node.
But what, if this "copy job" takes longer than one minute?
In this case, you either have the situation that the copy jobs overtake each other and never end, because the cluster node in question does nothing else but ’copy’ - and ’nothing else’ means ’nothing else’ - or the data is outdated every time.
Neither makes sense and is not desirable.
If you have the additional situation that all cluster nodes must not only read the data but also write it, ’practical copying’ no longer makes any sense at all. Usually, this problem is solved by using a SAN or NAS.
For a data center, where there are usually more than two machines running at 24 * 7 uptime, it may not be a problem to run one more machine per cluster group - this can be a ’disk pot’, known as a true SAN (storage area network), or it can be a network file server, known as a NAS (network-attached-storage).
However, small businesses and home users face the problem of having to pay for a SAN or NAS.
That’s where the DRBD - Distributed Replicated Block Device - product from LinBit ( www.linbit.com) comes in. DRBD gives you the ability to connect two or more cluster nodes together without using a SAN or NAS as a data device. DRBD runs like a local RAID controller creating a mirror device (RAID 1) - but with "local disks" connected by a LAN. You can also use this variant in a large data center if your cluster needs to be independent of a SAN or NAS. For example, you can think of a monitoring server that monitors the SAN or NAS and has to run highly available, especially when the SAN or NAS is not running. This cookbook teaches the basics of a DRBD active-passive cluster, extended by further possibilities (three-node cluster, backbone LAN, deployment of DRBD on a Veritas cluster, creation of an own cluster via PERL, cluster configuration via hardware systems and many more) and demonstrates the procedures in the form of ’listings’. All examples are based on a test configuration with OpenSuSE Leap 15.1 (except 6.1.1) and can - with the necessary background knowledge - also be implemented in other Linux distributions. In the text number 6.1.1the listing is done with SLES 11 SP 4 to show the commands and screen outputs of DRBD version 8 compared to DRBD version 9 because there are some differences. For using DRBD on Windows-Servers use chapter 12.
To distinguish keyboard inputs and on-screen outputs from the explanations, the commands and on-screen outputs are displayed as follows:
Listing 1.1: |
example of a session |
hostname:~ # echo "This is an example!"
This is an example!
In the scripts, the individual lines are numbered consecutively and the individual lines are briefly explained in tabular form in the text following the respective listing.
This means that the commands of the "recipes" can be entered on the shell as shown in the examples. The screen output should also be, as shown. The disclaimer ( 16.2) is explicitly pointed out here, because your systems do not have to match my systems.
In the course of creating this book, I made various mistakes while working out the recipes, which, after careful consideration, I simply took over into the recipe.
The reason for this is that these mistakes can also happen to you, during operation.
In the context of the respective cooking recipe, I then corrected these mistakes again - also to show you how to save the situation, and which factors - not clearly visible at first - had an influence on the respective error situation.
In this way, you can learn from my mistakes to avoid or solve similar mistakes in your systems.
In an old Siemens-Nixdorf-UNIX-manual, the configuration was explained using hostnamens like Jupiter and Saturn.
Because the dwarf planet pair Pluto and Charon (Charon is the greatest companion of the dwarf planet Pluto) have their common center of gravity, around which they circle, outside of their respective counterparts, these names seemed to me to be suitable to represent a cluster function. Consequently, the second largest moon of Pluto, Nix forms the third host in the three-cluster-node array.
2 Installation
2.1 Software
The DRBD software is provided for the Server or Enterprise editions starting with the following Linux distributions and is updated accordingly (as of summer 2020):
Red Hat Enterprise Linux (RHEL), versions 6, 7 and 8
Читать дальше