Friday, August 15, 2008

Manual setup for Physical Dataguard

# Create primary database, backup with rman

connect target /
RUN {
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/backup/rman_%d_%T_%s_%p';
BACKUP CURRENT CONTROLFILE FOR STANDBY;
BACKUP as compressed backupset database plus archivelog;
}

# Create standby database using rman duplicate database
# Standby should have the same db_name, but different db_unique_name
# If Standby is on same ORACLE_HOME as Primary, set lock_name_space.
# Make sure db_create_file_dest is set

connect target sys/password@a
connect auxiliary /
run{
allocate auxiliary channel aux1 device type disk;
duplicate target database for standby nofilenamecheck dorecover;
}

# setup tnsnames.ora and password files

# on Standby
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
alter system set log_archive_dest_state_1=defer;
alter system set log_archive_dest_1='SERVICE=a LGWR ASYNC REOPEN=60 MAX_FAILURE=15 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=a';
alter system set log_archive_dest_state_1=enable;
alter system set fal_server='a';
alter system set fal_client='b';
alter system set log_archive_config='dg_config=(a,b)';
alter system set standby_file_management=auto;

# on Primary
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE SIZE 52428800;
alter system set log_archive_dest_state_1=defer;
alter system set log_archive_dest_1='SERVICE=b LGWR ASYNC REOPEN=60 MAX_FAILURE=15 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=b';
alter system set log_archive_dest_state_1=enable;
alter system switch logfile;
alter system set fal_server='b';
alter system set fal_client='a';
alter system set log_archive_config='dg_config=(a,b)';
alter system set standby_file_management=auto;

# on Standby
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;