Saturday, August 26, 2017

OEM CONFIGURATION IN RAC

OEM CONFIGURATION IN RAC



SQL> alter user sysman identified by sysman;

User altered.

SQL> alter user sysman account unlock;

User altered.

SQL>  alter user dbsnmp  account unlock;

User altered.

SQL> alter user dbsnmp  identified by dbsnmp;

User altered.

SQL> conn sysman/sysman;
Connected.
SQL> select * from session_privs;

PRIVILEGE
----------------------------------------
CREATE SESSION
ALTER SESSION
UNLIMITED TABLESPACE
ALTER USER
CREATE TABLE
CREATE CLUSTER
CREATE PUBLIC SYNONYM
CREATE VIEW
CREATE SEQUENCE
CREATE PROCEDURE
CREATE TRIGGER

PRIVILEGE
----------------------------------------
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE
SELECT ANY DICTIONARY

15 rows selected.

SQL> select * from session_roles;

ROLE
------------------------------
RESOURCE
SELECT_CATALOG_ROLE
HS_ADMIN_SELECT_ROLE
MGMT_USER

SQL>

SQL> conn dbsnmp/dbsnmp
Connected.
SQL>  select * from session_roles;

ROLE
------------------------------
OEM_MONITOR
SELECT_CATALOG_ROLE
HS_ADMIN_SELECT_ROLE

SQL>  select * from session_privs;

PRIVILEGE
----------------------------------------
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE PROCEDURE
ANALYZE ANY
MANAGE ANY QUEUE
SELECT ANY DICTIONARY
ANALYZE ANY DICTIONARY
ADVISOR
CREATE JOB

10 rows selected.

SQL>


You have specified the following settings

Database ORACLE_HOME ................ /u01/app/oracle/product/11204/dbhome

Database instance hostname ................ Listener ORACLE_HOME ................ /u01/app/11204/grid
Listener port number ................ 1521
Cluster name ................ rcscan
Database unique name ................ DEV
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............
ASM ORACLE_HOME ................ /u01/app/11204/grid
ASM port ................ 1521
ASM user role ................ SYSDBA
ASM username ................ ASMSNMP


192.168.1.111   rac1pub111.dba.com    rac1pub111

INFO: >>>>>>>>>>> The Database Control URL is https://rac1pub111.dba.com:1158/em <<<<<<<<<<<
Aug 12, 2017 6:31:59 PM oracle.sysman.emcp.EMDBPostConfig showClusterDBCAgentMessage
INFO:
****************  Current Configuration  ****************
 INSTANCE            NODE           DBCONTROL_UPLOAD_HOST
----------        ----------        ---------------------

DEV               rac1pub111               rac1pub111.dba.com
DEV               rac2pub112               rac1pub111.dba.com


Aug 12, 2017 6:31:59 PM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING:
************************  WARNING  ************************

Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.  The encryption key has been placed in the file: /u01/app/oracle/product/11204/dbhome/rac1pub111_DEV/sysman/config/emkey.ora. Ensure this file is backed up as the encrypted data will become unusable if this file is lost.

***********************************************************
Enterprise Manager configuration completed successfully
FINISHED EMCA at Aug 12, 2017 6:31:59 PM



SQL> select status from gv$instance;

STATUS
------------
OPEN
OPEN

SQL> desc v$instance;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 INSTANCE_NUMBER                                    NUMBER
 INSTANCE_NAME                                      VARCHAR2(16)
 HOST_NAME                                          VARCHAR2(64)
 VERSION                                            VARCHAR2(17)
 STARTUP_TIME                                       DATE
 STATUS                                             VARCHAR2(12)
 PARALLEL                                           VARCHAR2(3)
 THREAD#                                            NUMBER
 ARCHIVER                                           VARCHAR2(7)
 LOG_SWITCH_WAIT                                    VARCHAR2(15)
 LOGINS                                             VARCHAR2(10)
 SHUTDOWN_PENDING                                   VARCHAR2(3)
 DATABASE_STATUS                                    VARCHAR2(17)
 INSTANCE_ROLE                                      VARCHAR2(18)
 ACTIVE_STATE                                       VARCHAR2(9)
 BLOCKED                                            VARCHAR2(3)

SQL> select INSTANCE_NUMBER,INSTANCE_NAME,ACTIVE_STATE from  gv$instance;

INSTANCE_NUMBER INSTANCE_NAME    ACTIVE_ST
--------------- ---------------- ---------
              1 DEV1             NORMAL
              2 DEV2             NORMAL

SQL>

How to check oem is running or not

[oracle@rac1pub111 u01]$ export ORACLE_UNQNAME=DEV
[oracle@rac1pub111 u01]$ emctl status agent
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
Agent Version     : 10.2.0.4.5
OMS Version       : 10.2.0.4.5
Protocol Version  : 10.2.0.4.5
Agent Home        : /u01/app/oracle/product/11204/dbhome/rac1pub111_DEV
Agent binaries    : /u01/app/oracle/product/11204/dbhome
Agent Process ID  : 51983
Parent Process ID : 51937
Agent URL         : https://rac1pub111.dba.com:3938/emd/main
Repository URL    : https://rac1pub111.dba.com:1158/em/upload/
Started at        : 2017-08-12 18:29:36
Started by user   : oracle
Last Reload       : 2017-08-12 19:05:34
Last successful upload                       : 2017-08-12 21:39:51
Total Megabytes of XML files uploaded so far :    24.32
Number of XML files pending upload           :        0
Size of XML files pending upload(MB)         :     0.00
Available disk space on upload filesystem    :    87.84%
Data channel upload directory                : /u01/app/oracle/product/11204/dbhome/rac1pub111_DEV/sysman/recv
Last successful heartbeat to OMS             : 2017-08-12 21:42:43
---------------------------------------------------------------
Agent is Running and Ready

How to start OEM:

$ emctl start dbconsole

from chrome: https://racpub111.dba.com

No rac to rac cloning Method 1(RCONFIG)

Method 1(RCONFIG):-
-----------------------------
1. Copy database / archive /controlfile backup from standalone to rac server 1)
----RAC SERVER 1:-
2. Create parameter file
vi initTEST.ora

*.audit_file_dest='/u01/app/oracle/admin/TEST/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='TEST'
*.diagnostic_dest='/u01/app/oracle'
*.remote_login_passwordfile='exclusive'
*.undo_tablespace='UNDOTBS01'
*.db_file_name_convert='/u01/prod','+DATA'
*.log_file_name_convert='/u01/prod','+DATA'
*.cluster_database=false
*.control_files='+DATA/TEST/CONTROLFILE/current.260.936693527'



SQL> create spfile='+DATA/spfileTEST.ora' from pfile;

[oracle@rac1pub dbs]$ cat initTEST.ora
spfile='+DATA/spfileTEST.ora'
[oracle@rac1pub dbs]$ export ORACLE_SID=TEST

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  238034944 bytes
Fixed Size                  2252016 bytes
Variable Size             180355856 bytes
Database Buffers           50331648 bytes
Redo Buffers                5095424 bytes

[oracle@rac1pub rman]$ rman auxiliary /
RMAN> duplicate target database to TEST backup location '/u01/rman/' nofilenamecheck;

RCONFIG:-CONVERT TEST TO RAC DATABASE

[oracle@rac1pub sampleXMLs]$ pwd
/u01/app/oracle/product/11203/dbhome_1/assistants/rconfig/sampleXMLs
[oracle@rac1pub sampleXMLs]$ cp -rf ConvertToRAC_AdminManaged.xml /u01/app/oracle/
[oracle@rac1pub oracle]$ mv ConvertToRAC_AdminManaged.xml rconfig.xml


[oracle@rac1pub oracle]$ cat rconfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<n:RConfig xmlns:n="http://www.oracle.com/rconfig"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.oracle.com/rconfig rconfig.xsd">
    <n:ConvertToRAC>
<!-- Verify does a precheck to ensure all pre-requisites are met, before the conversion is attempted. Allowable values are: YES|NO|ONLY -->
        <n:Convert verify="ONLY">  ###CHANGE from YES TO ONLY####
<!--Specify current OracleHome of non-rac database for SourceDBHome -->
              <n:SourceDBHome>/u01/app/oracle/product/11203/dbhome_1</n:SourceDBHome>  ##CHANGE O_H
<!--Specify OracleHome where the rac database should be configured. It can be same as SourceDBHome -->
              <n:TargetDBHome>/u01/app/oracle/product/11203/dbhome_1</n:TargetDBHome> ##CHANGE O_H
<!--Specify SID of non-rac database and credential. User with sysdba role is required to perform conversion -->
              <n:SourceDBInfo SID="TEST">  ###SID NAME
                <n:Credentials>
                  <n:User>sys</n:User>
                  <n:Password>manager</n:Password>  ###PASSWORD
                  <n:Role>sysdba</n:Role>
                </n:Credentials>
              </n:SourceDBInfo>
<!--Specify the list of nodes that should have rac instances running for the Admin Managed Cluster Database. LocalNode should be the first node in this nodelist. -->
              <n:NodeList>
                <n:Node name="rac1pub"/>  ###NODE NAME
                <n:Node name="rac2pub"/>  ### NODE NAME
              </n:NodeList>
<!--Specify RacOneNode along with servicename to convert database to RACOne Node -->
              <!--n:RacOneNode  servicename="TEST"/-->  ###SERVICE  NAME####
<!--Instance Prefix tag is optional starting with 11.2. If left empty, it is derived from db_unique_name.-->
              <n:InstancePrefix>TEST</n:InstancePrefix>  ####INSTANCE NAME###
<!-- Listener details are no longer needed starting 11.2. Database is registered with default listener and SCAN listener running from Oracle Grid Infrastructure home. -->
<!--Specify the type of storage to be used by rac database. Allowable values are CFS|ASM. The non-rac database should have same storage type. ASM credentials are no needed for conversion. -->
              <n:SharedStorage type="ASM">
<!--Specify Database Area Location to be configured for rac database.If this field is left empty, current storage will be used for rac database. For CFS, this field will have directory path. -->
                <n:TargetDatabaseArea>+DATA</n:TargetDatabaseArea>  ###DISKGROUP  NAME###
<!--Specify Fast Recovery Area to be configured for rac database. If this field is left empty, current recovery area of non-rac database will be configured for rac database. If current database is not using recovery Area, the resulting rac database will not have a recovery area. -->
                <n:TargetFlashRecoveryArea>+FRA</n:TargetFlashRecoveryArea>  ##FRA DISKGROUP NAME###
              </n:SharedStorage>
        </n:Convert>
    </n:ConvertToRAC>
</n:RConfig>


[oracle@rac1pub oracle]$ rconfig rconfig.xml
<?xml version="1.0" ?>
<RConfig version="1.1" >
<ConvertToRAC>
    <Convert>
      <Response>
        <Result code="0" >
          Operation Succeeded  #####IMP####
        </Result>
      </Response>
      <ReturnValue type="object">
There is no return value for this step     </ReturnValue>
    </Convert>
  </ConvertToRAC></RConfig>

$vi rconfig.xml

!-- Verify does a precheck to ensure all pre-requisites are met, before the conversion is attempted. Allowable values are: YES|NO|ONLY -->
        <n:Convert verify="YES">  ###CHANGE from ONLY TO YES####

[oracle@rac1pub oracle]$ rconfig rconfig.xml
Converting Database "TEST" to Cluster Database. Target Oracle Home: /u01/app/oracle/product/11203/dbhome_1. Database Role: PRIMARY.
Setting Data Files and Control Files

NON RAC TO RAC CLONING(METHOD-MANNUAL)

NON RAC TO RAC CLONING(METHOD-MANNUAL)

1. Copy backup of database/ archivelog / controlfile
[oracle@rac1pub111 u01]$ ls
11.2.0.4  11g.env  app  backup  grid.env  gridsw  lost+found
[oracle@rac1pub111 u01]$

2. scp backup to rac node 1
3. create parameter file and copy to asm disk group


[oracle@rac1pub111 dbs]$ cat initPROD.ora
*.audit_file_dest='/u01/app/oracle/admin/PROD/adump'
*.audit_trail='db'
*.cluster_database=false
*.compatible='11.2.0.4.0'
*.control_files='+DATA/PROD/controlfile/current.260.951842647'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='PROD'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PRODXDB)'
*.open_cursors=300
*.processes=150
*.remote_listener='rcscan:1521'
*.remote_login_passwordfile='exclusive'
*.undo_tablespace='UNDOTBS1'

log_file_name_convert='/u01/test','+DATA'
db_file_name_convert=='/u01/test','+DATA'
[oracle@rac1pub111 dbs]$


4. start database in nomount stage.

ASMCMD> mkdir PROD
ASMCMD> ls
DEV/
PROD/
shz1.dbf
tbs01.dbf
ASMCMD

ASMCMD> mkdir spfile
ASMCMD> pwd
+DATA/PROD
ASMCMD>

[oracle@rac1pub111 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 14 21:02:20 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  246386688 bytes
Fixed Size                  2252096 bytes
Variable Size             188744384 bytes
Database Buffers           50331648 bytes
Redo Buffers                5058560 bytes
SQL>


SQL>  create spfile='+DATA/PROD/spfile/spfilePROD.ora' from pfile;

File created.

SQL>

5. duplicate target database to clone
    rman auxiliary /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Aug 14 21:04:49 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to auxiliary database: PROD (not mounted)

RMAN> duplicate target database to 'PROD' backup location '/u01/backup' nofilenamecheck;
6.clone database open.




Mannually setps to convert non rac to rac.

first create spfile from pfile
SQL> create spfile='+DATA/PROD/spfile/spfilePROD.ora' from pfile;

File created.

then create pfile and add loction of spfile.
[oracle@rac1pub111 dbs]$ cat initPROD.ora
spfile='+DATA/PROD/spfile/spfilePROD.ora'

[oracle@rac1pub111 dbs]$


SQL> startup
ORACLE instance started.

Total System Global Area  246386688 bytes
Fixed Size                  2252096 bytes
Variable Size             188744384 bytes
Database Buffers           50331648 bytes
Redo Buffers                5058560 bytes
Database mounted.
Database opened.
SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/prod/spfile/spfileprod.o
                                                 ra
SQL>


SQL> alter system checkpoint;

System altered.

SQL> alter system switch logfile;

System altered.

SQL>  alter database add logfile thread 2 group 3 size 100m;

Database altered.

SQL>  alter database add logfile thread 2 group 5 size 100m;

Database altered.

SQL> alter database enable thread 2;

Database altered.

SQL> alter database add logfile thread 1 group 6 size 100m;

Database altered.

SQL> alter database add logfile thread 1 group 7 size 100m;

Database altered.

SQL>  alter database add logfile thread 1 group 8 size 100m;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> select thread#,group#,bytes/1024 from v$log;

   THREAD#     GROUP# BYTES/1024
---------- ---------- ----------
         1          3      51200
         2          4     102400
         2          5     102400
         1          6     102400
         1          7     102400
         1          8     102400



SQL> create undo tablespace UNDOTBS2 datafile '+DATA';

Tablespace created.



SQL> alter system set cluster_database=true scope=spfile;

System altered.

SQL> alter system set cluster_database_instances=2 scope=spfile;

System altered.

SQL> alter system set THREAD=1 scope=spfile sid='PROD1';

System altered.

SQL>  alter system set THREAD=2  scope=spfile sid='PROD2';

System altered.

SQL> show parameter undo_tablespace;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace                      string      UNDOTBS1
SQL> alter system set undo_tablespace=UNDOTBS1 scope=spfile SID='PROD1';

System altered.

SQL> alter system set undo_tablespace=UNDOTBS2 scope=spfile SID='PROD2';

System altered.

SQL> alter system set INSTANCE_NUMBER=1 scope=spfile sid='PROD1';

System altered.

SQL> alter system set INSTANCE_NUMBER=2 scope=spfile sid='PROD2';

System altered.


SQL> alter system set diagnostic_dest='/u01/app/oracle' scope=spfile sid='PROD1';

System altered.

SQL> alter system set diagnostic_dest='/u01/app/oracle' scope=spfile sid='PROD2';

System altered.

[oracle@rac1pub111 dbs]$ vi initPROD1.ora
[oracle@rac1pub111 dbs]$ orapwd file=orapwPROD1 password=manager
[oracle@rac1pub111 dbs]$ export ORACLE_SID=PROD1
[oracle@rac1pub111 dbs]$ !sq


node 2

[oracle@rac2pub112 dbs]$ mkdir -p /u01/app/oracle/admin/PROD/adump                  [oracle@rac2pub112 dbs]$

[oracle@rac2pub112 dbs]$ vi initPROD2.ora
[oracle@rac2pub112 dbs]$ orapwd file=orapwPROD2 password=manager
[oracle@rac2pub112 dbs]$ export ORACLE_SID=PROD2
[oracle@rac2pub112 dbs]$ !sq
SQL> startup
ORACLE instance started.

Total System Global Area  263090176 bytes
Fixed Size                  2252256 bytes
Variable Size             205521440 bytes
Database Buffers           50331648 bytes
Redo Buffers                4984832 bytes
Database mounted.
Database opened.
SQL>

SQL>  select status, instance_name  from gv$instance;

STATUS       INSTANCE_NAME
------------ ----------------
OPEN         PROD2
OPEN         PROD1

SQL>


[oracle@rac2pub112 admin]$ pwd
/u01/app/oracle/product/11204/dbhome/rdbms/admin
[oracle@rac2pub112 admin]$ ll catc
catcapi.sql   catcdc.sql    catclust.sql  catcrc.sql
catcapit.sql  catchnf.sql   catcmprm.sql  catcrsc.sql
catcap.sql    catcio.sql    catcmp.sql    catcr.sql
[oracle@rac2pub112 admin]$ ll catclust.sql
-rw-r--r-- 1 oracle oinstall 30182 Aug 12 16:26 catclust.sql
[oracle@rac2pub112 admin]$

FRom node 1


SQL> @?/rdbms/admin/catclust.sql;
 Node 2


SQL> sho parameter remote_listener;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_listener                      string      rcscan:1521
SQL>


node 1

# Generated by Oracle configuration tools.

DEV =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rcscan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = DEV)
    )
  )


PROD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rcscan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PROD)
    )
  )

[oracle@rac1pub112 admin]$

 node 2:

DEV =
(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rcscan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = DEV)
    )
  )


PROD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rcscan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PROD)
    )
  )



node 1

alter system set local_listener='(ADDRESS = (PROTOCOL=TCP)(HOST=192.168.1.113)(PORT=1521))' scope=both sid='PROD1' ;

alter system set local_listener='(ADDRESS = (PROTOCOL=TCP)(HOST=192.168.1.114)(PORT=1521))' scope=both sid='PROD2' ;


SQL> alter system register;

System altered.

SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

From node 1 only:


[oracle@rac1pub111 u01]$ srvctl add database -d PROD -o /u01/app/oracle/product/11204/dbhome -y AUTOMATIC

[oracle@rac1pub111 u01]$ srvctl config database -d prod
Database unique name: PROD
Database name:
Oracle home: /u01/app/oracle/product/11204/dbhome
Oracle user: oracle
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: PROD
Database instances:
Disk Groups:
Mount point paths:
Services:
Type: RAC
Database is administrator managed

[oracle@rac1pub111 u01]$ srvctl modify database -d PROD -p '+DATA/prod/spfile/spfilePROD.ora' -s open

[oracle@rac1pub111 u01]$ srvctl add instance -d PROD -i PROD1 -n rac1pub111
[oracle@rac1pub111 u01]$ srvctl add instance -d PROD -i PROD2 -n rac2pub112

node 1:
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

node 2:

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

NODE 1:

[oracle@rac1pub111 u01]$ srvctl start database -d PROD
[oracle@rac1pub111 u01]$ srvctl status database -d PROD
Instance PROD1 is running on node rac1pub111
Instance PROD2 is running on node rac2pub112
[oracle@rac1pub111 u01]$


HOW TO ENABLE FRA IN RAC



SQL> show parameter db_recovery_;

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------           -----------------
db_recovery_file_dest                string
db_recovery_file_dest_size           big integer 0

FROM ANY NODE

SQL> alter system set db_recovery_file_dest_size=20g scope=spfile sid='*';

System altered.

SQL> alter system set db_recovery_file_dest='+FRA' scope=spfile sid='*';

System altered.

SQL>

[oracle@rac1pub111 u01]$ srvctl stop database -d DEV
[oracle@rac1pub111 u01]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Aug 12 22:27:59 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size                  2253784 bytes
Variable Size            1040190504 bytes
Database Buffers          603979776 bytes
Redo Buffers                7094272 bytes
Database mounted.
SQL> alter database flashback on;

Database altered.

SQL> select flashback_on from v$database;

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

SQL>

[oracle@rac1pub111 u01]$ srvctl stop database -d DEV
[oracle@rac1pub111 u01]$ srvctl start database -d DEV
[oracle@rac1pub111 u01]$ srvctl status database -d DEV
Instance DEV1 is running on node rac1pub111
Instance DEV2 is running on node rac2pub112
[oracle@rac1pub111 u01]$


[oracle@rac2pub112 admin]$ !sq
sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Aug 12 22:33:51 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>  select flashback_on from v$database;

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

SQL>

Wednesday, August 2, 2017

How to configure Flashback Data Archive on Table level

Flashback Data Archive (FDA)

Points to Remember

1) A FDA can be configured to guarantee the ability to flash back a table to any time(perhaps to a time years ago).

2) Easy to configure – apply to all tables, one or a group of tables with simple “enable archive” command.

3) Secure – complete protection from accidental or malicious updates and deletes.

4) However, you cannot use this feature with clustered, temporary, nested, remote or external tables and
long or nested columns.


Create a new user and grant him the required privileges

SQL> create user adeeb identified by adeeb
Grant succeeded.


SQL> grant connect, resource, flashback archive administer to adeeb;

Grant succeeded.


Create a new separate tablespace for data archive

SQL> create tablespace fda_tsb datafile '/u01/panclone/fda_tsb.db' size 30m;

Tablespace created.



Create flashback archive on this tablespace using the create flashback archive commands follows

SQL>
create flashback archive fl_arch tablespace fda_tsb retention 1 year;
Flashback archive created.


With the above command, a flashback archive named fl_arch is created which resides in the 
tablespace fda_tsb and holds information for one year.
It means that you can use any flashback query which contains one year of historical information regarding the table that is assigned to this flashback archive.

Now, create a table, insert one row and assign it to the flashback archive

SQL> conn adeeb/adeeb
Connected.
SQL> create
table tbl_fl_archive (id number, name varchar2(20));  2

Table created.

SQL> insert into
tbl_fl_archive values(1,'Flashback Archive');  2

1 row created.

SQL> commit
  2  ;

Commit complete.

SQL>

SQL> select * from
tbl_fl_archive;  2

        ID NAME
---------- --------------------
         1 Flashback Archive

SQL>

SQL>  alter table  tbl_fl_archive flashback archive fl_arch;

Table altered.


The historical change on the table tbl_fl_archive will now be written to the flashback archive named fl_archive.

To test it, delete all rows from the table and use flashback queryon that table. Remember, it will not look for the undo data; it will look to the flashback archive file for the changes.



SQL>    select
to_char(sysdate,'ddmmyyyy hh24:mi:ss') ddate
from
dual;  2    3    4

DDATE
-----------------
28072017 19:07:33

SQL> delete
from tbl_fl_archive;  2

1 row deleted.

SQL> commit
  2  ;

Commit complete.

SQL> select * from
tbl_fl_archive;  2

no rows selected


SQL> select * from
tbl_fl_archive as of timestamp to_timestamp('28072017
19:07:33','ddmmyyyy hh24:mi:ss');
  2    3
        ID NAME
---------- --------------------
         1 Flashback Archive

SQL>


How to recover Data using Flashback Data Archive.

SQL> insert into tbl_fl_archive select * from tbl_fl_archive as of timestamp to_timestamp('28072017
19:07:33','ddmmyyyy hh24:mi:ss');  2

1 row created.

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
SYS_FBA_DDL_COLMAP_88630       TABLE
SYS_FBA_HIST_88630             TABLE
SYS_FBA_TCRV_88630             TABLE
TBL_FL_ARCHIVE                 TABLE

SQL> show user;
USER is "ADEEB"
SQL>
























Wednesday, April 26, 2017

RAC to non RAC data Guard (11gR2)

Here i created a physical standby database standby for RAC database TEST instance names TEST1 and TEST2.

PRIMARY(2node Rac)
STANDBY
IP
192.168.1.151
192.168.1.152
192.168.1.161
HOSTNAME
rac1-pub.dba.com
rac2-pub.dba.com
standby161.dba.com

DB NAME
TEST
TEST
DB UNIQUE NAME
TEST
STANDBY
DATAFILE PATH
+DATA/TEST/DATAFILE
/u01/standby/datafile
LOGFILE PATH
+DATA/TEST/ONLINELOG
/u01/standby/onlinelog




We assume:
·        There is an existing RAC database (TEST) on two nodes: rac1-pub and rac2-pub.
·        The standby server has no existing database.
·        The Oracle software 11gr2  is installed at standby site
·        The Primary database is running in ARCHIVELOG mode

Steps in primary database Servers:
  • ·        Database must in Archivelog mode.
  • ·        Enable Force Logging.
  • ·        Create the Standby Redo logs.
  • ·        Create a password file for all instances ( Password must same in all nodes).
  • ·        Update listener.ora file to include SID information on each node in cluster. Verify cluster Service is available.
  • ·        Verify TNSNAMES.ORA file.
  • ·        Modify init.ora Parameters For DataGuard Configuration.
  • ·        Create temporary directory to hold the RMAN backup of this database.
  • ·        Backup the Primary Database for Standby.
  • ·        Copy the Primary Database backup to the standby database server to create standby database.



Steps in Standby database server:
  • ·        Create required folders and directories.
  • ·        Modify the init.ora parameter on standby database.
  • ·        create a password file(Password must same as primary database instances)
  • ·        Update listener.ora file to include SID information
  • ·        Add required TNS entries for standby database on all servers.
  • ·        Verify TNSNAMES.ORA file.
  • ·        Create standby database.



1. ARCHIVELOG MODE
·        Primary database should be in archivelog mode. Enable archivelog mode if it is not done already.

2. FORCE LOGGING
·        Force logging should be enabled in primary database.

SQL> select instance_name,status from gv$instance;

INSTANCE_NAME    STATUS
---------------- ------------
TEST1            OPEN
TEST2            OPEN

SQL> select name, db_unique_name , database_role from gv$database;
NAME      DB_UNIQUE_NAME                 DATABASE_ROLE
--------- ------------------------------ ----------------
TEST       TEST                          PRIMARY
TEST     TEST                           PRIMARY

SQL> select name, force_logging from v$database;

NAME      FOR
--------- ---
TEST     NO

SQL> alter database force logging;

Database altered.

SQL> select name, force_logging from v$database;

NAME      FOR
--------- ---
TEST      YES



3. TNS SETTINGS
·         Both primary and standby servers must be able to tnsping each other. 
PRIMARY (TEST):
STANDBYTNS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = standby161.dba.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = standby)

standby:
TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = TEST)
   



CREATE lisneter.ora
[STANDBY]


SID_LIST_STANDBYLIST =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = standby)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = standby)
    )
  )

ADR_BASE_STANDBYLIST = /u01/app/oracle

STANDBYLIST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = standby161)(PORT = 1521))
  )


4. STANDBY LOG FILEs

·         The size of the standby logfile must be the same with the online redo logs.
·         There should be at least one more standby redo log group per thread than the online redo logs.

SQL> select MEMBERS, STATUS, GROUP# from v$log;

   MEMBERS STATUS               GROUP#
---------- ---------------- ----------
         2 INACTIVE                  1
         2 CURRENT                   2
         2 CURRENT                   3
         2 INACTIVE                  4

SQL> select group#,bytes from v$Log;

    GROUP#      BYTES
---------- ----------
         1   52428800
         2   52428800
         3   52428800
         4   52428800

SQL> col member for a56
SQL> select group#,member,type from v$logfile order by 1;

    GROUP# MEMBER                                                   TYPE
---------- -------------------------------------------------------- -------
         1 +FRA/test/onlinelog/group_1.286.941820983                ONLINE
         1 +DATA/test/onlinelog/group_1.277.941820977               ONLINE
         2 +FRA/test/onlinelog/group_2.287.941820991                ONLINE
         2 +DATA/test/onlinelog/group_2.278.941820987               ONLINE
         3 +DATA/test/onlinelog/group_3.281.941821451               ONLINE
         3 +FRA/test/onlinelog/group_3.288.941821457                ONLINE
         4 +DATA/test/onlinelog/group_4.282.941821463               ONLINE
         4 +FRA/test/onlinelog/group_4.289.941821467                ONLINE

8 rows selected.





      
SQL> alter database add standby logfile thread 1
group 5 size 5M,
group 6 size 5M;  2    3

Database altered.

SQL> alter database add standby logfile thread 2
group 7 size 5M,
group 8 size 5M;  2    3

Database altered.

SQL>  select group#,member,type from v$logfile order by 1;

    GROUP# MEMBER                                                   TYPE
---------- -------------------------------------------------------- -------
         1 +DATA/test/onlinelog/group_1.277.941820977               ONLINE
         1 +FRA/test/onlinelog/group_1.286.941820983                ONLINE
         2 +DATA/test/onlinelog/group_2.278.941820987               ONLINE
         2 +FRA/test/onlinelog/group_2.287.941820991                ONLINE
         3 +DATA/test/onlinelog/group_3.281.941821451               ONLINE
         3 +FRA/test/onlinelog/group_3.288.941821457                ONLINE
         4 +DATA/test/onlinelog/group_4.282.941821463               ONLINE
         4 +FRA/test/onlinelog/group_4.289.941821467                ONLINE
         5 +DATA/test/onlinelog/group_5.264.941822245               STANDBY
         5 +FRA/test/onlinelog/group_5.256.941822245                STANDBY
         6 +DATA/test/onlinelog/group_6.259.941822245               STANDBY

    GROUP# MEMBER                                                   TYPE
---------- -------------------------------------------------------- -------
         6 +FRA/test/onlinelog/group_6.282.941822247                STANDBY
         7 +DATA/test/onlinelog/group_7.258.941822269               STANDBY
         7 +FRA/test/onlinelog/group_7.281.941822269                STANDBY
         8 +DATA/test/onlinelog/group_8.257.941822269               STANDBY
         8 +FRA/test/onlinelog/group_8.280.941822269                STANDBY

16 rows selected.


5. PRIMARY PARAMETERS
·         Change the following dataguard related parameters in primary.

[PRIMARY] [on any node run once]
SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(test,standby)' sid='*' scope=both;
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test'  sid='*'  scope=both;
SQL> alter system set LOG_ARCHIVE_DEST_2='SERVICE=standbytns LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby' sid='*' scope=both;
SQL> alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE sid='*' scope=both;
SQL> alter system set LOG_ARCHIVE_DEST_STATE_2=ENABLE sid='*' scope=both;
SQL> alter system set FAL_SERVER='standbytns' sid='*' scope=both;
SQL> alter system set FAL_CLIENT='test' sid='*' scope=both;
SQL> alter system set log_archive_max_processes=10 sid='*' scope=both;
SQL> alter system set log_file_name_convert='/u01/standby/onlinelog','+DATA/TEST/DATAFILE' sid='*' scope=spfile;
SQL> alter system set db_file_name_convert= '/u01/standby/datafile','+DATA/TEST/ONLINELOG' sid='*' scope=spfile;
SQL> alter system set REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE sid='*' scope=spfile;
SQL> alter system set STANDBY_FILE_MANAGEMENT=AUTO  sid='*' scope=both;
SQL> alter system set DB_UNIQUE_NAME=TEST;
Bounce the db nodes for some of the parameters to be activated.


6. PASSWORD FILE
·         Copy the primary database’s password file to standby under $ORACLE_HOME/dbs

[PRIMARY] [on any node run once]
[oracle@rac2-pub dbs]$ ls
hc_PROD2.dat  hc_TEST2.dat  init.ora  initTEST2.ora  orapwTEST2
[oracle@rac2-pub dbs]$ scp -rp orapwTEST2 oracle@192.168.1.161:/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[STANDBY]
[oracle@standby161 dbs]$ ls
init.ora  orapwTEST2
[oracle@standby161 dbs]$ mv orapwTEST2 orapwSTANDBY
7. Take backup (Primary side)
·        First connect to rman target /
·        Backup database format ‘/location/bkp_database%U’;
·        Backup archivelog all format
·        Backup current controlfile for standby format


8. PFILE
·         Create pfile on standby

[STANDBY]
[oracle@standby161 dbs]$ cat initstandby.ora
*.audit_file_dest='/u01/app/oracle/admin/standby/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='11.2.0.4.0'
*.control_files='/u01/standby/controlfile.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/standby/datafile'
*.db_domain=''
*.db_file_name_convert='+DATA/TEST/DATAFILE','/u01/standby/datafile'
*.db_name='TEST'
*.db_recovery_file_dest='/u01/standby/fra'
*.db_recovery_file_dest_size=10645143552
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=STANDBYXDB)'
*.fal_server='test'
*.fal_client='standbytns'
*.log_archive_config='DG_CONFIG=(standby,test)'
*.log_archive_dest_1='LOCATION=/u01/standby/arch'
*.log_archive_dest_2='SERVICE=test LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=test'
*.DB_UNIQUE_NAME='standby'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes='10'
*.log_file_name_convert='+DATA/TEST/ONLINELOG','/u01/standby/onlinelog'
*.memory_target=834666496
*.open_cursors=300
*.processes=150
*.remote_listener='scan:1521'
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS'
*.cluster_database='false '

9. DUPLICATING THE PRIMARY ONTO STANDBY

SQL> startup nomount;
ORACLE instance started.
Total System Global Area  830930944 bytes
Fixed Size                  2257800 bytes
Variable Size             536874104 bytes
Database Buffers          289406976 bytes
Redo Buffers                2392064 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@standby161 dbs]$ clear
[oracle@standby161 dbs]$ rman target sys/manager@test auxiliary /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Apr 24 14:58:18 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: TEST (DBID=2239967401)
connected to auxiliary database: TEST (not mounted)
RMAN> duplicate target database for standby nofilenamecheck;
Starting Duplicate Db at 24-APR-17
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK
contents of Memory Script:
{
   restore clone standby controlfile;
}
executing Memory Script
Starting restore at 24-APR-17
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/bkp_contrl0is2g7u6
channel ORA_AUX_DISK_1: piece handle=/u01/backup/bkp_contrl0is2g7u6_1_1 tag=TAG2
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
output file name=/u01/standby/controlfile.ctl
Finished restore at 24-APR-17
contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script
sql statement: alter database mount standby database
RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names c
contents of Memory Script:
{
   set newname for tempfile  1 to
 "+data";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/u01/standby/datafile/system.272.941820785";
   set newname for datafile  2 to
 "/u01/standby/datafile/sysaux.273.941820787";
   set newname for datafile  3 to
 "/u01/standby/datafile/undotbs1.274.941820787";
   set newname for datafile  4 to
 "/u01/standby/datafile/users.275.941820787";
   set newname for datafile  5 to
 "/u01/standby/datafile/undotbs2.280.941821093";
   restore
   clone database
   ;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +data in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 24-APR-17
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/standby/datafile/system
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/standby/datafile/sysaux
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/standby/datafile/undotb
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/standby/datafile/users.
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/standby/datafile/undotb
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/database_0fs2g71t_
channel ORA_AUX_DISK_1: piece handle=/u01/backup/database_0fs2g71t_1_1 tag=TAG20
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:35
Finished restore at 24-APR-17
contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=942159673 file name=/u01/standby/datafile/syst
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=942159673 file name=/u01/standby/datafile/sysa
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=942159673 file name=/u01/standby/datafile/undo
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=942159673 file name=/u01/standby/datafile/user
datafile 5 switched to datafile copy
input datafile copy RECID=9 STAMP=942159673 file name=/u01/standby/datafile/undo
Finished Duplicate Db at 24-APR-17

10. START DATAGUARD RECOVERY

[STANDBY]

SQL> shut immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area  830930944 bytes
Fixed Size                  2257800 bytes
Variable Size             536874104 bytes
Database Buffers          289406976 bytes
Redo Buffers                2392064 bytes
SQL> alter database mount standby database;
Database altered.

SQL> alter database recover managed standby database disconnect from session;
Database altered.
[STANDBY]
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/standby/arch
Oldest online log sequence     48
Next log sequence to archive   0
Current log sequence           49

PRIMARY (TEST)

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


11. CONTROLS

CONTROL LOGS
·         If redo logs are being applied correctly, we should see IN-MEMORY phrased instead of NO. Switch the logfile of the primary database and observe the change insequence #.
[STANDBY]
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
 SEQUENCE# FIRST_TIM NEXT_TIME APPLIED
---------- --------- --------- ---------
        32 24-APR-17 24-APR-17 YES
        33 24-APR-17 24-APR-17 YES
        33 24-APR-17 24-APR-17 NO
        34 24-APR-17 24-APR-17 NO
        34 24-APR-17 24-APR-17 NO
        35 24-APR-17 24-APR-17 NO
        35 24-APR-17 24-APR-17 NO
        36 24-APR-17 24-APR-17 NO
        36 24-APR-17 24-APR-17 NO
        37 24-APR-17 24-APR-17 NO
        37 24-APR-17 24-APR-17 NO

 SEQUENCE# FIRST_TIM NEXT_TIME APPLIED
---------- --------- --------- ---------
        38 24-APR-17 24-APR-17 NO
        38 24-APR-17 24-APR-17 NO
        39 24-APR-17 24-APR-17 NO
        39 24-APR-17 24-APR-17 NO
        40 24-APR-17 24-APR-17 NO
        40 24-APR-17 24-APR-17 NO
        41 24-APR-17 24-APR-17 NO
        41 24-APR-17 24-APR-17 NO
        42 24-APR-17 24-APR-17 NO
        42 24-APR-17 24-APR-17 NO
        43 24-APR-17 24-APR-17 NO

 SEQUENCE# FIRST_TIM NEXT_TIME APPLIED
---------- --------- --------- ---------
        43 24-APR-17 24-APR-17 NO
        44 24-APR-17 24-APR-17 NO
        44 24-APR-17 24-APR-17 NO
        45 24-APR-17 24-APR-17 NO
        45 24-APR-17 24-APR-17 NO
        46 24-APR-17 24-APR-17 NO
        46 24-APR-17 24-APR-17 NO
        47 24-APR-17 24-APR-17 NO
        47 24-APR-17 24-APR-17 NO
        48 24-APR-17 24-APR-17 NO
        48 24-APR-17 24-APR-17 NO
33 rows selected.
SQL>  SELECT * FROM V$STANDBY_LOG;
    GROUP# DBID                                        THREAD#  SEQUENCE#
---------- ---------------------------------------- ---------- ----------
     BYTES  BLOCKSIZE       USED ARC STATUS     FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- --- ---------- ------------- ---------
NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME
------------ --------- ------------ ---------
         5 UNASSIGNED                                        1          0
   5242880        512          0 YES UNASSIGNED
         6 UNASSIGNED                                        1          0
   5242880        512          0 YES UNASSIGNED
    GROUP# DBID                                        THREAD#  SEQUENCE#
---------- ---------------------------------------- ---------- ----------
     BYTES  BLOCKSIZE       USED ARC STATUS     FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- --- ---------- ------------- ---------
NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME
------------ --------- ------------ ---------
         7 UNASSIGNED                                        2          0
   5242880        512          0 NO  UNASSIGNED
         8 UNASSIGNED                                        2          0
   5242880        512          0 YES UNASSIGNED
    GROUP# DBID                                        THREAD#  SEQUENCE#
---------- ---------------------------------------- ---------- ----------
     BYTES  BLOCKSIZE       USED ARC STATUS     FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- --- ---------- ------------- ---------
NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME
------------ --------- ------------ --------
12. GAP CONTROL
·         The gap query should return no-rows.

[STANDBY]
SQL> SELECT * FROM V$ARCHIVE_GAP;
no rows selected

13. CROSSCHECK THE SEQUENCES

[PRIMARY]

SQL>  SELECT SEQUENCE# FROM V$LOG WHERE STATUS='CURRENT';

 SEQUENCE#
----------
        49
        49

[STANDBY]

SQL>  SELECT SEQUENCE# FROM V$LOG WHERE STATUS='CURRENT';

 SEQUENCE#
----------
        49
        49


14. Post-installation steps

1.      Connect the standby database using SQL*Plus and check for the database role and status to ensure the database role is the physical standby.

SQL>  select db_unique_name,database_role,open_mode from
v$database; 

DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE
------------------------------ ---------------- --------------------
standby                        PHYSICAL STANDBY MOUNTED

2.      Use the v$logfile view to check the location of online and standby redo logfiles in the standby database.

SQL> select group#,type,member from v$logfile;
GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
2 ONLINE
/u01/standby/onlinelog/group_2.278.941820987

2 ONLINE
/u01/standby/datafile/TEST/onlinelog/o1_mf_2_dhvkh6oz_.log

1 ONLINE
/u01/standby/onlinelog/group_1.277.941820977

GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
1 ONLINE
/u01/standby/datafile/TEST/onlinelog/o1_mf_1_dhvkh2h1_.log

3 ONLINE
/u01/standby/onlinelog/group_3.281.941821451

3 ONLINE
/u01/standby/datafile/TEST/onlinelog/o1_mf_3_dhvkh9w6_.log

GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
4 ONLINE
/u01/standby/onlinelog/group_4.282.941821463

4 ONLINE
/u01/standby/datafile/TEST/onlinelog/o1_mf_4_dhvkhhn7_.log

5 STANDBY
/u01/standby/onlinelog/group_5.264.941822245

GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
5 STANDBY
/u01/standby/datafile/TEST/onlinelog/o1_mf_5_dhvkhox4_.log

6 STANDBY
/u01/standby/onlinelog/group_6.259.941822245

6 STANDBY
/u01/standby/datafile/TEST/onlinelog/o1_mf_6_dhvkhqbv_.log

GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
7 STANDBY
/u01/standby/onlinelog/group_7.258.941822269

7 STANDBY
/u01/standby/datafile/TEST/onlinelog/o1_mf_7_dhvkhqtb_.log

8 STANDBY
/u01/standby/onlinelog/group_8.257.941822269


GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
8 STANDBY
/u01/standby/datafile/TEST/onlinelog/o1_mf_8_dhvkhrpm_.log

1 ONLINE
/u01/standby/fra/TEST/onlinelog/o1_mf_1_dhvkh49o_.log

2 ONLINE
/u01/standby/fra/TEST/onlinelog/o1_mf_2_dhvkh7dg_.log


GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
3 ONLINE
/u01/standby/fra/TEST/onlinelog/o1_mf_3_dhvkhd53_.log

4 ONLINE
/u01/standby/fra/TEST/onlinelog/o1_mf_4_dhvkhhqc_.log

5 STANDBY
/u01/standby/fra/TEST/onlinelog/o1_mf_5_dhvkhoxm_.log


GROUP# TYPE
---------- -------
MEMBER
--------------------------------------------------------------------------------
6 STANDBY
/u01/standby/fra/TEST/onlinelog/o1_mf_6_dhvkhqcj_.log

7 STANDBY
/u01/standby/fra/TEST/onlinelog/o1_mf_7_dhvkhqtp_.log

8 STANDBY
/u01/standby/fra/TEST/onlinelog/o1_mf_8_dhvkhrpz_.log


24 rows selected.



3.      Verify if the redo transport service is active using the v$managed_standby view on the standby database:

SQL> SELECT THREAD#,SEQUENCE#,PROCESS,CLIENT_PROCESS,STATUS,BLOCKS
FROM V$MANAGED_STANDBY; 
   THREAD#  SEQUENCE# PROCESS   CLIENT_P STATUS           BLOCKS
---------- ---------- --------- -------- ------------ ----------
         1         57 ARCH      ARCH     CLOSING             667
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 ARCH      ARCH     CONNECTED             0
         0          0 RFS       ARCH     IDLE                  0
   THREAD#  SEQUENCE# PROCESS   CLIENT_P STATUS           BLOCKS
---------- ---------- --------- -------- ------------ ----------
         1         60 MRP0      N/A      WAIT_FOR_LOG          0
         0          0 RFS       UNKNOWN  IDLE                  0
         0          0 RFS       UNKNOWN  IDLE                  0
         0          0 RFS       UNKNOWN  IDLE                  0
         2         58 RFS       LGWR     IDLE                  1
         1         60 RFS       LGWR     IDLE                  1
         0          0 RFS       UNKNOWN  IDLE                  0
         0          0 RFS       UNKNOWN  IDLE                  0
         0          0 RFS       UNKNOWN  IDLE                  0
         0          0 RFS       UNKNOWN  IDLE                  0
         0          0 RFS       UNKNOWN  IDLE                  0
   THREAD#  SEQUENCE# PROCESS   CLIENT_P STATUS           BLOCKS
---------- ---------- --------- -------- ------------ ----------
         0          0 RFS       UNKNOWN  IDLE                  0
         0          0 RFS       ARCH     IDLE                  0
24 rows selected.
4.      On the standby database, query the V$ARCHIVED_LOG view for the archived and applied sequences. For the last archived sequence, use the following:

Standby
SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG;
MAX(SEQUENCE#)
--------------
            59


Primary
SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG;
MAX(SEQUENCE#)
--------------
            59
SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG WHERE
APPLIED='YES'; 
MAX(SEQUENCE#)
--------------
            59

5.      Check the status of the latest log sequence.

standby
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY
SEQUENCE#; 
 SEQUENCE# APPLIED
---------- ---------
        32 YES
        33 YES
        33 YES
        34 YES
        34 YES
        35 YES
        35 YES
        36 YES
        36 YES
        37 YES
        37 YES

 SEQUENCE# APPLIED
---------- ---------
        38 YES
        38 YES
        39 YES
        39 YES
        40 YES
        40 YES
        41 YES
        41 YES
        42 YES
        42 YES
        43 YES

 SEQUENCE# APPLIED
---------- ---------
        43 YES
        44 YES
        44 YES
        45 YES
        45 YES
        46 YES
        46 YES
        47 YES
        47 YES
        48 YES
        48 YES

 SEQUENCE# APPLIED
---------- ---------
        49 YES
        49 YES
        50 YES
        50 YES
        51 YES
        51 YES
        52 YES
        52 YES
        53 YES
        53 YES
        54 YES

 SEQUENCE# APPLIED
---------- ---------
        54 YES
        55 YES
        55 YES
        56 YES
        56 YES
        57 YES
        57 NO
        58 YES
        59 YES

53 rows selected.
primary
QL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG;

MAX(SEQUENCE#)
--------------
            59

SQL> SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG WHERE
APPLIED='YES';  2

MAX(SEQUENCE#)
--------------
            59

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY
SEQUENCE#;  2

 SEQUENCE# APPLIED
---------- ---------
         1 NO
         2 NO
         2 NO
         3 NO
         3 NO
         4 NO
         4 NO
         5 NO
         5 NO
         6 NO
         6 NO

 SEQUENCE# APPLIED
---------- ---------
         7 NO
         7 NO
         8 NO
         8 NO
         9 NO
         9 NO
        10 NO
        10 NO
        11 NO
        11 NO
        12 NO

 SEQUENCE# APPLIED
---------- ---------
        12 NO
        13 NO
        13 NO
        14 NO
        14 NO
        15 NO
        15 NO
        16 NO
        16 NO
        17 NO
        17 NO

 SEQUENCE# APPLIED
---------- ---------
        18 NO
        18 NO
        19 NO
        19 NO
        20 NO
        20 NO
        21 NO
        21 NO
        22 NO
        22 NO
        23 NO

 SEQUENCE# APPLIED
---------- ---------
        23 NO
        24 NO
        24 NO
        25 NO
        25 NO
        26 NO
        26 NO
        27 NO
        27 NO
        28 NO
        28 NO

 SEQUENCE# APPLIED
---------- ---------
        29 NO
        29 NO
        30 NO
        30 NO
        31 NO
        31 NO
        32 NO
        32 NO
        33 NO
        33 NO
        33 YES

 SEQUENCE# APPLIED
---------- ---------
        34 NO
        34 NO
        34 YES
        34 YES
        35 NO
        35 NO
        35 YES
        35 YES
        36 NO
        36 NO
        36 YES

 SEQUENCE# APPLIED
---------- ---------
        36 YES
        37 NO
        37 NO
        37 YES
        37 YES
        38 NO
        38 NO
        38 YES
        38 YES
        39 NO
        39 NO

 SEQUENCE# APPLIED
---------- ---------
        39 YES
        39 YES
        40 NO
        40 NO
        40 YES
        40 YES
        41 NO
        41 NO
        41 YES
        41 YES
        42 NO

 SEQUENCE# APPLIED
---------- ---------
        42 NO
        42 YES
        42 YES
        43 NO
        43 NO
        43 YES
        43 YES
        44 NO
        44 YES
        44 YES
        44 NO

 SEQUENCE# APPLIED
---------- ---------
        45 NO
        45 YES
        45 YES
        45 NO
        46 NO
        46 YES
        46 YES
        46 NO
        47 NO
        47 YES
        47 YES

 SEQUENCE# APPLIED
---------- ---------
        47 NO
        48 YES
        48 NO
        48 YES
        48 NO
        49 NO
        49 NO
        49 YES
        49 YES
        50 NO
        50 NO

 SEQUENCE# APPLIED
---------- ---------
        50 YES
        50 YES
        51 NO
        51 YES
        51 NO
        51 YES
        52 NO
        52 YES
        52 NO
        52 YES
        53 NO

 SEQUENCE# APPLIED
---------- ---------
        53 NO
        53 YES
        53 YES
        54 NO
        54 NO
        54 YES
        54 YES
        55 NO
        55 NO
        55 YES
        55 YES

 SEQUENCE# APPLIED
---------- ---------
        56 NO
        56 YES
        56 YES
        56 NO
        57 NO
        57 YES
        57 NO
        57 NO
        58 YES
        58 NO
        59 YES

 SEQUENCE# APPLIED
---------- ---------
        59 NO

166 rows selected.


6.      You can also check the apply lag on the standby database using the V$DATAGUARD_ STATS view in terms of time. Run the following query on the standby database.
SQL> SELECT name, value, datum_time, time_computed FROM
V$DATAGUARD_STATS WHERE name like 'apply lag'; 
NAME
--------------------------------
VALUE
----------------------------------------------------------------
DATUM_TIME                     TIME_COMPUTED
------------------------------ ------------------------------
apply lag
+00 00:41:02
04/25/2017 14:14:28            04/25/2017 14:15:28


Featured post

Migrate OCR & vote from external to normal or High redundancy in ASM

How to Move OCR & Vote from external to Normal or high. 1)  Create New diskgroup(CRS) with suitable redundancy for OCR and Voting files....

Popular Posts