Use GlusterFS to create a shared file system between two servers

Source: Internet
Author: User
Tags glusterfs gluster

Use GlusterFS to create a shared file system between two servers

The problem is that you want to make the files in a directory of the two servers consistent. I have read a method, such as using Rsync to synchronize directories and NFS shared directories. The following describes how to use GlusterFS. I have created several CentOS 7 virtual machines locally.

Virtual Machine
  • Balancer: 192.168.33.60
  • Web1: 192.168.33.61
  • Web2: 192.168.33.62
  • Database: 192.168.33.63
Step 1: edit the hosts file

Connect to web1 and web2 and edit the hosts file:

vi /etc/hosts

Add the following for the hosts files of web1 and web2:

192.168.33.61 web1
192.168.33.62 web2

In this way, web1 knows who web2 is and web2 knows who web1 is.

Step 2: Install GlusterFS

Install GulsterFS on both web1 and web2

curl download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo -o /etc/yum.repos.d/glusterfs-epel.repo yum -y install glusterfs-serversystemctl start glusterdsystemctl enable glusterd
Step 3: interconnect two servers

Run the following command on web1:

gluster peer probe web2

Return Value:

peer probe: success.

Run the following command on web2:

gluster peer probe web1

Return Value:

peer probe: success.
Step 4: create a shared volume

Create a directory for storing files managed by GlusterFS on web1 and web2.

mkdir /gluster-storage

On web1, create a replicable GlusterFS volume volume1 and execute:

gluster volume create volume1 replica 2 transport tcp web1:/gluster-storage web2:/gluster-storage force

Return Value:

volume create: volume1: success: please start the volume to access data

Start the created GlusterFS volume on web1:

gluster volume start volume1

Return Value:

volume start: volume1: success

View the created and started GlusterFS volume and run the following command:

gluster volume info

Return Value:

Volume Name: volume1Type: ReplicateVolume ID: 53ac1214-5dfd-4c6f-82f5-31b16b052cc9Status: StartedNumber of Bricks: 1 x 2 = 2Transport-type: tcpBricks:Brick1: web1:/gluster-storageBrick2: web2:/gluster-storage

Now we have the GlusterFS volume running, and we can mount it below, so that we can use it as the copied file system.

Step 5: Mount shared storage

First mount to web1 and edit fstab:

vi /etc/fstab

Add the following line of code at the bottom of the file. Here, use/storage-pool as the mount point. You can replace it with what you want.

web1:/volume1   /storage-pool   glusterfs defaults,_netdev 0 0

Save and exit. On web1, We can mount the GlusterFS volume to the/storage_pool File System:

mkdir /storage-poolmount /storage-pool

Return Value:

WARNING: getfattr not found, certain checks will be skipped ...)

In this way, a shared volume,/storage-pool, and df-h will be mounted on web1. you will see the mounted file system. What we do on web2.

On web2, edit fstab:

vi /etc/fstab

Add the following line at the bottom of the file and use/storage-pool as the mount point:

web2:/volume1    /storage-pool    glusterfs defaults,_netdev 0 0

Mount the GlusterFS volume on web2 to the/storage_pool:

mkdir /storage-poolmount /storage-pool
Step 6: Test

Test on web1 and web2. For example, you can create a file under the/storage-pool directory on web1 and view it on/storage-pool on web2, then, create a new file and go to the/storage-pool of web1.

Use GlusterFS as KVM backend storage

Distributed Storage System GlusterFS initial experience

GlusterFS globally unified namespace

Design new Xlator extension GlusterFS

GlusterFS Rebalance Analysis

Use Glusterfs in CentOS 6.0-x86_64

For details about GlusterFS, click here
GlusterFS: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.