Sunday, 8 May 2011

Non-RAC to RAC Conversion

There are several methods  that every one use for Non-RAC to RAC Conversion database . 
Here iam going to use a "rconfig" utility for the conversion.
Steps:-
1>  Convert from Non-ASM to ASM filesystem as per my previous post .


2>  Go to ORACLE_HOME/assistants/rconfig/sampleXMLS
      In the above path we get to see a file " convertToRac.xml "

3> Copy the above file to some location as below
     cp $ORACLE_HOME/assistants/rconfig/sampleXMLS/convertToRac.xml  /tmp/convert2RAC.xml

4> Change the following parameters in /tmp/convert2RAC.xml file
     a) Database SID  b) ASM SID  c) ASM pwd  d) Node names e) Listener port (accordingly)
 
     Sample file:-
========================================================================
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"--
--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="YES"--
--!--Specify current OracleHome of non-rac database for SourceDBHome ----
--n:SourceDBHome--/u01/app/oracle/product/10g/db_1--/n:SourceDBHome-----your source database home
--!--Specify OracleHome where the rac database should be configured. It can be same as SourceDBHome ----
--n:TargetDBHome--/u01/app/oracle/product/10g/db_1--/n:TargetDBHome-- ---your target database home
--!--Specify SID of non-rac database and credential. User with sysdba role is required to perform conversion ----
--n:SourceDBInfo SID="PROD"---------------your database name
--n:Credentials--
--n:User--sys--/n:User--
--n:Password--oracle--/n:Password--
--n:Role--sysdba--/n:Role--
--/n:Credentials--
--/n:SourceDBInfo--
--!--ASMInfo element is required only if the current non-rac database uses ASM Storage ----
--n:ASMInfo SID="+ASM1"---------------------your ASM Instance name
--n:Credentials--
--n:User--sys--/n:User--
--n:Password--oracle--/n:Password-- ----your ASM instance password
--n:Role--sysdba--/n:Role--
--/n:Credentials--
--/n:ASMInfo--
--!--Specify the list of nodes that should have rac instances running. LocalNode should be the first node in this nodelist. ----
--n:NodeList--
--n:Node name="rac1"/-------your rac1 hostname--n:Node name="rac2"/------your rac2 hostname
--/n:NodeList--
--!--Specify prefix for rac instances. It can be same as the instance name for non-rac database or different. The instance number will be attached to this prefix. ----
--n:InstancePrefix--
PROD--/n:InstancePrefix-----your database name
--!--Specify port for the listener to be configured for rac database.If port="", alistener existing on localhost will be used for rac database.The listener will be extended to all nodes in the nodelist ----
--n:Listener port="1551"/-----listener port number
--!--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. ----
--n:SharedStorage type="ASM"------your storage type
--!--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-- --/n:TargetDatabaseArea------leave blank
--!--Specify Flash 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-- --/n:TargetFlashRecoveryArea---leave blank
--/n:SharedStorage--
--/n:Convert--
--/n:ConvertToRAC--
--/n:RConfig--

=================================================================================
5> After modifying the convert2RAC.xml file as above under  /tmp/convert2RAC.xml , run rconfig tool as below


cd $ORACLE_HOME/bin
./rconfig /tmp/convert2RAC.xml


6> Change SID in /etc/oratab as PROD1 in rac1 m/c & PROD2 in rac2 m/c .


7> Finally run srvctl to configure the database
     srvctl config database -d PROD
     srvctl config database -d PROD




Thanks

Saturday, 7 May 2011

Convert ASM to Non-ASM File system

Steps:-
1>
 /u01/oracle>export ORACLE_SID=PROD
/u01/oracle>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu May 06 13:09:07 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

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

2> 

Go to init file or spfile , then modify the parameters mentioned above.
/u01/oracle/product/10.2.0/db_1>
/u01/oracle/product/10.2.0/db_1/database>vi initprod.ora
Eg: control_files='/U01/ORACLE/PRODUCT/10.2.0/ORADATA/PROD/CONTROL01.CTL','/U01/ORACLE/PRODUCT/10.2.0/ORADATA/PROD/CONTROL02.CTL’,’/U01/ORACLE/PRODUCT/10.2.0/ORADATA/PROD/CONTROL03.CTL'

3>
Accordingly change the other paths ASM DISK GROUP to normal file system.
u01/oracle/product/10.2.0/db_1/database>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 18 13:24:33 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.

SQL> STARTUP NOMOUNT PFILE='/u01/oracle/product/10.2.0/db_1/database/initPROD.ora
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 192940932 bytes
Database Buffers 411041792 bytes
Redo Buffers 7135232 bytes

4>
Open a new session and connect to RMAN and then copy the controlfile from older location to non-ASM location using the following command:
/u01/oracle/rman>export ORACLE_SID=PROD
/u01/oracle/rman>rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Thu May 06 13:27:40 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: prod (not mounted)

RMAN> restore controlfile from '+data/control01.ctl';
Starting restore at 06-MAY-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=/u01/oracle/product/10.2.0/oradata/PROD/CONTROL01.CTL
output filename=/u01/oracle/product/10.2.0/oradata/PROD/CONTROL02.CTL
output filename=/u01/oracle/product/10.2.0/oradata/PROD/CONTROL03.CTL
Finished restore at 06-MAY-11

5>
Now mount the database from existing RMAN session
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1

6>
Now take a backup copy into a file system location, this copied file system Database backup will be used as the actual non-ASM database files .
RMAN> backup as copy database format '/u01/oracle/product/10.2.0/oradata/prod/%U.dbf';
Starting backup at 06-MAY-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=154 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=+DATA/prod/datafile/system.259.711293871
output filename=/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-SYSTEM_FNO-1_08L6C22K.DBF tag=TAG20100218
T233755 recid=11 stamp=711329913
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=+DATA/prod/datafile/sysaux.260.711293917
output filename=/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-SYSAUX_FNO-3_09L6C242.DBF tag=TAG20100218
T233755 recid=12 stamp=711329942
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=+DATA/prod/datafile/undotbs1.261.711293941
output filename=/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-UNDOTBS1_FNO-2_0AL6C24R.DBF tag=TAG201002
18T233755 recid=13 stamp=711329949
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=+DATA/prod/datafile/users.262.711293945
output filename=/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-USERS_FNO-4_0BL6C24U.DBF tag=TAG20100218T
233755 recid=14 stamp=711329952
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=/u01/oracle/product/10.2.0/oradata/PROD/CF_D-PROD_ID-2256105880_0CL6C252.DBF tag=TAG20100218T233755 recid=15
stamp=711329955
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 06-MAY-11

7>
RMAN> switch database to copy;
datafile 1 switched to datafile copy "/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-SYSTEM_FNO-1_08L6C2
2K.DBF"
datafile 2 switched to datafile copy "/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-UNDOTBS1_FNO-2_0AL6
C24R.DBF"
datafile 3 switched to datafile copy "/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-SYSAUX_FNO-3_09L6C2
42.DBF"
datafile 4 switched to datafile copy "/u01/oracle/product/10.2.0/oradata/PROD/DATA_D-PROD_I-2256105880_TS-USERS_FNO-4_0BL6C24
U.DBF"

8>
Switch the tempfiles from ASM to non-ASM ,
RMAN> run{
2> set newname for tempfile 1 to '/u01/oracle/product/10.2.0/oradata/PROD/tempfile';
3> switch tempfile all;
4> }
executing command: SET NEWNAME
renamed tempfile 1 to /u01/oracle/product/10.2.0/oradata/PROD/tempfile in control file

9>
Now our database is switched from ASM to non- ASM
Now you can open the database
RMAN> ALTER DATABASE OPEN (RESETLOGS);
database opened

Now, and create new redo log files in the non-ASM file system and drop the existing ASM ONLINE LOG FILES:
SQL> select group#,member from v$logfile;
GROUP# MEMBER
---------- --------------------------------------------------
3 +DATA/prod/onlinelog/group_3.265.711296273
2 +DATA/prod/onlinelog/group_2.266.711296283
1 +DATA/prod/onlinelog/group_1.265.711296273

SQL> ALTER DATABASE ADD LOGFILE GROUP 4 ('/u01/oracle/product/10.2.0/oradata/PROD/REDO04.LOG');
Database altered.
SQL> ALTER DATABASE ADD LOGFILE GROUP 5 ('/u01/oracle/product/10.2.0/oradata/PROD/REDO05.LOG');
Database altered.
SQL> ALTER DATABASE ADD LOGFILE GROUP 6 ('/u01/oracle/product/10.2.0/oradata/PROD/REDO06.LOG');
Database altered.

SQL> select group#,member from v$logfile;
GROUP# MEMBER
---------- --------------------------------------------------
6 /u01/oracle/product/10.2.0/oradata/PROD/REDO06.LOG
5 /u01/oracle/product/10.2.0/oradata/PROD/REDO05.LOG
4 /u01/oracle/product/10.2.0/oradata/PROD/REDO04.LOG
1 +DATA/prod/onlinelog/group_1.265.711296273
2 +DATA/prod/onlinelog/group_2.266.711296283
3 +DATA/prod/onlinelog/group_3.267.711296293
6 rows selected.

Make sure that the ASM online redo logfiles are not in current/active state.
SQL> ALTER DATABASE DROP LOGFILE GROUP 1;
Database altered.
SQL> ALTER DATABASE DROP LOGFILE GROUP 2;
Database altered.
SQL> ALTER DATABASE DROP LOGFILE GROUP 3;

SQL> select group#,member from v$logfile;
GROUP# MEMBER
---------- ---------------------------------------------
6 /u01/oracle/product/10.2.0/oradata/PROD/REDO06.LOG
5 /u01/oracle/product/10.2.0/oradata/PROD/REDO05.LOG
4 /u01/oracle/product/10.2.0/oradata/PROD/REDO04.LOG


Convert Non-ASM to ASM File system


Overview:-

1.configure flash recovery area.

2.Migrate datafiles to ASM.
3.Control file to ASM.
4.Create Temporary tablespace.
5.Migrate Redo logfiles
6.Migrate spfile to ASM.


Innerview:-
step 1:Configure flash recovery area.

SQL> connect sys/sys@prod1 as sysdba
Connected.
SQL> alter database disable block change tracking;
Database altered.
SQL> alter system set db_recovery_file_dest_size=500m;
System altered.

SQL> alter system set db_recovery_file_dest=’+RECOVERYDEST’;
System altered
step 2& 3: Migrate data files and control file to ASM.

use RMAN to migrate the data files to ASM disk groups.
All data files will be migrated to the newly created disk group, DATA
SQL> alter system set db_create_file_dest='+DATA';
System altered.

SQL> alter system set control_files='+DATA/cnt1.dbf' scope=spfile;
System altered.

SQL> shut immediate

[oracle@rac1 bin]$ rman target/XXXX


RMAN> startup nomount
Oracle instance started


RMAN> restore controlfile from '/u01/oracle/oradata/PROD/control01.ctl';
Starting restore at 06-MAY-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=256 device type=DISK
channel ORA_DISK_1: copied control file copy
output file name=+DATA/cnt1.dbf
Finished restore at 06-MAY-11
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1

RMAN> backup as copy database format '+DATA';Starting backup at 06-MAY-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=256 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/oracle/oradata/PROD/system01.dbf
output file name=+DATA/PROD/datafile/system.257.705063763 tag=TAG20091208T110241 RECID=1 STAMP=705064274
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:08:39
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/oracle/oradata/PROD/sysaux01.dbf
output file name=+DATA/PROD/datafile/sysaux.258.705064283 tag=TAG20091208T110241 RECID=2 STAMP=705064812
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:08:56
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/oracle/oradata/PROD/undotbs01.dbf
output file name=+DATA/PROD/datafile/undotbs1.259.705064821 tag=TAG20091208T110241 RECID=3 STAMP=705064897
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=+DATA/PROD/controlfile/backup.260.705064907 tag=TAG20091208T110241 RECID=4 STAMP=705064912
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/oracle/oradata/PROD/users01.dbf
output file name=+DATA/PROD/datafile/users.261.705064915 tag=TAG20091208T110241 RECID=5 STAMP=705064915
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 06-MAY-11
channel ORA_DISK_1: finished piece 1 at 06-MAY-11
piece handle=+DATA/PROD/backupset/2009_12_08/nnsnf0_tag20091208t110241_0.262.705064919 tag=TAG20091208T110241 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 06-MAY-11
RMAN> switch database to copy;datafile 1 switched to datafile copy "+DATA/PROD/datafile/system.257.705063763"
datafile 2 switched to datafile copy "+DATA/PROD/datafile/sysaux.258.705064283"
datafile 3 switched to datafile copy "+DATA/PROD/datafile/undotbs1.259.705064821"
datafile 4 switched to datafile copy "+DATA/PROD/datafile/users.261.705064915"
RMAN> alter database open;
database opened

RMAN> exit
Recovery Manager complete.
SQL> conn sys/oracle as sysdba
Connected.

SQL> select tablespace_name,file_name from dba_data_files;
TABLESPACE_NAME                FILE_NAME
------------------------------ ---------------------------------------------

USERS                          +DATA/PROD/datafile/users.261.705064915

UNDOTBS1                       +DATA/PROD/datafile/undotbs1.259.705064821

SYSAUX                         +DATA/PROD/datafile/sysaux.258.705064283

SYSTEM                         +DATA/PROD/datafile/system.257.705063763

SQL> select name from v$controlfile;
NAME
----
+DATA/cnt1.dbf

NO       16384            594
step 4:Migrate temp tablespace to ASM.

SQL> alter tablespace temp add tempfile size 100m;
Tablespace altered.

SQL> select file_name from dba_temp_files;
FILE_NAME
---------------------------------------------
+DATA/PROD/tempfile/temp.263.705065455

otherwise,Create temporary tablespace in ASM disk group.

SQL> CREATE TABLESPACE temp1 ADD TEMPFILE ‘+diskgroup1’;
step 5:Migrate redo logs to ASM.

SQL> select member,group# from v$logfile;
MEMBER                                                 GROUP#
-------------------------------------------------- ----------

/u01/oracle/oradata/PROD/redo03.log                     3

/u01/oracle/oradata/PROD/redo02.log                     2

/u01/oracle/oradata/PROD/redo01.log                     1

SQL> alter database add logfile group 4 size 5m;
Database altered.

SQL> alter database add logfile group 5 size 5m;
Database altered.

SQL> alter database add logfile group 6 size 5m;
Database altered.

SQL> select member,group# from v$logfile;

MEMBER                                                 GROUP#
-------------------------------------------------- ----------

/u01/oracle/oradata/PROD/redo03.log                     3

/u01/oracle/oradata/PROD/redo02.log                     2

/u01/oracle/oradata/PROD/redo01.log                     1

+DATA/PROD/onlinelog/group_4.264.705065691                  4

+DATA/PROD/onlinelog/group_5.265.705065703                  5

+DATA/PROD/onlinelog/group_6.266.705065719                  6

SQL> alter system switch logfile;
System altered.

SQL> alter database drop logfile group 2;
Database altered.

SQL> alter database drop logfile group 3;
Database altered.

SQL> alter database drop logfile group 4;
Database altered.

SQL> alter database drop logfile group 1;
Database altered.
Add additional control file.
If an additional control file is required for redundancy,
you can create it in ASM as you would on any other filesystem.
SQL> connect sys/sys@prod1 as sysdba
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.

SQL> alter database backup controlfile to '+DATA/cf2.dbf';
Database altered.

SQL> alter system set control_files='+DATA/cf1.dbf '
  ,'+DATA/cf2.dbf' scope=spfile;
System altered.

SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

SQL> select name from v$controlfile;
NAME
---------------------------------------
+DATA/cf1.dbf
+DATA/cf2.dbf
step 6:Migrate spfile to ASM:

Create a copy of the SPFILE in the ASM disk group.
In this example, the SPFILE for the migrated database will be stored as +DISK/spfile.

If the database is using an SPFILE already, then run these commands:

run {
BACKUP AS BACKUPSET SPFILE;
RESTORE SPFILE TO "+DISK/spfile";
}

If you are not using an SPFILE, then use CREATE SPFILE
from SQL*Plus to create the new SPFILE in ASM.
For example, if your parameter file is called /u02/init.ora,
use the following command:

SQL> create spfile='+DISK/spfile' from pfile='/u02/init.ora'