Skip to content

Instantly share code, notes, and snippets.

@cloudrck
Created July 10, 2015 02:04
Show Gist options
  • Save cloudrck/7c75d8ee128a05efe8e4 to your computer and use it in GitHub Desktop.
Save cloudrck/7c75d8ee128a05efe8e4 to your computer and use it in GitHub Desktop.
Debian 8 Jessie GlusterFS Install and Configuration
#!/bin/bash
set -e
# Debian 8 'Jessie' GlusterFS Install
#########
#ToDo:
# * Change guid/suid of mount
# * Give option for cluster type
# * Change variables via command line read
########
# This script assumes you're running as a privileged non-root user
#
OPTIND=1 # Reset in case getopts has been used previously in the shell.
#################
# Change these values
#################
server1="s1.cloudrck.net"
server2="s2.cloudrck.net"
brickd="vdb"
brick="vdb1"
#################
#################
# Dependicies
#################
function install {
echo 'Installing XFSProgs'
sudo apt-get install xfsprogs -y
echo "Formatting Disk $brick"
read -p "Press any key to continue... " -n1 -s
echo -e "o\nn\np\n1\n\n\nw" | sudo fdisk /dev/$brickd
sudo mkfs.xfs -i size=512 /dev/$brick
sudo mkdir -p /data/brick1
echo "/dev/$brick /data/brick1 xfs defaults 1 2" | sudo tee --append /etc/fstab
echo "mounting brick"
sudo mount -a && sudo mount
echo "Setting up Offical GlusterFS repo"
read -p "Press any key to continue... " -n1 -s
echo "Getting GPG key"
wget -O - https://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.2/Debian/jessie/pub.key | sudo apt-key add -
echo 'deb http://download.gluster.org/pub/gluster/glusterfs/3.7/3.7.2/Debian/jessie/apt jessie main' | sudo tee --append /etc/apt/sources.list.d/gluster.list
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install nano curl glusterfs-server -y
}
#Second part after setup on second server
function post_install() {
sudo mkdir /data/brick1/gv0
#Next two functions only on one server
if [[ "$1" -eq 1 ]]; then
echo 'Creating Cluter....'
sudo gluster volume create gv0 replica 2 $server1:/data/brick1/gv0 $server2:/data/brick1/gv0
echo 'Starting Volume...'
read -p "Press any key to continue... " -n1 -s
sudo gluster volume start gv0
fi
}
while getopts "h?ip:" opt; do
case "$opt" in
h|\?)
echo 'help'
exit 0
;;
i)
install
;;
p)
post_install $OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment