Saturday, September 11, 2021

Prepare a primary database for a Data Guard environment in Oracle 21c (21.3.0)

Prepare a primary database for a Data Guard environment in Oracle 21c (21.3.0)

Environment:
==========
First Container Database: orcl
Pluggable Databases: PDB & PDB1
GI Version: 21c (21.3.0)
RDBMS Version: 21c (21.3.0)

[oracle@rac1-21c ~]$ . oraenv
ORACLE_SID = [orcl1] ? +ASM1
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@rac1-21c ~]$ asmcmd lsdg
State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512             512   4096  4194304     36852    23188                0           23188              0             N  DATA/
MOUNTED  EXTERN  N         512             512   4096  4194304     24568    24172                0           24172              0             Y  OCRVD/
MOUNTED  EXTERN  N         512             512   4096  4194304     36852    33244                0           33244              0             N  RECO/
[oracle@rac1-21c ~]$

[oracle@rac1-21c ~]$ ps -ef | grep pmon
oracle      8272       1  0 14:33 ?        00:00:00 asm_pmon_+ASM1
oracle     11342       1  0 14:34 ?        00:00:00 ora_pmon_orcl1
oracle     69999       1  0 15:10 ?        00:00:00 ora_pmon_orcldb1
oracle     87499   19459  0 15:22 pts/0    00:00:00 grep --color=auto pmon
[oracle@rac1-21c ~]$

[oracle@rac1-21c ~]$ . oraenv
ORACLE_SID = [+ASM1] ? orcl1
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@rac1-21c ~]$

[oracle@rac1-21c ~]$ sqlplus / as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Sat Sep 11 15:22:35 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle.  All rights reserved.
Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB                            READ WRITE NO
         4 PDB2                           READ WRITE NO

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     24
Current log sequence           25

SQL> select force_logging from gv$database;
FORCE_LOGGING
---------------------------------------
NO
NO
NO

SQL> select flashback_on from gv$database;
FLASHBACK_ON
------------------
NO
NO
NO

SQL> exit
Disconnected from Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
[oracle@rac1-21c ~]$

[oracle@rac1-21c ~]$ dgmgrl /
DGMGRL for Linux: Release 21.0.0.0.0 - Production on Sat Sep 11 15:23:36 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle and/or its affiliates.  All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "orcl"
Connected as SYSDG.
DGMGRL>

DGMGRL> help
The following commands are available:
@              Execute DGMGRL script file
!              Host operating system command
/              Repeat the last command
--             Comment to be ignored by DGMGRL
add            Adds a member to the broker configuration
connect        Connects to an Oracle database instance
convert        Converts a database from one type to another
create         Creates a broker configuration or far sync instance
disable        Disables a configuration, a member, or fast-start failover
edit           Edits a configuration or a member
enable         Enables a configuration, a member, or fast-start failover
exit           Exits the program
export         Export Data Guard Broker configuration to a file.
failover       Changes a standby database to be the primary database
help           Displays description and syntax for a command
host           Host operating system command
import         Import Data Guard Broker configuration from a file.
migrate        Migrate a pluggable database from one configuration to another.
prepare        Prepare a primary database for a Data Guard environment.
quit           Exits the program
reinstate      Changes a database marked for reinstatement into a viable standby
rem            Comment to be ignored by DGMGRL
remove         Removes a configuration or a member
set            Set a DGMGRLI CLI property to a specified value
show           Displays information about a configuration or a member
shutdown       Shuts down a currently running Oracle database instance
spool          store input and output of DGMGRL CLI in a file
sql            Executes a SQL statement
start          Starts the fast-start failover observer
startup        Starts an Oracle database instance
stop           Stops the fast-start failover observer
switchover     Switches roles between a primary and standby database
validate       Performs an exhaustive set of validations for a member
Use "help <command>" to see syntax for individual commands

DGMGRL> help prepare
Prepare a primary database for a Data Guard environment.
Syntax:
  PREPARE DATABASE FOR DATA GUARD
    [WITH [DB_UNIQUE_NAME IS <db-unique-name>]
          [DB_RECOVERY_FILE_DEST IS <directory-location>]
          [DB_RECOVERY_FILE_DEST_SIZE IS <size>]
          [BROKER_CONFIG_FILE_1 IS <broker-config-file-1-location>]
          [BROKER_CONFIG_FILE_2 IS <broker-config-file-2-location>]];

DGMGRL>

DGMGRL> PREPARE DATABASE FOR DATA GUARD 
> WITH 
> DB_UNIQUE_NAME IS ORCL 
> DB_RECOVERY_FILE_DEST IS "+RECO" 
> DB_RECOVERY_FILE_DEST_SIZE IS "10G" 
> BROKER_CONFIG_FILE_1 IS "+DATA" 
> BROKER_CONFIG_FILE_2 IS "+RECO";
Preparing database "orcl" for Data Guard.
Primary database must be restarted to enable archivelog mode.
Shutting down database "orcl".
Database stopped.
Starting database "orcl" to mounted mode.
Database started.
Initialization parameter DB_RECOVERY_FILE_DEST_SIZE set to '10G'.
Initialization parameter DB_RECOVERY_FILE_DEST set to '+RECO'.
Initialization parameter DG_BROKER_CONFIG_FILE1 set to '+DATA'.
Initialization parameter DG_BROKER_CONFIG_FILE2 set to '+RECO'.
LOG_ARCHIVE_DEST_n initialization parameter already set for local archival.
Initialization parameter LOG_ARCHIVE_DEST_2 set to 'location=use_db_recovery_file_dest valid_for=(all_logfiles, all_roles)'.
Initialization parameter LOG_ARCHIVE_DEST_STATE_2 set to 'Enable'.
Adding standby log group size 209715200 and assigning it to thread 3.
Adding standby log group size 209715200 and assigning it to thread 3.
Adding standby log group size 209715200 and assigning it to thread 2.
Adding standby log group size 209715200 and assigning it to thread 2.
Adding standby log group size 209715200 and assigning it to thread 1.
Adding standby log group size 209715200 and assigning it to thread 1.
Initialization parameter STANDBY_FILE_MANAGEMENT set to 'AUTO'.
Initialization parameter DG_BROKER_START set to TRUE.
Database set to FORCE LOGGING.
Database set to ARCHIVELOG.
Database set to FLASHBACK ON.
Shutting down database "orcl".
Database stopped.
Starting database "orcl".
Database started.
DGMGRL>


[oracle@rac1-21c ~]$ . oraenv
ORACLE_SID = [orcl1] ?
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@rac1-21c ~]$

[oracle@rac1-21c ~]$ sqlplus / as sysdba

SQL*Plus: Release 21.0.0.0.0 - Production on Sat Sep 11 15:42:43 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle.  All rights reserved.
Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB                            READ WRITE NO
         4 PDB2                           READ WRITE NO
SQL>

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     24
Next log sequence to archive   25
Current log sequence           25
SQL>

SQL> select force_logging from gv$database;

FORCE_LOGGING
---------------------------------------
YES
YES
YES

SQL> select flashback_on from gv$database;

FLASHBACK_ON
------------------
YES
YES
YES

SQL>

SQL> select group#,type,member from v$logfile where type like 'STAN%';

GROUP# TYPE            MEMBER
------ --------------- ------------------------------------------------------------
     7 STANDBY         +DATA/ORCL/ONLINELOG/group_7.324.1082993621
     7 STANDBY         +RECO/ORCL/ONLINELOG/group_7.310.1082993621
     8 STANDBY         +DATA/ORCL/ONLINELOG/group_8.325.1082993621
     8 STANDBY         +RECO/ORCL/ONLINELOG/group_8.311.1082993623
     9 STANDBY         +DATA/ORCL/ONLINELOG/group_9.326.1082993623
     9 STANDBY         +RECO/ORCL/ONLINELOG/group_9.312.1082993625
    10 STANDBY         +DATA/ORCL/ONLINELOG/group_10.327.1082993625
    10 STANDBY         +RECO/ORCL/ONLINELOG/group_10.313.1082993625
    11 STANDBY         +DATA/ORCL/ONLINELOG/group_11.328.1082993627
    11 STANDBY         +RECO/ORCL/ONLINELOG/group_11.314.1082993627
    12 STANDBY         +DATA/ORCL/ONLINELOG/group_12.329.1082993629
    12 STANDBY         +RECO/ORCL/ONLINELOG/group_12.315.1082993629

12 rows selected.

SQL> select group#,type,member from v$logfile where type like 'ONLIN%';

GROUP# TYPE            MEMBER
------ --------------- ------------------------------------------------------------
     2 ONLINE          +DATA/ORCL/ONLINELOG/group_2.263.1080574111
     2 ONLINE          +RECO/ORCL/ONLINELOG/group_2.258.1080574111
     1 ONLINE          +DATA/ORCL/ONLINELOG/group_1.262.1080574111
     1 ONLINE          +RECO/ORCL/ONLINELOG/group_1.257.1080574111
     3 ONLINE          +DATA/ORCL/ONLINELOG/group_3.271.1080574361
     3 ONLINE          +RECO/ORCL/ONLINELOG/group_3.259.1080574361
     4 ONLINE          +DATA/ORCL/ONLINELOG/group_4.272.1080574363
     4 ONLINE          +RECO/ORCL/ONLINELOG/group_4.260.1080574363
     5 ONLINE          +DATA/ORCL/ONLINELOG/group_5.273.1080574363
     5 ONLINE          +RECO/ORCL/ONLINELOG/group_5.261.1080574365
     6 ONLINE          +DATA/ORCL/ONLINELOG/group_6.274.1080574365
     6 ONLINE          +RECO/ORCL/ONLINELOG/group_6.262.1080574365

12 rows selected.

SQL>

No comments:

Post a Comment