Sunday, May 23, 2021

19c DataGuard Build Document

Environment:

Primary: RAC12C

2 Node NODE – node1.localdomain.com

                         - node2.lcoaldomain.com


Standby: RACSB

2 Node NODE – oraclenode1.localdomain.com

            - oraclenode2.lcoaldomain.com


Check RAC12C database status

oracle$ srvctl status database -d RAC12C


Check RAC12C database listener and tnsnames.ora

oracle$ cd $ORACLE_HOME/network/admin

oracle$ cat listener.ora

Node1:

oracle$ cat tnsnames.ora

>>> RAC12C

>>> RAC12C1

>>> RAC12C2

oracle$ lsnrcrtl status

oracle$ lsnrctl status LISTENER_RAC12C


Check GI listener status on PROD servers

grid$ cd $ORACLE_HOME/network/admin

grid$ cat listener.ora

grid$ lsnrcrtl status

grid$ lsnrctl status LISTENER


Check for ASM instance status on PROD Server

grid$ ps -ef|grep smon

>>> on all nodes


Check for All listener status on PROD servers

Check for all listeners (LISTENER and LISTENER_RAC12C will run on all the nodes but SCAN listener may run on any available nodes)

ps -ef|grep tns

>>> LISTENER (Should Run on all node)

>>> ASMNET1LSNR_ASM (Should Run on all node)

>>> LISTNERE_SCAN1

>>> LISTNERE_SCAN2

>>> LISTNERE_SCAN3

>>> LISTNERE_RAC12C (Should Run on all node)


Check cluster resource and Listeners are registered with cluster on PROD server

# crsctl stat res -t -init

# crsctl stat res -t

>>> on all nodes

>>> if not addended please add with below commands

srvctl add listener -l LISTENER_RAC12C -p 1522 -o /u01/app/oracle/product/12.2.0.1/dbhome_1

srvctl start listener -l LISTENER_RAC12C

srvctl stop listener -l LISTENER_RAC12C

srvctl status listener -l LISTENER_RAC12C

lsnrctl status LISTENER_RAC12C


Verify local listener and scan listener on all the DB instances

SQL> show parameter local_listener

>>> If you don’t see local listener then add local listener with below commands

alter system set local_listener ='(DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1522))))' scope=BOTH SID='RAC12C1';

alter system set local_listener ='(DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1522))))' scope=BOTH SID='RAC12C2';

SQL> show parameter remote_listener


Verify TNSPING and the password from primary database on all nodes

oracle$ tnsping RAC12C

oracle$ tnsping RAC12C1

oracle$ tnsping RAC12C2

sqlplus sys/Mallik123@RAC12C as sysdba

sqlplus sys/Mallik123@RAC12C1 as sysdba

sqlplus sys/Mallik123@RAC12C2 as sysdba


Add the standby TNS details on PROD Servers

oracle$ cd $ORACLE_HOME/network/admin

Add below entries

oracle$ vi tnsnames.ora

>>> RACSB

>>> RACSB1

>>> RACSB2


Create initRAC12C.ora in PROD DB servers

On Primary side check for the iniRAC12C.ora under $ORACLE_HOME/dbs directory if not available please create local init file.

oracle$ cd $ORACLE_HOME/dbs

oracle$ ls -lthr


If no initRAC12C.ora found please crease it with below commands

sqlplus / as sysdba

SQL> show parameter spfile;

SQL> create pfile from pfile;


Once created copy it RACSB side

cd $ORACLE_HOME/dbs

scp initRAC12C1.ora oraclenode1:/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/

scp initRAC12C1.ora oraclenode2:/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/


Copy local password file from ASM on PROD Servers

On primary verify the local password file under $ORACLE_HOME/dbs directory if not available please copy it from ASM.

Get password file lcoation:

ASMCMD>pwget --dbuniquename RAC12C


Copy Password file to local file system

ASMCMD>pwcopy '+DATA/RAC12C/PASSWORD/pwdrac12c.292.1067048971' '/tmp/orapwRAC12C'


Copy Password to Standby

scp /tmp/orapwRAC12C oraclenode1:/tmp/orapwRAC12C

scp /tmp/orapwRAC12C oraclenode2:/tmp/orapwRAC12C


Copy from /tmp to $ORACLE_HOME/dbs on Standby Servers

oraclenode1@oracle$ cp /tmp/orapwRAC12C $ORACLE_HOME/dbs

oraclenode2@oracle$ cp /tmp/orapwRAC12C $ORACLE_HOME/dbs


Move Password file to DiskGroup on Standby Servers

ASMCMD>mkdir +DATA/RACSB

ASMCMD>pwcopy '/tmp/orapwRAC12C' '+DATA/RACSB/orapwRACSB'

RAC12C prechks


Connect to primary database and verify force logging and redo logs groups

sqlplus sys/Mallik123@RAC12C as sysdba

select force_logging from v$database;

>>> FORCE_LOGING Should be YES

ALTER DATABASE FORCE LOGGING;


set lines 190 pages 190

col instance for a8

col member for a50

SELECT t.INSTANCE, l.THREAD#, l.GROUP#,  l.SEQUENCE#, l.bytes, l.archived, l.status, lf.MEMBER

FROM v$log l, v$logfile lf, v$thread t

WHERE t.THREAD# = l.THREAD#

AND l.GROUP# = lf.GROUP#

ORDER BY l.THREAD#, GROUP#;

>>> which will display log groups


col member format a50

select GROUP#,TYPE,MEMBER from v$logfile;

select GROUP#,THREAD#,SEQUENCE#,bytes/1024/1024,

MEMBERS,STATUS from v$log;


Add Standby Redo’s on RAC12C Server

Verify Primary side Standby Redo’s on RAC12C Server

col DBID for a10

select * from v$standby_log;

>>> if you don’t find any standby redologs then add the standby redo logs with 1 extra redo logs group on each thread

SQL> Alter database add standby logfile thread 1 group 5 ('+DATA', '+RECO') SIZE 200M;

SQL> Alter database add standby logfile thread 1 group 6 ('+DATA', '+RECO') SIZE 200M;

SQL> Alter database add standby logfile thread 1 group 7 ('+DATA', '+RECO') SIZE 200M;

SQL> Alter database add standby logfile thread 1 group 8 ('+DATA', '+RECO') SIZE 200M;

SQL> Alter database add standby logfile thread 1 group 9 ('+DATA', '+RECO') SIZE 200M;

 

Verify the standby redologs after adding at RAC12C Server

SQL>select * from v$standby_log;

SQL>select group#, thread#, sequence#, archived, status from v$standby_log;


Set dataguard parameter at RAC12C

 

Verify the below dataguard parameter at RAC12C and if not set please set as below

 

show parameter log_archive_config

show parameter standby_file_management

show parameter log_archive_dest_2

show parameter log_archive_dest_state_2

show parameter fal_server


>>> Set these parameter using below commands

alter system set log_archive_config = 'DG_CONFIG=(RAC12C,RACSB)' scope=both sid='*';

alter system set standby_file_management=AUTO scope=both sid='*';


alter system set log_archive_dest_2='SERVICE=RACSB VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=RACSB' scope=both sid='*';

ALTER SYSTEM SET log_archive_dest_2='service=RACSB async valid_for=(online_logfiles,primary_role) db_unique_name=RACSB' scope=both sid='*';

 

alter system set log_archive_dest_state_2='DEFER' scope=both;

alter system set fal_server='RACSB' scope=both sid='*';

ALTER SYSTEM SET db_file_name_convert=' +DATA/RAC12C',' +DATA/RACSB' SCOPE=SPFILE;

ALTER SYSTEM SET log_file_name_convert=' +DATA/RAC12C',' +DATA/RACSB',' +RECO/RAC12C',' +RECO/RACSB' SCOPE=SPFILE;


DR database restore script

cd /home/oracle/

vi Duplicate_RACSB_from_RAC12C.sh

 

export DT=`date '+%m%d%Y%H%M'`

export CUR_DATE=`date`

echo start_time $CUR_DATE

rman target sys/Mallik123@RAC12C auxiliary sys/Mallik123@RACSB1 log=/home/oracle /rmanLog_RACSB_dg_${DT}.log  << xx > dup_RACSB1_${DT}.log

run

{

ALLOCATE  AUXILIARY CHANNEL c1  DEVICE TYPE DISK ;

ALLOCATE  AUXILIARY CHANNEL c2  DEVICE TYPE DISK ;

ALLOCATE  AUXILIARY CHANNEL c3  DEVICE TYPE DISK ;

ALLOCATE  AUXILIARY CHANNEL c4  DEVICE TYPE DISK ;

ALLOCATE  AUXILIARY CHANNEL c5  DEVICE TYPE DISK ;

ALLOCATE  AUXILIARY CHANNEL c6  DEVICE TYPE DISK ;

ALLOCATE  AUXILIARY CHANNEL c7  DEVICE TYPE DISK ;

ALLOCATE  AUXILIARY CHANNEL c8  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c9  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c10  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c11  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c12  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c13  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c14  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c15  DEVICE TYPE DISK ;

ALLOCATE CHANNEL c16  DEVICE TYPE DISK ;

duplicate target database for standby from active database

spfile

parameter_value_convert 'RAC12C','RACSB'

set db_file_name_convert '+DATA/RAC12C/','+DATA/RACSB/'

set db_create_file_dest='+DATA'

set db_recovery_file_dest='+RECO'

set db_recovery_file_dest_size='50G'

set standby_file_management='AUTO'

set diagnostic_dest='/u01/app/oracle'

set db_name='RAC12C'

set db_unique_name='RACSB'

set log_file_name_convert='+DATA/RAC12C/','+DATA/RACSB/','+RECO/RAC12C/','+RECO/RACSB/'

set control_files='+DATA/RACSB/controlfile/control01.ctl','+RECO/RACSB/controlfile/control02.ctl'

set cluster_database='false'

set  core_dump_dest='/u01/app/oracle/diag/rdbms/racsb/RACSB1/cdump'

set  service_names='RACSB'

set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=oraclenode1-vip .localdomain.com)(PORT=1523))))'

set remote_listener= orclscan.localdomain.com:1521'

;

}

exit;

xx

echo end_time $CUR_DATE

 

Create dump and audit directories at RACSB servers

Verify the dump and audit directories and if not created create them

ls -ld /u01/app/oracle/diag/rdbms/racsb/RACSB1/adump

ls -ld /u01/app/oracle/diag/rdbms/racsb/RACSB1/cdump

ls -ld /u01/app/oracle/diag/audit


mkdir -p /u01/app/oracle/diag/rdbms/RACSB/RACSB1/tnodee

mkdir -p /u01/app/oracle/diag/rdbms/RACSB/RACSB1/cdump

mkdir -p /u01/app/oracle/diag/audit

 

Create initRACSB.ora at Standby Servers

Create initRACSB.ora file under $ORACLE_HOME/dbs directory

vi initRACSB.ora

db_name=RAC12C

db_unique_name=RACSB

RACSB.local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraclenode1-vip.localdomain.com)(PORT=1523)))'

remote_listener='orclscan.localdomain.com:1521'

 

Verify RACSB listener and tnsnames.ora file at RACSB Server

oracle$ cd $ORACLE_HOME/network/admin

oracle$ cat listener.ora

 

>>> Add the static listener registration method in listener.ora

[oracle@oraclenode1 admin]$ cat listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

ADR_BASE_LISTENER_RACSB = /u01/app/oracle

LISTENER_RACSB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = oraclenode1-vip.localdomain.com)(PORT = 1523))

  )

SID_LIST_LISTENER_RACSB =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = RACSB)

      (ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/dbhome_1)

      (SID_NAME = RACSB)

    )

  )

 

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_RACSB=ON               # line added by Agent

VALID_NODE_CHECKING_REGISTRATION_LISTENER_RACSB=SUBNET         # line added by Agent

 

oracle$ cat tnsnames.ora

>>> You should see all these below entries

 

>>> STANDB

>>> STANDB1

>>> STANDB2

>>> RAC12C

>>> RAC12C1

>>> RAC12C2

 

Start RACSB in nomount mode

Start the RACSB instance with local initRACSB.ora created in nomount mode.


. oraenv

>>> RACSB

 

vi .bash_profile

>>> set ORACLE_SID=RACSB

 

vi db.env

>>> export ORACLE_SID=RACSB


sqlplus / as sysdba

startup nomount pfile='/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/initRACSB.ora';

 

Add RACSB listener to cluster at RACSB Server

Will verify the STANDBD listener and add them to cluster.


srvctl add listener -l LISTENER_RACSB -p 1523 -o /u01/app/oracle/product/12.2.0.1/dbhome_1

srvctl start listener -l LISTENER_RACSB

srvctl stop listener -l LISTENER_RACSB

srvctl status listener -l LISTENER_RACSB

lsnrctl status LISTENER_RACSB

lsnrctl start LISTENER_RACSB

lsnrctl stop LISTENER_RACSB

 

srvctl remove listener -l LISTENER_RACSB

srvctl config listener -l LISTENER_RACSB

 

oracle$ lsnrcrtl status

oracle$ lsnrctl status LISTENER_RACSB

ps -ef|grep tns

 

Verify the tnsping and password connection at RACSB Server

oracle$ tnsping RAC12C

oracle$ tnsping RAC12C1

oracle$ tnsping RAC12C2

 

oracle$ tnsping RACSB

oracle$ tnsping RACSB1

oracle$ tnsping RACSB2

 

sqlplus sys/Mallik123@RAC12C as sysdba

sqlplus sys/Mallik123@RAC12C1 as sysdba

sqlplus sys/Mallik123@RAC12C2 as sysdba


sqlplus sys/Mallik123@RACSB as sysdba

sqlplus sys/Mallik123@RACSB1 as sysdba

 

Verify the RACSB listener are registered with cluster

grid$ crsctl stat res -t

 

Verify the RMAN connection with axillary instance

rman target sys/Mallik123@RAC12C auxiliary sys/Mallik123@RACSB

rman target sys/Mallik123@RAC12C auxiliary sys/Mallik123@RACSB1

 

Start RMAN active database duplication


Start the RMAN active database duplication and monitor the RACSB restore status using restore log file.

Run the Active database duplicate for standby restore script as below.

cd /home/oracle

nohup ./Duplicate_RACSB_from_RAC12C.sh > /dev/null &

tail -f /home/oracle/rmanLog_RACSB_dg_<DAT_TIMESTAMP>.log

 

Check RACSB restore status

Check the restore status by logging into ASM and datafile directory size.

>>> At RACSB ASM side

ASMCMD> cd +DATA/RACSB/DATAFILE

ASMCMD>ls -l

 

>>> At using restore logfile

tail -f /home/oracle/rmanLog_RACSB_dg_<DAT_TIMESTAMP>.log


After Restore complete verify the RACSB

sqlplus / as sysdba

select name,open_mode from v$database;

select instance_name, status from v$instance;

shut immediate

 

Create NODE initRACSB1.ora from from initRAC12C1.ora at RACSB Server

We will rename initRAC12C1.ora (already created and moved to RACSB in step 10) as initRACSB1.ora and modify the parameter as per RACSB servers.

 

oracle$ cp initRAC12C1.ora initRACSB1.ora

>>> Edit initRACSB1.ora and replace all RAC12C parameter as RACSB parameters

Example: .......

RAC12C1.instance_number=1>>> RACSB1.instance_number=1

RAC12C2.instance_number=2>>> RACSB2.instance_number=2

 

>>> Also we will change the SCAN listener and Local listener as per RACSB name.

node-sacn >>> node-sscan

node1-vip >>> oraclenode1-vip 

node2-vip >>> oraclenode2-vip 

 

Start RACSB instance using initSTANDB1.ora

Start the RACSB1 instance using above modified pfile initRACSB1.ora and create SPFILE inside DATA diskgroup


. oraenv

>>> RACSB1


vi .bash_profile

>>> export ORACLE_SID=RACSB1

 

vi db.env

>>> export ORACLE_SID=RACSB1

 

sqlplus / as sysdba

startup mount pfile='/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/initRACSB1.ora';

create spfile='+DATA/RACSB/PARAMETERFILE/spfileRACSB.ora' from pfile='/u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/initRACSB1.ora';

shut immediate;

 

ASMCMD>cd '+DATA/RACSB/PARAMETERFILE/

ASMCMD> ls -l

 

Create local pfile initSTANDB1.ora point to SPFILE inside diskgroup

Create local pfile initRACSB1.ora to point to SPFILE inside disk_group.

cd $ORACLE_HOME/dbs

mv initRACSB1.ora initRACSB1.ora_after_NODE_modified_GOLD

cp initRACSB1.ora_Final_point_to_SPfile initRACSB1.ora

 

Node1>>>

cd $ORACLE_HOME/dbs

cat > initRACSB1.ora

spfile='+DATA/RACSB/PARAMETERFILE/spfileRACSB.ora'

cat initRACSB1.ora


Node2 >>>

cat > initRACSB2.ora

spfile='+DATA/RACSB/PARAMETERFILE/spfileRACSB.ora'

cat initRACSB2.ora


Start RACSB1 instance and verify the SPFILE

Start RACSB1 instance and verify the it should start with SPFILE which is inside Disk_Group

 

sqlplus / as sysdba

startup mount;

 

show parameter spfile

shut immediate


Convert RACSB database to NODE and add NODE parameter

srvctl add database -d RAC12C -n RAC12C -o '/u01/app/oracle/product/12.2.0.1/dbhome_1' -p '+DATA/RACSB/PARAMETERFILE/spfileRACSB.ora' -t IMMEDIATE -a 'DATA,RECO'

 

Add the NODE instances

srvctl add instance -d RAC12C -i RACSB1 -n oraclenode1

srvctl add instance -d RAC12C -i RACSB2 -n oraclenode2

srvctl config database -d RAC12C

srvctl modify database -d RAC12C -r physical_standby

srvctl remove database -d RAC12C

 

srvctl status database -d RAC12C

srvctl stop database -d RAC12C

srvctl start database -d RAC12C -o mount

srvctl status database -d RAC12C


Verify the RACSB instance started with SPFILE on all nodes

sqlplus / as sysdba

show parameter spfile

Enable Log Archive Destination on Primary RAC12C Server


sqlplus / as sysdba

show parameter log_archive_dest_state_2

alter system set log_archive_dest_state_2=enable scope=both sid='*';

alter system set log_archive_dest_state_2= DEFER scope=both sid='*';

show parameter log_archive_dest_state_2

archive log list


SELECT   a.thread#,  b. last_seq, a.applied_seq, a.last_app_timestamp, b.last_seq-a.applied_seq   ARCHIVE_GAP

FROM (SELECT  thread#, MAX(sequence#) applied_seq, MAX(next_time) last_app_timestamp

FROM gv$archived_log WHERE applied = 'YES' GROUP BY thread#) a,

(SELECT  thread#, MAX (sequence#) last_seq FROM gv$archived_log GROUP BY thread#) b WHERE a.thread# = b.thread#;


Start MRP process on node1 at RACSB Server

sqlplus / as sysdba

set lines 300

select INST_ID,name,open_mode,db_unique_name,database_role from gv$database;

 

alter database recover managed standby database disconnect;

alter database recover managed standby database cancel;

 

select INST_ID,name,open_mode,db_unique_name,database_role from gv$database;

 

set lines 300 pages 300

select message from v$dataguard_status;

 

SELECT THREAD#,sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;


Regards,

Mallik


No comments:

Post a Comment

Automation Script | Archivelog Generation Hourly Monitoring

1. List out all the running databases and pic one database where we want to monitore the archive log generation from last 1 month. [oracle@o...