Armazenamento · 3 min read · Feb 06, 2026

Armazenamento de Alta Disponibilidade Com GlusterFS No Mandriva 2010.0 - Replicação Automática de Arquivos Entre Dois Servidores de Armazenamento - Página 2

3 Configurando O Cliente GlusterFS

client1.example.com:

No cliente, podemos instalar o cliente GlusterFS da seguinte forma:

urpmi glusterfs-client glusterfs-server

Em seguida, criamos o seguinte diretório:

mkdir /mnt/glusterfs

Em seguida, criamos o arquivo /etc/glusterfs/glusterfs.vol:

vi /etc/glusterfs/glusterfs.vol

| volume remote1 type protocol/client option transport-type tcp option remote-host server1.example.com option remote-subvolume brick end-volume volume remote2 type protocol/client option transport-type tcp option remote-host server2.example.com option remote-subvolume brick end-volume volume replicate type cluster/replicate subvolumes remote1 remote2 end-volume volume writebehind type performance/write-behind option window-size 1MB subvolumes replicate end-volume volume cache type performance/io-cache option cache-size 512MB subvolumes writebehind end-volume |

Certifique-se de usar os nomes de host ou endereços IP corretos nas linhas de opção remote-host!

É isso! Agora podemos montar o sistema de arquivos GlusterFS em /mnt/glusterfs com um dos seguintes dois comandos:

glusterfs -f /etc/glusterfs/glusterfs.vol /mnt/glusterfs

ou

mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs

Agora você deve ver o novo compartilhamento nas saídas de…

mount
[root@client1 administrator]# mount  
/dev/sda1 on / type ext4 (rw,relatime)  
none on /proc type proc (rw)  
/dev/sda6 on /home type ext4 (rw,relatime)  
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)  
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)  
nfsd on /proc/fs/nfsd type nfsd (rw)  
/etc/glusterfs/glusterfs.vol on /mnt/glusterfs type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)  
[root@client1 administrator]#

… e…

df -h
[root@client1 administrator]# df -h  
Filesystem            Size  Used Avail Use% Mounted on  
/dev/sda1              12G  1.5G  9.8G  13% /  
/dev/sda6              16G  172M   16G   2% /home  
/etc/glusterfs/glusterfs.vol  
                       29G  1.7G   26G   6% /mnt/glusterfs  
[root@client1 administrator]#

( server1.example.com e server2.example.com têm cada um 29GB de espaço para o sistema de arquivos GlusterFS, mas como os dados são espelhados, o cliente não vê 58GB (2 x 29GB), mas apenas 29GB.)

Em vez de montar o compartilhamento GlusterFS manualmente no cliente, você pode modificar /etc/fstab para que o compartilhamento seja montado automaticamente quando o cliente inicializa.

Abra /etc/fstab e adicione a seguinte linha:

vi /etc/fstab

| [...] /etc/glusterfs/glusterfs.vol /mnt/glusterfs glusterfs defaults 0 0 |

Para testar se sua modificação em /etc/fstab está funcionando, reinicie o cliente:

reboot

Após a reinicialização, você deve encontrar o compartilhamento nas saídas de…

df -h

… e…

mount

4 Testando

Agora vamos criar alguns arquivos de teste no compartilhamento GlusterFS:

client1.example.com:

touch /mnt/glusterfs/test1  
touch /mnt/glusterfs/test2

Agora vamos verificar o diretório /data/export em server1.example.com e server2.example.com. Os arquivos test1 e test2 devem estar presentes em cada nó:

server1.example.com/server2.example.com:

ls -l /data/export
[root@server1 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test2  
[root@server1 administrator]#

Agora desligamos server1.example.com e adicionamos/removemos alguns arquivos no compartilhamento GlusterFS em client1.example.com.

server1.example.com:

shutdown -h now

client1.example.com:

touch /mnt/glusterfs/test3  
touch /mnt/glusterfs/test4  
rm -f /mnt/glusterfs/test2

As alterações devem ser visíveis no diretório /data/export em server2.example.com:

server2.example.com:

ls -l /data/export
[root@server2 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test3  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test4  
[root@server2 administrator]#

Vamos reiniciar server1.example.com novamente e dar uma olhada no diretório /data/export:

server1.example.com:

ls -l /data/export
[root@server1 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test2  
[root@server1 administrator]#

Como você pode ver, server1.example.com não percebeu as alterações que ocorreram enquanto estava desligado. Isso é fácil de corrigir, tudo o que precisamos fazer é invocar um comando de leitura no compartilhamento GlusterFS em client1.example.com, por exemplo:

client1.example.com:

ls -l /mnt/glusterfs/
[root@client1 administrator]# ls -l /mnt/glusterfs/  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test3  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test4  
[root@client1 administrator]#

Agora dê uma olhada no diretório /data/export em server1.example.com novamente, e você deve ver que as alterações foram replicadas para aquele nó:

server1.example.com:

ls -l /data/export
[root@server1 administrator]# ls -l /data/export  
total 0  
-rw-r--r-- 1 root root 0 2009-12-18 15:37 test1  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test3  
-rw-r--r-- 1 root root 0 2009-12-18 15:39 test4  
[root@server1 administrator]#

5 Links

Share: X/Twitter LinkedIn

Receba novas postagens na sua caixa de entrada

Sem spam. Cancele a assinatura a qualquer momento.