Sunteți pe pagina 1din 21

Steps to manually register a primary and

standby database, then backup each to


ZDLRA
Contents
ZDLRA Steps .................................................................................................................................................. 3
Create a new protection policy on the primary ZDLRA and Standby ZDLRA ........................................... 3
Create the VPC user account on the primary ZDLRA and on the standby ZDLRA (this is only necessary if
you want a new user)................................................................................................................................ 4
Making Enterprise Manager Aware of Recovery Appliance Virtual Private Catalogs .............................. 4
Add the primary database to the primary ZDLRA metadata and standby ZDLRA metadata................... 5
Allow VPC users to manage the primary database on both primary ZDLRA and standby ZDLRA ............ 6
Prepare the Protected database servers to register the primary database and the standby database. ..... 7
Execute RA backup module using Java (Alternative 1) ............................................................................ 7
Manually configure protected database server (Alternative 2) .............................................................. 7
Create the wallet on the protected database server(s). ....................................................................... 7
Test the wallet on the protected database server(s)............................................................................ 8
Add wallet location lines to sqlnet.ora. ................................................................................................ 8
Add the SBT library file to the protected database server(s). ............................................................. 9
Register the primary protected database with the primary ZDLRA and standby ZDLRA ....................... 10
Configure real-time redo apply for the primary protected database and the standby
database(Optional). ................................................................................................................................ 10
Update wallet configuration ............................................................................................................... 11
Update database configuration parameters on both the primary and standby databases ............... 11
Set the LOG_ARCHIVE_CONFIG initialization parameter on primary to include a DG_CONFIG
list. ....................................................................................................................................................... 11
Create redo transport users on primary database ............................................................................ 12
Copy the password file from the primary database to the standby database ................................... 12
Verify the password file on both the primary database and the standby database .......................... 13
Change the redo transport user on primary database ....................................................................... 13
Change the redo transport user on standby database ....................................................................... 13
Add the primary ZDLRA as an archive destination to the primary database...................................... 14
Bounce the primary database to enable changes .............................................................................. 14
Add standby ZDLRA as an archive destination to the standby database........................................... 14
Test the archive log configuration on the primary database.............................................................. 14
Add default channel configuration in primary database and standby database.................................... 15
Backing up databases.................................................................................................................................. 15
Perform an explicit level 0 backup .......................................................................................................... 15
Schedule a regular Incremental .............................................................................................................. 15
Architectural view ....................................................................................................................................... 18
Final environment ....................................................................................................................................... 19
Appendix ..................................................................................................................................................... 20
Multiple VPC users in same $ORACLE_HOME ........................................................................................ 20
Creating a standby database from Primary database backup ................................................................ 20
Restore database file from opposite ZDLRA ........................................................................................... 20
ZDLRA Steps
Create a new protection policy on the primary ZDLRA and Standby
ZDLRA (this is optional since you might be using an existing policy)

 Log in as RASYS to the ZDLRA database (primary or standby). This can be done locally on
the ZDLRA, or remotely using SQL*net.

o Once connected execute the create_protection_policy procedure to make the DB


known to the ZDLRA (this procedure has specific parameters that need to be set).
Refer to the documentation for parameter values.

PROCEDURE create_protection_policy (
protection_policy_name IN VARCHAR2,
description IN VARCHAR2 DEFAULT NULL,
storage_location_name IN VARCHAR2,
polling_policy_name IN VARCHAR2 DEFAULT NULL,
recovery_window_goal IN DSINTERVAL_UNCONSTRAINED,
max_retention_window IN DSINTERVAL_UNCONSTRAINED DEFAULT NULL,
recovery_window_sbt IN DSINTERVAL_UNCONSTRAINED DEFAULT NULL,
unprotected_window IN DSINTERVAL_UNCONSTRAINED DEFAULT NULL,
guaranteed_copy IN VARCHAR2 DEFAULT 'NO',
allow_backup_deletion IN VARCHAR2 DEFAULT 'YES',
store_and_forward IN VARCHAR2 DEFAULT 'NO');

Example
Exec dbms_ra. create_protection_policy (
‘GOLD_POLICY’,
‘Gold Protection Policy’,
‘DELTA’,
null,
INTERVAL '30' DAY,
null,
null,
INTERVAL '15' minute,
‘NO’ ,
'YES',
'NO');
Create the VPC user account on the primary ZDLRA and on the standby
ZDLRA (this is only necessary if you want a new user).
 Log in as RASYS to the ZDLRA database (primary or standby). This can be done locally on
the ZDLRA, or remotely using SQL*net.

./racli add vpc_user --user_name=vpcuser

NOTE: When the process of configuring a protected database to send backups to a


Recovery Appliance is performed outside of Enterprise Manager, Enterprise Manager will not
be aware of the configuration and therefore will not be able to schedule backups to the
Recovery Appliance. In order to make Enterprise Manager aware of the externally-performed
configuration, perform the following steps:

 Discover the protected database in Enterprise Manager (if not already done).

 From the protected database Home page, select the menu item Availability > Backup &
Recovery > Recovery Catalog Settings.

 Select Use Recovery Catalog and in the Recovery Catalog choice list select the
Recovery Appliance virtual private catalog (VPC) that the protected database was
registered with during the external configuration process. (If the required VPC is not in
the list, that means Enterprise Manager was not used by the Recovery Appliance
administrator to enroll the database with the Recovery Appliance, in which case the
steps below must be performed.)

Making Enterprise Manager Aware of Recovery Appliance Virtual


Private Catalogs
Enterprise Manager becomes aware of Recovery Appliance VPCs when the
Recovery Appliance administrator runs the Enterprise Manager Add Protected
Database workflow. If that operation is performed outside of Enterprise Manager,
Enterprise Manager will not be aware of the VPC, which will result in Enterprise
Manager not being able to perform the database-side configuration to send backups
to Recovery Appliance or schedule backups to Recovery Appliance. The problem will
be apparent in the database Backup Settings page, if after selecting a Recovery
Appliance the desired VPC is not listed in the Virtual Private Catalog User choice list.

This issue can be addressed by performing the following steps to make Enterprise
Manager aware of the VPC:
 In the Enterprise Manager Targets menu, select Databases; on the Databases page,
select the menu item Availability > Recovery Catalogs.

 Select the base Recovery Appliance catalog, then click Manage Virtual Private
Catalogs.

 Select the Manage an existing virtual private catalog with Enterprise Manager radio
button and continue through the process.

Add the primary database to the primary ZDLRA metadata and standby
ZDLRA metadata

Log in as RASYS to the ZDLRA database (primary or standby).

NOTE – You can only register a primary database (not a standby). You will be
registering the db_unique_name of the primary database on both the primary ZDLRA
and the standby ZDLRA.

NOTE – The steps can be delayed on the Dataguard Database if it is created later.

This can be done locally on the ZDLRA, or remotely using SQL*net.

o Once connected execute the add_db procedure to make the DB known to the
ZDLRA (this procedure has specific parameters that need to be set). NOTE : this only
adds metadata to the ZDLRA configuration, not the RMAN catalog.
 DBMS_RA.ADD_DB

PROCEDURE add_db (
db_unique_name IN VARCHAR2,
protection_policy_name IN VARCHAR2,
reserved_space IN VARCHAR2);

--- reserved_space should be about 2x the size of the database.

Example
Dbms_ra. add_db (
‘mydb’,
‘OLD’,
‘1500G’);
Allow VPC users to manage the primary database on both primary
ZDLRA and standby ZDLRA

Log in as RASYS to the ZDLRA database (primary or standby).

NOTE – You can only register a primary database (not a standby). You will be
registering the db_unique_name of the primary database on both the primary ZDLRA
and the standby ZDLRA.

NOTE – The steps can be delayed on the Dataguard Database if it is created later.

o Also connect the ZDLRA database VPC user to the database so that the VPCUSER
account can used to manage the new database. This account is used for backing
up/Restoring the database. Multiple VPCUSERS can be allowed to manage the
database, but typically only one is used.

PROCEDURE grant_db_access (
username IN VARCHAR2,
--- Username of the Recovery appliance user (
the VPCUSER)
db_unique_name IN VARCHAR2);

Example

Dbms_ra. grant_db_access (
‘VPCUSER1’,
‘mydb’);
Prepare the Protected database servers to register the primary database
and the standby database.

NOTE – This only needs to be done once for each $ORACLE_HOME.

NOTE – The steps can be delayed on the Standby Database server(s) if it is created later.

Execute RA backup module using Java (Alternative 1)

 Download the current backup module from oracle. It can be found here
 Execute the ra_install.jar using information from the README file. The two steps that need
to be completed are
o Creating the wallet file to store ZDLRA catalog credentials
o Download the current libra.so file for the appropriate OS/platform.
 For a RAC cluster, either execute this process on all nodes, or add the configuration files on
all nodes
o Wallet file
o Libra.so
o Sqlnet.ora changes

Manually configure protected database server (Alternative 2)

Create the wallet on the protected database server(s).

 Create directory to hold the wallet ($ORACLE_HOME/dbs/zdlra)


 Run mkstore to create wallet file or add new credential using the ezconnect
format.

mkstore -wrl $ORACLE_HOME/dbs/zdlra/ -createCredential


<db SCAN listener:PORT/Service:dedicated> <VPCUSER>
<password>

Example

mkstore -wrl $ORACLE_HOME/dbs/zdlra/ -createCredential


slcm_adm03_scan.us.mycompany.com:1521/zdlra1:dedicated
VPCUSER1 welcome1
NOTE :

 Add the connect string/VPC user for both the primary ZDLRA and the
standby ZDLRA. This needs to be done for both the primary database
server(s) and the standby database server(s)

 This must be done on every host in a rac cluster (the sqlnet.ora and
wallet file can be copied between nodes)

 Each database home connecting to the ZDLRA needs to have this done,
and it needs to be copied over to any new installations.

 The wallet file needs to be backed up as part of an OS backup

 This can be pre-staged if you are using a standard VPCUSER account


for the database. Copy a current wallet file containing the VPCUSER
credentials from a central location.

 Only one connect string (/@<db SCAN


listener:PORT/Service:dedicated>) can be in the wallet for each
$ORACLE_HOME. See Appendix 1 for more information.

Test the wallet on the protected database server(s).

 Test the wallet file entry through sqlplus on the ALL database server(s) for both
the primary ZDLRA and the standby ZDLRA.

SQL > sqlplus /@<primary ZDLRA connection>


SQL> sqlplus /@<standby ZDLRA connections

Sqlplus /@<db SCAN listener:PORT/Service:dedicated>

Example

Sqlplus /@slcm_adm03_scan.us.mycompany.com:1521/zdlra1:dedicated

 Listing the credentials

mkstore -wrl $ORACLE_HOME/dbs/zdlra -listCredential

Add wallet location lines to sqlnet.ora. This is an optional step if not utilizing real-
time redo for any databases in this $ORACLE_HOME location. It should look like this.
SQLNET.WALLET_OVERRIDE = true

WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY = <ORACLE_HOME>/dbs/zdlra
)
)

Add the SBT library file to the protected database server(s).

 Download the current libra.so file from here OR copy the current libra.so file from
another server utilizing the same OS/platform
 This typically sits in the $ORACLE_HOME/lib directory.
 This needs to be done for all nodes in a RAC cluster. The library can be copied from
one node to another.
Register the primary protected database with the primary ZDLRA and standby
ZDLRA

NOTE – You can only register a primary database (not a standby). You will be registering the
primary database on both the primary ZDLRA and the standby ZDLRA.

Register database with the ZDLRA RMAN catalog on both the primary ZDLRA and the standby ZDLRA
through the RMAN client on protected database. With the wallet in place, you will be able to connect to
the recovery catalog.

RMAN> CONNECT TARGET /


connected to target database: PROD (DBID=1619241818)

RMAN> CONNECT CATALOG /@<db_SCAN_name:PORT/Service:dedicated>


connected to recovery catalog database

RMAN> REGISTER DATABASE;


database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

NOTE : after registering the database manually, from within OEM you will see a message on the screen

Click on “recovery catalog settings” and change the database to use a recovery catalog rather than the
controlfile.

Configure real-time redo apply for the primary protected database and the
standby database(Optional).

 The database must be in archivelog mode.


 The database db_unique_name must be set
Update wallet configuration
 Typically the same VPCUSER account on the ZDLRA that manages the databases
backups, is utilized for redo transport. This user will be in the wallet already.

 If the automated ra_install.jar process was used to configure the ZDLRA, then ensure
you followed the steps to add the wallet location to the SQLNET.ORA file.

Update database configuration parameters on both the primary and standby


databases

REMOTE_LOGIN_PASSWORDFILE=shared
LOG_ARCHIVE_FORMAT=’log_%d_%t_%s_%r.arc’

Set the LOG_ARCHIVE_CONFIG initialization parameter on primary to include a


DG_CONFIG list.

 From the protected database, alter the archive log configuration to include both the
ZDLRA, and the current protected database

SQL > ALTER SYSTEM SET LOG_ARCHIVE_CONFIG=


’DG_CONFIG=(<ZDLRA
DB>,<DB_UNIQUE_NAME_PRIMARY>,<DB_UNIQUE_NAME_STANDY>)’
SCOPE=BOTH;
Create redo transport users on primary database

NOTE – You will be adding the VPC user for both primary ZDLRA and the standby ZDLRA.

 From the primary protected database, create the vpc users in the database that will
be used to send primary redo logs.

SQL>create <VPCUSER PRIMARY> identified by xxx;

SQL> grant create session to <VPCUSER PRIMARY >;

SQL>grant sysdg to <VPCUSER PRIMARY > ; --- if 12c

SQL>grant sysoper to <VPCUSER PRIMARY >; -- Not 12c

SQL>create <VPCUSER STANDBY> identified by xxx;

SQL> grant create session to <VPCUSER STANDBY >;

SQL>grant sysdg to <VPCUSER STANDBY > ; --- if 12c

SQL>grant sysoper to <VPCUSER STANDBY >; -- Not 12c

SQL> alter system archive log current; -- ensure it transfers to standby database.

Copy the password file from the primary database to the standby database

NOTE – This must be after the VPCUSER for the standby database is created to ensure
it contains both.

Copy the orapw<primarydatabase> file from $ORACLE_HOME/dbs on the primary


database server to $ORACLE_HOME/dbs/orapw<stdby database> on the standby database
server.
Verify the password file on both the primary database and the standby database

TESTING -- Execute on both the primary and the dataguard database. You should see
both VPC users in the password file

SQL> select * from v$pwfile_users;

USERNAME SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM CON_ID

------------------------------ ----- ----- ----- ----- ----- ----- ---------

SYS TRUE TRUE FALSE FALSE FALSE FALSE 0

SYSDG FALSE FALSE FALSE FALSE TRUE FALSE 0

SYSBACKUP FALSE FALSE FALSE TRUE FALSE FALSE 0

SYSKM FALSE FALSE FALSE FALSE FALSE TRUE 0

<VPCUSER PRIMARY> FALSE FALSE FALSE FALSE TRUE FALSE 0

<VPCUSER STANDBY> FALSE FALSE FALSE FALSE TRUE FALSE 0

Change the redo transport user on primary database

 alter the redo_transport_user parameter to utilize the primary ZDLRA VPCUSER.

SQL> alter system redo_transport_user=<VPCUSER PRIMARY>;

Change the redo transport user on standby database

NOTE – If the Standby database is created later, this step can be delayed.

SQL> Alter system set redo_transport_user=<VPCUSER STANDBY>;


Add the primary ZDLRA as an archive destination to the primary database

 Update the next log destination to contain primary ZDLRA connection information.
Use the connect string specified when creating the wallet file

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_<next>=


‘SERVICE=”<primary string from wallet>”,
VALID_FOR=(ALL_LOGFILES, ALL_ROLES) ASYNC
DB_UNIQUE_NAME=<primary ZDLRA DB>’ SCOPE=BOTH;

 Update the next log destination state to be enabled.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_<next>=


ENABLE SCOPE=BOTH;

Bounce the primary database to enable changes

 Shutdown/startup all instances to enable the sql*net change. If the database


already has the sqnet.ora file in place when started this is not necessary.

Add standby ZDLRA as an archive destination to the standby database

 Update the next log destination to contain standby ZDLRA connection information.
Use the connect string specified when creating the wallet file

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_<next>=


‘SERVICE=”<standby string from wallet>”,
VALID_FOR=(ALL_LOGFILES, ALL_ROLES) ASYNC
DB_UNIQUE_NAME=<standby ZDLRA DB>’ SCOPE=BOTH;

 Update the next log destination state to be enabled.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_<next>=


ENABLE SCOPE=BOTH

Test the archive log configuration on the primary database


 select status,error from v$archive_dest where dest_id=<destination>;
***** Ensure recovery is still working correctly after changing user

Add default channel configuration in primary database and standby database

NOTE – the channel will be configured to point to the appropriate ZDLRA

RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' FORMAT '%d_%U'


PARMS "SBT_LIBRARY=<ORACLE_HOME>/lib/libra.so,
ENV=(RA_WALLET='location=file:<ORACLE_HOME>/dbs/zdlra credential_alias=<
string from wallet >’)";

RMAN> CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM <n> BACKUP TYPE TO BACKUPSET;

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

RMAN> CONFIGURE BACKUP OPTIMIZATION ON;

RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO ALL STANDBY;

RMAN> CONFIGURE DEFAULT DEVICE TYPE to SBT_TAPE;

Backing up databases

Perform an explicit level 0 backup


RMAN> connect target /

RMAN> connect catalog /@<string from wallet>

RMAN>run

{
backup cumulative incremental level 0 section size 32g database plus archivelog
not backed up;
}

Schedule a regular Incremental


RMAN> connect target /

RMAN> connect catalog /@<string from wallet>


RMAN>run

{
backup cumulative incremental level 1 database plus archivelog not backed up;
}
Architectural view

Environment
Final environment

The configuration should be symmetrical to ensure backups work regardless of which datacenter is
primary and which is standby. It is critical all these pieces match.

 Wallet files
 Both VPC users exist in the database
 Password files
 Redo destinations in databases should point to local ZDLRA
 Redo transport users should be local ZDLRA VPC user
Appendix

Multiple VPC users in same $ORACLE_HOME

Each connect string in the wallet file can only be configured for a single VPC user.

The best workaround is to add entries in the TNSNAMES.ORA file. You can then use the
TNS_NAMES entry in the wallet, channel configuration etc.

Creating a standby database from Primary database backup

Steps are identified in the configure database guide for the ZDLRA

RMAN> connect auxiliary /


RMAN> connect catalog /@<primary zdlra connection>
RMAN> startup nomount
RMAN> run
RMAN> {
RMAN> Allocate auxiliary channel <primary zdlra information>;
RMAN> duplicate database <db_name> for standby dorecover;
RMAN> ;

Restore database file from opposite ZDLRA

Rman script to restore a Standby database file from the primary ZDLRA would look like
this. This can be changed for other situations.

RMAN > connect target /


RMAN > connect /@<primary zdlra connection>
RMAN > Configure channel device type ‘sbt_tape’ <primary zdlra configuration>
RMAN > Run
RMAN > {
RMAN > set newname for datafile x to ‘< file name on the standby db>’;
RMAN > restore datafile x;
RMAN > }
RMAN > configure channel device type ‘sbt_tape’ <standby zdlra configuration>
RMAN > exit.

RMAN> connect target /


RMAN> connect /@<standby zdlra connection>
RMAN> recover database;
RMAN> exit
RMAN>
RMAN>

S-ar putea să vă placă și