How to create a replicated GlusterFS volume

A replicated GlusterFS volume is the direct choice when a shared volume must keep serving data after one brick or server fails. Each file is stored on every brick in the replica set, so the volume creation step must pair bricks across separate failure domains rather than simply list any empty directories.

The gluster volume create command writes the volume definition into the trusted storage pool, but the volume remains inaccessible until it is started. The replica count controls how many full copies are stored, and the listed bricks form the replica set for this focused non-distributed layout.

Use dedicated brick filesystems and consistent node names before creating the volume. A two-way replica can keep serving data after one replica member is unavailable, but it has less split-brain protection than a three-way or arbiter design, so choose the replica count before client data is written.

Steps to create a replicated GlusterFS volume:

  1. Check peer connectivity from a trusted-pool node.
    $ sudo gluster peer status
    Number of Peers: 1
    
    Hostname: node2
    Uuid: 0f8b8d42-8d5f-4d19-9a1f-2c1d4d7b9b10
    State: Peer in Cluster (Connected)
  2. Create the brick directory on each replica node.
    $ sudo mkdir -p /srv/gluster/volume1/brick

    Use an empty directory on a dedicated brick filesystem. Creating a brick on the system root filesystem can fill the operating system volume and may require unsafe force usage.

  3. Create the replicated volume from separate peer nodes.
    $ sudo gluster volume create volume1 replica 2 transport tcp node1:/srv/gluster/volume1/brick node2:/srv/gluster/volume1/brick
    volume create: volume1: success: please start the volume to access data

    Keep every brick in the replica set on a different server or failure domain. GlusterFS can reject same-peer replica layouts unless force is appended, and forcing that layout reduces fault tolerance.

  4. Start the replicated volume.
    $ sudo gluster volume start volume1
    volume start: volume1: success
  5. Verify the volume type and brick layout.
    $ sudo gluster volume info volume1
    Volume Name: volume1
    Type: Replicate
    Status: Started
    Number of Bricks: 1 x 2 = 2
    Transport-type: tcp
    Bricks:
    Brick1: node1:/srv/gluster/volume1/brick
    Brick2: node2:/srv/gluster/volume1/brick
  6. Check that the brick processes are online.
    $ sudo gluster volume status volume1
    Status of volume: volume1
    Gluster process                             TCP Port  RDMA Port  Online  Pid
    ------------------------------------------------------------------------------
    Brick node1:/srv/gluster/volume1/brick      49152     0          Y       2148
    Brick node2:/srv/gluster/volume1/brick      49153     0          Y       1987
    Self-heal Daemon on node1                   N/A       N/A        Y       1763
    Self-heal Daemon on node2                   N/A       N/A        Y       1814
    
    Task Status of Volume volume1
    ------------------------------------------------------------------------------
    There are no active volume tasks
  7. Create a temporary mount point on a Linux client.
    $ sudo mkdir -p /mnt/volume1
  8. Mount the new volume from the client.
    $ sudo mount -t glusterfs node1:/volume1 /mnt/volume1
  9. Write a smoke-test file through the client mount.
    $ sudo touch /mnt/volume1/replica-test.txt
  10. Verify the smoke-test file is visible on the mounted volume.
    $ ls -l /mnt/volume1/replica-test.txt
    -rw-r--r-- 1 root root 0 Jun 16 10:30 /mnt/volume1/replica-test.txt
  11. Remove the smoke-test file after verification.
    $ sudo rm /mnt/volume1/replica-test.txt
  12. Unmount the manual client test mount.
    $ sudo umount /mnt/volume1
  13. Remove the temporary mount point.
    $ sudo rmdir /mnt/volume1