Friday, December 27, 2013

Membuat NFS Menggunakan GlusterFS di Ubuntu 9.10

Halo Sobat !!
Saya akan memberi tutorial bagaimana membuat NFS Server menggunakan GlusterFS di Ubuntu.9.10
Sebelum saya mulai saya akan memberitahu apa pengertian NFS itu.
NFS atau Network File System adalah sebuah protokol berbagai pakai berkas melalui jaringan. NFS ini meng-share file ataupun resource melalui network atau jaringan tanpa peduli sistem operasi apa.
Tapi untuk kebanyakan orang menginstall NFS server di Linux seperti Ubuntu, CentOs, RedHat dll.


Oke langsung saja kita mulai Setup NFS Server menggunakan GlusterFS di Ubuntu 9.10.


1.Langkah Awal  

Dalam tutorial ini saya memakai 2 sistem yaitu Server dan Client :

  • server1.example.com: IP address 192.168.0.100 (server)
  • client1.example.com: IP address 192.168.0.101 (client)
Sebelum memulai membuat NFS ketik ini di terminal ubuntu untuk mengizinkan Hak Akses :

Sudo Su
Setelah itu kita akan set host dan ip untuk set server gluster fs dengan mengetikan script dibawah

vi etc/hosts
Dan hasilnya :
127.0.0.1       localhost.localdomain   localhost
192.168.0.100   server1.example.com     server1
192.168.0.101   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

2.Setup GluseterFS Server

 Setelah itu kita mulai setup GlusterFS nya dengan mengunnakan command dibawah :  
aptitude install glusterfs-server

Jika berhasil diinstal makan akan ada pemberitahuan seperti ini :

root@server1:~# glusterfs --version
glusterfs 2.0.2 built on Jun 29 2009 23:49:59
Repository revision: 07019da2e16534d527215a91904298ede09bb798
Copyright (c) 2006-2009 Z RESEARCH Inc. 
GlusterFS comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.
root@server1:~#

Selanjutnya kitra membuat beberapa direktori dengan menggunakan command dibawah :

mkdir /data/
mkdir /data/export
mkdir /data/export-ns
Selanjutnya kita membuat Konfigurasi File Server GlusterFS /etc/glusterfs/glusterfsd.vol (Kita akan membuat backup asli /etc/glusterfs/glusterfsd.vol) dimana file konfigurasi akan di ekspor dari server ke client (/data/export) dan client akan mulai menkoneksikan dengan server untuk mengimpor file.Contoh Client (192.168.0.101 = client1.example.com):
cp /etc/glusterfs/glusterfsd.vol /etc/glusterfs/glusterfsd.vol_orig
cat /dev/null > /etc/glusterfs/glusterfsd.vol
vi /etc/glusterfs/glusterfsd.vol
Lalu setting ip address nya :

volume posix
  type storage/posix
  option directory /data/export
end-volume

volume locks
  type features/locks
  option mandatory-locks on
  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.101 # Edit and add list of allowed clients comma separated IP addrs(names) here
  subvolumes brick
end-volume
Jika ingin menggunakan 2 atau lebih ip sekaligus gunakan separator koma (,) setelah ip (192.168.0.*) Contoh : (192.168.0.101,192.168.0.120)

Setelah itu kita akan jalankan GlusterFS dengan command dibawah :

/etc/init.d/glusterfs-server start

3.Setup GlusterFS Client

Pertama kita install GlusterFS di client dengan command dibawah :

aptitude install glusterfs-client glusterfs-server
lalu kita buat beberapa direktori :

mkdir /mnt/glusterfs

Selanjutnya kita membuat file /etc/glusterfs/glusterfs.vol (kita akan membuat bakcup asli /etc/glusterfs/glusterfs.vol terlebih dahulu):
cp /etc/glusterfs/glusterfs.vol /etc/glusterfs/glusterfs.vol_orig
cat /dev/null > /etc/glusterfs/glusterfs.vol
vi /etc/glusterfs/glusterfs.vol


volume remote
  type protocol/client
  option transport-type tcp
  option remote-host server1.example.com # can be IP or hostname
  option remote-subvolume brick
end-volume

volume writebehind
  type performance/write-behind
  option window-size 4MB
  subvolumes remote
end-volume

volume cache
  type performance/io-cache
  option cache-size 512MB
  subvolumes writebehind
end-volume

Diusahakan IP Address yang dimasukkan benar pada line option remote-host

OK ! Selanjutnya kita mount File Sistem GlusterFS ke /mnt/glusterfs . Ada 2 cara untuk mount ke file system :

glusterfs -f /etc/glusterfs/glusterfs.vol /mnt/glusterfs
atau
mount -t glusterfs /etc/glusterfs/glusterfs.vol /mnt/glusterfs
Sekarang untuk melihat hasilnya ketikkan command dibawah :

Mount

Hasil :

root@client1:~# mount
/dev/mapper/client1-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sda5 on /boot type ext2 (rw)
/etc/glusterfs/glusterfs.vol on /mnt/glusterfs type fuse.glusterfs (rw,max_read=131072,allow_other,default_permissions)
root@client1:~#
Lalu ketikkan :

df -h

Hasilnya :

root@client1:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/client1-root
                       29G  808M   26G   3% /
udev                  248M  152K  247M   1% /dev
none                  248M     0  248M   0% /dev/shm
none                  248M   36K  248M   1% /var/run
none                  248M     0  248M   0% /var/lock
none                  248M     0  248M   0% /lib/init/rw
/dev/sda5             228M   15M  202M   7% /boot
/etc/glusterfs/glusterfs.vol
                       18G  807M   16G   5% /mnt/glusterfs
root@client1:~#

Untuk memounting GlusterFS adalah dengan acara manual tetapi kita bisa memodifikasi /etc /fstab jadi GlusterFS akan me-mount secara otomatis ketika memulai boot klien.

Untuk memodifikasi  /etc/fstab ketikkan command dibawah :

vi /etc/fstab
 lalu ketikkan command ini :

[...]
/etc/glusterfs/glusterfs.vol  /mnt/glusterfs  glusterfs  defaults  0  0
Untuk mengecek apakah modifikasi berhasil atau tidak sekarang restart client-nya:
reboot
Setelah restart kita akan mencari output bagian dalam client menggunakan command :

df -h 
Setelah itu ketikan :
Mount 
Selamat Server dan Client GlusterFS telah terinstall dan berjalan :).Semoga tutorial dari saya ini bermanfaat untuk sobat blogger :)

No comments:

Post a Comment