In Windows Server 2008 R2, Microsoft introduced a set of failover cluster PowerShell commands (cmdlets) as the preferred scripting tool for managing failover clusters. PowerShell is the new command and scripting language offered by Microsoft and intends to replace the old command (CMD) environment used in the past. The new failover cluster cmdlets has replaced the old command line utility, CLUSTER.EXE
, which might not be available in the future releases of Windows Server. Oracle now provides a new set of PowerShell cmdlets that has also replaced the old FSCMD.EXE
utility.
The PowerShell cmdlets may be used on server systems, such as Windows Server 2008 R2, or on client systems, like Windows 7. The Microsoft failover cluster cmdlets are added to a server when the failover cluster feature is added to the system. The failover cluster cmdlets can be added to a client system by installing the Remote Server Administration Tools package available in Microsoft. Oracle Fail Safe cmdlets are installed as part of the Oracle Fail Safe Manager installation component.
Note:
Beginning with Windows Server 2008 R2, Windows PowerShell is installed by default on all Windows Server systems. PowerShell must be manually installed on systems older than Windows Server 2008 R2.To start a basic PowerShell session on a system that already has PowerShell installed, click on Start, All Programs, Accessories, Windows PowerShell, and finally double-click Windows PowerShell. This starts a basic PowerShell session with the standard cmdlets loaded.
A group of related cmdlets are packaged in a container called a module. Before using the cmdlets that are specific to failover clusters, load them into the PowerShell session using the Import-Module cmdlet. Use the following command to load the failover clusters module.
PS C:\Users\admin> Import-Module FailoverClusters
A PowerShell module also contains a link to the descriptions of the commands that it contains. After loading the module, find out what cmdlets are contained in the module and display the help text describing each of the cmdlets.
For example, to see what cmdlets are provided by the FailSafe module, type the following command:
PS C:\Users\Admin> Get-Command -Module FailSafe
CommandType Name Definition ----------- ---- ---------- Cmdlet Add-OracleClusterResource Add-OracleClusterResource [[... Cmdlet Get-OracleClusterResource Get-OracleClusterResource [[... Cmdlet Remove-OracleClusterResource Remove-OracleClusterResource... Cmdlet Stop-OracleClusterDatabase Stop-OracleClusterDatabase [... Cmdlet Test-OracleCluster Test-OracleCluster [[-Name] ... Cmdlet Test-OracleClusterAvailableD... Test-OracleClusterAvailableD... Cmdlet Test-OracleClusterGroup Test-OracleClusterGroup [[-N...
To get basic information about all cmdlets that contain the string “cluster”, use the following command:
PS C:\Users\Admin> Get-Help cluster
Name Category Synopsis ---- -------- -------- Add-OracleClusterResource Cmdlet Adds an Oracle resource to a fai... Get-OracleClusterResource Cmdlet Gets an Oracle resource object Remove-OracleClusterResource Cmdlet Removes an Oracle cluster resour... Stop-OracleClusterDatabase Cmdlet Stops an Oracle database Test-OracleCluster Cmdlet Verifies the installation and co... Test-OracleClusterAvailableDat... Cmdlet Verifies the configuration of an... Test-OracleClusterGroup Cmdlet Verifies the configuration of Or... Add-ClusterDisk Cmdlet Make a new disk available for us... Add-ClusterFileServerRole Cmdlet Create a clustered file server (... . . .
To get information specific to a particular cmdlet specify the cmdlet name to Get-Help
.
Example 6-1 Get-OracleClusterResource
PS C:\Users\Admin> Get-Help Get-OracleClusterResource NAME Get-OracleClusterResource SYNOPSIS Gets an Oracle resource object. SYNTAX Get-OracleClusterResource [[-Name] <String>] [-Available] [-InputObject <PS Object>] [-Cluster <String>] [-Credential <PSCredential>] [<CommonParameter s>] DESCRIPTION This cmdlet will return an Oracle cluster resource object or objects based on the input provided. RELATED LINKS Add-OracleClusterResource Remove-OracleClusterResource Test-OracleClusterAvailableDatabase Stop-OracleClusterDatabase REMARKS To see the examples, type: "get-help Get-OracleClusterResource -examples". For more information, type: "get-help Get-OracleClusterResource -detailed". For technical information, type: "get-help Get-OracleClusterResource -full".
Oracle Fail Safe cmdlets displays the same progress information that is shown in the Oracle Fail Safe Manager progress dialog output box for the same operation. However, for the output to be displayed the -Verbose
switch must be specified.
PS C:\Users\Admin > Test-OracleClusterGroup “Test Group” -Verbose VERBOSE: FS-10371: FSWIN3 : Performing initialization processing VERBOSE: FS-10371: FSWIN4 : Performing initialization processing VERBOSE: FS-10373: FSWIN3 : Determining owner node of resource . . .
To run a cmdlet on a different cluster, the -Cluster
parameter must be added to a command. This is mandatory for running a cmdlet on a Windows client system that only has the Oracle Fail Safe Manager component installed. For example, to show the Oracle cluster resources on a cluster named “FinanceCluster" use the following command:
PS C:\Users\Admin > Get-OracleClusterResource -Cluster FinanceCluster
Name State Group ---- ----- ----- OracleOraDb11g_home1TNSLis... Online Receivables OracleOraDb12c_home1TNSLis... Online Payables ReceivablesDb Online Receivables PayablesDb Online Payables
Some commands are not expected to be used as pipeline input. Thus running these commands does not send an object to the pipeline. To force the command to write the target object to the output pipeline stream, use the -PassThru
switch. For example, the following command does not send any objects to the pipeline.
PS C:\Users\Admin> Get-ClusterGroup | Test-OracleClusterGroup
Adding the -PassThru
switch forces the cluster group objects to be sent to the pipeline.
PS C:\Users\Admin> Get-ClusterGroup | Test-OracleClusterGroup -PassThru
Name OwnerNode ---- --------- Test Group Node1 Cluster Group Node2 Available Storage Node2
Some Oracle Fail Safe cmdlets will prompt the user for confirmation before proceeding. For example, the Test-OracleClusterAvailableDatabase
cmdlet discovers that the specified database instance is not running and asks if the instance can be started. This is not a problem in an interactive session, but when running a script, the confirmation prompt receives the next command line in the script, and that may cause the script to fail. PowerShell provides different methods to address this situation. One way to avoid prompts is to specify the "-Confirm:$false
" parameter in a command. When that qualifier is present, no confirmation prompt is displayed and the cmdlet proceeds without interruption. In the following example, the first command causes a confirmation prompt to be displayed while the second command that includes "-Confirm:$false
", proceeds without asking the user if the database may be started.
PS C:\Users\Admin> Test-OracleClusterAvailableDatabase TestDb WARNING: FS-10349: Database instance OFS3 is not alive. Do you want to stop and restart the database instance? Confirm Are you sure you want to perform this action? Performing operation "Test-OracleClusterAvailableDatabase" on Target "TestDb". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): N WARNING: FS-10340: Database instance OFS3 is not started and therefore cannot be fully verified. PS C:\Users\Admin> Test-OracleClusterAvailableDatabase TestDb –Confirm:$false
Another way to prevent confirmation prompts is to set the default response variable, $ConfirmPreference
. You can set this variable to the lowest level that requires confirmation (“high”, “medium”, “low” or “none”). For example, most Oracle Fail Safe cmdlets are known to have a high impact on system operations. Therefore for Oracle Fail Safe cmdlets to be confirmed automatically, you must set the $ConfirmPreference
variable to “none”
, as shown below.
PS C:\Users\Admin> $ConfirmPreference=”none” PS C:\Users\Admin> Test-OracleClusterAvailableDatabase TestDb
Some commands, such as the Stop-OracleClusterDatabase
command are always expected to prompt for confirmation before proceeding. This cmdlet provides a -Force
switch that can be used to prevent a confirmation prompt.
PS C:\Users\Admin> Stop-OracleClusterDatabase TestDb -Force
The following table lists FSCMD.EXE
commands and the Oracle Fail Safe PowerShell cmdlet(s) that can be used to accomplish the same task.
FSCMD.EXE Command | PowerShell Command |
---|---|
DISABLEISALIVE |
(Get-OracleClusterResource <db name>).IsAliveEnabled=$false |
ENABLEISALIVE |
(Get-OracleClusterResource <db name>).IsAliveEnabled=$true |
MOVEGROUP |
Move-ClusterGroup |
OFFLINEGROUP |
Stop-ClusterGroup |
OFFLINERESOURCE |
Stop-ClusterResource or Stop-OracleClusterDatabase |
ONLINEGROUP |
Start-ClusterGroup |
ONLINERESOURCE |
Start-ClusterResource |
VERIFYALLGROUPS |
Get-ClusterGroup|Test-OracleClusterGroup |
VERIFYCLUSTER |
Test-OracleCluster |
VERIFYGROUP |
Test-OracleGroup |
When operating system (OS) authentication is not enabled for a cluster or a database it is necessary to provide a user name and password for the database. The Test-OracleClusterAvailableDatabase
cmdlet provides the -SysPwd
parameter for specifying the password for the database SYS
account. Note that the password is obtained from the user by running the Read-Host
cmdlet.
PS C:\Users\Admin> Test-OracleClusterAvailableDatabase TestDb -SysPwd (Read-Host -AsSecureString -Prompt ”SYS Password”) SYS password: ****
When adding an Oracle resource, depending on the resource type, the resource may or may not have a user name and password property. For a database resource, if OS authentication is not being used, the user name and password have to be set in the resource before it is added to a cluster group.
PS C:\Users\Admin> $testdb = Get-OracleClusterResource TestDb -Available PS C:\Users\Admin> $testdb.UserName="SYS" PS C:\Users\Admin> $testdb.Password=Read-Host -AsSecureString -Prompt "SYS Password" SYS Password: **** PS C:\Users\Admin> $testdb | Add-OracleClusterResource -Group FsTutorial
By using the pipeline capabilities of PowerShell you can link together various commands.
In the following example, all Oracle resources are first fetched, then the databases selected from that list, and finally the databases are stopped using the immediate mode.
PS C:\Users\Admin> Get-OracleClusterResource | >> where {($_.Type -ieq "Oracle Database")} | >> Stop-OracleClusterDatabase -Mode Immediate –Force