GNU/Linux >> Belajar Linux >  >> Debian

Penyimpanan Replika Terdistribusi Di Empat Node Penyimpanan Dengan GlusterFS Di Debian Lenny

Tutorial ini menunjukkan cara menggabungkan empat server penyimpanan tunggal (menjalankan Debian Lenny) ke penyimpanan replika terdistribusi dengan GlusterFS. Node 1 dan 2 (replikasi1) serta 3 dan 4 (replikasi2) akan saling mencerminkan, dan replikasi1 dan replikasi2 akan digabungkan ke satu server penyimpanan yang lebih besar (distribusi). Pada dasarnya, ini adalah RAID10 melalui jaringan. Jika Anda kehilangan satu server dari replikasi1 dan satu dari replikasi2, volume terdistribusi akan terus berfungsi. Sistem klien (Debian Lenny 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.

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 terlihat seperti berikut di kelima sistem:

vi /etc/hosts
127.0.0.1       localhost.localdomain   localhost
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

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

(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 Debian untuk Debian Lenny, oleh karena itu kita harus membangunnya sendiri. Pertama kita install prasyaratnya:

aptitude install sshfs build-essential flex bison byacc libdb4.6 libdb4.6-dev

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.1.tar.gz
tar xvfz glusterfs-2.0.1.tar .gz
cd glusterfs-2.0.1
./configure --prefix=/usr> /dev/null

server1:/tmp/glusterfs-2.0.1# ./configure --prefix=/usr > /dev/null

Ringkasan konfigurasi GlusterFS
===========================
FUSE client        : tidak
Kata kerja Infiniband   : tidak
epoll IO multiplex : ya
Berkeley-DB       :yes
libglusterfsclient : yes
mod_glusterfs     : no ()
argp-standalone    : no

server1:/tmp/glusterfs-2.0.1#

buat &&buat instal
ldconfig

Perintah

glusterfs --version

sekarang harus menunjukkan versi GlusterFS yang baru saja Anda kompilasi (2.0.1 dalam hal ini):

server1:/tmp/glusterfs-2.0.1# glusterfs --version
glusterfs 2.0.1 dibuat pada 29 Mei 2009 17:23:10
Revisi repositori:5c1d9108c1529a1155963cb1911f8870a674ab5b
Hak Cipta (c) 2006 -2009 Z RESEARCH Inc.
GlusterFS BENAR-BENAR TIDAK ADA JAMINAN.
Anda dapat mendistribusikan ulang salinan GlusterFS di bawah persyaratan Lisensi Publik Umum GNU.
server1:/tmp/glusterfs-2.0.1#

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 link startup sistem untuk skrip init glusterfsd...

update-rc.d glusterfsd defaults

... dan mulai glusterfsd:

/etc/init.d/glusterfsd start

3 Menyiapkan Klien GlusterFS

client1.example.com:

Pada klien, kita perlu menginstal fuse dan GlusterFS. Alih-alih menginstal paket libfuse2 dari repositori Debian, kami menginstal versi yang ditambal dengan dukungan yang lebih baik untuk GlusterFS.

Pertama kita install lagi prasyaratnya:

aptitude install sshfs build-essential flex bison byacc libdb4.6 libdb4.6-dev

Kemudian kita membuat fuse sebagai berikut (Anda dapat menemukan versi patch fuse terbaru di ftp://ftp.zresearch.com/pub/gluster/glusterfs/fuse/):

cd /tmp
wget ftp://ftp.zresearch.com/pub/gluster/glusterfs/fuse/fuse-2.7.4glfs11.tar.gz
tar -zxvf fuse-2.7.4glfs11.tar. gz
cd fuse-2.7.4glfs11
./configure
make &&make install

Setelah itu kita bangun GlusterFS (seperti di server)...

cd /tmp
wget http://ftp.gluster.com/pub/gluster/glusterfs/2.0/TERBARU/glusterfs-2.0.1.tar.gz
tar xvfz glusterfs-2.0.1.tar .gz
cd glusterfs-2.0.1
./configure --prefix=/usr> /dev/null

make &&make install
ldconfig
glusterfs --version

... dan 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 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

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

client1:/tmp/glusterfs-2.0.1# mount
/dev/sda1 on / ketik ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw ketik tmpfs (rw, nosuid,mode=0755)
proc aktif /proc ketik proc (rw,noexec,nosuid,nodev)
sysfs aktif /sys ketik sysfs (rw,noexec,nosuid,nodev)
udev aktif /dev ketik tmpfs (rw,mode=0755)
tmpfs aktif /dev/shm ketik tmpfs (rw,nosuid,nodev)
devpts aktif /dev/pts ketik devpts (rw,noexec,nosuid,gid =5,mode=620)
fusectl pada /sys/fs/fuse/connections ketik fusectl (rw)
/etc/glusterfs/glusterfs.vol pada /mnt/glusterfs ketik fuse.glusterfs (rw, max_read=131072,allow_other,default_permissions)
client1:/tmp/glusterfs-2.0.1#

... dan...

df -h

client1:/tmp/glusterfs-2.0.1# df -h
Sistem file          Ukuran  Digunakan Tersedia Penggunaan% Dipasang di
/dev/sda1           29G  935M    27G    27G /lib/init/rw
udev 10m 80k 10m 1%/dev
tmpfs 126m 0 126m 0%/dev/shm
/etc/glusterfs/glusterfs.vol
48g 1.7 G   44G   4% /mnt/glusterfs
client1:/tmp/glusterfs-2.0.1#

(Ukuran penyimpanan terdistribusi dihitung dengan replikasi1 + replikasi2, di mana kedua volume replikasi sebesar batu bata terkecil.)

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 replikasi1 serta replikasi2 hanya menampung sebagian dari file/direktori yang membentuk bagian GlusterFS pada klien, tetapi node yang membentuk replikasi1 (server1 dan server2) atau replikasi2 (server3 dan server4) berisi sama file (mirroring):

server1.example.com:

ls -l /data/export 

server1:/tmp/glusterfs-2.0.1# ls -l /data/ekspor
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test1
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test2
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test4
-rw-r--r-- 1 root root 0 06-03 15:24 test5
server1:/tmp/glusterfs-2.0.1#

server2.example.com:

ls -l /data/export 

server2:/tmp/glusterfs-2.0.1# ls -l /data/ekspor
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test1
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test2
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test4
-rw-r--r-- 1 root root 0 06-03 15:24 test5
server2:/tmp/glusterfs-2.0.1#

server3.example.com:

ls -l /data/export 

server3:/tmp/glusterfs-2.0.1# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test3
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test6
server3:/tmp/glusterfs-2.0.1#

server4.example.com:

ls -l /data/export 

server4:/tmp/glusterfs-2.0.1# ls -l /data/ekspor
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test3
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test6
server4:/tmp/glusterfs-2.0.1#

Sekarang kita mematikan server1.example.com dan server4.example.com dan menambahkan/menghapus beberapa file pada share GlusterFS di 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

Perubahan harus terlihat di direktori /data/export di server2.example.com dan server3.example.com:

server2.example.com:

ls -l /data/export

server2:/tmp/glusterfs-2.0.1# ls -l /data/ekspor
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test1
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test2
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test4
server2:/tmp/glusterfs-2.0.1#

server3.example.com:

ls -l /data/export

server3:/tmp/glusterfs-2.0.1# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test3
server3:/tmp/glusterfs-2.0.1#

Mari kita boot server1.example.com dan server4.example.com lagi dan lihat direktori /data/export:

server1.example.com:

ls -l /data/export

server1:~# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test1
-rw- r--r-- 1 root root 0 2009-06-03 15:24 test2
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test4
- rw-r--r-- 1 root root 0 2009-06-03 15:24 test5
server1:~#

server4.example.com:

ls -l /data/export

server4:~# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test3
-rw- r--r-- 1 root root 0 2009-06-03 15:24 test6
server4:~#

Seperti yang Anda lihat, server1.example.com dan server4.example.com belum melihat perubahan yang terjadi saat sedang down. Ini mudah diperbaiki, yang perlu kita lakukan hanyalah menjalankan perintah baca pada bagian GlusterFS di client1.example.com, mis.:

client1.example.com:

ls -l /mnt/glusterfs/

client1:~# ls -l /mnt/glusterfs/
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test1
-rw -r--r-- 1 root root 0 2009-06-03 15:24 test2
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test3
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test4
client1:~#

Sekarang lihat kembali direktori /data/export di server1.example.com dan server4.example.com, dan Anda akan melihat bahwa perubahan telah direplikasi ke node ini:

server1.example.com:

ls -l /data/export 

server1:~# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test1
-rw- r--r-- 1 root root 0 2009-06-03 15:24 test2
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test4
server1 :~#

server4.example.com:

ls -l /data/export 

server4:~# ls -l /data/export
total 0
-rw-r--r-- 1 root root 0 2009-06-03 15:24 test3
server4:~ #

  • GlusterFS:http://www.gluster.org/
  • Debian:http://www.debian.org/

Debian
  1. Penyimpanan Ketersediaan Tinggi dengan GlusterFS di Debian 8 - Mencerminkan di dua server penyimpanan

  2. Penyimpanan Terdistribusi Di Empat Node Penyimpanan Dengan GlusterFS 3.2.x Di Ubuntu 12.10

  3. Penyimpanan Replika Terdistribusi Di Empat Node Penyimpanan Dengan GlusterFS 3.2.x Di Ubuntu 12.10

  1. Striping Di Empat Node Penyimpanan Dengan GlusterFS 3.2.x Di Ubuntu 12.10

  2. Penyimpanan Ketersediaan Tinggi Dengan GlusterFS 3.2.x Pada Debian Wheezy - Replikasi File Otomatis (Cermin) Di Dua Server Penyimpanan

  3. Penyimpanan Replika Terdistribusi Di Empat Node Penyimpanan Dengan GlusterFS Di Fedora 12

  1. Penyimpanan Ketersediaan Tinggi Dengan GlusterFS Di Debian Lenny - Replikasi File Otomatis Di Dua Server Penyimpanan

  2. Striping Di Empat Node Penyimpanan Dengan GlusterFS Di Fedora 12

  3. Penyimpanan Terdistribusi Di Empat Node Penyimpanan Dengan GlusterFS Di Fedora 12