How to Glusterfs in Centos 7
1. Setup glusterfs on server
The setup need to be setup in every each server
Install the repo:
yum -y install epel-release yum -y install yum-priorities yum -y install centos-release-gluster
Install the Glusterfs:
yum -y install glusterfs-server gluster*
Start Glusterfs:
systemctl enable glusterd.service systemctl start glusterd.service
Do this setup in Node1
~Note : Node1 = adi.ot Node2 = davi.ot (These are hostname)
gluster peer probe davi.ot
Check if node1 and node2 are connected:
gluster peer status
Output node1:
Number of Peers: 1 Hostname: adi.ot Uuid: bcdd0750-f850-4c16-95b5-5873b4e18666 State: Peer in Cluster (Connected)
Output node2:
Number of Peers: 1 Hostname: davi.ot Uuid: bqqd0150-d750-4c16-15c5-5873r4e18111 State: Peer in Cluster (Connected)
If you wanted to create shared volume replicated:
gluster volume create nostra replica 2 transport tcp adi.ot:/mnt/data davi.ot:/mnt/data force
If you wanted to create shared volume Distributed:
gluster volume create nostra adi.ot:/mnt/data davi.ot:/mnt/data force
Start the volume that we have been created:
gluster volume start nostra
Check if we have been connected:
gluster volume info
Output:
Volume Name: nostra Type: Replicate Volume ID: 0d0fd355-3531-40f4-999d-0b2e1f3976a1 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 2 = 2 Transport-type: tcp Bricks: Brick1: adi.ot:/mnt/data Brick2: davi.ot:/mnt/data Options Reconfigured: transport.address-family: inet
2. Setup glusterfs on Client
Install glusterfs for client:
yum -y install glusterfs-client glusterfs glusterfs-fuse attr
Create mount folder:
mkdir /opt/data
Mount the folder:
mount glusterfs adi.ot:nostra /opt/data
Check if it's already connected:
df -h
Output:
Filesystem Size Used Avail Use% Mounted on /dev/sda2 31G 1,6G 28G 6% / devtmpfs 911M 0 911M 0% /dev tmpfs 920M 0 920M 0% /dev/shm tmpfs 920M 8,4M 912M 1% /run tmpfs 920M 0 920M 0% /sys/fs/cgroup /dev/sda1 976M 266M 644M 30% /boot tmpfs 184M 0 184M 0% /run/user/0 adi.ot:nostra 31G 1,8G 28G 6% /opt/data
Check if the mounting is succed:
touch /opt/data/testingFile.txt
~Automatic Mounting
Open fstab file:
nano /etc/fstab
Use this code so that your Glusterfs mounting automatically when machine is rebooted:
adi.ot:nostra /opt/data glusterfs defaults,_netdev 0 0
3. See the file that created by client in server
Try this command on node1 and node2:
ll /mnt/data
Output:
testingFile.txt
Komentar
Posting Komentar