How to Install and Configure GlusterFS on Ubuntu 16.04

Requirements

Launch Alibaba Cloud ECS Instance

apt-get update -y

Configure Hostname Resolution

nano /etc/hosts
192.168.0.101 GlusterFS1
192.168.0.102 GlusterFS2
192.168.0.103 GlusterFS-Client
ping GlusterFS1
ping GlusterFS2
ping GlusterFS-Client

Install GlusterFS

apt-get install software-properties-common -y
add-apt-repository ppa:gluster/glusterfs-3.10
GlusterFS 3.10
More info: https://launchpad.net/~gluster/+archive/ubuntu/glusterfs-3.10
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpj4keidrx/secring.gpg' created
gpg: keyring `/tmp/tmpj4keidrx/pubring.gpg' created
gpg: requesting key 3FE869A9 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpj4keidrx/trustdb.gpg: trustdb created
gpg: key 3FE869A9: public key "Launchpad PPA for Gluster" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
apt-get update -y
apt-get install glusterfs-server -y
systemctl start glusterfs-server 
systemctl enable glusterfs-server
systemctl status glusterfs-server
glusterfs-server.service - LSB: GlusterFS server
Loaded: loaded (/etc/init.d/glusterfs-server; bad; vendor preset: enabled)
Active: active (running) since Mon 2018-08-06 22:16:27 IST; 1min 1s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/glusterfs-server.service
└─8030 /usr/sbin/glusterd -p /var/run/glusterd.pid
Aug 06 22:16:22 Node1 systemd[1]: Starting LSB: GlusterFS server...
Aug 06 22:16:22 Node1 glusterfs-server[8019]: * Starting glusterd service glusterd
Aug 06 22:16:27 Node1 glusterfs-server[8019]: ...done.
Aug 06 22:16:27 Node1 systemd[1]: Started LSB: GlusterFS server.
Aug 06 22:17:23 Node1 systemd[1]: Started LSB: GlusterFS server.

Configure GlusterFS Storage

fdisk /dev/sdb
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x96eae0dd.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-4194303, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194303, default 4194303):
Created a new partition 1 of type 'Linux' and of size 2 GiB.Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 524032 4k blocks and 131072 inodes
Filesystem UUID: d8fc7e2b-a3a3-4e7d-b278-51cf8395c3b2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
mkdir /glusterfs
mount /dev/sdb1 /glusterfs
nano /etc/fstab
/dev/sdb1 /glusterfs ext4 defaults 0 0

Configure GlusterFS Storage Pool

gluster peer probe GlusterFS2
gluster peer status
peer probe: success.
gluster pool list
UUID                    Hostname      State
64fca937-4fde-4d13-bd85-a05ba906e1f1 GlusterFS2 Connected
eda74d66-597d-4d80-a408-e20093401fea localhost Connected

Configure GlusterFS Volume

mkdir /glusterfs/gvol0
gluster volume create gvol0 replica 2 GlusterFS1:/glusterfs/gvol0 GlusterFS2:/glusterfs/gvol0
volume create: gvol0: success: please start the volume to access data
gluster volume start gvol0
gluster volume info gvol0
Volume Name: gvol0
Type: Replicate
Volume ID: 94f27972-9ecf-49f1-810c-67d3c6d219ce
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: GlusterFS1:/glusterfs/gvol0
Brick2: GlusterFS2:/glusterfs/gvol0
Options Reconfigured:
transport.address-family: inet
nfs.disable: on

Configure GlusterFS Client

apt-get install software-properties-common -y
add-apt-repository ppa:gluster/glusterfs-3.10
apt-get update -y
apt-get install glusterfs-client -y
mkdir /glusterfs
mount -t glusterfs GlusterFS1:/gvol0 /glusterfs
cat /proc/mounts  | grep glusterfs
GlusterFS1:/gvol0 /glusterfs fuse.glusterfs rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072 0 0
nano /etc/fstab
GlusterFS1:/gvol0 /glusterfs glusterfs  defaults,_netdev 0 0

Test GlusterFS

mount -t glusterfs GlusterFS1:/gvol0 /mnt
mount -t glusterfs GlusterFS2:/gvol0 /mnt
touch /glusterfs/test1
touch /glusterfs/test2
ls -l /mnt
total 0
-rw-r--r-- 1 root root 0 Aug 6 22:39 test1
-rw-r--r-- 1 root root 0 Aug 6 22:39 test2
ls -l /mnt
total 0
-rw-r--r-- 1 root root 0 Aug 6 22:39 test1
-rw-r--r-- 1 root root 0 Aug 6 22:39 test2
ls -l /glusterfs/
touch /glusterfs/test3 
touch /glusterfs/test4
touch /glusterfs/test5
mount -t glusterfs GlusterFS1:/gvol0 /mnt
ls -l /mnt
-rw-r--r-- 1 root root 0 Aug  6 22:39 test1
-rw-r--r-- 1 root root 0 Aug 6 22:39 test2
-rw-r--r-- 1 root root 0 Aug 6 22:58 test3
-rw-r--r-- 1 root root 0 Aug 6 22:58 test4
-rw-r--r-- 1 root root 0 Aug 6 22:58 test5

Related Alibaba Cloud Products

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store