Questo tutorial mostra come combinare quattro server di archiviazione singoli (che eseguono CentOS 5.4) in uno storage replicato distribuito con GlusterFS. I nodi 1 e 2 (replica1) e 3 e 4 (replica2) si rispecchieranno a vicenda e la replica1 e la replica2 verranno combinate in un server di archiviazione più grande (distribuzione). Fondamentalmente, questo è RAID10 su rete. Se si perde un server dalla replica1 e uno dalla replica2, il volume distribuito continua a funzionare. Il sistema client (anche CentOS 5.4) sarà in grado di accedere allo storage come se fosse un filesystem locale.GlusterFS è un file system in cluster in grado di scalare a diversi peta-byte. Aggrega vari blocchi di archiviazione su Infiniband RDMA o interconnessione TCP/IP in un unico file system di rete parallelo di grandi dimensioni. I mattoni di archiviazione possono essere realizzati con qualsiasi hardware di consumo come server x86_64 con RAID SATA-II e HBA Infiniband.
Non garantisco che questo funzionerà per te!
1 Nota preliminare
In questo tutorial utilizzo cinque sistemi, quattro server e un client:
- server1.example.com:indirizzo IP 192.168.0.100 (server)
- server2.example.com:indirizzo IP 192.168.0.101 (server)
- server3.example.com:indirizzo IP 192.168.0.102 (server)
- server4.example.com:indirizzo IP 192.168.0.103 (server)
- client1.example.com:indirizzo IP 192.168.0.104 (client)
Tutti e cinque i sistemi dovrebbero essere in grado di risolvere i nomi host degli altri sistemi. Se ciò non può essere fatto tramite DNS, dovresti modificare il file /etc/hosts in modo che contenga le seguenti righe su tutti e cinque i sistemi:
vi /etc/hosts
[...] 192.168.0.100 server1.example.com server1 192.168.0.101 server2.example.com server2 192.168.0.102 server3.example.com server3 192.168.0.103 server4.example.com server4 192.168.0.104 client1.example.com client1 [...] |
(È anche possibile utilizzare indirizzi IP invece di nomi host nella configurazione seguente. Se preferisci utilizzare indirizzi IP, non devi preoccuparti se i nomi host possono essere risolti o meno.)
2 Configurazione dei server GlusterFS
server1.example.com/server2.example.com/server3.example.com/server4.example.com:
GlusterFS non è disponibile come pacchetto per CentOS 5.4, quindi dobbiamo costruirlo noi stessi. Per prima cosa installiamo i prerequisiti:
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'
yum install libibverbs-devel fuse-devel
Quindi scarichiamo l'ultima versione di GlusterFS da http://www.gluster.org/download.php e la costruiamo come segue:
cd /tmp
wget http://ftp.gluster.com/pub/gluster/glusterfs/2.0/LATEST/glusterfs-2.0.9.tar.gz
tar xvfz glusterfs-2.0.9.tar .gz
cd glusterfs-2.0.9
./configure
Alla fine del comando ./configure, dovresti vedere qualcosa del genere:
[...]
GlusterFS configure sommario
============================
FUSE client :sì
Verbi Infiniband : sì
epoll IO multiplex : sì
Berkeley-DB : sì
libglusterfsclient : sì
argp-standalone : no
[[email protetta] glusterfs-2.0.9]#
make &&make install
ldconfig
Controlla la versione GlusterFS in seguito (dovrebbe essere 2.0.9):
glusterfs --version
[[email protected] glusterfs-2.0.9]# glusterfs --version
glusterfs 2.0.9 costruito il 1 marzo 2010 15:34:50
Revisione del repository:v2.0.9
Copyright ( c) 2006-2009 Gluster Inc.
GlusterFS viene fornito con ASSOLUTAMENTE NESSUNA GARANZIA.
È possibile ridistribuire copie di GlusterFS secondo i termini della GNU General Public License.
[[email protected] glusterfs-2.0.9]#
Quindi creiamo alcune directory:
mkdir /data/
mkdir /data/export
mkdir /data/export-ns
mkdir /etc/glusterfs
Ora creiamo il file di configurazione del server GlusterFS /etc/glusterfs/glusterfsd.vol che definisce quale directory verrà esportata (/data/export) e quale client può connettersi (192.168.0.104 =client1.example.com):
vi /etc/glusterfs/glusterfsd.vol
volume posix type storage/posix option directory /data/export end-volume volume locks type features/locks subvolumes posix end-volume volume brick type performance/io-threads option thread-count 8 subvolumes locks end-volume volume server type protocol/server option transport-type tcp option auth.addr.brick.allow 192.168.0.104 subvolumes brick end-volume |
Si noti che è possibile utilizzare caratteri jolly per gli indirizzi IP (come 192.168.*) e che è possibile specificare più indirizzi IP separati da virgole (es. 192.168.0.104,192.168.0.105).
Successivamente creiamo il seguente collegamento simbolico...
ln -s /usr/local/sbin/glusterfsd /sbin/glusterfsd
... e quindi i collegamenti di avvio del sistema per il server GlusterFS e avviarlo:
chkconfig --levels 35 glusterfsd su
/etc/init.d/glusterfsd start
3 Configurazione del client GlusterFS
client1.example.com:
GlusterFS non è disponibile come pacchetto per CentOS 5.4, quindi dobbiamo costruirlo noi stessi. Per prima cosa installiamo i prerequisiti:
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'
yum install libibverbs-devel fuse-devel
Quindi carichiamo il modulo del kernel fuse...
modprobe fuse
... e crea il file /etc/rc.modules con i seguenti contenuti in modo che il modulo fuse kernel venga caricato automaticamente ogni volta che il sistema si avvia:
vi /etc/rc.modules
modprobe fuse |
Rendi eseguibile il file:
chmod +x /etc/rc.modules
Quindi scarichiamo i sorgenti di GlusterFS 2.0.9 (si noti che questa è la stessa versione installata sul server!) e costruiamo GlusterFS come segue:
cd /tmp
wget http://ftp.gluster.com/pub/gluster/glusterfs/2.0/LATEST/glusterfs-2.0.9.tar.gz
tar xvfz glusterfs-2.0.9.tar .gz
cd glusterfs-2.0.9
./configure
Alla fine del comando ./configure, dovresti vedere qualcosa del genere:
[...]
GlusterFS configure sommario
============================
FUSE client :sì
Verbi Infiniband : sì
epoll IO multiplex : sì
Berkeley-DB : sì
libglusterfsclient : sì
argp-standalone : no
make &&make install
ldconfig
Controlla la versione GlusterFS in seguito (dovrebbe essere 2.0.9):
glusterfs --version
[[email protected] glusterfs-2.0.9]# glusterfs --version
glusterfs 2.0.9 costruito il 1 marzo 2010 15:58:06
Revisione del repository:v2.0.9
Copyright ( c) 2006-2009 Gluster Inc.
GlusterFS viene fornito con ASSOLUTAMENTE NESSUNA GARANZIA.
È possibile ridistribuire copie di GlusterFS secondo i termini della GNU General Public License.
[[email protected] glusterfs-2.0.9]#
Quindi creiamo le seguenti due directory:
mkdir /mnt/glusterfs
mkdir /etc/glusterfs
Quindi creiamo il file /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 remote3 type protocol/client option transport-type tcp option remote-host server3.example.com option remote-subvolume brick end-volume volume remote4 type protocol/client option transport-type tcp option remote-host server4.example.com option remote-subvolume brick end-volume volume replicate1 type cluster/replicate subvolumes remote1 remote2 end-volume volume replicate2 type cluster/replicate subvolumes remote3 remote4 end-volume volume distribute type cluster/distribute subvolumes replicate1 replicate2 end-volume volume writebehind type performance/write-behind option window-size 1MB subvolumes distribute end-volume volume cache type performance/io-cache option cache-size 512MB subvolumes writebehind end-volume |
Assicurati di utilizzare i nomi host del server o gli indirizzi IP corretti nelle righe dell'host remoto dell'opzione!
Questo è tutto! Ora possiamo montare il filesystem GlusterFS su /mnt/glusterfs con uno dei seguenti due comandi:
glusterfs -f /etc/glusterfs/glusterfs.vol /mnt/glusterfs
o
mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs
Ora dovresti vedere la nuova condivisione negli output di...
mount
[[email protected] ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts su /dev/pts tipo devpts (rw,gid=5,mode=620)
/dev/sda1 su /boot tipo ext3 (rw)
tmpfs su / dev/shm tipo tmpfs (rw)
none su /proc/sys/fs/binfmt_misc tipo binfmt_misc (rw)
sunrpc su /var/lib/nfs/rpc_pipefs tipo rpc_pipefs (rw)
glusterfs#/etc/glusterfs/glusterfs.vol su /mnt/glusterfs type fuse (rw,allow_other,default_permissions,max_read=131072)
[[email protected] ~]#
... e...
df -h
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
29G 2.2G 25/
tmpfs 187m 0 187m 0%/dev/shm
glusterfs#/etc/glusterfs/glusterfs.vol
56g 2.3g 54g 4%/ mnt/glusterfs
[[email protected] ~]#
(La dimensione dello storage distribuito viene calcolata da replica1 + replica2, dove entrambi i volumi di replica sono grandi quanto il mattone più piccolo.)
Invece di montare manualmente la condivisione GlusterFS sul client, è possibile modificare /etc/fstab in modo che la condivisione venga montata automaticamente all'avvio del client.
Apri /etc/fstab e aggiungi la seguente riga:
vi /etc/fstab
[...] /etc/glusterfs/glusterfs.vol /mnt/glusterfs glusterfs defaults 0 0 |
Per verificare se il tuo /etc/fstab modificato funziona, riavvia il client:
reboot
Dopo il riavvio, dovresti trovare la condivisione negli output di...
df -h
... e...
mount
4 Test
Ora creiamo alcuni file di prova sulla condivisione GlusterFS:
client1.example.com:
touch /mnt/glusterfs/test1
touch /mnt/glusterfs/test2
touch /mnt/glusterfs/test3
touch /mnt/glusterfs/test4
touch /mnt/glusterfs/ test5
tocca /mnt/glusterfs/test6
Ora controlliamo la directory /data/export su server1.example.com, server2.example.com, server3.example.com e server4.example.com. Noterai che replica1 e replica2 contengono solo una parte dei file/directory che compongono la condivisione GlusterFS sul client, ma i nodi che compongono replica1 (server1 e server2) o replica2 (server3 e server4) contengono lo stesso file (mirroring):
server1.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test1
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test2
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test4
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test5
[[email protected] ~]#
server2.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test1
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test2
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test4
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test5
[[email protected] ~]#
server3.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test3
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test6
[[email protected] ~]#
server4.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test3
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test6
[[email protected] ~]#
Ora chiudiamo server1.example.com e server4.example.com e aggiungiamo/eliminiamo alcuni file nella condivisione GlusterFS su client1.example.com.
server1.example.com/server4.example.com:
shutdown -h now
client1.example.com:
rm -f /mnt/glusterfs/test5
rm -f /mnt/glusterfs/test6
Le modifiche dovrebbero essere visibili nella directory /data/export su server2.example.com e server3.example.com:
server2.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test1
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test2
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test4
[[email protetta] ~]#
server3.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test3
[[email protetta] ~]#
Avviamo nuovamente server1.example.com e server4.example.com e diamo un'occhiata alla directory /data/export:
server1.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test1
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test2
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test4
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test5
[[email protected] ~]#
server4.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test3
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test6
[[email protected] ~]#
Come puoi vedere, server1.example.com e server4.example.com non hanno notato i cambiamenti avvenuti mentre erano inattivi. Questo è facile da risolvere, tutto ciò che dobbiamo fare è invocare un comando di lettura sulla condivisione GlusterFS su client1.example.com, ad esempio:
client1.example.com:
ls -l /mnt/glusterfs/
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test1
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test2
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test3
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test4
[[email protected] ~]#
Ora dai un'occhiata alla directory /data/export su server1.example.com e server4.example.com di nuovo e dovresti vedere che le modifiche sono state replicate su questi nodi:
server1.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test1
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test2
-rw-r--r-- 1 radice radice 0 2010-02-23 15:41 test4
[[email protetta] ~]#
server4.example.com:
ls -l /data/export
[[email protetta] ~]# ls -l /data/export
totale 0
-rw-r--r-- 1 radice radice 0 23-02-2010 15:41 test3
[[email protetta] ~]#
5 link
- GlusterFS:http://www.gluster.org/
- CentOS:http://www.centos.org/