Thursday, May 4, 2017

glusterfs basic

*** information ***
- host1:
- host2:
- /dev/sdc1, on both hosts, and will be used in glusterfs configuration
- update your hosts file or dns server to  match hostname and ip

1- install glusterfs-server on both host
$ sudo apt-get install glusterfs-server

2- format /dev/sdc1 as xfs filesysterm and mount to /mnt on both host
$ sudo mkfs.xfs /dev/sdb1
$ echo '/dev/sdb1 /mnt xfs defaults 1 2' >> /etc/fstab
$ mount -a

3- peering each other to the cluster
- on host1 probe host2
$  gluster peer probe host2
- on host2 probe host1
$  gluster peer probe host1

- if everything is ok, it should display the status on both host, (hostname will be changed depend on host that execute the command)
$ gluster peer status
Number of Peers: 1

Hostname: host1
Uuid: 487d7d5a-b361-4a8a-a5ca-9ff797e889e2
State: Peer in Cluster (Connected)

- we can detach host from cluster with command below
$ gluster detach
$ gluster detach host2

4- now can start create our first volume, call gv0 (execute command on either hosts)
$ gluster volume create gv0 replica 2 host2:/mnt/gv0 host1:/mnt/gv0 

- start the volume
$ gluster volume start gv0

- to get volumes information using the command below
$ gluster volume info

Volume Name: gv0
Type: Replicate
Volume ID: 5035b73e-0f88-437d-8006-22339f7380bf
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Brick1: host2:/data/brick1/gv0
Brick2: host1:/data/brick1/gv0
Options Reconfigured:
nfs.disable: on
performance.readdir-ahead: on
transport.address-family: inet

5- now we can mount the gluster volume to a mount point, so every files created/deleted will replica among those those hosts
$ sudo mount.glusterfs host1:/gv0 /media

$ df -h
host1:/gv0      8.0G   33M  8.0G   1% /media

everything we create on host1, will replica to host2 automatically.

No comments:

Post a Comment