DRBD with MySQL Centos 8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

Drbd is a distributed replicated storage system for the Linux platform. It is implemented as a kernel driver, several userspace management applications, and some shell scripts. It is traditionally used in high availability (HA) computer clusters. Still, beginning with DRBD version 9, can also use it to create larger software-defined storage pools focusing on cloud integration.

If you are using the virtual kernel as part of a virtual machine, you will need to compile the drbd module manually. It may be easier to install the Linux-server package inside the virtual machine. Check drbd user’s guide and MySQL.

Create a playbook to install all requirements

Playbook provided is just a sample task to give a sequence for setting the cluster.

# cat > drbd.setupcentos8.yml
---
- hosts: all
  gather_facts: no
  become: true
  tasks:
  - hostname:
        name: "{{ ansible_hostname }}"

  - get_url:
      url: https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
      dest: /tmp/elrepo-release-8.el8.elrepo.noarch.rpm

  - name: install repo
    command: rpm -ivh /tmp/elrepo-release-8.el8.elrepo.noarch.rpm
    ignore_errors: yes

  - command: rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
    ignore_errors: yes

  - shell: echo drbd > /etc/modules-load.d/drbd.conf

  - yum:
      name: "{{ item }}"
      state: present
    loop:
     - drbd90-utils
     - kmod-drbd90
     - lvm2
     - policycoreutils-python-utils

  - systemd:
       name: firewalld
       state: stopped
       enabled: no

  - selinux_permissive:
      name: drbd_t
      no_reload: false
      permissive: true

  - lvg:
      vg: drbdvg
      pvs: /dev/sdb

  - lvol:
      vg: drbdvg
      lv: drbdlv
      size: +100%FREE

Remove the global default config from the installation.

Move the file and create a new configuration file.

# mv /etc/drbd.d/global_common.conf /etc/drbd.d/global_common.conf.back

Create the new configuration you require

The configuration file on this tutorial.

# cat > /etc/drbd.d/global_common.conf
global {
 usage-count no;
}
common {
 net {
  protocol C;
 }
}

Create a resource configuration file

Note that the resource should be the name of the file as a standard practice. In this tutorial, we will use drbd0.

#cat > /etc/drbd.d/drbd0.res
resource drbd0 {
protocol C;
net {
  verify-alg sha256;
 }
on node1 {
                device /dev/drbd0;
                disk /dev/drbdv/lvdrdb;
                node-id 0;
                address 192.168.55.61:7788;
                meta-disk internal;
                }
on node2 {
                device /dev/drbd0;
                disk /dev/drbdv/lvdrdb;
                node-id 1;
                address 192.168.55.62:7788;
                meta-disk internal;
                }
on node3 {
                device /dev/drbd0;
                node-id 2;
                disk /dev/drbdv/lvdrdb;
                address 192.168.55.63:7788;
                meta-disk internal;
                }
 connection-mesh {
  hosts node1 node2 node3;
 }

}

Resource simple requirement parameter for clustered setup

Please check the required parameters for your choice of setup

  • on host-name [uname -n]
  • node-id [unique node identifier. range 0 to 16]
  • disk {[disk] | none}
  • address [address-family] address:port

Create drbd block device

This command will create the block device required.

Enable drbd device on all nodes

Enable the device by executing the command stated below.

Check drbd status

This will output the status of the device on all nodes.

Configure who’s going to be the primary node.

This will configure where the sync should be copied from.

Check status of the cluster

Now devices are sync.

Create a filesystem from the drbd device on the primary

This will be the one being used for clustering. Note only anyone from the cluster can be chosen.

Now mount mysql directory to drbd device

Data will be shared across all nodes.

Move resource from node1 to node2

Note that MySQL service should be stopped first before the migration of resources.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook