Oracle 11g Physical Standy Setup

 

Step1: take Binaries tar backup from Primary DB server

tar -cvf /path/11.2.0.4.tar 11.2.0.4

Step2: untar Binaries tar back on Standby DB server

tar -xvf /path/11.2.0.4.tar -C /path

###################### Binaries Cloning ###################

Step3: run clone command on Standby DB server

export ORACLE_HOME=<PATH>

cd $ORACLE_HOME/clone/bin

perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE='<PATH>' ORACLE_HOME='<PATH>' ORACLE_HOME_NAME='<ANY_NAME>'


###################### POST Binaries Cloning ###################

Step4: run root scripts

$ORACLE_BASE/oraInventory/orainstRoot.sh

$ORACLE_HOME/root.sh


###################### Pre-requisites ###################

Standby:

Step5: update hostnames in listener and tnsnames files

Step6: start the listener in standby Server

Primary:

Step7: check force logging enabled -- to make sys activities will logged in redo logs

SQL> select force_logging from v$database; - NO ( default )

to enable force logging - SQL> alter database force logging;

SQL> select force_logging from v$database; - Yes

Step8: Create standby redo logs -- it will replicate automatically during rman

SQL> col "redo file name" for a60

col status for a20

select i.group#,l.thread#,bytes/1048576 "Size_MB",l.sequence#,l.archived,l.status,f.member "redo file name" from v$log l join v$logfile f on l.group#=f.group# order by l.group#;

SQL> col "redo file name" for a60

col status for a20

select i.group#,l.thread#,bytes/1048576 "Size_MB",l.sequence#,l.archived,l.status,f.member "redo file name" from v$standby_log l join v$logfile f on l.group#=f.group# order by l.group#;

SQL> alter database add standby logfile thread <number> group <number> ('/path/redo1a.log','/path/redo1b.log') size <number>g; --> size should same as primary redo logs otherwise apply  always shows lag and we need to manually switch log file in primary to check the apply LAG status

Standby:

SQL>alter system set db_unique_name='<ORACLE_SID>_p' scope=spfile;

SQL>alter system set db_recovery_file_dest_size=<number>g;

SQL>alter system set db_recovery_file_dest='+FRA'; -- ASM or filesystem

SQL>alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles.all_roles)' scope=both sid='*';

SQL>ALTER SYSTEM SET DB_CREATE_FILE_DEST='+DATA'; -- ASM or filesystem

SQL> alter system set  db_create_online_log_dest_1='+RECO'; -- ASM or filesystem

SQL> alter system set log_file_name_convert='<OLD_PATH_FOLDER>','+RECO','<OLD_PATH_FOLDER>','+RECO' scope=spfile;

NOTE: incase standby redo logs are not converted then after restoring data try to rename standby redo logs manually.

--SQL> alter database rename file '<OLD_PATH_FILENAME>' TO '+RECO/FILENAME';

SQL>alter system set db_file_name_convert='<OLD_PATH_FOLDER>','+DATA','<OLD_PATH_FOLDER>','+DATA' scope=spfile;

SQL> alter system set control_files='+DATA','+RECO' scope=spfile;

Step8: use rman to restore data from standby Db server

prepare below content and save clone.rcv

connect target sys/password@primarydb

connect auxiliary sys/password@standbydb

run {

allocate channel c1 type disk;

allocate auxiliary channel d1 type disk;

set newname for database to '+DATA'; -- ASM 

duplicate target database for standby from active database nofilenamecheck dorecover;

}

run the rman command:

nohup $ORACLE_HOME/bin/rman @clone.rcv > stby.log 2>&1 &


Step9: Enable Archive shipping and apply

Primary:

SQL> alter system set fal_server='<standby_db_unique_name>'  scope=both sid='*';

SQL> alter system set fal_client='<primary_db_unique_name>'  scope=both sid='*';

SQL> alter system set log_archive_config='dg_config=(<primary_db_unique_name>,<standby_db_unique_name>)' scope=both sid='*';

Standby:

SQL> alter system set fal_server='<primary_db_unique_name>'  scope=both sid='*';

SQL> alter system set fal_client='<standby_db_unique_name>'  scope=both sid='*';

SQL> alter system set log_archive_config='dg_config=(<standby_db_unique_name>,<primary_db_unique_name>)' scope=both sid='*';

Primary:

SQL> alter system set log_archive_dest_2='service=<service_name> async noaffirm reopen=15 valid_for=(all_logfiles,primary_role)  db_unique_name=<standby_db_unique_name>' scope=both sid='*';

SQL> alter system set log_archive_dest_state_2='ENABLE' scope=both sid='*';

NOTE: check in primary alert log log_archive_dest_state_2 should be ACTIVE

Step10: Start the MRP process

Standby:

SQL> select process,thread#,sequence#,status from gv$managed_standby where process='MRP0';

SQL> recover managed standby database disconnect from session; -- start MRP

Step 11: once LAG recovered, 

Primary and Standby:

SQL> alter system set standby_file_management=auto scope=both;


Step11 ( OPTIONAL ):

incase standby redo logs are not on new disk location ( ASM )

Primary and Standby:

SQL> alter system set standby_file_management=MANUAL scope=both;

Standby

SQL> select process,thread#,sequence#,status from gv$managed_standby where process='MRP0';

SQL> alter database recover managed standby database cancel; -- stop MRP

SQL> alter database rename file '<OLD_LOCATION>' to '<NEW_LOCATION>';

SQL> recover managed standby database disconnect from session; -- start MRP

SQL> select process,thread#,sequence#,status from gv$managed_standby where process='MRP0';

Primary and Standby:

SQL> alter system set standby_file_management=auto scope=both;


####################### DGMGRL setup #######################

Step1: listener.ora  and tnsnames.ora files update

Standby:

 listener.ora

(SID_DESC =

                (GLOBAL_DBNAME = <standby_db_unique_name>_DGMGRL.<domain_name>)

                (SID_NAME = <primary_db_unique_name>)

                (ORACLE_HOME = <ORACLE_HOME>)

        )

tnsnames.ora

<standby_db_unique_name>_DGMGRL.<domain_name>=

    (DESCRIPTION =

        (ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>) (PORT = <number>))

        (CONNECT_DATA = (SERVER = DEDICATED)

        (SID = <primary_db_unique_name>)

        (SERVICE_NAME = <standby_db_unique_name>_DGMGRL.<domain_name>)

)

)

primary:

(SID_DESC =

                (GLOBAL_DBNAME = <primary_db_unique_name>_DGMGRL.<domain_name>)

                (SID_NAME = <primary_db_unique_name>)

                (ORACLE_HOME = <ORACLE_HOME>)

        )

tnsnames.ora

<primary_db_unique_name>_DGMGRL.<domain_name>=

    (DESCRIPTION =

        (ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>) (PORT = <number>))

        (CONNECT_DATA = (SERVER = DEDICATED)

        (SID = <primary_db_unique_name>)

        (SERVICE_NAME = <primary_db_unique_name>_DGMGRL.<domain_name>)

)

)

Step2: Add DGMGRL configurations

Primary and standby:

SQL> alter system set dg_broker_start=TRUE scope=both sid='*';

Primary:

dgmgrl sys/password@<primary_db_unique_name>_DGMGRL.<domain_name>

DGMGRL> create configuration '<DBNAME_dg>' as primary database is '<primary_db_unique_name>' connect identifier is '<primary_db_unique_name>_DGMGRL.<domain_name>';

DGMGRL> add database <standby_db_unique_name> as connect identifier is '<standby_db_unique_name>_DGMGRL.<domain_name>';

NOTE: update StaticConnectIdentifier ( e.g hostname ) for primary and standby properties.

DGMGRL> edit database <primary_db_unique_name> set property StaticConnectIdentifier=' (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>) (PORT = <number>))    (CONNECT_DATA = (SERVICE_NAME = <primary_db_unique_name>_DGMGRL.<domain_name>)(INSTANCE_NAME=<primary_db_unique_name>)(SERVER = DEDICATED)))

DGMGRL> edit database <standby_db_unique_name> set property StaticConnectIdentifier=' (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = <hostname>) (PORT = <number>))    (CONNECT_DATA = (SERVICE_NAME = <standby_db_unique_name>_DGMGRL.<domain_name>)(INSTANCE_NAME=<standby_db_unique_name>)(SERVER = DEDICATED)))


NOTE: check any inconsistent parameters values

DGMGRL> show database <primary_db_unique_name> InconsistentProperties

DGMGRL> show database <standby_db_unique_name> InconsistentProperties


DGMGRL>  enable configuration

DGMGRL>  show configuration

DGMGRL>  show database verbose <standby_db_unique_name> - no lag should be appear








Comments

Popular Posts

AWR Report Analysis

Goldengate 19c Installation with issue resolution

Oracle 12c 2-node RAC setup in VMware Player 15 -- Part01

Execution_Explain Plan

Oracle to Postgres

Active Session History Analysis

General Queries

Fragmentation & Re-organisation

Postgresql installation offline using NGINX