Showing posts with label ASM. Show all posts
Showing posts with label ASM. Show all posts

Sunday, August 12, 2012

MULTIPLEX CONTROLFILES on the ASM storage

WE CAN SEE HERE THAT WE HAVE 3 CONTROLFILE IN /u01


[oracle@localhost ~]$ export ORACLE_SID=shoaibdb
[oracle@localhost ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 12 11:57:14 2012

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              92276304 bytes
Database Buffers          188743680 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.

SQL> select name from v$controlfile;

NAME
---------------------------------------------------
/u01/app/oracle/oradata/shoaibdb/control01.ctl
/u01/app/oracle/oradata/shoaibdb/control02.ctl
/u01/app/oracle/oradata/shoaibdb/control03.ctl

SQL> show parameter spfile

NAME   TYPE    VALUE
------ ------- ----------------------------------------------------------
spfile string  /u01/app/oracle/product/10.2.0/db_1/dbs/spfileshoaibdb.ora
SQL> show parameter control        

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /u01/app/oracle/oradata/shoaibdb/c
                                                 ontrol01.ctl, /u01/app/oracle/
                                                 oradata/shoaibdb/control02.ctl, /u
                                                 01/app/oracle/oradata/shoaibdb/con
                                                 trol03.ctl


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

SQL> startup mount
ORACLE instance started.





NOW WE WILL TAKE THE BACKUP OF THE DATABASE AND CONTROLFILE


[oracle@localhost ~]$ export ORACLE_SID=shoaibdb
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Aug 12 12:34:36 2012

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

connected to target database: shoaibdb (DBID=563191061)

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_shoaibdb.f'; # default

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> backup database;

Starting backup at 12-AUG-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/shoaibdb/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/shoaibdb/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/shoaibdb/rmans01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/shoaibdb/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/shoaibdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-AUG-12
channel ORA_DISK_1: finished piece 1 at 12-AUG-12
piece handle=/u01/app/oracle/flash_recovery_area/shoaibdb/backupset/2012_08_12/o1_mf_nnndf_TAG20120812T123853_82gon5tp_.bkp tag=TAG20120812T123853 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 12-AUG-12

Starting Control File and SPFILE Autobackup at 12-AUG-12
piece handle=/u01/app/oracle/flash_recovery_area/shoaibdb/autobackup/2012_08_12/o1_mf_s_791123989_82goozc0_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-AUG-12

RMAN> exit




NOW WE WILL EDIT THE CONTROL_FILES INIT PARAMETER AND ADD THE 4th CONTROLFILE PATH OF THE ASM STORAGE


[oracle@localhost ~]$ export ORACLE_SID=shoaibdb
[oracle@localhost ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 12 11:57:14 2012

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


SQL> alter system set control_files='/u01/app/oracle/oradata/shoaibdb/control01.ctl','/u01/app/oracle/oradata/shoaibdb/control02.ctl','/u01/app/oracle/oradata/shoaibdb/control03.ctl','+DATA' scope=spfile;

System altered.

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

SQL> startup nomount;
ORACLE instance started.
Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size              96470608 bytes
Database Buffers          184549376 bytes
Redo Buffers                2973696 bytes
SQL> 
SQL> 
SQL> select status from v$instance;

STATUS
------------
STARTED




NOW USING THE RMAN WE WILL RESTORE THE CONTROLFILE FROM THE RMAN BACKUP TO THE ASM STORAGE


[oracle@localhost ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Aug 12 12:42:22 2012

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

connected to target database: shoaibdb (not mounted)

RMAN> restore controlfile from autobackup;

Starting restore at 12-AUG-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: shoaibdb
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/app/oracle/flash_recovery_area/shoaibdb/autobackup/2012_08_12/o1_mf_s_791123989_82goozc0_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/app/oracle/oradata/shoaibdb/control01.ctl
output filename=/u01/app/oracle/oradata/shoaibdb/control02.ctl
output filename=/u01/app/oracle/oradata/shoaibdb/control03.ctl
output filename=+DATA/shoaibdb/controlfile/current.256.791124165
Finished restore at 12-AUG-12

RMAN> exit


NOW WE WILL RECOVER THE DATABASE


[oracle@localhost ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Aug 12 12:49:16 2012

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

connected to target database: shoaibdb (DBID=563191061, not open)

RMAN> recover database;

Starting recover at 12-AUG-12
Starting implicit crosscheck backup at 12-AUG-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 12-AUG-12

Starting implicit crosscheck copy at 12-AUG-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 12-AUG-12

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/shoaibdb/autobackup/2012_08_12/o1_mf_s_791123989_82goozc0_.bkp

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/oradata/shoaibdb/redo02.log
archive log filename=/u01/app/oracle/oradata/shoaibdb/redo02.log thread=1 sequence=3
media recovery complete, elapsed time: 00:00:01
Finished recover at 12-AUG-12

RMAN> 



BACK ON THE SQLPLUS WE CAN SEE THAT WE HAVE MULTIPLEX THE CONTROLFILE AND THE 4th CONTROLFILE IS ADDED IN ASM


SQL> alter database open resetlogs;

Database altered.



SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/shoaibdb/control01.ctl
/u01/app/oracle/oradata/shoaibdb/control02.ctl
/u01/app/oracle/oradata/shoaibdb/control03.ctl
+DATA/shoaibdb/controlfile/current.256.791124165

SQL> 






























Wednesday, June 13, 2012

Moving datafile from non-asm to asm



[oracle@localhost ~]$ export ORACLE_SID=newdb

[oracle@localhost ~]$ sqlplus '/ as sysdba'

SQL> select status from v$instance;

OPEN

SQL> select name from v$database;

NEWDB

SQL> select name from v$datafile;

NAME

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

/u01/app/oracle/oradata/newdb/system01.dbf

/u01/app/oracle/oradata/newdb/undotbs01.dbf

/u01/app/oracle/oradata/newdb/sysaux01.dbf

/u01/app/oracle/oradata/newdb/users01.dbf

/u01/app/oracle/oradata/newdb/example01.dbf

/u01/app/oracle/oradata/newdb/addm1.dbf

/u01/app/oracle/oradata/newdb/old1.dbf

+DGROUP1/newdb/datafile/tbsasm.256.729953755

8 rows selected.

FOR THIS PRACTICAL WE CREATED A NORMAL TABLESPACE IN NON ASM DATABASE.

SQL> create tablespace tbsasmmig datafile 'asmmig1.dbf' size 3M;

Tablespace created.

SQL> select name from v$datafile;

NAME

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

/u01/app/oracle/oradata/newdb/system01.dbf

/u01/app/oracle/oradata/newdb/undotbs01.dbf

/u01/app/oracle/oradata/newdb/sysaux01.dbf

/u01/app/oracle/oradata/newdb/users01.dbf

/u01/app/oracle/oradata/newdb/example01.dbf

/u01/app/oracle/oradata/newdb/addm1.dbf

/u01/app/oracle/oradata/newdb/old1.dbf

+DGROUP1/newdb/datafile/tbsasm.256.729953755

/u01/app/oracle/product/10.2.0/db_1/dbs/asmmig1.dbf

9 rows selected.

SQL> create table l3(c number) tablespace tbsasmmig;

Table created.

SQL> insert into l3 values(1);

1 row created.

SQL> select * from l3;

C

----------

1

1

Non ASM to ASM shoaib.ansari@pathinfotech.com

SQL> host rman target / nocatalog

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Sep 21 10:34:31 2010

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

connected to target database: NEWDB (DBID=2968639662)

using target database control file instead of recovery catalog

RMAN> sql "alter tablespace tbsasmmig offline";

sql statement: alter tablespace tbsasmmig offline

RMAN> backup as copy tablespace tbsasmmig format '+DGROUP1';

Starting backup at 21-SEP-10

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=148 devtype=DISK

channel ORA_DISK_1: starting datafile copy

input datafile fno=00009 name=/u01/app/oracle/product/10.2.0/db_1/dbs/asmmig1.dbf

output filename=+DGROUP1/newdb/datafile/tbsasmmig.257.730290999 tag=TAG20100921T103638 recid=4

stamp=730291001

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07

Finished backup at 21-SEP-10

RMAN> switch tablespace tbsasmmig to copy;

datafile 9 switched to datafile copy "+DGROUP1/newdb/datafile/tbsasmmig.257.730290999"

RMAN> sql "alter tablespace tbsasmmig online";

sql statement: alter tablespace tbsasmmig online

RMAN> exit

Recovery Manager complete.

SQL> column file_name format a48

SQL> select tablespace_name,file_name from dba_data_files;

TABLESPACE_NAME FILE_NAME

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

EXAMPLE /u01/app/oracle/oradata/newdb/example01.dbf

USERS /u01/app/oracle/oradata/newdb/users01.dbf

SYSAUX /u01/app/oracle/oradata/newdb/sysaux01.dbf

UNDOTBS1 /u01/app/oracle/oradata/newdb/undotbs01.dbf

SYSTEM /u01/app/oracle/oradata/newdb/system01.dbf

TBSADDM /u01/app/oracle/oradata/newdb/addm1.dbf

OLD /u01/app/oracle/oradata/newdb/old1.dbf

TBSASM +DGROUP1/newdb/datafile/tbsasm.256.729953755

TBSASMMIG +DGROUP1/newdb/datafile/tbsasmmig.257.730290999

9 rows selected.

ORA-12519: TNS:no appropriate service handler found error

ORA-12519: TNS: no appropriate service handler found error The real problem lies in the PROCESSES parameter All you need ...