Tutorial ini menunjukkan cara menggabungkan empat server penyimpanan tunggal (menjalankan CentOS 5.4) ke satu server penyimpanan besar (penyimpanan terdistribusi) dengan GlusterFS. Sistem klien (CentOS 5.4 juga) akan dapat mengakses penyimpanan seolah-olah itu adalah sistem file lokal. GlusterFS adalah sistem file berkerumun yang mampu menskalakan hingga beberapa peta-byte. Ini menggabungkan berbagai bata penyimpanan melalui Infiniband RDMA atau TCP/IP interkoneksi ke dalam satu sistem file jaringan paralel yang besar. Bata penyimpanan dapat dibuat dari perangkat keras komoditas apa pun seperti server x86_64 dengan RAID SATA-II dan HBA Infiniband.
Harap dicatat bahwa jenis penyimpanan ini (penyimpanan terdistribusi) tidak menyediakan fitur ketersediaan tinggi, seperti halnya dengan penyimpanan yang direplikasi.
Saya tidak memberikan jaminan apa pun bahwa ini akan berhasil untuk Anda!
1 Catatan Awal
Dalam tutorial ini saya menggunakan lima sistem, empat server dan satu klien:
- server1.example.com:alamat IP 192.168.0.100 (server)
- server2.example.com:alamat IP 192.168.0.101 (server)
- server3.example.com:alamat IP 192.168.0.102 (server)
- server4.example.com:alamat IP 192.168.0.103 (server)
- client1.example.com:alamat IP 192.168.0.104 (klien)
Kelima sistem harus dapat menyelesaikan nama host sistem lain. Jika ini tidak dapat dilakukan melalui DNS, Anda harus mengedit file /etc/hosts sehingga berisi baris berikut di kelima sistem:
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 [...] |
(Dimungkinkan juga untuk menggunakan alamat IP alih-alih nama host dalam pengaturan berikut. Jika Anda lebih suka menggunakan alamat IP, Anda tidak perlu peduli apakah nama host dapat diselesaikan atau tidak.)
2 Menyiapkan Server GlusterFS
server1.example.com/server2.example.com/server3.example.com/server4.example.com:
GlusterFS tidak tersedia sebagai paket untuk CentOS 5.4, oleh karena itu kita harus membangunnya sendiri. Pertama kita install prasyaratnya:
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'
yum install libibverbs-devel fuse-devel
Kemudian kami mengunduh rilis GlusterFS terbaru dari http://www.gluster.org/download.php dan membangunnya sebagai berikut:
cd /tmp
wget http://ftp.gluster.com/pub/gluster/glusterfs/2.0/TERBARU/glusterfs-2.0.9.tar.gz
tar xvfz glusterfs-2.0.9.tar .gz
cd glusterfs-2.0.9
./configure
Di akhir perintah ./configure, Anda akan melihat sesuatu seperti ini:
[...]
Ringkasan konfigurasi GlusterFS
==========================
Klien FUSE :yes
Kata kerja Infiniband : yes
epoll IO multiplex : yes
Berkeley-DB : yes
libglusterfsclient : yes
argp-standalone : no
[[email protected] glusterfs-2.0.9]#
buat &&buat instal
ldconfig
Periksa versi GlusterFS setelahnya (seharusnya 2.0.9):
glusterfs --version
[[email protected] glusterfs-2.0.9]# glusterfs --version
glusterfs 2.0.9 dibuat pada 1 Mar 2010 15:34:50
Revisi repositori:v2.0.9
Hak Cipta ( c) 2006-2009 Gluster Inc.
GlusterFS datang dengan BENAR-BENAR TANPA JAMINAN.
Anda dapat mendistribusikan kembali salinan GlusterFS di bawah persyaratan Lisensi Publik Umum GNU.
[[email protected] glusterfs-2.0.9]#
Selanjutnya kita buat beberapa direktori:
mkdir /data/
mkdir /data/ekspor
mkdir /data/ekspor-ns
mkdir /etc/glusterfs
Sekarang kita membuat file konfigurasi server GlusterFS /etc/glusterfs/glusterfsd.vol yang menentukan direktori mana yang akan diekspor (/data/ekspor) dan klien apa yang diizinkan untuk terhubung (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 |
Harap dicatat bahwa dimungkinkan untuk menggunakan wildcard untuk alamat IP (seperti 192.168.*) dan Anda dapat menentukan beberapa alamat IP yang dipisahkan dengan koma (misalnya 192.168.0.104,192.168.0.105).
Setelah itu kita buat symlink berikut...
ln -s /usr/local/sbin/glusterfsd /sbin/glusterfsd
... dan kemudian sistem startup menautkan untuk server GlusterFS dan memulainya:
chkconfig --levels 35 glusterfsd aktif
/etc/init.d/glusterfsd mulai
3 Menyiapkan Klien GlusterFS
client1.example.com:
GlusterFS tidak tersedia sebagai paket untuk CentOS 5.4, oleh karena itu kita harus membangunnya sendiri. Pertama kita install prasyaratnya:
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'
yum install libibverbs-devel fuse-devel
Kemudian kita memuat modul kernel sekering...
modprobe fuse
... dan buat file /etc/rc.modules dengan konten berikut sehingga modul kernel fuse akan dimuat secara otomatis setiap kali sistem boot:
vi /etc/rc.modules
modprobe fuse |
Jadikan file tersebut dapat dieksekusi:
chmod +x /etc/rc.modules
Kemudian kami mengunduh sumber GlusterFS 2.0.9 (harap dicatat bahwa ini adalah versi yang sama yang diinstal pada server!) dan membangun GlusterFS sebagai berikut:
cd /tmp
wget http://ftp.gluster.com/pub/gluster/glusterfs/2.0/TERBARU/glusterfs-2.0.9.tar.gz
tar xvfz glusterfs-2.0.9.tar .gz
cd glusterfs-2.0.9
./configure
Di akhir perintah ./configure, Anda akan melihat sesuatu seperti ini:
[...]
Ringkasan konfigurasi GlusterFS
==========================
Klien FUSE :yes
Kata kerja Infiniband : yes
epoll IO multiplex : yes
Berkeley-DB : yes
libglusterfsclient : yes
argp-standalone : no
buat &&buat instal
ldconfig
Periksa versi GlusterFS setelahnya (seharusnya 2.0.9):
glusterfs --version
[[email protected] glusterfs-2.0.9]# glusterfs --version
glusterfs 2.0.9 dibuat pada 1 Mar 2010 15:58:06
Revisi repositori:v2.0.9
Hak Cipta ( c) 2006-2009 Gluster Inc.
GlusterFS datang dengan BENAR-BENAR TANPA JAMINAN.
Anda dapat mendistribusikan kembali salinan GlusterFS di bawah persyaratan Lisensi Publik Umum GNU.
[[email protected] glusterfs-2.0.9]#
Kemudian kita buat dua direktori berikut:
mkdir /mnt/glusterfs
mkdir /etc/glusterfs
Selanjutnya kita buat 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 distribute type cluster/distribute subvolumes remote1 remote2 remote3 remote4 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 |
Pastikan Anda menggunakan nama host server atau alamat IP yang benar pada opsi baris host jarak jauh!
Itu dia! Sekarang kita dapat memasang sistem file GlusterFS ke /mnt/glusterfs dengan salah satu dari dua perintah berikut:
glusterfs -f /etc/glusterfs/glusterfs.vol /mnt/glusterfs
atau
mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs
Anda sekarang akan melihat bagian baru di output...
mount
[[email protected] ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / ketik ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts ketik devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot ketik ext3 (rw)
tmpfs on / dev/shm ketik tmpfs (rw)
none di /proc/sys/fs/binfmt_misc ketik binfmt_misc (rw)
sunrpc di /var/lib/nfs/rpc_pipefs ketik rpc_pipefs (rw)
glusterfs#/etc/glusterfs/glusterfs.vol pada /mnt/glusterfs jenis sekering (rw,allow_other,default_permissions,max_read=131072)
[[email protected] ~]#
... dan...
df -h
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Dipasang di
/dev/mapper/VolGroup00-LogVol00
> /dev/sda1 99m 13m 82m 14%/boot
TMPFS 187M 0 187M 0%/dev/shm
GLUSTERFS#/etc/GLUSTERFS/GLUSTERFS.VOL
112g 2.3g 110g 2%/ mnt/glusterfs
[[email protected] ~]#
(server1.example.com, server2.example.com, server3.example.com, dan server4.example.com masing-masing memiliki sekitar 28GB ruang untuk sistem file GlusterFS, sehingga bagian yang dihasilkan memiliki ukuran sekitar 4 x 28GB ( 112 GB).)
Alih-alih memasang bagian GlusterFS secara manual pada klien, Anda dapat memodifikasi /etc/fstab sehingga bagian tersebut dipasang secara otomatis saat klien melakukan booting.
Buka /etc/fstab dan tambahkan baris berikut:
vi /etc/fstab
[...] /etc/glusterfs/glusterfs.vol /mnt/glusterfs glusterfs defaults 0 0 |
Untuk menguji apakah /etc/fstab Anda yang dimodifikasi berfungsi, reboot klien:
reboot
Setelah reboot, Anda akan menemukan share di output...
df -h
... dan...
mount
4 Pengujian
Sekarang mari kita buat beberapa file uji pada share GlusterFS:
client1.example.com:
sentuh /mnt/glusterfs/test1
sentuh /mnt/glusterfs/test2
sentuh /mnt/glusterfs/test3
sentuh /mnt/glusterfs/test4
sentuh /mnt/glusterfs/ test5
sentuh /mnt/glusterfs/test6
Sekarang mari kita periksa direktori /data/export di server1.example.com, server2.example.com, server3.example.com, dan server4.example.com. Anda akan melihat bahwa setiap node penyimpanan hanya menyimpan sebagian dari file/direktori yang membentuk bagian GlusterFS di klien:
server1.example.com:
ls -l /data/export
[[email protected] ~]# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2010-02-22 20:15 test1
-rw-r--r-- 1 root root 0 2010-02-22 20:15 test2
-rw-r--r-- 1 root root 0 2010-02-22 20:15 test5
[[dilindungi email] ~]#
server2.example.com:
ls -l /data/export
[[email protected] ~]# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2010-02-22 20:15 test4
[[dilindungi email] ~]#
server3.example.com:
ls -l /data/export
[[email protected] ~]# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2010-02-22 20:15 test6
[[dilindungi email] ~]#
server4.example.com:
ls -l /data/export
[[email protected] ~]# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2010-02-22 20:15 test3
[[dilindungi email] ~]#
5 Tautan
- GlusterFS:http://www.gluster.org/
- CentOS:http://www.centos.org/