Scripting Storage Management Solutions with Hitachi Device Manager Software October 31, 2007 Craig Chan Software Design Manager 2007 Hitachi Data Systems
Welcome to the WebTech Series Series of webcasts targeted specifically toward the more technical user of Hitachi solutions Goals: Maximize the potential from your existing IT infrastructure Deploy best-in-class techniques for storage and storage management Benefit from real-life before and after scenarios Webcasts are once or twice a month suggestions welcome for upcoming sessions View entire schedule and register at www.hds.com/webtech 2
What We Will be Covering How to download and install HiCommand Command Line Interface (CLI) for Device Manager Testing your installation with a few simple commands Editing the properties file to simplify commands Creating some batch scripts to execute on demand Using the system scheduler to run batch scripts periodically Using the CLI Batch and understanding its benefits 3
Key Functions in the CLI RefreshStorageArrays/AddStorageArray These commands let you get the latest information from the arrays. To get the latest information from all arrays, use RefreshStorageArrays. Be aware this will take a lot of time for Device Manager instances with several arrays to manage. To get the latest information from a specific array, use the AddStorageArray with a specific array to update the information for that array only. GetStorageArray This command retrieves details about the storage subsystem already registered with the HiCommand Device Manager. Array Group Filter FreeSpace HostStorageDomain Journal Pool LDEV LogicalDKC LogicalUnit Path PDEV GetServerInfo Port Returns information about your Device Manager installation including version information and registered arrays. 4
More Functions in the CLI - Provisioning AddHostStorageDomain Creates a Host Storage Domain to add LUNs to. AddWWNForHostStorageDomain Adds world wide names from the host to ensure only that host can access the LUNs. AddLun This command creates a path from the host to the volume (logical unit). This command is use to allocate storage to a host. AddArrayReservation Locks the array so other users can t interfere with resources you are about to use. DeleteArrayReservation Removes your lock on the array so other users can once again manage the array. You should always do this after you are done. 5
Getting Started Installing the CLI Download the CLI package to any host machine 6
Getting Started Download Install Files Choose the installation files for you platform The CLI requires the JRE as well HDvM has specific JRE requirements which may not be easily found on the link provided. It s often easier to search for the right JRE version online instead. Install the files on the host of your choosing Ensure communication with the server is available Check ports Confirm LAN settings 7
Test a Command Try retrieving some information using GetServerInfo C:\HiCommandCLI http://192.168.101.1:2001/service GetServerInfo u system p manager RESPONSE: An instance of ServerInfo serverversion=hicommand Device Manager Server v5.8 Build 0580-03 (Aug 27, 2007) serverurl=http://localhost:2001 uptime=35 minutes 26 seconds upsince=thu, 25 Oct 2007 16:50:24 GMT currentapiversion=5.8 license=0 List of 3 StorageArray elements: An instance of StorageArray arrayfamily=ams/wms displayarrayfamily=ams/wms An instance of StorageArray arrayfamily=usp displayarrayfamily=usp An instance of StorageArray arrayfamily=r600 displayarrayfamily=usp_v 8
Test Another Command Usually we refresh the storage array to make sure we have the latest information C:\HiCommandCLI http://192.168.101.1:2001/service AddStorageArray ipaddress=172.16.100.1 family=usp u system p manager 9 RESPONSE: An instance of StorageArray objectid=array.usp.15050 name=usp@172.16.100.1 description=usp (15050) at 172.16.100.1 serialnumber=15050 arrayfamily=usp arraytype=usp microcodeversion=50-09-00/00 agentversion=04_09_00 productname=raid500 controllerversion=50-09-00-00/00 numberofcontrollers=1 capacityingb=7,847 cacheinmb=32,768 sharedmemoryinmb=-1 numberofsparedrives=-1 freecapacityingb=5,290 allocatedcapacityingb=2,530
Too Much Typing Everything works, but notice we tend to type the same things over and over. We keep typing the URL to point to the server the commands are sent to. And we keep typing the username and password to perform the commands as. C:\HiCommandCLI http://192.168.101.1:2001/service GetSystemInfo u system p manager C:\HiCommandCLI http://192.168.101.1:2001/service AddStorageArray ipaddress=172.16.100.1 family=usp u system p manager We can simplify this by putting these settings in the HiCommandCLI.properties file. 10
Editing the Properties File Edit the HiCommandCLI.properties file in the CLI directory Make sure the URL points to your Device Manager Server ################################# # # Device Manager Command Line Interface (CLI) Properties File # # Can be used to provide options and default parameters for the # Device Manager CLI program. # # The Device Manager CLI program does not require any of the properties to be set. <snip!> # set the server url #HiCommandCLI.serverurl=http://localhost:2001/service HiCommandCLI.serverurl=http://172.16.100.1:2001/service ##### OPTIONS #### #user=khalsa # password can be provided directly, or from a password file #password=khalsa #password=@d:\\devicemanager\\.passwd <snip!> 11
Editing the Properties File Change the username to the one you want to execute the commands Change the password to correspond to that user. ################################# # # Device Manager Command Line Interface (CLI) Properties File # # Can be used to provide options and default parameters for the # Device Manager CLI program. # # The Device Manager CLI program does not require any of the properties to be set. <snip!> # set the server url HiCommandCLI.serverurl=http://172.16.100.1:2001/service ##### OPTIONS #### user=system #user=khalsa Note: Passwords should not be included in clear text in this file. We are doing this for demonstration purposes only # password can be provided directly, or from a password file password=manager #password=khalsa #password=@d:\\devicemanager\\.passwd <snip!> 12
Easier Commands Now we can type fewer parameters URL is always the same Username and password is always the same C:\HiCommandCLI GetServerInfo RESPONSE: An instance of ServerInfo serverversion=hicommand Device Manager Server v5.8 Build 0580-03 (Aug 27, 2007) serverurl=http://localhost:2001 uptime=35 minutes 26 seconds upsince=thu, 25 Oct 2007 16:50:24 GMT currentapiversion=5.8 license=0 List of 3 StorageArray elements: C:\HiCommandCLI AddStorageArray ipaddress=172.16.100.1 family=usp RESPONSE: An instance of StorageArray objectid=array.usp.15050 name=usp@172.16.100.1 description=usp (15050) at 172.16.100.1 13
Creating Your First Script A common task is to refresh the Device Manager database so it is up to date with the latest changes to the array. RefreshArrays.bat REM This batch file refreshes all the arrays in Device Manager to make sure you REM have the latest information in your instance of Device Manager. This may take REM a long time to run so be aware of your environment @ECHO OFF ECHO Starting to refresh all arrays in HDvM. CALL HiCommandCLI RefreshStorageArrays Then running the command is as simple as specifying the batch file name C:\RefreshArrays.bat Starting to refresh all arrays in HDvM RESPONSE: An instance of StorageArray objectid=array.usp.15050 name=usp@172.16.100.1 description=usp (15050) at 172.16.100.1 serialnumber=15050 arrayfamily=usp arraytype=usp microcodeversion=50-09-00/00 14
Extending Your First Script We should really perform a LUN Scan as well to update host and logical group information with any new WWNs, but this script is more complicated RefreshArrays.bat REM This batch file refreshes all the arrays in Device Manager to make sure you REM have the latest information in your instance of Device Manager. This may take REM a long time to run so be aware of your environment @ECHO OFF ECHO Starting to refresh all arrays in HDvM. CALL HiCommandCLI -o "allarrays.txt" RefreshStorageArrays ECHO Updating hosts and logical groups for serialnum=15050 model=usp CALL HiCommandCLI AddLunScan serialnum=15050 model=usp ECHO Updating hosts and logical groups for serialnum=77010000 model=ams1000 CALL HiCommandCLI AddLunScan serialnum=77010000 model=ams1000 ECHO Updating hosts and logical groups for serialnum=15060 model=r600 CALL HiCommandCLI AddLunScan serialnum=15060 model=r600 Now our script will update the host and logical group information as well C:\RefreshArrays.bat Starting to refresh all arrays in HDvM Updating hosts and logical groups for serialnum=15050 model=usp Updating hosts and logical groups for serialnum=77010000 model=ams1000 Updating hosts and logical groups for serialnum=15060 model=r600 15
Something Complicated but Useful It would be nice to have a script that could just be dropped into your environment and work instead of having to edit the file. RefreshArrays.bat REM This batch file refreshes all the arrays in Device Manager to make sure you REM have the latest information in your instance of Device Manager. This may take REM a long time to run so be aware of your environment @ECHO OFF ECHO Starting to refresh all arrays in HDvM. CALL HiCommandCLI -o "allarrays.txt" RefreshStorageArrays FOR /F "tokens=1,2 delims==" %%i IN (allarrays.txt) DO ( IF "%%i"==" objectid" ( FOR /F "tokens=2,3 delims=." %%q IN ("%%j") DO ( ECHO Updating hosts and logical groups for serialnum=%%r model=%%q CALL HiCommandCLI AddLunScan serialnum=%%r model=%%q ))) Now we can refresh Device Manager without updating this script. C:\RefreshArrays.bat Starting to refresh all arrays in HDvM Updating hosts and logical groups for serialnum=15050 model=usp Updating hosts and logical groups for serialnum=77010000 model=ams1000 Updating hosts and logical groups for serialnum=15060 model=r600 16
Even More Specifically 17 Maybe you want to refresh only one array in Device Manager s database RefreshUSP.bat REM This batch file refreshes only the USP array in Device Manager, to make sure REM you have the latest information in your instance of Device Manager. Since we REM also know the serial number, we ll refresh the hosts and logical groups as well. @ECHO OFF ECHO Starting to refresh all arrays in HDvM. HiCommandCLI AddStorageArray ipaddress=172.16.100.1 family=usp ECHO Updating the Hosts and Logical Groups CALL HiCommandCLI AddLunScan serialnum=15050 model=usp This command will take less time to execute since only one array is updated C:\RefreshUSP.bat Starting to refresh all arrays in HDvM RESPONSE: An instance of StorageArray objectid=array.usp.15050 name=usp@172.16.100.1 description=usp (15050) at 172.16.100.1 serialnumber=15050 arrayfamily=usp arraytype=usp microcodeversion=50-09-00/00
Now For Something Useful It would be nice to ensure the Device Manager database was up to date each morning Let s take the RefreshArrays.bat script we created and schedule it to run every night at 2:00 am 18
Provisioning Through CLI 19 Let s break down the tasks you need to perform Create a Host Storage Domain with the appropriate port Add world wide names to this Host Storage Domain Set the host mode settings to be specific to your environment Add logical units to your Host Storage Add these new storage paths to Logical Groups Here s what it looks like in CLI commands REM This batch file allocates storage to hosts. @ECHO OFF ECHO Allocating storage to hosts. CALL HiCommandCLI AddHostStorageDomain serialnum=15050 model=usp port=cl1-a domain=0x01 nickname=exchserver1 hostmode= Windows Extension CALL HiCommandCLI AddWWNForHostStorageDomain serialnum=15050 model=usp port=cl1-a domain=1 wwn=aa.aa.aa.aa.aa.aa.aa.aa CALL HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:08 CALL HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=1 domain=0x01 devnum=0a:09 CALL HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=2 domain=0x01 devnum=0a:10 CALL HiCommandCLI AddObjectForLogicalGroup logicalpath= /Windows/Server1/USP groupelements=path.usp.15050.0.1.2568 CALL HiCommandCLI AddObjectForLogicalGroup logicalpath= /Windows/Server1/USP groupelements=path.usp.15050.0.1.2569 CALL HiCommandCLI AddObjectForLogicalGroup logicalpath= /Windows/Server1/USP
Performance of CLI CLI commands are executed serially This results in linear performance of the same AddLun command With CLI Batch, the commands are almost executed in parallel This results in a much faster response when allocating several LUNs Time [sec] 2500 2000 1500 1000 500 CLI CLI Batch 0 1 10 20 30 40 50 60 70 80 90 100 The Number of LUNS 20
Provisioning Through CLI Batch First create a file to contain the batch commands (batch.txt) beginbatch HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:08 HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:09 HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:10 HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:11 HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:12 HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:13 HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:14 HiCommandCLI AddLUN serialnum=15050 model=usp port=cl1-a lun=0 domain=0x01 devnum=0a:15 endbatch Then we ll add LUNs to the host we previously defined. REM This batch file allocates multiple LUNs to hosts. REM It uses a faster process for multiple LUNs to provide quicker execution @ECHO OFF CALL HiCommandCLI AddArrayReservation serialnum=15050 model=usp pause REM If the array reservation fails, hit CTRL-C here to abort and try again CALL HiCommandCLI b batch.txt CALL HiCommandCLI DeleteArrayResrvation serialnum=15050 model=usp 21
What You Learned Today You should now be able to download and install HiCommand CLI for Device Manager You can use the command line to manage your arrays You can create scripts to execute multiple commands You can schedule scripts to run periodically You can batch commands together to perform quicker 22
References for the Material Today These scripts are available to you to use in your own environment You will be able to find these scripts on the WebTech Portal in both Windows Batch and Perl. Please contact John Harker at Hitachi Data Systems to have these scripts sent to you. Additional details for the commands used today can be found in the following guides: Command Line Interface (CLI) User s Guide found on the Device Manager CD 23
Upcoming WebTech Sessions: We have several additional WebTech sessions planned this year November 13: Eliminating Redundant Data in Your Backup Environment November 28: Best Practices for Oracle Automatic Storage Management and Hitachi Replication Software December 05: Using Hitachi Dynamic Link Manager to Enable Server Boot from the SAN December 13: Effective Compliance Strategies How to Protect Yourself and Your Company We will be adding additional sessions based upon participant requests. Please go to www.hds.com/webtech next week for the a link to the recording, presentation, and FAQ in addition to registering for upcoming WebTechs. 24
25 Questions/Discussion
26 Thank You