• No results found

Scenarios Using the DGMGRL Command-Line Interface

This chapter describes the prerequisites for getting started using the Data Guard command-line interface (DGMGRL). It also describes scenarios that demonstrate how to use DGMGRL to create, manage, and monitor a broker configuration.

This chapter contains the following sections: ■ Prerequisites for Getting Started

■ Scenario 1: Creating a Configuration ■ Scenario 2: Setting Database Properties

■ Scenario 3: Enabling the Configuration and Databases ■ Scenario 4: Setting the Configuration Protection Mode

■ Scenario 5: Enabling Fast-Start Failover and Starting the Observer ■ Scenario 6: Performing Routine Management Tasks

■ Scenario 7: Performing a Switchover Operation ■ Scenario 8: Performing a Manual Failover Operation ■ Scenario 9: Reinstating a Failed Primary Database

■ Scenario 10: Converting a Physical Standby to a Snapshot Standby ■ Scenario 11: Monitoring a Data Guard Configuration

7.1 Prerequisites for Getting Started

One of the prerequisites for using DGMGRL is that a primary database and any standby databases must already exist. The DG_BROKER_START initialization

parameter must be set to TRUE for all databases in the configuration. You must use a server parameter file with the broker (see Section 2.1 and Section 8.1.3).

Convert the initialization parameter files (PFILE) on both primary and standby databases into server parameter files (SPFILE), if necessary. Use the following SQL*Plus command:

CREATE SPFILE FROM PFILE='pfilename';

If an instance was not started with a server parameter file, then you must shut down the instance and restart it using the server parameter file.

After starting the Oracle instance, set the DG_BROKER_START=TRUE initialization parameter using the SQL ALTER SYSTEM statement. The parameter value will be

Scenario 1: Creating a Configuration

saved in the server parameter file. The next time you start the Oracle instance, the broker is started automatically, and you do not need to issue the SQL ALTER SYSTEM statement again.

The following assumptions are made for the scenarios in this chapter: ■ TCP/IP is used to connect to primary and standby databases.

■ The standby database has been created from backups of the primary database control files and datafiles as described in the Oracle Data Guard Concepts and

Administration.

■ The scenarios in this chapter assume the following broker configuration: The configuration name is DRSolution.

The database unique name (DB_UNIQUE_NAME) of the primary database is North_Sales.

The database unique name (DB_UNIQUE_NAME) of the remote standby database is DR_Sales.

The protection mode is maximum performance mode.

There are standby redo log files and the transport mode is ASYNC.

The standby database is a physical standby database.

7.2 Scenario 1: Creating a Configuration

This section provides examples that create a broker configuration named

DRSolution that includes a primary and standby database named North_Sales and DR_Sales.

The following steps show how to create a configuration and add one physical standby database.

Step 1 Invoke DGMGRL.

To start DGMGRL, enter DGMGRL at the command-line prompt on a system where Oracle Data Guard is installed:

$ dgmgrl

DGMGRL for Linux: Version 11.1.0.1.0 - Production

Copyright (c) 2000, 2007, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

DGMGRL>

Step 2 Connect to the primary database.

Before you specify any command (other than the HELP, EXIT, or QUIT), you must first connect to the primary database using the DGMGRL CONNECT command.

The account from which you connect to the database (SYS in this example) must have SYSDBA privileges on the primary and standby databases.

See Also: Oracle Database Administrator's Guide for detailed

Scenario 1: Creating a Configuration

The following examples show two variations of the CONNECT command. Example 7–1

shows how to connect to the default database on the local system, and Example 7–2

includes the Oracle Net Services connect identifier

(North_Sales.foo.com) to make a connection to a database located on a remote system.

Example 7–1 Connecting to the Primary Database on the Local System

DGMGRL> CONNECT sys/<password>; Connected.

Example 7–2 Connecting to the Primary Database on a Remote System

DGMGRL> CONNECT sys/<password>@North_Sales.foo.com; Connected.

Optionally, you can combine the steps shown in Example 7–1 and Example 7–2 by including the connection information on the command line:

$ DGMGRL sys/<password>@<connect identifier>

Step 3 Create the broker configuration.

To create the broker configuration, you first define the configuration including a profile for the primary database, which in this case is called North_Sales. In a later command, you will add a profile for the standby database, DR_Sales.

Use the CREATE CONFIGURATION command to create the DRSolution configuration and define the primary database, North_Sales:

DGMGRL> CREATE CONFIGURATION 'DRSolution' AS > PRIMARY DATABASE IS 'North_Sales'

> CONNECT IDENTIFIER IS North_Sales.foo.com;

DGMGRL returns the following information:

Configuration "DRSolution" created with primary database "North_Sales"

The name North_Sales is the value of this database’s DB_UNIQUE_NAME initialization parameter.

Step 4 Show the configuration information.

Use the SHOW CONFIGURATION command to display a brief summary of the configuration:

DGMGRL> SHOW CONFIGURATION;

DGMGRL returns the following information:

Note: You do not have to include AS SYSDBA on the CONNECT command because SYSDBA is the default setting for this command.

Note: The names for the primary and standby databases must match their database unique names. Fetch these from their DB_ UNIQUE_NAME initialization parameter as follows:

Scenario 2: Setting Database Properties

Configuration

Name: DRSolution Enabled: NO

Protection Mode: MaxPerformance Databases:

North_Sales - Primary database

Fast-Start Failover: DISABLED

Current status for "DRSolution": DISABLED

Step 5 Add a standby database to the configuration.

To add a standby database to the DRSolution configuration, use the ADD DATABASE command to create a broker configuration profile for the standby database.

The following command defines DR_Sales as a standby database, which is the standby database associated with the primary database called North_Sales:

DGMGRL> ADD DATABASE 'DR_Sales' AS

> CONNECT IDENTIFIER IS DR_Sales.foo.com;

DGMGRL returns the following information:

Database "DR_Sales" added

The name DR_Sales is the value of the database’s DB_UNIQUE_NAME initialization parameter.

Use the SHOW CONFIGURATION command to verify that the DR_Sales database was added to the DRSolution configuration:

DGMGRL> SHOW CONFIGURATION;

DGMGRL returns the following information:

Configuration

Name: DRSolution Enabled: NO

Protection Mode: MaxPerformance Databases:

North_Sales - Primary database

DR_Sales - Physical standby database

Fast-Start Failover: DISABLED

Current status for "DRSolution": DISABLED

7.3 Scenario 2: Setting Database Properties

After you create the configuration with DGMGRL, you can set database properties at any time. For example, the following statements set the LogArchiveFormat and StandbyArchiveLocation configurable database properties for the DR_Sales standby database:

DGMGRL> EDIT DATABASE 'DR_Sales' SET PROPERTY 'LogArchiveFormat'='log_%t_%s_%r_%d.arc'; Property "LogArchiveFormat" updated.

DGMGRL> EDIT DATABASE 'DR_Sales' SET PROPERTY 'StandbyArchiveLocation'='/archfs/arch/'; Property "StandbyArchiveLocation" updated.

Scenario 2: Setting Database Properties

Use the SHOW DATABASE VERBOSE command to view all properties and their values for a database. The following example shows the properties for the DR_Sales database.

DGMGRL> SHOW DATABASE VERBOSE 'DR_Sales';

Database

Name: DR_Sales

Role: PHYSICAL STANDBY Enabled: NO

Intended State: APPLY-ON Instance(s): dr_sales1 Properties: DGConnectIdentifier = 'DR_Sales.foo.com' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '30' RedoCompression = 'DISABLE' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '5' LogArchiveMinSucceedDest = '1' DbFileNameConvert = 'dbs/t, dbs/bt' LogFileNameConvert = 'dbs/t, dbs/bt' FastStartFailoverTarget = '' StatusReport = '(monitor)' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' HostName = 'dr_sales.foo.com' SidName = 'dr_sales1' StandbyArchiveLocation = '/archfs/arch' AlternateLocation = '' LogArchiveTrace = '8191' LogArchiveFormat = 'db2r_%d_%t_%s_%r.arc' LatestLog = '(monitor)' TopWaitEvents = '(monitor)'

Current status for "DR_Sales": DISABLED

If broker management of the database is enabled, setting a database property value causes the underlying parameter value to be changed in the corresponding database, and the value for the changed parameter is reflected in the server parameter file. Thus, if the database is shut down and restarted outside of Oracle Enterprise Manager and DGMGRL (such as from the SQL*Plus interface), the database uses the new parameter values from the updated server parameter file when it starts. However, you should not

Scenario 3: Enabling the Configuration and Databases

make changes to the redo transport services initialization parameters through SQL statements. Doing so will cause an inconsistency between the database and the broker.

You can change a property if the database is enabled or disabled. However, if the database is disabled when you change a property, the change does not take effect until the database is enabled.

7.4 Scenario 3: Enabling the Configuration and Databases

So far, the DRSolution configuration is disabled, which means it is not under the control of the Data Guard broker. When you finish configuring the databases into a broker configuration and setting any necessary database properties, you must enable the configuration to allow the Data Guard broker to manage it.

You can enable:

■ The entire configuration, including all of its databases ■ A standby database