GlusterFS Utility Storage Cluster

From GlusterDocumentation

This information is out of date
and does not contain information related to the current version of Gluster

Documentation Home


Utility used to quickly set up clusters of Gluster. This article was last updated for the version 1.2.3 of GlusterFS

Perl script: storage_cluster

Usage:

$ ./storage_cluster [number of server nodes]

Example:

$ ./storage_cluster 4
Starting Storage Cluster with 4 nodes..
Configuring node #0... up! (dir:/home/cfs0 - port:6996)
Configuring node #1... up! (dir:/home/cfs1 - port:6997)
Configuring node #2... up! (dir:/home/cfs2 - port:6998)
Configuring node #3... up! (dir:/home/cfs3 - port:6999)
Mounting partition...
glusterfs:28026 on /home/toad/gfs/glusterfs type fuse (rw,allow_other,default_permissions)

Script:

#! /usr/bin/perl -w

$|=1;
my $nodes = shift @ARGV or die("syntax");
print "Starting Storage Cluster with $nodes nodes..\n";

open UNINSTALL, "> uninstall";
`chmod a+x ./uninstall`;
print UNINSTALL "#! /bin/sh\n";
open CLIENT_CONF, "> client.vol";
my $clientVolumes = ;

# Storage nodes creation
for ($i = 0; $i < $nodes; $i++)
{
   print "Configuring node #$i... ";
       # Creates directory (/home/cfsX)
   $directory = "/home/cfs$i";
   `./create_dir $directory`;
   # Writes volume definition - with a different listening port: 6996+X
   $port = 6996 + $i;
   $config = "./server$i.vol";
   `./gen_server_conf $directory $port > $config`;
   # Launchs server node
   `sudo glusterfsd -f ./server$i.vol`;

   my $volume = "client$i";
   $clientVolumes .= "$volume ";
   print CLIENT_CONF "volume $volume\n";
   print CLIENT_CONF " type protocol/client\n";
   print CLIENT_CONF " option transport-type tcp/client\n";
   print CLIENT_CONF " option remote-host 127.0.0.1\n";
   print CLIENT_CONF " option remote-port $port\n";
   print CLIENT_CONF " option remote-subvolume brick\n";
   print CLIENT_CONF "end-volume\n";

   print "up! (dir:$directory - port:$port)\n";
   print UNINSTALL "rm -f $config\n";
   print UNINSTALL "sudo rm -fr $directory\n";
   print UNINSTALL "echo removed storage node $i files\n";
}
print UNINSTALL "sudo kill `pidof [glusterfsd]`\n";
print UNINSTALL "echo kill all instances of glusterfsd\n";
print UNINSTALL "rm -f client.vol\n";

print UNINSTALL "sudo umount /home/toad/gfs/glusterfs\n";
print UNINSTALL "echo umounted glusterfs partition\n";
print UNINSTALL "rm -f ./uninstall\n";
print UNINSTALL "echo removed configuration file for client\n";

`./gen_client_conf $clientVolumes >> ./client.vol`;

print "Mounting partition...\n";
`sudo glusterfs -f ./client.vol /home/toad/gfs/glusterfs`;
system("mount | tail -1");

Shell script (BASH): create_dir

#! /bin/sh

directory=$1
sudo mkdir $directory
sudo chmod 1777 $directory

Shell script (BASH): gen_server_conf

#! /bin/sh

directory=$1
port=$2

cat <<EOF

volume brick
        type storage/posix
        option directory $directory
        option debug off
end-volume

volume server
        type protocol/server
        option transport-type tcp/server
        option listen-port $port
        option bind-address 127.0.0.1
        subvolumes brick
        option auth.ip.brick.allow 127.0.0.1
end-volume


EOF

Shell script (BASH): gen_client_conf

#! /bin/sh

param=$@
cat <<EOF

volume bricks
  type cluster/unify
  subvolumes $param
  option debug off
  option scheduler rr
end-volume

### Add write-behind feature
volume writebehind
  type performance/write-behind
  option aggregate-size 131072 # unit in bytes
  subvolumes bricks
end-volume

### Add readahead feature
volume readahead
  type performance/read-ahead
  option page-size 65536     # unit in bytes
  option page-count 16       # cache per file  = (page-count x page-size)
  subvolumes writebehind
end-volume

EOF

About

This information is out of date
and does not contain information related to the current version of Gluster

Documentation Home

 

Copyright © Gluster, Inc. All Rights Reserved.