How to create Glusterfs (Replicated Volume) ?

Continuing in Glusterfs article series, creating replicated Gluster Volume in this article. Replication help us to provide the redundancy.

[root@Node1 ~]# cat /etc/redhat-storage-release
Red Hat Storage Server 3.0 Update 2

Step 1 : I have created one logical volume using below commands on both server and after creating that created xfs file system on it.

I created new filesystem on both nodes by using below commands.

[root@Node1 ~]# lvcreate -n ReplicatedLV1 –size 1G FirstVG
[root@Node1 ~]# mkfs.xfs -i size=512 /dev/FirstVG/ReplicatedLV1
[root@Node1 ~]# mkdir /Replicated
Added the below entry in /etc/fstab

[root@Node1 ~]# cd /Replicated/
[root@Node1 Replicated]# mkdir RepBrickNode1
[root@Node1 ~]# mount /Replicated/
[root@Node1 ~]# df -h /Replicated/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/FirstVG-ReplicatedLV1
1014M   33M  982M   4% /Replicated

Step 2 : Created replicated volume and started it. We need to do this step on one node only.

[root@Node1 ~]# gluster volume create RepVol1 replica 2 Node1:/Replicated/RepBrickNode1 Node2:/Replicated/RepBrickNode2
volume create: RepVol1: success: please start the volume to access data

[root@Node1 ~]# gluster vol start RepVol1
volume start: RepVol1: success

Step 3 : Checking the information of replicated volume.

[root@Node1 ~]# gluster volume status RepVol1
Status of volume: RepVol1
Gluster process                                         Port    Online  Pid
——————————————————————————
Brick Node1:/Replicated/RepBrickNode1                   49153   Y       2625
Brick Node2:/Replicated/RepBrickNode2                   49153   Y       2593
NFS Server on localhost                                 2049    Y       2641
Self-heal Daemon on localhost                           N/A     Y       2646
NFS Server on Node2                                     2049    Y       2608
Self-heal Daemon on Node2                               N/A     Y       2610

Task Status of Volume RepVol1
——————————————————————————
There are no active volume tasks

Step 4 : Mounting the volume on client side using NFS. Look at the size of mount point even thou we have created volume using two bricks each of 1GB. Because its replication hence showing the size as 1GB which is expected.

[root@client1 ~]# mkdir /ReplicatedVol1
[root@client1 ~]# mount -t nfs Node1:/RepVol1 /ReplicatedVol1
[root@client1 ~]# df -h /ReplicatedVol1/
Filesystem      Size  Used Avail Use% Mounted on
Node1:/RepVol1 1014M   32M  982M   4% /ReplicatedVol1

Step 5 : Go to the path of mountpoint and created five files in it for testing.

[root@client1 ~]# cd /ReplicatedVol1/

[root@client1 ReplicatedVol1]# for i in {1..5}; do touch file$i; done

Step 6 : I can see the files are present on both Gluster nodes Node1 and Node2.

[root@Node1 ~]# cd /Replicated/RepBrickNode1/
[root@Node1 RepBrickNode1]# ll
total 0
-rw-r–r– 2 root root 0 Dec 24 16:42 file1
-rw-r–r– 2 root root 0 Dec 24 16:42 file2
-rw-r–r– 2 root root 0 Dec 24 16:42 file3
-rw-r–r– 2 root root 0 Dec 24 16:42 file4
-rw-r–r– 2 root root 0 Dec 24 16:42 file5

[root@Node2 ~]# cd /Replicated/RepBrickNode2/
[root@Node2 RepBrickNode2]# ll
total 0
-rw-r–r– 2 root root 0 Dec 24 16:42 file1
-rw-r–r– 2 root root 0 Dec 24 16:42 file2
-rw-r–r– 2 root root 0 Dec 24 16:42 file3
-rw-r–r– 2 root root 0 Dec 24 16:42 file4
-rw-r–r– 2 root root 0 Dec 24 16:42 file5

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s