Wednesday, 28 February 2018

Installation and Prerequisites to Setup Oracle Goldengate 12c on Linux

In this post we’ll cover step by step approach for installing Golden Gate Software on both Windows based and Unix based operating system. Below are some requirements that should be met before installing the 
Golden Gate software:-

Memory Requirements:

At least between 25 and 55 Mb of RAM memory is required for each GoldenGate Replicat and Extract process. Oracle Goldengate supports up to 300 concurrent processes for Extract and Replicat per Goldengate instance. As a rule of thumb, you will need to take into consideration that at least 1–2 Extract processes and multiple Replicat processes will be required in addition to manager processes for a basic Oracle Goldengate installation. The best way to assess total memory requirement is to run the GGSCI command to view the current report file and to examine the PROCESS AVAIL VM FROM OS (min) to determine if you have sufficient swap memory for your platform.

Disk Space Requirements:

Following are some things you should do to ensure having enough disk space to support your Goldengate replication needs:

• Allocate at least 50–150 MB of disk space for the Oracle GoldenGate software binaries.
• Allocate 40 MB of disk space per instance of Goldengate for working directories and files per server. For a basic configuration with Oracle Goldengate, you will need to allocate 40 MB on the source and 40 MB on the target system for a total requirement of 80 MB of disk space.
• Allocate sufficient disk space to temporary files to accommodate GoldenGate operations. By default, Goldengate stores temporary files in the dirtmp directory under the default installation directory. A good rule of thumb to use for temp file space is around 10 GB of disk space.
• Plan on at least 10 MB per trail file. As a rule of thumb, we recommend that you start with at least 1 GB of disk space allocated per system for trail files. Alternatively, use the following formula that Oracle provides to determine the amount of disk space to set aside:
[log volume in one hour] x [number of hours downtime] x 0.4 = trail disk space.

One way to calculate the total amount required for trail file space is by querying the V$ARCHIVED_LOG view from within the source Oracle database. The following query shows you how to do so:

SQL>select trunc(COMPLETION_TIME),count(*)*100 size_in_MB
from v$archived_log
group by trunc(COMPLETION_TIME);
TRUNC(COM SIZE_IN_MB
--------- ----------
15-MAY-11 500
Run tests after installing Goldengate to measure your specific transaction mix and
load, and to gauge the total disk space required for trail files.

Network Requirements:

Since Oracle Goldengate software operates between source and target systems over networks, you must configure TCP/IP networking to accommodate all hosts within DNS to include host names that will be included in the Oracle Goldengate infrastructure deployed. In the event of firewalls, hosts must be allowed to send and receive data for open ports that the manager, Extract, and Replicat processes require access to in order to send and receive data. This range of ports must be allocated for the Goldengate environments. Also allocate ports for Goldengate manager, Extract, and Replicat processes. By default, manager uses port 7840. The recommendation is that you keep this port available. In addition, keep a record of ports allocated to Goldengate processes to avoid port conflicts.

Operating System Requirements

Linux or UNIX:

Source DB Server:ggate1
DB Name: ORCL1

Target DB Server:ggate2
DB Name: ORCL2


Download Oracle GoldenGate 12.2.0.1.1 for Oracle on Linux X86_64(454MB) Binary file from Oracle official website under Oracle GoldenGate 12.2.0.1 tab

Once we have downloaded, We need to transfer file from your local desk top to Linux Machine where source DB/Target was running 

I have transffered golden gate binaries to source DB server and hosted on /home/oracle

[oracle@ggate1]$ cd /home/oracle
[oracle@ggate1]$ ls -lrt
-rw-r----- 1 oracle oinstall 475611228 Dec 31 13:02 fbo_ggs_x64_shiphome.zip


[oracle@ggate1]$ cd /home/oracle
[oracle@ggate12]$ ls -lrt
-rw-r----- 1 oracle oinstall 475611228 Dec 31 13:02 fbo_ggs_x64_shiphome.zip

Source Side Installation: goldengate1

Unzip binary file

[oracle@ggate1]$pwd
/home/oracle
[oracle@ggate1]$ unzip fbo_ggs_x64_shiphome.zip

Once we unzip tha binary file, A directory will be created with name:fbo_ggs_x64_shiphome 
[oracle@ggate1]$ ls -lrt
-rw-r----- 1 oracle oinstall 475611228 Dec 31 13:02 fbo_ggs_x64_shiphome.zip
drwxr-r--r-- 1 oracle oinstall 475611228 Dec 31 13:02 fbo_ggs_x64_shiphome

Just for installation purpose, we don't require more than 5GB disk space

Once uzip file go to fbo_ggs_x64_shiphome inside directory

[oracle@ggate1]$ cd fbo_ggs_x64_shiphome
[oracle@ggate1]$ ls
Disk1
[oracle@ggate1]$ cd Disk1
[oracle@ggate1]$ ls
install responce runInstaller stage

Let us set the display as root user to enable GUI mode

[root@ggate1]# xhost+
access control disabled, clients can connect from any host
[root@ggate1]#

From 12c onwards golden gate introduced GUI based installation, Till 11gR2 it was command line installation.
Create directory for GG_HOME

[oracle@ggate1]$ cd /u01/app/oracle/product/12.1.0
[oracle@ggate1]$  mkdir ggsource1

Now run runInstaller from oracle user
[oracle@ggate1]$ cd /home/oracle/fbo_ggs_x64_shiphome/Disk1
[oracle@ggate1]$ ls
install responce runInstaller stage
[oracle@ggate1]$./runInstaller
Starting Oracle Universal Installer...

Checking Temp space: must be grater than 120 MB. Actual 7109 MB  Passed
Checking Swap space: must be grater than 150 MB. Actual 8190 MB  Passed
Checking monitor: must be configured to display at least 256 colors.   Actual 167777216  Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-05-24 10-20-35PM. Please wait...[oracle@ggate1]$

First it checks prerequesites like temp space and swap space, Once all prerequesites are passed it wll open the GUI window

Oracle 12GoldenGate binaries will support for both 12c and 11g Databases

If  database is 10g or 9i or any other lower version, We need to use lower than 12c GoldenGate binaries

In our case my Oracle databse is 12

Select Oracle GoldenGate for Oracle Database 12c and then click on next button

Once we click on next button it will ask us location for software installation(GG Home),Database Location(ORACLE_HOME) and Manager port(Default-7809)

Provide Location details as below

Software Location:/u01/app/oracle/product/12.1.0/ggsource1

Database Location:/u01/app/oracle/product/12.1.0/db_1

Manager Port:7809

Select Start Manager check box

If we select Start Manager check box , Manager will start 

Port 7809 should be open and provided by the network team

Once all locations defined, Click on Next button

Now it will ask us to review all Locations , Once reviewed click on install button

Now installtion in progress

Once installtion complted we will get the message "GoldedGate installation was successfuly", Now click on close

Till now installtion completed successfully

Now got to location where we have installed GG and connect GG prompt by executing ./ggsci (GoldenGate Software Command Interface)
[oracle@ggate1]$ cd /u01/app/oracle/product/12.1.0/ggsource1
[oracle@ggate1]$./ggsci
Oracle GoldenGate Command Interpreter for Oracle

Version 12.2.0.1.1  OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401_FBO

Linux, x64, 64bit (optimized), Oracle 11g on Sep 25 2015 00:31:13

Operating system character set identified as UTF-8.



Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved.



GGSCI (ggate1) 1>


Now to check what processes are configured run "info all" 
GGSCI (ggate1) 1>
Program   Status Group Lag at Chkpt Time Since Chkpt

MANAGER   Running

Target Side Installation: ggate2



Unzip binary file



[oracle@ggate2]$pwd

/home/oracle

[oracle@ggate2]$ unzip fbo_ggs_x64_shiphome.zip



Once we unzip tha binary file, A directory will be created with name:fbo_ggs_x64_shiphome 

[oracle@ggate2]$ ls -lrt

-rw-r----- 1 oracle oinstall 475611228 Dec 31 13:02 fbo_ggs_x64_shiphome.zip

drwxr-r--r-- 1 oracle oinstall 475611228 Dec 31 13:02 fbo_ggs_x64_shiphome



Just for installation purpose, we don't require more than 5GB disk space



Once uzip file go to fbo_ggs_x64_shiphome inside directory



[oracle@ggate2]$ cd fbo_ggs_x64_shiphome

[oracle@ggate2]$ ls

Disk1

[oracle@ggate2]$ cd Disk1

[oracle@ggate2]$ ls

install responce runInstaller stage



Let us set the display as root user to enable GUI mode



[root@ggate2]# xhost+

access control disabled, clients can connect from any host

[root@ggate2]#



From 12c onwards golden gate introduced GUI based installation, Till 11gR2 it was command line installation.

Create directory for GG_HOME



[oracle@ggate2]$ cd /u01/app/oracle/product/12.1.0

[oracle@ggate2]$  mkdir ggtarget2



Now run runInstaller from oracle user

[oracle@ggate2]$ cd /home/oracle/fbo_ggs_x64_shiphome/Disk1

[oracle@ggate2]$ ls

install responce runInstaller stage

[oracle@ggate2]$./runInstaller

Starting Oracle Universal Installer...



Checking Temp space: must be grater than 120 MB. Actual 7109 MB  Passed

Checking Swap space: must be grater than 150 MB. Actual 8190 MB  Passed

Checking monitor: must be configured to display at least 256 colors.   Actual 167777216  Passed

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-05-24 10-20-35PM. Please wait...[oracle@ggate2]$



First it checks prerequesites like temp space and swap space, Once all prerequesites are passed it wll open the GUI window



Oracle 12GoldenGate binaries will support for both 12c and 11g Databases



If  database is 10g or 9i or any other lower version, We need to use lower than 12c GoldenGate binaries



In our case my Oracle databse is 12



Select Oracle GoldenGate for Oracle Database 12c and then click on next button



Once we click on next button it will ask us location for software installation(GG Home),Database Location(ORACLE_HOME) and Manager port(Default-7809)



Provide Location details as below



Software Location:/u01/app/oracle/product/12.1.0/ggtarget2



Database Location:/u01/app/oracle/product/12.1.0/db_1



Manager Port:7809



Select Start Manager check box

Here we will uncheck Start Manager check box


If we uncheck Start Manager check box , Port and Database location will be disabled and Manager won't start automaticall after installation 





Port 7809 should be open and provided by the network team



Once all locations defined, Click on Next button



Now it will ask us to review all Locations , Once reviewed click on install button



Now installtion in progress



Once installtion complted we will get the message "GoldedGate installation was successfuly", Now click on close



Till now installtion completed successfully



Now got to location where we have installed GG and connect GG prompt by executing ./ggsci (GoldenGate Software Command Interface)

[oracle@ggate2]$ cd /u01/app/oracle/product/12.1.0/ggtarget2

[oracle@ggate2]$./ggsci

Oracle GoldenGate Command Interpreter for Oracle



Version 12.2.0.1.1  OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401_FBO



Linux, x64, 64bit (optimized), Oracle 11g on Sep 25 2015 00:31:13



Operating system character set identified as UTF-8.







Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved.







GGSCI (ggate2) 1>





Now to check what processes are configured run "info all" 

GGSCI (ggate2) 1>info all

Program   Status Group Lag at Chkpt Time Since Chkpt


MANAGER   STOPPED

Here Manager stoped , Since we have unchecked "Start Manager check box during installation process"



To start manager we need to define the port number and need to create subdirectories.
GGSCI (ggate2) 1>create subdirs

Creating subdirectories under current directory ggtarget2/u01/app/oracle/product/12.1.0/ggtarget2

Parameter files /u01/app/oracle/product/12.1.0/ggtarget2/dirprm: created
Report files /u01/app/oracle/product/12.1.0/ggtarget2/dirrpt: created
Checkpoint files /u01/app/oracle/product/12.1.0/ggtarget2/dirchk: created
Process status files /u01/app/oracle/product/12.1.0/ggtarget2/dirpcs: created
SQL script files /u01/app/oracle/product/12.1.0/ggtarget2/dirsql: created
Database definitions files /u01/app/oracle/product/12.1.0/ggtarget2/dirdef: created
Extract data files /u01/app/oracle/product/12.1.0/ggtarget2/dirdat: created
Temporary files /u01/app/oracle/product/12.1.0/ggtarget2/dirtmp: created
Credenttial store files /u01/app/oracle/product/12.1.0/ggtarget2/dircrd: created
Masterkey wallet files /u01/app/oracle/product/12.1.0/ggtarget2/dirwlt: created
Dump files /u01/app/oracle/product/12.1.0/ggtarget2/dirdmp: created

Subdirectories create , Now define port numer by editing MGR process and save and quite param file


GGSCI (ggate2) 1>edit param mgr


Now start manager and check

GGSCI (ggate2) 1>start mgr
Manager started.

GGSCI (ggate2) 1>info all

Program   Status Group Lag at Chkpt Time Since Chkpt


MANAGER   STOPPED


Finally Manager process is successfully running at source and target

DML Replication using GoldenGate 12c Multitenant Architecture:

Aim:Replicate data from TEST1@ORACL1 to TEST2@ORACL2 

Prerequisites:

At Database Level:

At Source DB Side:

1. SQL>alter system set enable_goldengate_replication=True;

System altered.

We need to create new user for Goldengate on both source and target, Which is responsible to read data from multiple schemas.

In 12c in multitenant architecture it needs to be created on a container database.

So create a user in container database with prefix c##. 
In 12c this user is common to all the pluggable presents

2. SQL>create user c##ggadmin1 identified by ggadmin1 default tablespace gg_tbps;

If it's non multitenant architecure we can use any name, no need any prefix.

3. SQL>grant dba to c##ggadmin1 container=ALL;

Grant succeeded.

We need to add supplemental logging .

4. SQL>Alter database add supplemental log data(all) columns.

Database altered.

We can check whether supplemental enabled or not using below query

SQL>select supplemental_Log_data_all from v$database;

SUP
----
YES

5. DB must be in archivelog mode.

SQL>select log_mode from v$database;

LOG_MODE
---------
ARCHIVELOG

At Target DB Side:

1. SQL>alter system set enable_goldengate_replication=True;
  
   System altered.

2. SQL>create user c##ggadmin2 identified by ggadmin2 default              tablespace gg_tbps;

3. SQL>grant dba to c##ggadmin1;

Grant succeeded.

Friday, 23 February 2018

Oracle Cold||Offline||Consistence backup and restoration

To take the cold backup we need to shutdown the database and take CRD(Controfile/Datafile/Redologfiles) and Pfile or Spfile

Cold backup is consistent backup, No need archivelog backup.



How to take oracle database cold backup:


Follow the steps mentioned below for cold backup and restoration.


1. List down the oracle data files which you have to backup, following SQL command will help you to determine file name and its location:

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
XYZ       READ WRITE

SQL> set linesize 400 pages 4000
SQL> col file_name for a35

FILE_NAME
-----------------------------------
/u01/datafiles/USERS01.DBF
/u01/datafiles/UNDOTBS01.DBF
/u01/datafiles/SYSAUX01.DBF
/u01/datafiles/SYSTEM01.DBF

2. List down all online redologs and its location with following SQL command:

SQL> col member for a30
SQL> select member from v$logfile;

MEMBER
--------------------------
/u01/datafiles/REDO2A.LOG
/u01/datafiles/REDO2B.LOG
/u01/datafiles/REDO1A.LOG
/u01/datafiles/REDO1B.LOG
/u01/datafiles/REDO3A.LOG
/u01/datafiles/REDO3B.LOG

6 rows selected.

3. List down all control files and its location by following:

SQL> select name from v$controlfile;
SQL?col name for a30
------------------------------
/u01/datafiles/CONTROL01.CTL
/u01/datafiles/CONTROL02.CTL
/u01/datafiles/CONTROL03.CTL


4. List down all temp files and its location by following:

SQL> select file_name from dba_temp_files;

FILE_NAME
-----------------------------------
/u01/datafiles/TEMP01.DBF

SQL>

We have gathered all the physical file list that we’ll need for backup.


5. Create directory on your system, In this case I am using “OFFLINEBKP” for backup location, as you know this is my test environment.

[oracle@PR ~]$ mkdir -p /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cd /u01/bkup/OFFLINEBKP
[oracle@PR OFFLINEBKP]$ pwd
/u01/bkup/OFFLINEBKP

Note: It’s recommended to backup this files on Tape OR External hard drive, as per your convenience other than same server directory.

6.Grace fully shutdown your database with following command:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

7. Now copy all the physical file that you have found in step number 1,2 3 and 4.

[oracle@PR ~]$ cd /u01/datafiles/
[oracle@PR ~]$ pwd
/u01/datafiles/
[oracle@PR ~]$ cp /u01/datafiles/USERS01.DBF  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/UNDOTBS01.DBF  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/SYSAUX01.DBF  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/SYSTEM01.DBF  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/REDO2A.LOG  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/REDO2B.LOG  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/REDO1A.LOG  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/REDO1B.LOG  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/REDO3A.LOG  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/REDO3B.LOG  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/CONTROL01.CTL  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/CONTROL02.CTL  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/CONTROL03.CTL  /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp /u01/datafiles/TEMP01.DBF  /u01/bkup/OFFLINEBKP

Copy pfile or spfile from ORACLE_HOME location to backup directory "/u01/bkup/OFFLINEBKP"
[oracle@PR ~]$ cd /u01/app/oracle/product/12.1.0.2/home_1
[oracle@PR ~]$ pwd
/u01/app/oracle/product/12.1.0.2/home_1
[oracle@PR ~]$ cp INITXYZ.ora /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp SPFILEXYZ.ora /u01/bkup/OFFLINEBKP


Once copy process complete, kindly verify the backup directory with all copied files.

[oracle@PR ~]$ cd /u01/bkup/OFFLINEBKP
[oracle@PR OFFLINEBKP]$ ls -lrt
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/USERS01.DBF  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/UNDOTBS01.DBF  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/SYSAUX01.DBF  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/SYSTEM01.DBF  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/REDO2A.LOG  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/REDO2B.LOG  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/REDO1A.LOG  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/REDO1B.LOG  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/REDO3A.LOG  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/REDO3B.LOG  
-rw-r----- 1 oracle oinstall 10043392 Nov 15 23:02/u01/datafiles/CONTROL01.CTL  
-rw-r----- 1 oracle oinstall 10043392 Nov 15 23:02/u01/datafiles/CONTROL02.CTL  
-rw-r----- 1 oracle oinstall 10043392 Nov 15 23:02/u01/datafiles/CONTROL03.CTL  
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/TEMP01.DBF 
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/INITXYZ.ora 
-rw-r----- 1 oracle oinstall 34273392 Nov 15 23:02/u01/datafiles/SPFILEXYZ.ora  

There is no need to backup temporary datafile those are associated with temporary tablespace

Cold backup Restoration:

1. Restore or copy spfile or pfile from /u01/bkup/OFFLINEBKP to ORACLE_HOME /u01/app/oracle/product/12.1.0.2/home_1/dbs

[oracle@PR ~]$ cd /u01/bkup/OFFLINEBKP
[oracle@PR ~]$ cp INITXYZ.ora /u01/app/oracle/product/12.1.0.2/home_1/dbs
[oracle@PR ~]$ cp SPFILEXYZ.ora /u01/app/oracle/product/12.1.0.2/home_1/dbs

2. Copy or restore  CRD and Tempfiles to thier respective directory structure.

[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/USERS01.DBF  /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/UNDOTBS01.DBF /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/SYSAUX01.DBF /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/SYSTEM01.DBF /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/REDO2A.LOG /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/REDO2B.LOG /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/REDO1A.LOG /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/REDO1B.LOG /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/REDO3A.LOG /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/REDO3B.LOG /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/CONTROL01.CTL  /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/CONTROL02.CTL  /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/CONTROL03.CTL  /u01/datafiles/
[oracle@PR ~]$ cp /u01/bkup/OFFLINEBKP/TEMP01.DBF /u01/datafiles/

3. Start your database with pfile or spfile:

 SQL> startup ;
 ORACLE instance started.
 Total System Global Area 1469792256 bytes
 Fixed Size 2213456 bytes
 Variable Size 1040189872 bytes
 Database Buffers 419430400 bytes
 Redo Buffers 7958528 bytes
 Database mounted.

 Database opened.

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
XYZ       READ WRITE

########################################Good Luck ########################################

Saturday, 3 February 2018

Drop all object of Schemas

Sometimes we need to drop the all objects of schemas while importing. The basic approach is drop the schemas and recreate the schemas. This method is quite efficient . To perform this operation we need the system or sysdba privileges to create and drop the user. If anyone have not the system and sysdba privileges then, dropping all objects is the option . Below is the Demo where we will drop all objects of "SCOTT" schemas.

Step 1 : Generate the scripts for dropping the schemas :

SQL> spool C:\genera_dropall.sql
SQL> select 'drop '||object_type||' '|| object_name||  DECODE(OBJECT_TYPE,'TABLE',' CASCADE CONSTRAINTS;',';')  from user_objects;

'DROP'||OBJECT_TYPE||''||OBJECT_NAME||DECODE(OBJECT_TYPE,'TABLE','CASCADECONSTRAINTS;',';')          
------------------------------------------------------------------------------------------------------------
drop TABLE SALGRADE CASCADE CONSTRAINTS;                                                                                                                                                        
drop TABLE BONUS CASCADE CONSTRAINTS;                                                                                                                                                         
drop INDEX PK_EMP;                                                                                                                                                                      
drop TABLE EMP CASCADE CONSTRAINTS;                                                                                                                                         
drop TABLE DEPT CASCADE CONSTRAINTS;                                                                                                                                                     
drop INDEX PK_DEPT;                                                                                                                                                                         
6 rows selected.
Since we have the drop script as 'genera_dropall.sql'

Step  2  :  Now we will drop all_objects i.e, 'genera_dropall.sql' script is used to drop everything in schemas.

SQL>@"genera_dropall.sql" 
Now check the object in scott schemas

SQL> select * from tab;
TNAME                                                       TABTYPE           CLUSTERID
------------------------------                               ------------             --------------
BIN$5JksbkFeSai/0JTwbJOenQ==$0           TABLE
BIN$KtthiEIaRZmkv/5+FoYu5A==$0              TABLE
BIN$L/qcqzTxTsm8XHkDrfANOg==$0          TABLE
BIN$opUCTunxRf+0AUbhOzzBgw==$0        TABLE

The SQL was written against Oracle (hence the "purge recyclebin" at the bottom and the exclusion of objects already in the recycle bin from the "drop" loop).

Step  3  : Purge the recyclebin objects.

SQL>purge recyclebin ;
Recyclebin purged.

This will produce a list of drop statements. Not all of them will execute - if we drop with cascade, dropping the PK_* indices will fail. But in the end, you will have a pretty clean schema. Confirm with: 

SQL> select * from user_objects;
no rows selected


###############################################  All The Best ###############################################

Configuration of Snapshot Standby Database in Oracle 11g

Snapshot Standby is a new features introduced in Oracle 11g. A snapshot standby database is a type of updatable standby database that provides full data protection for a primary database. A snapshot standby database receives and archives, but does not apply, redo data from its primary database. Redo data received from the primary database is applied when a snapshot standby database is converted back into a physical standby database, after discarding all local updates to the snapshot standby database.

The main benefits of snapshot standby database is that we can convert the physical standby database into a read-write real time clone of the production database and we can then temporarily use this environment for carrying out any kind of  development testing, QA type work or to test the impact of a proposed production change on an application. 

The best part of this snapshot features is that the Snapshot Standby database in turn uses the Flashback Database technology to create a guaranteed restore point to which the database can be later flashed back to.All the features of the flashback  are inherent in the snapshot standby.

Here we will configure the snapshot standby database

Step 1 : Create the physical standby database 
Create the physical standby database .

Step 2:  Enable Flashack Parameter 

SQL>  alter system set db_recovery_file_dest_size=4G  scope=both  ; 
System altered.

SQL> alter system set db_recovery_file_dest='D:\standby\fra\'  scope=both ; 
System altered.

SQL> show  parameter  db_recovery
NAME                                            TYPE                   VALUE
-----------------------------      -----------      -------------------------
db_recovery_file_dest                string                  D:\standby\fra\
db_recovery_file_dest_size         big integer              4G

Step 3  :  Stop the media recovery process 
SQL> alter database recover managed standby database cancel;
Database altered.

Step 4 : Ensure that the database is mounted, but not open.
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount

Step 5  :  Create guaranteed restore point
SQL> create restore point snapshot_rspt guarantee flashback database;
Restore point created.

Step 6  :  Perform the conversion to snapshot standby database
SQL> alter database convert to snapshot standby ;
Database altered.

SQL> select name,open_mode,database_role from v$database;
NAME           OPEN_MODE            DATABASE_ROLE
---------        --------------        --------------------------
NOIDA           MOUNTED              SNAPSHOT STANDBY

SQL> alter database open;
Database altered.

SQL> select name,db_unique_name ,open_mode,database_role from v$database;
NAME      DB_UNIQUE_NAME    OPEN_MODE          DATABASE_ROLE
-------   ----------------------    ---------------      ------------------------
NOIDA         gurgoan                  READ WRITE        SNAPSHOT STANDBY

Since the database is in read-write mode , so we can make some changes or even change the parameter say tunning parameter and check there performance after converting to physical standby and further flashback the whole changes.

SQL> select name,guarantee_flashback_database  from  v$restore_point;
NAME                                                                                            GUA
-----------------------------------------------------------------      -------
SNAPSHOT_STANDBY_REQUIRED_11/18/2011 20:41:01            YES
SNAPSHOT_RSPT                                                                      YES

While the original physical standby database has been now converted to snapshot database, some changes are happening on the Primary database and those changes are shipped to the standby site but not yet applied. They will accumulate on the standby site and will be applied after the snapshot standby database is converted back to a physical standby database.

Step  7  :  Convert snapshot standby to physical standby 
SQL> shut immediate 
SQL> startup mount

SQL> alter database convert to physical standby ;
Database altered.

SQL>shut immediate
SQL> startup mount

SQL> alter database recover managed standby database disconnect from session;
Database altered.

SQL> alter database recover managed standby database cancel;
Database altered.

SQL> alter database open;
Database altered.

SQL> select name,open_mode,db_unique_name,database_role from v$database;
NAME      OPEN_MODE        DB_UNIQUE_NAME      DATABASE_ROLE
-------    --------------     -----------------------    ----------------------
NOIDA    READ ONLY          gurgoan                     PHYSICAL STANDBY

SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.

Hence, we finally back to physical standby database.


Enjoy    :-) 

How fix ORA-00059: maximum number of DB_FILES exceeded

Symptom:

How fix ORA-00059: maximum number of DB_FILES exceeded

create tablespace data_tbs38 datafile "+DATA' size 100M;
*
ERROR at line 1:
ORA-00059: maximum number of DB_FILES exceeded


Solution:

Increase db_files initialization parameter and bounce the database. Increase this parameter will incease the PGA consumation for every server process.


SQL> alter system set db_files=500 scope=spfile sid='*';

System altered.


How about MAXDATAFILES specified when creating database?

From Oracle8 onwards, Controlfile will auto-expend if MAXDATAFILES is smaller. similar inforamtion could be found in the alert log:


SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.0.1 - Beta
PL/SQL Release 11.2.0.0.1 - Beta
CORE    11.2.0.0.1      Beta
TNS for 32-bit Windows: Version 11.2.0.0.1 - Beta
NLSRTL Version 11.2.0.0.1 - Beta



SQL> select type,record_size rs, records_total rt, records_used ru,first_index f
  2  last_index li, last_recid lr from v$controlfile_record_section;

TYPE                             RS       RT  RU  FI  LI  LR
---------------------------- ------ -------- --- --- --- ---
DATABASE                        316        1   1   0   0   0
CKPT PROGRESS                  8180       11   0   0   0   0
REDO THREAD                     256        8   1   0   0   0
REDO LOG                         72       16   3   0   0   0
DATAFILE                        520       52  23   0   0  17
FILENAME                        524     2138  27   0   0   0
TABLESPACE                       68       40  24   0   0  18
TEMPORARY FILENAME               56       20   1   0   0   1
RMAN CONFIGURATION             1108       50   2   0   0   2
LOG HISTORY                      56      292   1   1   1   1
OFFLINE RANGE                   200       81   0   0   0   0

TYPE                             RS       RT  RU  FI  LI  LR
---------------------------- ------ -------- --- --- --- ---
ARCHIVED LOG                    584      308   3   1   3   3
BACKUP SET                       40      409   0   0   0   0
BACKUP PIECE                    736       44   0   0   0   0
BACKUP DATAFILE                 200       81   0   0   0   0
BACKUP REDOLOG                   76      215   0   0   0   0
DATAFILE COPY                   736       44   0   0   0   0
BACKUP CORRUPTION                44      371   0   0   0   0
COPY CORRUPTION                  40      409   0   0   0   0
DELETED OBJECT                   20      818   0   0   0   0
PROXY COPY                      928       88   0   0   0   0
BACKUP SPFILE                   124      131   0   0   0   0

TYPE                             RS       RT  RU  FI  LI  LR
---------------------------- ------ -------- --- --- --- ---
DATABASE INCARNATION             56      292   1   1   1   1
FLASHBACK LOG                    84     2048   0   0   0   0
RECOVERY DESTINATION            180        1   1   0   0   0
INSTANCE SPACE RESERVATION       28     1055   1   0   0   0
REMOVABLE RECOVERY FILES         32     1000   0   0   0   0
RMAN STATUS                     116      141   0   0   0   0
THREAD INSTANCE NAME MAPPING     80        8   8   0   0   0
MTTR                            100        8   1   0   0   0
DATAFILE HISTORY                568       57   0   0   0   0
STANDBY DATABASE MATRIX         400       31  31   0   0   0
GUARANTEED RESTORE POINT        212     2048   0   0   0   0

TYPE                             RS       RT  RU  FI  LI  LR
---------------------------- ------ -------- --- --- --- ---
RESTORE POINT                   212     2083   0   0   0   0
DATABASE BLOCK CORRUPTION        80     2045   0   0   0   0
ACM OPERATION                   104       64   5   0   0   0
FOREIGN ARCHIVED LOG            604     1002   0   0   0   0

37 rows selected.



Expanded controlfile section 6 from 20 to 40 records
The number of logical blocks in section 6 remains the same
Completed: create tablespace test12 datafile size 10m
create tablespace test13 datafile size 10m
Expanded controlfile section 4 from 20 to 52 records
Requested to grow by 32 records; added 1 blocks of records

ORA-10456: cannot open standby database; media recovery session may be in progress


Once while starting my standby database i found that database is not opening in normal mode. It throws the error-10456 :cannot standby database. 


On performing some R&D and googling comes to the conclusion that this error is generally occurs because a media recovery or RMAN session may have been in progress on a mounted instance of a standby database when an attempt was made to open the standby database. Hence to solve of this issue we have to cancel any conflicting recovery session and then open the standby database.

Here is the issue what i have experienced .

C:\>sqlplus sys/xxxx@red as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Oct 3 12:47:32 2011
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

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

NAME OPEN_MODE DATABASE_ROLE

--------- --------------------

NOIDA MOUNTED PHYSICAL STANDBY


SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-10456: cannot open standby database; media recovery session may be in progress

SQL> alter database recover managed standby database cancel;
Database altered.

SQL> alter database open;
Database altered.

SQL> alter database recover managed standby database using current logfile disconnect ; 
Database altered.



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

NAME  OPEN_MODE              DATABASE_ROLE

------ -------------------  ----------------

NOIDA READ ONLY WITH APPLY   PHYSICAL STANDBY


Hence, finally we solve the issues.


Enjoy    :-)