Whilst working on an Exalogic Upgrade I was working with the ZFS
storage and having executed the same commands a number of times I
decided to script them. This short blog entry, although it will
grow over time, contains the scripts I find useful. For each of
the scripts I will simply provide a brief description and the
source of the script and occasionally add the output assuming it
is not too long. Where I need to pass the Hostname / IP Address of
the storage heads the scripts will use the flags (unless otherwise
specified):
- -p <Primary - first storage head>
- -s <Secondary - Second storage head>
I will be using a combinations of simple bash scripts and the
more function ZFS scripting language.
Show Config
Executing this script against one of the storage heads will read
and show all the properties that are current set on the specified
storage head. Simply redirecting the output to a file provides me
with a backup before I execute any modifications.
To run the script you will need to execute the following:
ssh root@<Storage IP> < showConfig.aksh > storageConfig.log
showConfig.aksh
script function processNode(node) { run('cd /'); run(node); printf("*****************************************************\n"); printf("%s\n", node); printf("*****************************************************\n\n"); printf("%s", run('list')); printf("\n\n*****************************************************\n\n"); var nodeChildren = children(); for (var i = 0; i < nodeChildren.length; i++) { processNode(node + "" + nodeChildren[i]); run('cd ..'); } } processNode('');
Show Shares
This script, modified from the ZFS Admin Guide, will display a
list of all Projects/Shares on the storage along with the amount
of spece used and available.
To run the script you will need to execute the following:
ssh root@<Storage IP> < showShares.aksh
showShares.aksh
script run('shares'); projects = list(); printf("%-50s %-10s %-10s\n", "Project/Share", "Used", "Available"); printf("%-50s %-10s %-10s\n", "=============", "====", "========="); for (i = 0; i < projects.length; i++) { run('select ' + projects[i]); shares = list(); for (j = 0; j < shares.length; j++) { run('select ' + shares[j]); share = projects[i] + '/' + shares[j]; used = run('get space_data').split(/\s+/)[3]; available = run('get space_available').split(/\s+/)[3]; printf("%-50s %-10s %-10s\n", share, used, available); run('cd ..'); } run('cd ..'); }
showShares.aksh
[root@slce50cn01 ~]# ssh root@slce50sn01 < showShares.aksh Pseudo-terminal will not be allocated because stdin is not a terminal. Project/Share Used Available ============= ==== ========= ExalogicControl/ExalogicControl 312G 21.9T ExalogicControl/ExalogicPool1 1.28G 21.9T ExalogicControl/ExalogicPool2 31.5K 21.9T ExalogicControl/ExalogicPool3 31.5K 21.9T ExalogicControl/ExalogicPool4 31.5K 21.9T ExalogicControl/ExalogicRepo 1.01T 21.9T ExalogicControl/Exalogic_EnterpriseController 37.5K 21.9T ExalogicControl/Exalogic_OVAB 31.5K 21.9T ExalogicControl/Exalogic_ProxyController 31.5K 21.9T ExalogicControl/Exalogic_RDBMS 31.5K 21.9T
Set NFSv4 Delegation
The following script will set the NFSv4 Delegation flag to false
(recommended) and also the appropriate IPMP values. If you know
the location of the value to set then the following should be easy
to modify.
To run the script you will need to execute the following:
./setIPMPAndNFSV4Delegation.sh [-s <Secondary Storage Node hostname/IP>] [-p <Primary Storage Node hostname/IP>]
setIPMPAndNFSV4Delegation.sh
#!/bin/bash PRIMARY= SECONDARY= while [ $# -gt 0 ] do case "$1" in -p) PRIMARY="$2"; shift;; -s) SECONDARY="$2"; shift;; *) echo ""; echo >&2 \"usage: $0 [-s <Secondary Storage Node hostname/IP>] [-p <Primary Storage Node hostname/IP>] " echo""; exit 1;; *) break;; esac shift done function updateStorage { ssh root@$1 << EOF cd / configuration services ipmp show set interval=5000 set failback=false commit cd / configuration services nfs show set enable_delegation=false commit quit EOF } if [ "$PRIMARY" != "" ] then updateStorage $PRIMARY fi if [ "$SECONDARY" != "" ] then updateStorage $SECONDARY fi