Skip to content

Commit

Permalink
Release version 0.7.
Browse files Browse the repository at this point in the history
- Force cluster creation
- Allow for definition of which nodes will be storage nodes
- Enable direct-io for GlusterFS backend volumes
- Temporarily comment out NFS functionality
  • Loading branch information
jarrpa committed Jan 18, 2016
1 parent d9820c5 commit 6f989bc
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 47 deletions.
98 changes: 59 additions & 39 deletions src/storage-ha
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ HA_NUM_SERVERS=0
HA_CONF="%CONFDIR/sysconfig/storage-ha.conf"
HA_CONF_INCDIR="%CONFDIR/sysconfig/storage-ha.d/"
CLUSTER_NAME_OPTION=""
HA_SERVERS=""
STORAGE_SERVERS=""
STORAGE_NUM_SERVERS=0

### Cluster functions

Expand Down Expand Up @@ -64,6 +67,8 @@ determine_servers()
IFS=${tmp_ifs}
HA_NUM_SERVERS=${num_servers}
HA_SERVERS="${HA_NODES//,/ }"
STORAGE_SERVERS="${STORAGE_NODES//,/ }"
STORAGE_NUM_SERVERS=$(wc -w <<< "${STORAGE_SERVERS}")
else
ha_servers=$(pcs status | grep "Online:" | grep -o '\[.*\]' | sed -e 's/\[//' | sed -e 's/\]//')
IFS=$' '
Expand All @@ -85,8 +90,8 @@ setup_cluster()

logger "Setting up cluster ${name} on the following servers: ${servers}"

pcs cluster auth ${servers} -u hacluster -p ${HA_PASSWORD}
pcs cluster setup ${CLUSTER_NAME_OPTION} ${name} ${servers}
pcs cluster auth ${servers} -u hacluster -p ${HA_PASSWORD} --force
pcs cluster setup --force ${CLUSTER_NAME_OPTION} ${name} ${servers}
if [ $? -ne 0 ]; then
logger "pcs cluster setup ${CLUSTER_NAME_OPTION} ${name} ${servers} failed"
exit 1;
Expand All @@ -105,6 +110,16 @@ setup_cluster()
done
sleep 1

local tmp_ifs=${IFS}
IFS=$' '
for server in ${STORAGE_SERVERS:-$HA_SERVERS} ; do
pcs property set --node $server role=storage
if [ $? -ne 0 ]; then
logger "warning: pcs property set --node $server role=storage failed"
fi
done
IFS=${tmp_ifs}

if [ ${num_servers} -lt 3 ]; then
pcs property set no-quorum-policy=ignore
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -173,17 +188,19 @@ setup_create_resources()
device="localhost:/$HA_SMB_VOL" \
directory="/gluster/lock" \
fstype="glusterfs" \
options="_netdev,defaults,transport=tcp,xlator-option=*client*.ping-timeout=10" \
--clone ctdb_lock-clone ctdb_lock meta interleave="true"
options="_netdev,defaults,direct-io-mode=enable,transport=tcp,xlator-option=*client*.ping-timeout=10" \
--clone ctdb_lock-clone ctdb_lock meta interleave="true" clone-max="${STORAGE_NUM_SERVERS}"

mkdir -p /gluster/state
pcs -f $cibfile resource create ganesha_state ocf:heartbeat:Filesystem \
params \
device="localhost:/$HA_NFS_VOL" \
directory="/gluster/state" \
fstype="glusterfs" \
options="_netdev,defaults,transport=tcp,xlator-option=*client*.ping-timeout=10" \
--clone ganesha_state-clone ganesha_state meta interleave="true"
pcs -f $cibfile constraint location ctdb_lock-clone rule resource-discovery=exclusive score=0 role eq storage

# mkdir -p /gluster/state
# pcs -f $cibfile resource create ganesha_state ocf:heartbeat:Filesystem \
# params \
# device="localhost:/$HA_NFS_VOL" \
# directory="/gluster/state" \
# fstype="glusterfs" \
# options="_netdev,defaults,direct-io-mode=enable,transport=tcp,xlator-option=*client*.ping-timeout=10" \
# --clone ganesha_state-clone ganesha_state meta interleave="true" clone-max="${STORAGE_NUM_SERVERS}"

pcs cluster cib-push $cibfile
if [ $? -ne 0 ]; then
Expand All @@ -202,44 +219,45 @@ setup_create_resources()
op monitor interval="10" timeout="30" \
op start interval="0" timeout="90" \
op stop interval="0" timeout="100" \
--clone ctdb-clone ctdb meta interleave="true" globally-unique="false"
--clone ctdb-clone ctdb meta interleave="true" globally-unique="false" clone-max="${STORAGE_NUM_SERVERS}"

# CTDB: We need our shared recovery lock file
pcs -f $cibfile constraint colocation add ctdb-clone with ctdb_lock-clone INFINITY
pcs -f $cibfile constraint order ctdb_lock-clone then ctdb-clone INFINITY

# Samba
pcs -f $cibfile resource create nmb lsb:nmb \
pcs -f $cibfile resource create nmb systemd:nmb \
op start timeout="60" interval="0" \
op stop timeout="60" interval="0" \
op monitor interval="60" timeout="60"
pcs -f $cibfile resource create smb lsb:smb \
pcs -f $cibfile resource create smb systemd:smb \
op start timeout="60" interval="0" \
op stop timeout="60" interval="0" \
op monitor interval="60" timeout="60"
pcs -f $cibfile resource group add samba-group nmb smb
pcs -f $cibfile resource clone samba-group meta interleave="true"
pcs -f $cibfile resource clone samba-group meta interleave="true" clone-max="${STORAGE_NUM_SERVERS}"

# Samba: We need CTDB
pcs -f $cibfile constraint colocation add samba-group-clone with ctdb-clone INFINITY
pcs -f $cibfile constraint order ctdb-clone then samba-group-clone INFINITY

# Ganesha
pcs -f $cibfile resource create ganesha ganesha \
params \
config="/etc/glusterfs-ganesha/nfs-ganesha.conf" \
--clone ganesha-clone ganesha meta interleave="true" \
globally-unique="false" \
notify="true"

# Ganesha: We need our shared state FS
pcs -f $cibfile constraint colocation add ganesha-clone with ganesha_state-clone INFINITY
pcs -f $cibfile constraint order ganesha_state-clone then ganesha-clone INFINITY

pcs cluster cib-push $cibfile
if [ $? -ne 0 ]; then
logger "Failed to create service resources."
exit 0
fi
# pcs -f $cibfile resource create ganesha ganesha \
# params \
# config="/etc/glusterfs-ganesha/nfs-ganesha.conf" \
# --clone ganesha-clone ganesha meta interleave="true" \
# globally-unique="false" \
# notify="true"
#
# # Ganesha: We need our shared state FS
# pcs -f $cibfile constraint colocation add ganesha-clone with ganesha_state-clone INFINITY
# pcs -f $cibfile constraint order ganesha_state-clone then ganesha-clone INFINITY
#
# pcs cluster cib-push $cibfile
# if [ $? -ne 0 ]; then
# logger "Failed to create service resources."
# exit 0
# fi

# Virtual IPs
local ipcount=0
Expand All @@ -252,13 +270,15 @@ setup_create_resources()
op monitor interval=60s \
meta resource-stickiness="0"

pcs -f $cibfile resource create vip${ipcount}_trigger ocf:heartbeat:ganesha_trigger \
params \
ip=${ip} \
meta resource-stickiness="0"
pcs -f $cibfile constraint location vip${ipcount} rule resource-discovery=exclusive score=0 role eq storage

# pcs -f $cibfile resource create vip${ipcount}_trigger ocf:heartbeat:ganesha_trigger \
# params \
# ip=${ip} \
# meta resource-stickiness="0"

pcs -f $cibfile constraint colocation add vip${ipcount}_trigger with vip${ipcount} INFINITY
pcs -f $cibfile constraint order vip${ipcount} then vip${ipcount}_trigger
# pcs -f $cibfile constraint colocation add vip${ipcount}_trigger with vip${ipcount} INFINITY
# pcs -f $cibfile constraint order vip${ipcount} then vip${ipcount}_trigger
done

pcs cluster cib-push $cibfile
Expand Down Expand Up @@ -337,7 +357,7 @@ case "${cmd}" in
determine_servers "setup"

if [ ${HA_NUM_SERVERS} -gt 1 ]; then
setup_state_volume ${HA_SERVERS}
# setup_state_volume ${HA_SERVERS}
setup_cluster ${HA_NAME} ${HA_NUM_SERVERS} "${HA_SERVERS}"
setup_create_resources ${HA_SERVERS}
else
Expand Down
Binary file removed src/storage-ha-0.6.tar.gz
Binary file not shown.
Binary file added src/storage-ha-0.7.tar.gz
Binary file not shown.
6 changes: 5 additions & 1 deletion src/storage-ha.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ HA_NAME="storage-ha"
# Password of the hacluster user
HA_PASSWORD="hacluster"

# The server on which cluster-wide ocnfiguration is managed.
# The server on which cluster-wide configuration is managed.
# IP/Hostname
HA_SERVER="server1"

# The set of nodes that forms the HA cluster.
# Comma-deliminated IP/Hostname list
HA_NODES="server1,server2,..."

# [OPTIONAL] A subset of HA nodes that will serve as storage servers.
# Comma-deliminated IP/Hostname list
STORAGE_NODES="server2,..."

# Virtual IPs of each of the nodes specified above.
# Whitespace-deliminated IP address list
HA_VIPS="10.x.x.x 10.x.x.x"
Expand Down
50 changes: 43 additions & 7 deletions src/storage-ha.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%define major_version 0
%define minor_version 6
%define minor_version 7
%define release 1%{?dist}

Name: storage-ha
Expand All @@ -16,8 +16,12 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root
Source0: %{name}-%{version}.tar.gz

Requires: glusterfs-server
%if %{defined rhel} && %{rhel} < 7
Requires: cman
Requires: pacemaker
%else
Requires: fence-agents-all
%endif
Requires: pcs

%description
Expand Down Expand Up @@ -47,7 +51,7 @@ High-Availability SMB add-on for storage servers


%prep
%setup -q -c
%setup -q -n %{name}

%install
%{__rm} -rf %{buildroot}
Expand All @@ -67,6 +71,19 @@ install -m 0755 ganesha %{buildroot}%{_prefix}/lib/ocf/resource.d/heartbeat/gane
install -m 0755 ganesha_trigger %{buildroot}%{_prefix}/lib/ocf/resource.d/heartbeat/ganesha_trigger

%post
%if %{defined rhel} && %{rhel} < 7
chkconfig corosync off
chkconfig pacemaker on
chkconfig pcsd on
service pcsd start
%else
systemctl start pcsd.service
systemctl enable pcsd.service
%endif


%post smb
%if %{defined rhel} && %{rhel} < 7
chkconfig ctdb off
chkconfig smb off
chkconfig nmb off
Expand All @@ -75,26 +92,36 @@ service ctdb stop
service smb stop
service nmb stop
service winbind stop
%else
systemctl stop ctdb smb nmb winbind
systemctl disable ctdb smb nmb winbind
%endif

%post nfs
%if %{defined rhel} && %{rhel} < 7
chkconfig nfs-server off
chkconfig nfs-lock off
service nfs-server stop
service nfs-lock stop
%else
systemctl stop nfs-server nfs-lock
systemctl disable nfs-server nfs-lock
%endif

[ -d /var/lib/nfs.backup ] || mv /var/lib/nfs /var/lib/nfs.backup
[ -d /var/lib/nfs ] && rm -rf /var/lib/nfs
ln -s /gluster/state/`hostname`/nfs /var/lib/nfs

if [[ ! -f /etc/dbus-1/system.d/org.ganesha.nfsd.conf ]]; then
cp /etc/glusterfs-ganesha/org.ganesha.nfsd.conf /etc/dbus-1/system.d/
%if %{defined rhel} && %{rhel} < 7
service messagebus restart
%else
systemctl restart messagebus
%endif
fi

chkconfig pacemaker on
chkconfig pcsd on
service pcsd start

%postun
%postun nfs
if [ -d /var/lib/nfs.backup ]; then
rm -rf /var/lib/nfs
mv /var/lib/nfs.backup /var/lib/nfs
Expand All @@ -121,6 +148,15 @@ fi


%changelog
* Mon Jan 18 2016 Jose A. Rivera <[email protected]> - 0.7-1
- Force cluster creation
- Allow for definition of which nodes will be storage nodes
- Enable direct-io for GlusterFS backend volumes
- Temporarily comment out NFS functionality

* Thu Nov 19 2015 Jose A. Rivera <[email protected]> - 0.6-2
- Add functionality for EL7

* Thu Apr 23 2015 Jose A. Rivera <[email protected]> - 0.6-1
- Properly update CIB file during cluster creation
- Better tempfile handling
Expand Down

0 comments on commit 6f989bc

Please sign in to comment.