Wednesday, December 23, 2009

Duplicate RAC Database Using RMAN

Oracle provides following methods to convert a single instance database to RAC. You can choose any method based upon your convince.
1. Manual (Using RMAN)
2. Enterprise Manager
3. DBCA
4. RCONFIG (from 10gR2)

Duplicating RAC database is very simple, first duplicate RAC Database to a single instance using RMAN and convert the single instance into a RAC cluster. Please note that straight RAC to RAC duplicate is not possible.

Follow the simple steps to duplicate RAC Database using ASM or other filesystem.



Step1: Create a parameter file for duplicate database(auxiliary)
The easy ways is copy Init.ora parameter from Target database, replace the Target database name with Auxiliary database name and comment all RAC related parameters for ex:- cluster_database, cluster_instances, thread ...Etc

Set CONTROL_FILES to two copies of the control file to +DISKGRP or file system

Step 2: Set DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT to convert the datafile and redo log file names from +DISKGRP1 to +DISKGRP2 or /dbs1 to /dbs2 (For Non-ASM file systems)

Also Set DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_DEST_n to ‘+DISKGRP2’ or /dbs2

Step 3: set _no_recovery_through_resetlogs=TRUE parameter to avoid internal Bug 4355382 ORA-38856: FAILED TO OPEN DATABASE WITH RESETLOGS WHEN USING RAC BACKUP

Step 4: Create a password file for auxiliary database using below command.
$ orapwd file=orapwdupDB password=xxxxxxxx

Step 5: Create a static listener for auxiliary database and reload, because auxiliary database will not register itself with the listener.

(SID_DESC =
(GLOBAL_DBNAME =dupDB.oracleracexpert.com)
(ORACLE_HOME = /oracle/product/db/10202)
(SID_NAME = dupDB)
)

Step 6: Take Full database backup of Target database
RMAN > backup database plus archivelog;

Copy the backup dumps from Target to Auxiliary host. If backup directory structure is different then update the RMAN configuration of the target database to reflect the new backup location

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle/rman/dupDB';

Step7: Set ORACLE_SID and start auxiliary database in NO MOUNT state
$ export ORACLE_SID=dupDB
SQL> startup nomount

Step 8: Duplicate Target Database using RMAN Duplicate command
RMAN> CONNECT TARGET /;
RMAN> CONNECT CATALOG rman/*****@catadb;
RMAN> CONNECT AUXILIARY sys/*****@dupDB;
RMAN> DUPLICATE TARGET DATABASE TO dupDB;

Step 9: Add second thread of online redo logs and enable that thread:
SQL> alter database add logfile thread 2
group 3 ('+DISKGRP1','+DISKGRP2') size 50m reuse;
SQL> alter database add logfile thread 2
group 4 ('+DISKGRP1','+DISKGRP2') size 50m reuse;
SQL> alter database enable public thread 2;

For Non-ASM file systems replace ‘+DISKGRP1’, ‘+DISKGRP2' with actual file systems path

Step 10: Uncomment or add all RAC related parameters, shutdown the instance and startup both Instances.

Step 11: create spfile on the shared storage, because all instances must use the same server parameter file. See the link to “Create spfile from pfile”.

Step12: Register RAC instances with CRS
$ srvctl add database -d dupDB -o /oracle/product/db/10202
$ srvctl add instance -d dupDB -i dupDB1 -n testrac01
$ srvctl add instance -d dupDB -i dupDB2 -n testrac02

Step13: Shutdown and startup instances using srvctl
$ srvctl start database –d dupDB

Regards,
Satishbabu Gunukula
http://www.oracleracexpert.com/

Tuesday, November 24, 2009

Oracle SPFILE and PFILE

Oracle provides two different parameter files, PFILE and SPFILE.

PFILE is a text based file and in order to add/modify any database parameters, need to edit the INIT.ORA file using “vi” in unix or notepad in windows. To apply new or modified database parameters changes, database restart is required.

SPFILE is a binary file and introduced in Oracle 9i. SPFILE simplifies administration, maintaining parameter settings consistent and Server parameter file is a binary file let you make persistent changes to individual parameters. Use the CREATE SPFILE statement to create a Server Parameter file from PFILE with SYSDBA/SYSOPER privilege.

By default PFILE or SPFILE default location is “$ORACLE_HOME/dbs” for UNIX and LINUX, %ORACLE_HOME%\database for Windows. In case of RAC, SPFILE located on the shared storage.

You can change the SPFILE parameters using Enterprise manager or ALTER SYSTEM SET ‘parameter’ statement with SCOPE clause. The SCOPE clause has three values MEMORY, SPFILE and BOTH.

SPFILE: The change is applied in the server parameter file only and is effective at the next startup.
For Ex: - SQL> ALTER SYSTEM SET SGA_MAX_SIZE=1024m SCOPE=spfile;

Memory: The change is applied in memory only and the effect is immediate.
For Ex:- SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=50 SCOPE=MEMORY;

BOTH: The change is applied in both the server parameter file and memory. For dynamic parameters the effect is immediate.
Ex: - SQL> ALTER SYSTEM SET SGA_TARGET=1024m SCOPE=BOTH;

For Static parameters the MEMROY, BOTH specifications are not allowed. Only SPFILE is allowed.

If you do not specify the SCOPE clause then the default is BOTH. For Dynamic parameters you can specify DEFERRED keyword and the specified change is effective only for future sessions.

During Database startup Oracle searches for initialization parameter file under $ORACLE_HOME/dbs in UNIX and $ORACLE_HOME/database on Windows in following order.

spfileSID.ora
spfile.ora
initSID.ora
init.ora

Backup/Restore parameter files(SPFILE and PFILE):
Using Recovery Manager(RMAN), SPFILE can be backed up with database control file by setting
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
SPFILE can be restored using following RMAN command.
RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;

PFILE cannot be backed-up using RMAN, backup and restore can be done using O/S copy command.

Common Errors and solutions in modifying SPFILE:
1. SQL>alter system SET LOG_ARCHIVE_DEST='/oradata/TESTDB' scope=both;
alter system SET LOG_ARCHIVE_DEST='/oradata/ TESTDB' scope=both
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-16018: cannot use LOG_ARCHIVE_DEST with LOG_ARCHIVE_DEST_n or
DB_RECOVERY_FILE_DEST

Solution: OCATION keyword is required.
SQL> alter system set log_archive_dest_1='location=/oradata/ TESTDB' scope=both;
System altered.

2. SQL> alter system set log_archive_dest_1='location=/oradta/ TESTDB' scope=both;
alter system set log_archive_dest_1='location=/oradata/ TESTDB' scope=both
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-16032: parameter LOG_ARCHIVE_DEST_1 destination string cannot be translated
ORA-07286: sksagdi: cannot obtain device information.
Linux-x86_64 Error: 2: No such file or directory

Solution: LOG_ARCHIVE_DEST_1 is incorrect or does not exist. Prove correct path.

Regards,
Satishbabu Gunukula
http://www.oracleracexpert.com

Send EMAIL using UTL_MAIL in Oracle 10g

This summary is not available. Please click here to view the post.

Thursday, November 12, 2009

How to restore a database to Point in Time using RMAN

You can recover whole database to a specific SCN, time or log sequence number using RMAN, this is called incomplete recovery or point-in-time Recovery (DBPITR).

You must restore all data files from backups create prior to the time to which you want to recovery and you must open database with RESETLOGS option when completes. Please note that RESETLOGS operation creates a new incarnation of the database.

Usually incomplete recovery will be performed under following situations:
1. Corrupt or destroy of some or all online redo logs due to media failure
2. User error causes data loss, for ex accidental drop of a table
3. Archive log missing and you cannot able to perform incomplete recovery
4. Loss of current control file and must use a backup control file to open database.



Follow the steps to recover the database until a specified SCN, time or log sequence

Step 1: Shutdown and startup mount
SQL> SHUTDOWN IMMEDAITE;
SQL> STARTUP MOUNT;

Step 2: Determine the SCN, time or log sequence that you want to recovery the
SCN – you can get the SCN from alert.log file
Sequence – v$log_history

3. Perform the incomplete recovery
If specifying a time, then set NLS_LANG and NLS_DATE_FORMAT environment variables.

RUN
{
SET UNTIL TIME 'Aug 10 2009 11:00:00';
# SET UNTIL SCN 100; # alternatively, specify SCN
# SET UNTIL SEQUENCE 123; # alternatively, specify log seq
RESTORE DATABASE;
RECOVER DATABASE;
}

4. Open database with resetlogs
SQL> ALTER DATABASE OPEN RESETLOGS;

Regards,
Satishbabu Gunukula
http://www.oracleracexpert.com/

Oracle ODBC, OCI, OCCI Drivers, Downloads and Documentation

Oracle ODBC(Open Database Connectivity):
The Oracle ODBC Driver provides access to Oracle databases for applications written using the ODBC interface. With ODBC you can access the Oracle database using .NET, applications from any .NET programming language.

Download Oracle ODBC Driver
http://www.oracle.com/technology/software/tech/windows/odbc/index.html

Oracle ODBC Documentation
http://www.oracle.com/technology/docs/tech/windows/odbc/index.html

Please see the Oracle ODBC Driver discussion forum for any questions/issues.
http://forums.oracle.com/forums/forum.jsp?forum=145

Oracle Call Interface(OCI):
The Oracle Call Interfaces (OCI) is a set of low-level APIs (Application Programming Interface Calls) used to interact with the Oracle Database. It allows one to use operations like logon, execute, parse, fetch, etc.

Download Oracle Call Interface (OCI)
http://www.oracle.com/technology/tech/oci/instantclient/index.html

Please see the below link for OCI documentation
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/toc.htm

Please see the OCI (Oracle Call Interface) Discussion forum for any questions/issues
http://forums.oracle.com/forums/forum.jspa?forumID=67

Oracle C++ Call Interface:
Oracle C++ Call Interface (OCCI) is a high-performance and comprehensive API to access the Oracle database and used for client-server, middle-tier, and complex object modeling applications.

Download OCCI for Linux/Windows
http://www.oracle.com/technology/tech/oci/occi/occidownloads.html

Please see the below link for documentation
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28390/toc.htm

Please see the C++ Call Interface (OCCI) Discussion forum for any questions/issues.
http://forums.oracle.com/forums/forum.jspa?forumID=168

Regards,
Satishbabu Gunukula
http://www.oracleracexpert.com/