Exalogic 2.0.1 Tea Break Snippets - Some Simple ZFS Scripts

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

Snapshot ZFS Project or Share

This script will allow you to create a snapshot of a ZFS Project or Share on the internal storage. You have the option of specifying the Snapshot name but if this is not supplied it will default to a date stamped name.

To run the script you will need to execute the following:

snapshotZFS.sh -ip <Storage Node hostname/IP> -p <Project Name> [-s <Share Name>] [-n <Snapshot Name>]

snapshotZFS.sh

#!/bin/bash

BAK_EXT=`date +"%Y%m%d-%H%M%S"`
PROJECT=""
SHARE=""
IPADDRESS=""
SNAPSHOTNAME="SnapShot-$BAK_EXT"

while [ $# -gt 0 ]
do
 case "$1" in 
 -ip) IPADDRESS="$2"; shift;;
 -p) PROJECT="$2"; shift;;
 -s) SHARE="$2"; shift;;
 -n) SNAPSHOTNAME="$2"; shift;;
 *) echo ""; echo >&2 \
 "usage: $0 -ip <Storage Node hostname/IP> -p <Project Name> [-s <Share Name>] [-n <Snapshot Name>] "
 echo""; exit 1;;
 *) break;;
 esac
 shift
done

if [ "$IPADDRESS" == "" ]
then
 echo "IP Address or Hostname of the Storage must be provided"
 exit 1
fi

if [ "$PROJECT" == "" ]
then
 echo "Project name must be provided"
 exit 1
fi

echo $SNAPSHOTNAME

ssh root@$IPADDRESS <<EOF
script
 try {
 run('cd /');
 run('shares');
 run('select $PROJECT');
 printf('%s\n', run('list'));
 try {
 run('select $SHARE');
 } catch (e) {
 }
 run('snapshots');
 run('snapshot $SNAPSHOTNAME');
 
 } catch (err) {
 if (err.code == EAKSH_ENTITY_BADSELECT) {
 printf('ERROR: "$SHARE" is not a share in the "$PROJECT" project\n');
 } else {
 printf('ERROR: (%s)\n', err.message);
 }
 }
EOF

This entry was originally posted on the The Old Toxophilist Site.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The primary contributors to this blog are comprised of the Exalogic and Cloud Application Foundation contingent of Oracle's Fusion Middleware Architecture Team, fondly known as the A-Team. As part of the Oracle development organization, The A-Team supports some of Oracle's largest and most strategic customers worldwide. Our mission is to provide deep technical expertise to support various Oracle field organizations and customers deploying Oracle Fusion Middleware related products. And to collect real world feedback to continuously improve the products we support. In this blog, our experts and guest experts will focus on Exalogic, WebLogic, Coherence, Tuxedo/mainframe migration, Enterprise Manager and JDK/JRockIT performance tuning. It is our way to share some of our experiences with Oracle community. We hope our followers took away something of value from our experiences. Thank you for visiting and please come back soon.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today