Instalar GlusterFS 10 em Rocky Linux 8.9 replicado em 3 vias sem ponto único de falhas para usar com SGBD MySQL 8.0.35

 



Objetivo

O objetivo principal é não ter ponto único de falha no armazenamento compartilhado e replicado em três vias e conseguir desempenho e estabilidade suficientes para usar com um SGBD MySQL.

O projeto CentOS, no qual o Rocky Linux é baseado, descontinuou o Storage Special Interest Group e seu repositório. O projeto Rocky Linux replicou as últimas versões disponíveis para seus repositórios até que um novo SIG seja formado dentro do próprio projeto, por exemplo.

Os volumes do Gluster serão criados em bricks em cada servidor e serão criados sobre XFS sobre LVM .

Os procedimentos foram testados sobre máquinas virtuais em KVM e VmWare.

Os clientes poderão ser outras vm ou nos próprios servidores, num caso especial de acessar ponto de montagem.

Ajustar os nomes dos servidores

Você precisa ajustar os nomes dos nós servidores no seu DNS ou editar manualmente os arquivos /etc/hosts para incluir os FQDN dos nós.

Como é um laboratório, usaremos o segundo método.


192.168.122.26 node1.cluster.local
192.168.122.85 node2.cluster.local
192.168.122.223 node3.cluster.local

Depois, EM CADA NÓ, executar os RESPECTIVOS comandos:

hostnamectl set-hostname node1.cluster.local
hostnamectl set-hostname node2.cluster.local
hostnamectl set-hostname node3.cluster.local


Criar os lvm

 

ls /dev/v*
pvcreate /dev/vdb
vgcreate vg_data /dev/vdb
lvcreate -l 100%FREE -n lv_data vg_data
mkfs.xfs /dev/vg_data/lv_data
mkdir -p /data/glusterfs/volume1
mkdir -p /data/glusterfs/volume1/brick0
nano /etc/fstab


/dev/mapper/vg_data-lv_data /data/glusterfs/volume1        xfs     defaults        1 2


mount -a
df -h

mkdir -p /data/glusterfs/volume1/brick0


Ajustar repositório


nano /etc/yum.repos.d/CentOS-Gluster-10.repo


[centos-gluster10] 

name=CentOS-$releasever - Gluster 10 

#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=$releasever&repo=storage-gluster-10 

baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/storage/x86_64/gluster-10/ 

gpgcheck=1 

enabled=1 

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage 



Testar dentro dos servidores gluster se eles se conhecem por hostname FQDN


ping -c 3 node1.cluster.local
ping -c 3 node2.cluster.local
ping -c 3 node3.cluster.local


Ajuste repositórios e instale dependências para o GlusterFS


dnf update

dnf install yum-utils
dnf install epel-release
dnf config-manager --set-enabled powertools


Instalar pacotes do GlusterFS 10

 

dnf install centos-release-gluster10
dnf repolist
dnf install glusterfs glusterfs-libs glusterfs-server

Ajuste o firewall


firewall-cmd --zone=public --add-service=glusterfs --permanent


Habilitar serviço em cada servidor Gluster


systemctl enable glusterfsd.service glusterd.service
systemctl start glusterfsd.service glusterd.service
systemctl status glusterfsd.service glusterd.service


Executar apenas no primeiro node para incluir os nodes no cluster


gluster peer probe node1.cluster.local

gluster peer probe node2.cluster.local
gluster peer probe node3.cluster.local

gluster peer status



Criar o volume Gluster a partir do primeiro node servidor


ls -lah /data/glusterfs/volume1/brick0


gluster volume create volume1 replica 3 node1.cluster.local:/data/glusterfs/volume1/brick0/ node2.cluster.local:/data/glusterfs/volume1/brick0/  node3.cluster.local:/data/glusterfs/volume1/brick0/  


gluster volume start volume1
gluster volume status
gluster volume info


Executar na vm cliente


dnf install glusterfs-client
mkdir -p /data/clientefs
mount.glusterfs node1.cluster.local:/volume1 /data/clientefs

touch /data/clientefs/lixo3.txt

ls -lah /data/glusterfs/volume1/brick0

ls -lah /data/clientefs

umount /data/clientefs



Ajustar parâmetros do Gluster para usar com SGBD MySQL

Resumidamente, configurar para escritas síncronas e desabilitar vários caches de escrita e leitura.

Mais adiante será necessário ajustar similarmente os parâmetros do MySQL também, desabilitando query cache e usar external locking cedido ao filesystem.


gluster volume set volume1 performance.open-behind off
gluster volume set volume1 performance.write-behind off
gluster volume set volume1 performance.stat-prefetch off
gluster volume set volume1  performance.quick-read off
gluster volume set volume1 performance.strict-o-direct on
gluster volume set volume1  performance.read-ahead off
gluster volume set volume1 performance.io-cache off
gluster volume set volume1 performance.readdir-ahead off

gluster volume status
gluster volume info

mount -t glusterfs  -o direct-io-mode=enable  node1.cluster.local:/volume1 /data/clientefs

df -h




Ajustar o /etc/fstab de cada respectivo cliente 

No caso de ser o próprio nó servidor, use a respectiva linha.


node1.cluster.local:/volume1 /data/clientefs glusterfs defaults,_netdev,direct-io-mode=enable 0 0 


node2.cluster.local:/volume1 /data/clientefs glusterfs defaults,_netdev,direct-io-mode=enable 0 0
 

node3.cluster.local:/volume1 /data/clientefs glusterfs defaults,_netdev,direct-io-mode=enable 0 0



Execute alguns benchmarks básicos a partir do cliente

Ajuste os tamanhos de acordo com a memória RAM disponível


dnf install ioping fio

ioping -c 10 -DYy /data/clientefs/

fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=random_write.fio --bs=4k --iodepth=64 --size=512M --readwrite=randwrite

Você pode também executar os benchmarks em sistemas de arquivos locais, para comparações.


Ajuste os parâmetros do MySQL

Precisa ajustar o external locking , delayed key write e desabilitar o query cache no arquivo de configuração do sgbd, o my.cnf .

No MySQL 8.x já foram removidos o query cache e suas variáveis, depreciados desde 5.7.20 porque não funcionava bem em servidores de vários núcleos. Mas listamos as variáveis, caso esteja usando MySQL mais antigo.

Atenção que alguns parâmetros DEVEM ser numéricos quando ajustados no my.cnf e outros não exigem isso.



delay_key_write = 0

query_cache_type = 0

skip_external_locking = OFF


Considerações

Note que estamos trocando desempenho por disponibilidade de dados. Podemos esperar uma redução de desempenho de 4 vezes ou mais, pois o GlusterFS opera em espaço de usuário (user space), escreve sobre um sistema de arquivos nativo em kernel space, se comunica através de rede TCP/IP neste caso, e configuramos para escritas síncronas. Só devolve êxito após escrever em todos os bricks.

Ainda mais, desabilitamos os recursos de software para aumento de desempenho, como os vários tipos de cache. Tudo para aumentar a estabilidade e confiabilidade das escritas do servidor de banco de dados.

E nem consideramos a camada de virtualização.

Portanto, invista no melhor hardware e infraestrutura de rede que lhe seja possível para implantar em produção.

Ainda estamos observando o servidor sob carga de produção. 

O procedimento foi implantado em ambiente de produção virtualizado em VmWare e SSD storage corporativo high-end, praticamente apenas mudando a etapa de DNS ou arquivo /etc/hosts, pois em produção é utilizado um servidor DNS próprio.



Bibliografia


https://github.com/gluster/glusterfs

https://www.howtoforge.com/how-to-install-glusterfs-on-rocky-linux/

https://www.golinuxcloud.com/glusterfs-distributed-volume-centos-rhel-8/

https://shape.host/resources/how-to-set-up-glusterfs-on-rocky-linux-8-a-comprehensive-guide

https://docs.rockylinux.org/guides/file_sharing/glusterfs/

https://www.centos.org/keys/

https://github.com/CentOS-Storage-SIG/centos-release-storage-common/blob/master/RPM-GPG-KEY-CentOS-SIG-Storage

https://access.redhat.com/documentation/pt-br/red_hat_enterprise_linux/7/html/storage_administration_guide/nfs-pnfs

https://access.redhat.com/documentation/pt-br/red_hat_enterprise_linux/8

https://access.redhat.com/documentation/pt-br/red_hat_enterprise_linux/8/html/configuring_gfs2_file_systems/assembly_planning-gfs2-deployment-configuring-gfs2-file-systems

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_file_systems/enabling-pnfs-scsi-layouts-in-nfs_managing-file-systems

https://stackoverflow.com/questions/52297719/what-is-the-difference-between-posix-storage-and-nfs

https://dev.mysql.com/doc/refman/8.0/en/disk-issues.html

https://serverfault.com/questions/171166/can-i-run-mysqld-on-top-of-glusterfs

https://docs.gluster.org/en/latest/Install-Guide/Setup-aws/

https://dev.mysql.com/doc/refman/8.0/en/external-locking.html ***

https://github.com/gluster/glusterfs/issues/4063

https://gluster-users.gluster.narkive.com/sTaqq7fZ/mysql-on-gluster-vms

https://www.mail-archive.com/gluster-users@gluster.org/msg36246.html

https://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/

https://wiki.centos.org/SpecialInterestGroup(2f)Storage.html

https://wiki.centos.org/SpecialInterestGroup(2f)Storage(2f)Gluster.html

https://rockylinux.pkgs.org/8/rockylinux-devel-aarch64/centos-release-gluster11-1.0-1.el8.noarch.rpm.html

https://ahelpme.com/software/glusterfs/install-and-create-a-glusterfs-11-replica-cluster-under-centos-stream-9/

https://dl.rockylinux.org/vault/centos/8.5.2111/storage/x86_64/gluster-10/Packages/

https://docs.gluster.org/en/latest/Administrator-Guide/arbiter-volumes-and-quorum/

https://www.centos.org/

https://docs.gluster.org/en/latest/Install-Guide/Community-Packages/

https://wiki.rockylinux.org/special_interest_groups/

https://buildlogs.centos.org/centos/8-stream/storage/x86_64/gluster-11/Packages/g/

http://mirror.centos.org/centos/8/storage/x86_64/gluster-10/

https://dl.rockylinux.org/vault/centos/8.5.2111/storage/x86_64/gluster-10/

https://github.com/geerlingguy/ansible-role-glusterfs/issues/39

https://ahelpme.com/linux/centos-stream-9/missing-the-centos-stream-9-crb-repository-nothing-provides-python3-pyxattr-needed-by/

https://blog.csdn.net/hknaruto/article/details/112461509

https://linux.how2shout.com/how-to-enable-powertools-repository-on-rocky-linux-8/

https://access.redhat.com/documentation/pt-br/red_hat_gluster_storage/3.1/html/administration_guide/sect-creating_distributed_replicated_volumes *

https://access.redhat.com/documentation/pt-br/red_hat_gluster_storage/3.1/html/administration_guide/sect-managing_split-brain#sect-Preventing_Split-brain

https://docs.gluster.org/en/main/Administrator-Guide/Automatic-File-Replication/#more-on-the-afr-xattrs

https://docs.gluster.org/en/v3/Administrator%20Guide/Setting%20Up%20Volumes/

https://stackoverflow.com/questions/51134558/why-read-speed-is-very-low-in-glusterfs-with-direct-i-o-mode-enabled

https://stackoverflow.com/questions/37892090/enable-direct-i-o-mode-in-glusterfs

https://access.redhat.com/documentation/en-us/red_hat_openshift_container_storage/3.10/html/deployment_guide/chap-documentation-red_hat_gluster_storage_container_native_with_openshift_platform-setting_shared_pv *******

https://serverfault.com/questions/517775/glusterfs-direct-i-o-mode

https://docs.gluster.org/en/main/Administrator-Guide/Tuning-Volume-Options/

https://lists.gluster.org/pipermail/gluster-devel/2016-February/048434.html

https://manpages.ubuntu.com/manpages/xenial/man8/glusterfs.8.html

https://docs.gluster.org/en/v3/Administrator%20Guide/Setting%20Up%20Clients/

https://www.spinics.net/lists/gluster-devel/msg18532.html

https://dannyda.com/2022/06/06/how-to-test-check-measure-benchmark-disk-hdd-ssd-storage-i-o-read-write-speed-performance-and-latency-in-terminal-command-line-console-ssh-in-linux-debian-ubuntu-kali-linux-fedora-redhat-rocky-linux-e/

https://cloudzy.com/blog/test-disk-speed-in-linux/

https://stanislas.blog/2018/10/how-to-mount-local-glusterfs-volume-boot-fstab-systemd-fix/

https://docs.gluster.org/en/main/Administrator-Guide/Setting-Up-Clients/#automatically-mounting-volumes

https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_delay_key_write

 

Comentários

Postagens mais visitadas deste blog

Tutorial Cyrus IMAP aggregator (murder) 2.3.16 sobre Debian GNU Linux 5.x Lenny

How to configure multipath for high availability and performance on Debian and CentOS for storage at IBM DS8300 SAN

Como instalar Oracle Client no Debian e Ubuntu