12
Scripts for Configuring IP Multipathing in Oracle Solaris  Prashant Pilankar, April 2010

Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

Embed Size (px)

Citation preview

Page 1: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 1/12

Scripts for Configuring

IP Multipathing

in Oracle Solaris Prashant Pilankar, April 2010

Page 2: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 2/12

Introduction

This tech tip provides a main script and several subscripts that are useful for configuring IP Multipathing in the

Oracle Solaris operating system. The scripts can be modified as needed and can be used to perform the

following tasks:

• Displaying prerequisite information prior to IPMP configuration

• Configuring unique MAC addresses (SPARC systems only)

• Configuring IP addresses

• Configuring the interface as part of a multipath group

• Configuring a test address for the interface

• Verifying link-based IPMP operation

• Making the IPMP configuration persistent across reboot

Note: All the scripts work on both SPARC and x86 machines, with the exception of the script for configuring

unique MAC addresses. That script works only on SPARC systems.

This tech tip covers the following topics:

• Screen Shots From Running the Main Script

• Code for the Scripts

• About the Author 

Screen Shots From Running the Main Script

This section contains screen shots that show how to use the main script, ipmpconf, for performing various

tasks.

First, here is a screen shot of the menu provided by the ipmpconf script:

Task 1: Displaying Prerequisite Information Prior to IPMP Configuration

Page 3: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 3/12

Select option 1 in the script.

Task 2: Configuring Unique MAC Addresses (SPARC Systems Only)

Select option 2 in the script.

Note: Option 2 is capable of configuring unique MAC addresses only on SPARC systems. Its functionality

works fine, but I was not able to provide a screen shot for it because I only have a test Oracle Solaris instance

running on an x86 system with VMware.

Task 3: Configuring IP Addresses

Select option 3 in the script.

Page 4: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 4/12

Task 4: Configuring the Interface as Part of a Multipath Group

Select option 4 in the script.

Page 5: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 5/12

Task 5: Configuring a Test Address for the Interface

Select option 5 in the script.

Page 6: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 6/12

Let's add one more interface as part of the multipath group:

Let's add a test address for the interface:

Task 6: Verifying Link-based IPMP Operation

Page 7: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 7/12

Select option 6 in the script.

It seems I have missed the task of making the IPMP configuration persistent across reboot. So next I add the

missing task before I reveal the logic of the script.

Task 7: Making This IPMP Configuration Persistent Across Reboot

Select option 7 in the script.

Page 8: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 8/12

Initially, let's update the /etc/hostname.<interface> file for the e1000g2 interface.

 Now let's update the /etc/hostname.<interface> file for the e1000g1 interface:

The following files got created and updated:

/etc/hostname.e1000g2sys11 netmask + broadcast + group mpgrp-one up addif sys11-test-e1000g2 deprecatednetmask + broadcast + -failover up

Page 9: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 9/12

/etc/hostname.e1000g1sys11-data-e1000g1 netmask + broadcast + group mpgrp-one up addif sys11-test-e1000g1deprecated netmask + broadcast + -failover up

Task 8: Exiting From the Main Script

Select option 8 from the menu.

Code for the Scripts

 Now that we have seen how to use the main ipmpconf script, let's have a look at the code for all the scripts.

Here's a link to the ipmp_scripts.zip  file , which contains the source code for the main script and the

subscripts.

To use the scripts, do the following:

1. Unzip the .zip file.

2. Place the subscripts in the same directory where you place the main ipmpconf script.

3. Modify the path in the main script as needed, so it points to the directory where you placed the scripts.

(Currently, /export/home/pilankar/ipmp_scripts is used in the script.)

Here are the scripts inline, so you can review them:

First, here's the main ipmpconf script:

#!/usr/bin/bash#Version 1.0#Author: Prashant Pilankar#Email : [email protected]# Script for IP Multipathing Configuration in Solaris OS

tput civis # Turn off the cursor

while [ 1 ]do

echo -e '\E[42;38m' # Set colors: bg=blue, fg=whiteclear # Note: colors may be different in xtermsecho -e '\E[44;38m' # bg=red

for n in `seq 6 20`do

tput cup $n 15echo " "

donetput cup 6 25 ; echo -n " ******Please Ensure to be Root Prior to Executing this

Script******* "echo -ne '\E[45;38m' # bg=magentatput cup 8 25 ; echo -n " ***********I P M P C O N F I G U R A T I O N M A I N

M E N U*************** "echo -e '\E[44;38m' # bg=red

tput cup 9 25 ; echo -n " --------------------------------------------------------"

tput cup 10 25 ; echo -n " |1. Pre-requisites Information for IPMP Configuration|"

tput cup 11 25 ; echo -n " |2. Configure Unique MAC Addresses (Sparc Only)|"

Page 10: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 10/12

tput cup 12 25 ; echo -n " |3. Configure the IP Addresses|"

tput cup 13 25 ; echo -n " |4. Configure the Interface as Part of a Multipath Group|"

tput cup 14 25 ; echo -n " |5. Configure a Test Address for the Interface|"

tput cup 15 25 ; echo -n " |6. Verify Link-based IPMP Operation|"

tput cup 16 25 ; echo -n " |7. Make Persistent IPMP Settings

|" tput cup 17 25 ; echo -n " |8. I do not know !|"

tput cup 18 25 ; echo -n " --------------------------------------------------------"read case;#simple case bash structure# note in this case $case is variable and does not have to# be named case this is just an examplecase $case in

1) /export/home/pilankar/ipmp_scripts/info.sh;;2) /export/home/pilankar/ipmp_scripts/umac.sh;;3) /export/home/pilankar/ipmp_scripts/hupdate.sh;;4) /export/home/pilankar/ipmp_scripts/datanic.sh;;5) /export/home/pilankar/ipmp_scripts/testnic.sh;;6) /export/home/pilankar/ipmp_scripts/vlbipmp.sh;;7) /export/home/pilankar/ipmp_scripts/pipmp.sh;;8) exit

esacdone

Following are the subscripts that are called from the main ipmpconf script.

Code for info.sh subscript:

#!/usr/bin/bash

#Script to display the current Interface Configuration and OS Release#Author: Prashant Pilankarecho"======================================================================================================="echo " `tput smso` Network Interfaces Configured `tputrmso`"echo -e "\033[32m `/usr/sbin/ifconfig -a` \e[m" ; sleep 4echo " `tput smso` Solaris OS Release `tput rmso`"echo -e "\033[32m `cat /etc/release` \e[m" ; sleep 4echo " `tput smso` Contents of /etc/default/mpathd file`tput rmso`"echo -e "\033[32m `cat /etc/default/mpathd ` \e[m" ; sleep 4echo"======================================================================================================="

Code for umac.sh subscript:

#!/usr/bin/bash#Script to set the local-mac-address? variable to true only for sparc systems#Author: Prashant Pilankarecho -e "\033[41m Following is the existing value of the local-mac-address? variable onsparc system \e[m"eeprom "local-mac-address?"echo "Would you like to continue to set the variable to true (y/n)?"

read fif [ $f = y ]then

eeprom "local-mac-address?=true" ; echo "now the variable value is set to" ; eeprom"local-mac-address?" ; sleep 5

Page 11: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 11/12

elseecho "bye for now " ; sleep 4 ; exit

fi

Code for hupdate.sh subscript:

#!/usr/bin/bash#Script to update the /etc/inet/hosts file for ipmp#Author: Prashant Pilankar

echo -e "\033[44m Add the data and test IP addresses to the /etc/inet/hosts file for thesake of clarity \e[m"echo "Please input the following information"echo "IP Address"echo "Associated hostname"echo "Comment"echo "==================================================================="echo -e "\033[41m Example : 192.168.1.1 sys11 # Data address for hme0 \e[m"echo "==================================================================="read a b cecho $a $b $c >> /etc/inet/hostsechoecho -e "\033[45m Following are the contents of the /etc/inet/hosts file \e[m"

cat /etc/inet/hosts ; sleep 5

Code for datanic.sh subscript:

#!/usr/bin/bash#Script to configure a interface as part of a Multipath group#Author: Prashant Pilankarecho -e "\033[41m This script assumes the /etc/inet/hosts & /etc/inet/netmasks file's areupdated \e[m"echo -e "\033[41m Please input the following information \e[m"echo "Interface Name"echo "Name of the Multipath group"

echo "Hostname associated with the interface"echo "==================================================================="echo -e "\033[44m Example : hme0 mpgrp-one sys11 \e[m"echo "==================================================================="read a b c

echo "Is the interface already plumbed and up (y/n)?"read f

if [ $f = y ]then

ifconfig $a group $b &> /dev/null ; ifconfig -a ; sleep 6elseifconfig $a plumb $c netmask + broadcast + &> /dev/null ; ifconfig $a group $b up

&> /dev/null ; ifconfig -a ; sleep 6fi

Code for testip.sh subscript:

#!/usr/bin/bash#Script to configure a interface as part of a Multipath group#Author: Prashant Pilankarecho -e "\033[44m This script assumes the /etc/inet/hosts file is updated \e[m"echo -e "\033[44m Please input the following information \e[m"echo "Interface Name"echo "Test Address of the Interface"echo "==================================================================="echo -e "\033[41m Example : hme0 192.168.1.51 \e[m"echo "==================================================================="read a b

Page 12: Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

8/8/2019 Scripts for Configuring IP Multi Pa Thing in Oracle Solaris

http://slidepdf.com/reader/full/scripts-for-configuring-ip-multi-pa-thing-in-oracle-solaris 12/12

ifconfig $a addif $b deprecated netmask + broadcast + -failover up &> /dev/null ; echo"===========================" ; ifconfig -a ; sleep 5

Code for vlbipmp.sh subscript:

#!/usr/bin/bash#Script to Verify Link-based IPMP Operation#Author: Prashant Pilankarecho -e "\033[44m Please input the following Information to Verify Link-based IPMP

Operation \e[m"echo "Interface Name"echo "=========================================="echo -e "\033[41m Example : hme0 \e[m"echo "=========================================="read aif_mpadm -d $a ; echo -e "\033[45m Following is the NIC Configuration after the forcedFailover \e[m" ; ifconfig -aecho " `tput smso` Recent update to /var/adm/messages file `tput rmso`" ; tail -2 /var/adm/messagesecho "========Please Wait forcing Failback===========" ; sleep 6if_mpadm -r $a ; echo -e "\033[45m Following is the NIC Configuration after the forcedFailback \e[m" ; ifconfig -a ; sleep 6

echo " `tput smso` Recent update to /var/adm/messages file `tput rmso`" ; tail -2 /var/adm/messagesecho "========================================================"

Code for pipmp.sh subscript:

#!/usr/bin/bash#This script makes the IPMP Settings persistent across reboot#Author: Prashant Pilankarecho -e "\033[44m This script updates the /etc/hostname.<interface> files forPersistent IPMP Settings \e[m"echo -e "\033[44m Please input the following information for each \e[m"

echo -e "\033[44m Physical Interface part of the IPMP group \e[m"echo "Hostname Associated With the Physical Interface"echo "IPMP groupname"echo "Hostname Associated with the Test Interface"echo "============================================================"echo -e "\033[45m Example : hme0 sys11 mpgrp-one sys11-test-hme0 \e[m"echo "============================================================"read a b c dtouch /etc/hostname.$aecho "`echo $b` netmask + broadcast + group `echo $c` up addif `echo $d` deprecatednetmask + broadcast + -failover up" > /etc/hostname.$aecho -e "\033[45m Following are the updates made to the file /etc/hostname.`echo $a`\e[m"

cat /etc/hostname.$a ; sleep 5

About the Author

Prashant Shashikant Pilankar has been a Solaris System Administrator for nearly nine years. He has experience

in Veritas Volume Manger and Basic Veritas Cluster and Basic Veritas NetBackup from Symantec, plus several

IT certifications, including the Solaris OS, Veritas, Oracle, Cisco, and Microsoft technology.