facebook twitter youtube facebook facebook facebook

E-Mail : info@askmlabs.com

Phone : +1.215.353.8306

Latest Post

RMAN recovery scenarios

Written By askMLabs on Wednesday, March 27, 2013 | 2:29 PM

Recently i took RMAN sessions to some group of people and as a part of it i explained various scenarios of rman restore and recovery operation. I tried to record the video for the purpose of the people who follow my blog.

In this present session we will see various recovery scenarios mentioned below.

  1. Complete database restore and recovery

  2. Loss of System Datafile

  3. Non-System datafile ( closed and Open )

  4. Restoring a tablespace ( closed and Open )

  5. Restoring a datafile if no backups

  6. Restoring a datafile to different location

  7. Restoring controlfile

  8. restoring spfile

  9. Restoring online redologs

  10. Restoring temporary datafiles

  11. Incomplete Recovery ( time based , Change based and SCN based )

  12. Recovering archived logs

The following video demo gives you detailed explanation of each scenario and how to restore and recover under different scenarios.




Setup:
Let me explain you the environment used for this practice. I am using a database with ORACLE_SID=orcl as my database for testing all the different scenarios mentioned above. I am using a recovery catalog for my rman configuration and its details are ORACLE_SID=rmandb and schema used for rman catalog data is rman and the tns alias to connect to catalog database is rmandb.

I have both my databases orcl and rmandb in archive log mode and i also have backup for my database orcl.

For all my restore and recover operations i am using the following syntax to connect to target database and catalog database.

rman target / catalog rman/*******@rmandb

Complete database restore
SQL> select name,user from v$database;NAME USER
--------- ------------------------------
ORCL SYSSQL> select open_mode from v$database;OPEN_MODE
--------------------
READ WRITESQL> select username,default_tablespace from dba_users where username='SH';

USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
SH USERS

SQL> conn scott/oracle
Connected.
SQL> select count(1) from emp;

COUNT(1)
----------
14

SQL> select * from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> select * from dept;

DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

SQL> cl scr

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ cd /home/oracle/app/oracle/oradata/orcl/
[oracle@localhost orcl]$ ls -lrt
total 2754360
-rw-r----- 1 oracle oracle 239869952 Mar 23 21:40 users01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 23 21:40 redo03.log
-rw-r----- 1 oracle oracle 52429312 Mar 23 21:40 redo02.log
-rw-r----- 1 oracle oracle 85991424 Mar 23 21:40 example01.dbf
-rw-rw---- 1 oracle oracle 8396800 Mar 23 21:40 APEX_1265209995679366.dbf
-rw-rw---- 1 oracle oracle 2105344 Mar 23 21:40 APEX_1246426611663638.dbf
-rw-r----- 1 oracle oracle 165683200 Mar 23 22:40 temp01.dbf
-rw-r----- 1 oracle oracle 845160448 Mar 23 23:05 system01.dbf
-rw-r----- 1 oracle oracle 1158684672 Mar 23 23:07 sysaux01.dbf
-rw-r----- 1 oracle oracle 144711680 Mar 23 23:08 undotbs01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:08 redo01.log
-rw-r----- 1 oracle oracle 9748480 Mar 23 23:08 control01.ctl
[oracle@localhost orcl]$ rm *.dbf
[oracle@localhost orcl]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sat Mar 23 23:09:18 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> conn scoot/tiger
ERROR:
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
SQL> conn scott/oracle
Connected.
SQL> select * from emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> alter system flush sga;
alter system flush sga
*
ERROR at line 1:
ORA-02000: missing SHARED_POOL/BUFFER_CACHE/GLOBAL CONTEXT keyword

SQL> alter system flush shared pool;
alter system flush shared pool
*
ERROR at line 1:
ORA-02000: missing SHARED_POOL/BUFFER_CACHE/GLOBAL CONTEXT keyword

SQL> conn /as sysdba
Connected.
SQL> alter system flush shared pool;
alter system flush shared pool
*
ERROR at line 1:
ORA-02000: missing SHARED_POOL/BUFFER_CACHE/GLOBAL CONTEXT keyword

SQL> alter system flush shared_pool;

System altered.

SQL> conn scott/oracle
ERROR:
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/home/oracle/app/oracle/oradata/orcl/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

Warning: You are no longer connected to ORACLE.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> exit
Disconnected
[oracle@localhost orcl]$ ps -ef | grep -i pmon
oracle 2309 1 0 21:39 ? 00:00:11 ora_pmon_orcl
oracle 3513 3193 0 23:12 pts/1 00:00:00 grep -i pmon
[oracle@localhost orcl]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sat Mar 23 23:12:55 2013

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

Connected.
SQL> shut immediate
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/home/oracle/app/oracle/oradata/orcl/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shut abort
ORACLE instance shut down.

========================== break =================================================
[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 - Production on Sat Mar 23 23:13:11 2013

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

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/home/oracle/app/oracle/oradata/orcl/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
[oracle@localhost ~]$

========================= break ==============================

SQL> startup nomount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
SQL>

============================= Break ===========================================

RMAN> run {
2> alter database mount;
3> restore database;
4> recover database;
5> }

database mounted
released channel: ORA_DISK_1

Starting restore at 23-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf
channel ORA_DISK_1: restoring datafile 00007 to /home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp tag=FULL_WEEKLY_HOT
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:26
Finished restore at 23-MAR-13

Starting recover at 23-MAR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /home/oracle/app/oracle/oradata/orcl/system01.dbf
destination for restore of datafile 00002: /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
destination for restore of datafile 00003: /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
destination for restore of datafile 00005: /home/oracle/app/oracle/oradata/orcl/example01.dbf
destination for restore of datafile 00006: /home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf
destination for restore of datafile 00007: /home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp tag=LVL1C_FULL_DB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=360
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=361
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=362
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=363
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp tag=TAG20130224T034327
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx712yq_.arc thread=1 sequence=360
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx712yq_.arc RECID=17 STAMP=810861876
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx7131f_.arc thread=1 sequence=361
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx7131f_.arc RECID=14 STAMP=810861875
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx713x6_.arc thread=1 sequence=362
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx713x6_.arc RECID=15 STAMP=810861876
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx714b8_.arc thread=1 sequence=363
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx714b8_.arc RECID=16 STAMP=810861876
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
media recovery complete, elapsed time: 00:00:14
Finished recover at 23-MAR-13
starting full resync of recovery catalog
full resync complete

RMAN> alter database open;

database opened

RMAN>

============================ Break =============================

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

NAME USER OPEN_MODE
--------- ------------------------------ --------------------
ORCL SYS READ WRITE

SQL> select count(1) from scott.emp;

COUNT(1)
----------
14

SQL> select count(1) from scott.dept;

COUNT(1)
----------
4

SQL>

=======================================================


System Datafile
[oracle@localhost orcl]$ ls -lrt
total 2593432
-rw-rw---- 1 oracle oracle 239869952 Mar 23 23:25 users01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:25 redo03.log
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:25 redo01.log
-rw-rw---- 1 oracle oracle 85991424 Mar 23 23:25 example01.dbf
-rw-rw---- 1 oracle oracle 8396800 Mar 23 23:25 APEX_1265209995679366.dbf
-rw-rw---- 1 oracle oracle 2105344 Mar 23 23:25 APEX_1246426611663638.dbf
-rw-rw---- 1 oracle oracle 20979712 Mar 23 23:25 temp01.dbf
-rw-rw---- 1 oracle oracle 144711680 Mar 23 23:31 undotbs01.dbf
-rw-rw---- 1 oracle oracle 845160448 Mar 23 23:32 system01.dbf
-rw-rw---- 1 oracle oracle 1158684672 Mar 23 23:34 sysaux01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:35 redo02.log
-rw-r----- 1 oracle oracle 9748480 Mar 23 23:35 control01.ctl
[oracle@localhost orcl]$ rm system01.dbf
[oracle@localhost orcl]$ sqlplus '/as sysdba'SQL*Plus: Release 11.1.0.7.0 - Production on Sat Mar 23 23:35:12 2013Copyright (c) 1982, 2008, Oracle. All rights reserved.ERROR:
ORA-01075: you are currently logged onEnter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied

Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied

SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
[oracle@localhost orcl]$ sqlplus /nolog

SQL*Plus: Release 11.1.0.7.0 - Production on Sat Mar 23 23:35:22 2013

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

SQL> conn /as sysdba
ERROR:
ORA-01075: you are currently logged on

SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORA-00000: normal, successful completion
SQL> select open_mode from v$database;
SP2-0640: Not connected
SQL> SELECT file#, name FROM v$datafile;
SP2-0640: Not connected
SQL> conn '/as sysdba'
Enter password:
ERROR:
ORA-01005: null password given; logon denied

SQL> shut abort
ORA-01031: insufficient privileges
SQL> conn /as sysdba
Connected.
SQL> SELECT file#, name FROM v$datafile;
SELECT file#, name FROM v$datafile
*
ERROR at line 1:
ORA-01507: database not mounted

SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL> SELECT file#, name FROM v$datafile;

FILE#
----------
NAME
--------------------------------------------------------------------------------
1
/home/oracle/app/oracle/oradata/orcl/system01.dbf

2
/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf

3
/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf

FILE#
----------
NAME
--------------------------------------------------------------------------------
4
/home/oracle/app/oracle/oradata/orcl/users01.dbf

5
/home/oracle/app/oracle/oradata/orcl/example01.dbf

6
/home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf

FILE#
----------
NAME
--------------------------------------------------------------------------------
7
/home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf

7 rows selected.

SQL> desc v$datafile
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
CHECKPOINT_CHANGE# NUMBER
CHECKPOINT_TIME DATE
UNRECOVERABLE_CHANGE# NUMBER
UNRECOVERABLE_TIME DATE
LAST_CHANGE# NUMBER
LAST_TIME DATE
OFFLINE_CHANGE# NUMBER
ONLINE_CHANGE# NUMBER
ONLINE_TIME DATE
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
PLUGGED_IN NUMBER
BLOCK1_OFFSET NUMBER
AUX_NAME VARCHAR2(513)
FIRST_NONLOGGED_SCN NUMBER
FIRST_NONLOGGED_TIME DATE
FOREIGN_DBID NUMBER
FOREIGN_CREATION_CHANGE# NUMBER
FOREIGN_CREATION_TIME DATE
PLUGGED_READONLY VARCHAR2(3)
PLUGIN_CHANGE# NUMBER
PLUGIN_RESETLOGS_CHANGE# NUMBER
PLUGIN_RESETLOGS_TIME DATE

SQL> select file#,name,status from v$datafile;

FILE#
----------
NAME
--------------------------------------------------------------------------------
STATUS
-------
1
/home/oracle/app/oracle/oradata/orcl/system01.dbf
SYSTEM

2
/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
ONLINE

FILE#
----------
NAME
--------------------------------------------------------------------------------
STATUS
-------

3
/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
ONLINE

4
/home/oracle/app/oracle/oradata/orcl/users01.dbf

FILE#
----------
NAME
--------------------------------------------------------------------------------
STATUS
-------
ONLINE

5
/home/oracle/app/oracle/oradata/orcl/example01.dbf
ONLINE

6

FILE#
----------
NAME
--------------------------------------------------------------------------------
STATUS
-------
/home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.dbf
ONLINE

7
/home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.dbf
ONLINE

7 rows selected.

SQL>

====================== break ===============================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 - Production on Sat Mar 23 23:39:06 2013

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

connected to target database: ORCL (DBID=1229390655, not open)
connected to recovery catalog database

RMAN> run {
2> restore datafile 1;
3> recover datafile 1;
4> alter database open;
5> }

Starting restore at 23-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_21/o1_mf_nnnd0_FULL_WEEKLY_HOT_8lcsnr7j_.bkp tag=FULL_WEEKLY_HOT
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:06
Finished restore at 23-MAR-13

Starting recover at 23-MAR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_nnnd1_LVL1C_FULL_DB_8lmjd52r_.bkp tag=LVL1C_FULL_DB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=360
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=361
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=362
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=363
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp tag=TAG20130224T034327
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx83bfk_.arc thread=1 sequence=360
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_360_8nx83bfk_.arc RECID=22 STAMP=810862973
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx83bjo_.arc thread=1 sequence=361
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_361_8nx83bjo_.arc RECID=19 STAMP=810862971
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx83cvw_.arc thread=1 sequence=362
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_362_8nx83cvw_.arc RECID=20 STAMP=810862972
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx83d7w_.arc thread=1 sequence=363
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_363_8nx83d7w_.arc RECID=21 STAMP=810862972
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
media recovery complete, elapsed time: 00:00:04
Finished recover at 23-MAR-13

database opened

RMAN>

============================= break ===========================

SQL> SELECT file#, name,status FROM v$datafile;

FILE# NAME STATUS
----- ------------------------------------------------------------ ----------
1 /home/oracle/app/oracle/oradata/orcl/system01.dbf SYSTEM
2 /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf ONLINE
3 /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf ONLINE
4 /home/oracle/app/oracle/oradata/orcl/users01.dbf ONLINE
5 /home/oracle/app/oracle/oradata/orcl/example01.dbf ONLINE
6 /home/oracle/app/oracle/oradata/orcl/APEX_1246426611663638.d ONLINE
bf

7 /home/oracle/app/oracle/oradata/orcl/APEX_1265209995679366.d ONLINE
bf

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='SYSTEM';

TABLESPACE_NAME STATUS
------------------------------ ----------
SYSTEM ONLINE


Non-System datafile ( closed and Open )
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ ls -lrt
total 2593432
-rw-rw---- 1 oracle oracle 20979712 Mar 23 23:25 temp01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:43 redo01.log
-rw-rw---- 1 oracle oracle 239869952 Mar 23 23:43 users01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:43 redo02.log
-rw-rw---- 1 oracle oracle 85991424 Mar 23 23:43 example01.dbf
-rw-rw---- 1 oracle oracle 8396800 Mar 23 23:43 APEX_1265209995679366.dbf
-rw-rw---- 1 oracle oracle 2105344 Mar 23 23:43 APEX_1246426611663638.dbf
-rw-rw---- 1 oracle oracle 845160448 Mar 23 23:49 system01.dbf
-rw-rw---- 1 oracle oracle 144711680 Mar 23 23:49 undotbs01.dbf
-rw-rw---- 1 oracle oracle 1158684672 Mar 23 23:49 sysaux01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:49 redo03.log
-rw-r----- 1 oracle oracle 9748480 Mar 23 23:49 control01.ctl
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus '/as sysdba'SQL*Plus: Release 11.1.0.7.0 - Production on Sat Mar 23 23:50:30 2013Copyright (c) 1982, 2008, Oracle. All rights reserved.Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> col file# for 999
SQL> col name for a60
SQL> col status for a10
SQL> set linesize 120
SQL> SELECT file#, name,status FROM v$datafile where tablespace_name='USERS';
SELECT file#, name,status FROM v$datafile where tablespace_name='USERS'
*
ERROR at line 1:
ORA-00904: "TABLESPACE_NAME": invalid identifier

SQL> DESC V$DATAFILE
Name Null? Type
----------------------------------------------------------------- -------- --------------------------------------------
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
CHECKPOINT_CHANGE# NUMBER
CHECKPOINT_TIME DATE
UNRECOVERABLE_CHANGE# NUMBER
UNRECOVERABLE_TIME DATE
LAST_CHANGE# NUMBER
LAST_TIME DATE
OFFLINE_CHANGE# NUMBER
ONLINE_CHANGE# NUMBER
ONLINE_TIME DATE
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
PLUGGED_IN NUMBER
BLOCK1_OFFSET NUMBER
AUX_NAME VARCHAR2(513)
FIRST_NONLOGGED_SCN NUMBER
FIRST_NONLOGGED_TIME DATE
FOREIGN_DBID NUMBER
FOREIGN_CREATION_CHANGE# NUMBER
FOREIGN_CREATION_TIME DATE
PLUGGED_READONLY VARCHAR2(3)
PLUGIN_CHANGE# NUMBER
PLUGIN_RESETLOGS_CHANGE# NUMBER
PLUGIN_RESETLOGS_TIME DATE

SQL> desc dba_data_files
Name Null? Type
----------------------------------------------------------------- -------- --------------------------------------------
FILE_NAME VARCHAR2(513)
FILE_ID NUMBER
TABLESPACE_NAME VARCHAR2(30)
BYTES NUMBER
BLOCKS NUMBER
STATUS VARCHAR2(9)
RELATIVE_FNO NUMBER
AUTOEXTENSIBLE VARCHAR2(3)
MAXBYTES NUMBER
MAXBLOCKS NUMBER
INCREMENT_BY NUMBER
USER_BYTES NUMBER
USER_BLOCKS NUMBER
ONLINE_STATUS VARCHAR2(7)

SQL> select file_name,file_id,tablespace_name from dba_data_files where tablespace_name='USERS';

FILE_NAME
------------------------------------------------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME
---------- ------------------------------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME
------------------------------------------------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ----------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status fro v$datafile where file#=4;
select file#,TS#,status fro v$datafile where file#=4
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL> alter system flush shared_pool;

System altered.

SQL> select count(1) from scott.emp;
select count(1) from scott.emp
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

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

NAME USER OPEN_MODE
------------------------------------------------------------ ------------------------------ --------------------
ORCL SYS READ WRITE

SQL>

======================== break =============================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 - Production on Sat Mar 23 23:55:32 2013

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

connected to target database: ORCL (DBID=1229390655)
connected to recovery catalog database

RMAN> run {
2> restore datafile 4;
3> recover datafile 4;
4> }

Starting restore at 23-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 03/23/2013 23:56:44
ORA-19573: cannot obtain exclusive enqueue for datafile 4
ORA-19600: input file is datafile-copy 2 (/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf)
ORA-19601: output file is datafile 4 (/home/oracle/app/oracle/oradata/orcl/users01.dbf)

RMAN>

=========================== break =============================

SQL> ALTER DATABASE DATAFILE 4 OFFLINE;

Database altered.

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME
------------------------------------------------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ----------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 RECOVER

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

NAME USER OPEN_MODE
------------------------------------------------------------ ------------------------------ --------------------
ORCL SYS READ WRITE

SQL>

============================== break =========================================

RMAN> run {
2> restore datafile 4;
3> recover datafile 4;
4> sql 'atler database datafile 4 online';
5> }

Starting restore at 24-MAR-13
using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
media recovery complete, elapsed time: 00:00:03
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: atler database datafile 4 online
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 03/24/2013 00:01:08
RMAN-11003: failure during parse/execution of SQL statement: atler database datafile 4 online
ORA-00900: invalid SQL statement

RMAN>

RMAN> run {
2> sql 'alter database datafile 4 online';
3> }

sql statement: alter database datafile 4 online

RMAN>

========================== break =============================

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME
------------------------------------------------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ----------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL> select count(1) from scott.emp;

COUNT(1)
----------
14

SQL> create table test (sno number) tablespace users;

Table created.

SQL>

============================================================================================

Lost non system datafile :( Online method )

[oracle@localhost orcl]$ ls -lrt
total 2593488
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:43 redo01.log
-rw-r----- 1 oracle oracle 52429312 Mar 23 23:43 redo02.log
-rw-rw---- 1 oracle oracle 85991424 Mar 23 23:43 example01.dbf
-rw-rw---- 1 oracle oracle 8396800 Mar 23 23:43 APEX_1265209995679366.dbf
-rw-rw---- 1 oracle oracle 2105344 Mar 23 23:43 APEX_1246426611663638.dbf
-rw-rw---- 1 oracle oracle 20979712 Mar 24 00:00 temp01.dbf
-rw-rw---- 1 oracle oracle 239869952 Mar 24 00:06 users01.dbf
-rw-rw---- 1 oracle oracle 1158684672 Mar 24 00:10 sysaux01.dbf
-rw-rw---- 1 oracle oracle 144711680 Mar 24 00:11 undotbs01.dbf
-rw-rw---- 1 oracle oracle 845160448 Mar 24 00:11 system01.dbf
-rw-r----- 1 oracle oracle 52429312 Mar 24 00:11 redo03.log
-rw-r----- 1 oracle oracle 9748480 Mar 24 00:12 control01.ctl
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 00:12:39 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> col file# for 999
col name for a60
col status for a10
set linesize 120
select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';SQL> SQL> SQL> SQL>

FILE_NAME
------------------------------------------------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ----------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL> alter system flush shared_pool;

System altered.

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL> select count(1) from scott.emp;

COUNT(1)
----------
14

SQL> alter system flush shared_pool;

System altered.

SQL> select count(1) from scott.emp;

COUNT(1)
----------
14

SQL> drop table test;

Table dropped.

SQL> create table test (sno number) tablespace users;
create table test (sno number) tablespace users
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

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

NAME USER OPEN_MODE
------------------------------------------------------------ ------------------------------ --------------------
ORCL SYS READ WRITE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL> shut immediate
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> startup mount
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';
select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS'
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL>

====================== break ==============================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Mar 24 00:18:11 2013

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

connected to target database: ORCL (DBID=1229390655, not open)
connected to recovery catalog database

RMAN> run {
2> restore datafile 4;
3> recover datafile 4;
4> sql 'alter database datafile 4 online';
5> }

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
media recovery complete, elapsed time: 00:00:01
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: alter database datafile 4 online

RMAN>

========================================== break ===================================================

SQL> alter database open;

Database altered.

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME
------------------------------------------------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ----------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,TS#,status from v$datafile where file#=4;

FILE# TS# STATUS
----- ---------- ----------
4 4 ONLINE

SQL> select count(1) from scott.emp;

COUNT(1)
----------
14

SQL> create table test (sno number) tablespace users;

Table created.

SQL> drop table test;

Table dropped.

SQL> sho parameter recycle

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
buffer_pool_recycle string
db_recycle_cache_size big integer 0
recyclebin string on
SQL> purge recyclebin;

Recyclebin purged.

SQL>


Restoring a tablespace ( closed and Open )


Restoring a tablespace : (open mode)[oracle@localhost orcl]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 00:32:07 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='USERS';

TABLESPACE_NAME STATUS
------------------------------ ---------
USERS ONLINE

SQL> desc dba_tablespaces
Name Null? Type
----------------------------------------- -------- ----------------------------
TABLESPACE_NAME NOT NULL VARCHAR2(30)
BLOCK_SIZE NOT NULL NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NOT NULL NUMBER
MAX_EXTENTS NUMBER
MAX_SIZE NUMBER
PCT_INCREASE NUMBER
MIN_EXTLEN NUMBER
STATUS VARCHAR2(9)
CONTENTS VARCHAR2(9)
LOGGING VARCHAR2(9)
FORCE_LOGGING VARCHAR2(3)
EXTENT_MANAGEMENT VARCHAR2(10)
ALLOCATION_TYPE VARCHAR2(9)
PLUGGED_IN VARCHAR2(3)
SEGMENT_SPACE_MANAGEMENT VARCHAR2(6)
DEF_TAB_COMPRESSION VARCHAR2(8)
RETENTION VARCHAR2(11)
BIGFILE VARCHAR2(3)
PREDICATE_EVALUATION VARCHAR2(7)
ENCRYPTED VARCHAR2(3)
COMPRESS_FOR VARCHAR2(12)

SQL> desc v$tablespace
Name Null? Type
----------------------------------------- -------- ----------------------------
TS# NUMBER
NAME VARCHAR2(30)
INCLUDED_IN_DATABASE_BACKUP VARCHAR2(3)
BIGFILE VARCHAR2(3)
FLASHBACK_ON VARCHAR2(3)
ENCRYPT_IN_BACKUP VARCHAR2(3)

SQL> select ts#,name from v$tablespace where name='USERS';

TS# NAME
---------- ------------------------------
4 USERS

SQL> desc dba_data_files
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE_NAME VARCHAR2(513)
FILE_ID NUMBER
TABLESPACE_NAME VARCHAR2(30)
BYTES NUMBER
BLOCKS NUMBER
STATUS VARCHAR2(9)
RELATIVE_FNO NUMBER
AUTOEXTENSIBLE VARCHAR2(3)
MAXBYTES NUMBER
MAXBLOCKS NUMBER
INCREMENT_BY NUMBER
USER_BYTES NUMBER
USER_BLOCKS NUMBER
ONLINE_STATUS VARCHAR2(7)

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ---------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> desc v$datafile
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE# NUMBER
CREATION_CHANGE# NUMBER
CREATION_TIME DATE
TS# NUMBER
RFILE# NUMBER
STATUS VARCHAR2(7)
ENABLED VARCHAR2(10)
CHECKPOINT_CHANGE# NUMBER
CHECKPOINT_TIME DATE
UNRECOVERABLE_CHANGE# NUMBER
UNRECOVERABLE_TIME DATE
LAST_CHANGE# NUMBER
LAST_TIME DATE
OFFLINE_CHANGE# NUMBER
ONLINE_CHANGE# NUMBER
ONLINE_TIME DATE
BYTES NUMBER
BLOCKS NUMBER
CREATE_BYTES NUMBER
BLOCK_SIZE NUMBER
NAME VARCHAR2(513)
PLUGGED_IN NUMBER
BLOCK1_OFFSET NUMBER
AUX_NAME VARCHAR2(513)
FIRST_NONLOGGED_SCN NUMBER
FIRST_NONLOGGED_TIME DATE
FOREIGN_DBID NUMBER
FOREIGN_CREATION_CHANGE# NUMBER
FOREIGN_CREATION_TIME DATE
PLUGGED_READONLY VARCHAR2(3)
PLUGIN_CHANGE# NUMBER
PLUGIN_RESETLOGS_CHANGE# NUMBER
PLUGIN_RESETLOGS_TIME DATE

SQL> select file#,ts#,status from v$datafile where ts#=4;

FILE# TS# STATUS
---------- ---------- -------
4 4 ONLINE

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 00:35:42 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='USERS';

TABLESPACE_NAME STATUS
------------------------------ ---------
USERS ONLINE

SQL> select ts#,name from v$tablespace where name='USERS';

TS# NAME
---------- ------------------------------
4 USERS

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ---------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,ts#,status from v$datafile where ts#=4;

FILE# TS# STATUS
---------- ---------- -------
4 4 ONLINE

SQL> create table test (sno number) tablespace users;
create table test (sno number) tablespace users
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> alter tablespace users offline;
alter tablespace users offline
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> alter tablespace users offline force;
alter tablespace users offline force
*
ERROR at line 1:
ORA-02141: invalid OFFLINE option

SQL> alter tablespace users force offline;
alter tablespace users force offline
*
ERROR at line 1:
ORA-02142: missing or invalid ALTER TABLESPACE option

SQL> alter tablespace users offline;
alter tablespace users offline
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL> alter tablespace users offline;
alter tablespace users offline
*
ERROR at line 1:
ORA-01109: database not open

SQL>

================================= break ===========================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Mar 24 00:41:20 2013

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

connected to target database: ORCL (DBID=1229390655, not open)
connected to recovery catalog database

RMAN> run {
2> restore tablespace users;
3> recover tablespace users;
4> sql 'alter database open';
5> }

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/users01.dbf RECID=0 STAMP=0
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log for thread 1 with sequence 369 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc thread=1 sequence=367
media recovery complete, elapsed time: 00:00:03
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: alter database open

RMAN>

=================================== Break ==============================================

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

NAME USER OPEN_MODE
--------- ------------------------------ --------------------
ORCL SYS READ WRITE

SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='USERS';

TABLESPACE_NAME STATUS
------------------------------ ---------
USERS ONLINE

SQL> select ts#,name from v$tablespace where name='USERS';

TS# NAME
---------- ------------------------------
4 USERS

SQL> select file_name,file_id,tablespace_name,status from dba_data_files where tablespace_name='USERS';

FILE_NAME
--------------------------------------------------------------------------------
FILE_ID TABLESPACE_NAME STATUS
---------- ------------------------------ ---------
/home/oracle/app/oracle/oradata/orcl/users01.dbf
4 USERS AVAILABLE

SQL> select file#,ts#,status from v$datafile where ts#=4;

FILE# TS# STATUS
---------- ---------- -------
4 4 ONLINE

SQL> create table test (sno number) tablespace users;

Table created.

SQL> drop table test;

Table dropped.

SQL> purge recyclebin;

Recyclebin purged.

SQL>


Restoring a datafile if no backups


Restoring a datafile if no backups[oracle@localhost orcl]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 01:52:39 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create tablespace test_ts datafile '/home/oracle/app/oracle/oradata/orcl/test_ts01.dbf' size 5m;

Tablespace created.

SQL> create table test tablespace test_ts as select * from scott.emp;

Table created.

SQL> select * from test;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ rm test_ts01.dbf
[oracle@localhost orcl]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 01:54:06 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select count(1) from test;

COUNT(1)
----------
14

SQL> select * from test;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> alter system flush shared_pool;

System altered.

SQL> select * from test;

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000
20

7839 KING PRESIDENT 17-NOV-81 5000
10

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100
20

7900 JAMES CLERK 7698 03-DEC-81 950
30

EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300
10

14 rows selected.

SQL> select segment_name,tablespace_name from dba_segments where segment_name='TEST';

SEGMENT_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
TEST
TEST_TS

SQL> shut immediate
ORA-01116: error in opening database file 8
ORA-01110: data file 8: '/home/oracle/app/oracle/oradata/orcl/test_ts01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shut abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
Database mounted.
SQL>

=============================================== Break =========================================================

RMAN> run {
2> sql 'alter database datafile 8 offline';
3> restore datafile 8;
4> recover datafile 8;
5> sql 'alter database datafile 8 online';
6> }

starting full resync of recovery catalog
full resync complete
sql statement: alter database datafile 8 offline

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK

creating datafile file number=8 name=/home/oracle/app/oracle/oradata/orcl/test_ts01.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 24-MAR-13

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 24-MAR-13

sql statement: alter database datafile 8 online

RMAN>

============================================== Break ==========================================

SQL> alter database open;

Database altered.

SQL> create table test tablespace test_ts as select * from scott.emp;
create table test tablespace test_ts as select * from scott.emp
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> create table test1 tablespace test_ts as select * from scott.emp;

Table created.

SQL>
SQL> drop table test;

Table dropped.

SQL> drop table test1;

Table dropped.

SQL>

SQL> drop tablespace test_ts including contents and datafiles;

Tablespace dropped.

SQL>


Restoring a datafile to different location
Restoring a datafile to different location[oracle@localhost orcl]$ clear
[oracle@localhost orcl]$ ls -lrt user*
-rw-rw---- 1 oracle oracle 239869952 Mar 24 02:01 users01.dbf
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus '/as sysdba'SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 02:10:36 2013Copyright (c) 1982, 2008, Oracle. All rights reserved.Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table scott.test tablespace uses as select * from scott.emp;
create table scott.test tablespace uses as select * from scott.emp
*
ERROR at line 1:
ORA-00959: tablespace 'USES' does not exist

SQL> create table scott.test tablespace users as select * from scott.emp;
create table scott.test tablespace users as select * from scott.emp
*
ERROR at line 1:
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3

SQL> alter database datafile 4 offline;

Database altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost orcl]$ mkdir askm
[oracle@localhost orcl]$ cd askm
[oracle@localhost askm]$ pwd
/home/oracle/app/oracle/oradata/orcl/askm
[oracle@localhost askm]$ ls
[oracle@localhost askm]$

=============================================== Break ==========================================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Mar 24 02:12:20 2013

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

connected to target database: ORCL (DBID=1229390655)
connected to recovery catalog database

RMAN> run {
2> set newname for datafile 4 to '/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf';
3> restore datafile 4;
4> switch datafile 4;
5> recover datafile 4;
6> sql 'alter database datafile 4 online';
7> }

executing command: SET NEWNAME
starting full resync of recovery catalog
full resync complete

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK

channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=2 STAMP=808202600 file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
destination for restore of datafile 00004: /home/oracle/app/oracle/oradata/orcl/askm/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf RECID=10 STAMP=810872051
Finished restore at 24-MAR-13

datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=810872055 file name=/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf
starting full resync of recovery catalog
full resync complete

Starting recover at 24-MAR-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log for thread 1 with sequence 369 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
archived log for thread 1 with sequence 370 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc
archived log for thread 1 with sequence 371 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc thread=1 sequence=367
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc thread=1 sequence=368
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc thread=1 sequence=369
media recovery complete, elapsed time: 00:00:04
Finished recover at 24-MAR-13
starting full resync of recovery catalog
full resync complete

sql statement: alter database datafile 4 online

RMAN>

================================= Break ======================================================

[oracle@localhost askm]$ pwd
/home/oracle/app/oracle/oradata/orcl/askm
[oracle@localhost askm]$ ls -lrt
total 234484
-rw-rw---- 1 oracle oracle 239869952 Mar 24 02:14 users01.dbf
[oracle@localhost askm]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 02:15:49 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table scott.test tablespace users as select * from scott.emp;

Table created.

SQL> drop table scott.test;

Table dropped.

SQL>


Restoring controlfile
Restoring controlfile
=======================SQL> desc v$controlfile
Name Null? Type
----------------------------------------- -------- ----------------------------
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBERSQL> select name,status from v$controlfile;NAME
--------------------------------------------------------------------------------
STATUS
-------
/home/oracle/app/oracle/oradata/orcl/control01.ctl/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost askm]$ rm /home/oracle/app/oracle/oradata/orcl/control01.ctl /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
[oracle@localhost askm]$ ps -ef | grep -i pmon
oracle 5502 1 0 01:56 ? 00:00:04 ora_pmon_orcl
[oracle@localhost askm]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.7.0 - Production on Sun Mar 24 02:25:15 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table scott.test tablespace users as select * from scott.emp;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> shut immediate
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/home/oracle/app/oracle/oradata/orcl/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shut abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 456146944 bytes
Fixed Size 1344840 bytes
Variable Size 394267320 bytes
Database Buffers 54525952 bytes
Redo Buffers 6008832 bytes
ORA-00205: error in identifying control file, check alert log for more info

SQL>

================================== Break =================================================

[oracle@localhost ~]$ rman target / catalog rman/oracle@rmandb

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Mar 24 02:29:14 2013

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

connected to target database: ORCL (not mounted)
connected to recovery catalog database

RMAN> set dbid=1229390655

executing command: SET DBID
database name is "ORCL" and DBID is 1229390655

RMAN> restore controlfile;

Starting restore at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_ncsn1_LVL1C_FULL_DB_8lmjhknt_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_ncsn1_LVL1C_FULL_DB_8lmjhknt_.bkp tag=LVL1C_FULL_DB
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/home/oracle/app/oracle/oradata/orcl/control01.ctl
output file name=/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 24-MAR-13

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 03/24/2013 02:30:27
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> recover database;

Starting recover at 24-MAR-13
Starting implicit crosscheck backup at 24-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 24-MAR-13

Starting implicit crosscheck copy at 24-MAR-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 24-MAR-13

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

List of Cataloged Files
=======================
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_372_8nxkowqt_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_8ln2ptb0_.dbf
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_23/o1_mf_ncsn1_LVL1C_FULL_DB_8lmjhknt_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T033253_8lmym81j_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp

using channel ORA_DISK_1
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=810873044 file name=/home/oracle/app/oracle/oradata/orcl/askm/users01.dbf

starting media recovery

archived log for thread 1 with sequence 364 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc
archived log for thread 1 with sequence 365 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc
archived log for thread 1 with sequence 366 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc
archived log for thread 1 with sequence 367 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc
archived log for thread 1 with sequence 368 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc
archived log for thread 1 with sequence 369 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc
archived log for thread 1 with sequence 370 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc
archived log for thread 1 with sequence 371 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc
archived log for thread 1 with sequence 372 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_372_8nxkowqt_.arc
archived log for thread 1 with sequence 373 is already on disk as file /home/oracle/app/oracle/oradata/orcl/redo01.log
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=360
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=361
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=362
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=363
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2013_02_24/o1_mf_annnn_TAG20130224T034327_8lmz7150_.bkp tag=TAG20130224T034327
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_360_8nxky72y_.arc thread=1 sequence=360
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_360_8nxky72y_.arc RECID=22 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_361_8nxky74t_.arc thread=1 sequence=361
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_361_8nxky74t_.arc RECID=19 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_362_8nxky831_.arc thread=1 sequence=362
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_362_8nxky831_.arc RECID=20 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_363_8nxky876_.arc thread=1 sequence=363
channel default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_363_8nxky876_.arc RECID=21 STAMP=810873048
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_364_8ln4t99n_.arc thread=1 sequence=364
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_365_8ln4tbcr_.arc thread=1 sequence=365
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_02_24/o1_mf_1_366_8ln4td5w_.arc thread=1 sequence=366
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_367_8nx72rtt_.arc thread=1 sequence=367
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_23/o1_mf_1_368_8nx83s2t_.arc thread=1 sequence=368
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_369_8nxbcp4n_.arc thread=1 sequence=369
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_370_8nxclvch_.arc thread=1 sequence=370
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc thread=1 sequence=371
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc thread=1 sequence=371
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_371_8nxj70f0_.arc thread=1 sequence=371
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2013_03_24/o1_mf_1_372_8nxkowqt_.arc thread=1 sequence=372
archived log file name=/home/oracle/app/oracle/oradata/orcl/redo01.log thread=1 sequence=373
media recovery complete, elapsed time: 00:00:01
Finished recover at 24-MAR-13

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 03/24/2013 02:31:09
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open resetlog;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "resetlogs, ;"
RMAN-01008: the bad identifier was: resetlog
RMAN-01007: at line 1 column 21 file: standard input

RMAN>

============================================ Break ========================================================

SQL> alter database open resetlogs;

Database altered.

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

NAME USER OPEN_MODE
--------- ------------------------------ --------------------
ORCL SYS READ WRITE

SQL> archive list logs;
SP2-0734: unknown command beginning "archive li..." - rest of line ignored.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL>

============================================== Break ==========================================

RMAN> list incarnation;

List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 18 ORCL 1229390655 PARENT 1 13-AUG-09
1 2 ORCL 1229390655 CURRENT 754488 30-OCT-09

RMAN>

============================================== Break ===========================================


restoring spfile
Refer video
Restoring online redologs
Refer Video
Restoring temporary datafiles
Refer Video
Incomplete Recovery ( time based , Change based and SCN based )
Refer Video
Recovering archived logs
Refer Video

Hope it helps
SRI

Edit Add Modify Delete Oem 12c Agent Registration Password

Written By askMLabs on Saturday, January 19, 2013 | 10:44 AM

Sun Oracle Servers Animated App For Your iPhone

Written By askMLabs on Thursday, January 17, 2013 | 1:02 PM

I have an interesting iPhone app on my phone which shows  animated graphical representation of all the Sun Oracle servers. It reminds me of my old working experience on telephone exchanges installation. Particularly OCB and E10B telephone exchanges racks and their cabling between different racks are similar to the sun oracle server racks. It gives me more interest to go through these server details.

But its a worth looking at this app if you are working on oracle technologies. Neatly animated , compact and small application with good valuable content.

https://itunes.apple.com/us/app/oracle-hardware-virtual-tour/id535920742?mt=8

Thanks

SRI

How To Setup CISCO VPN On iPhone

Written By askMLabs on Thursday, January 3, 2013 | 12:58 PM

Apple announced that it can support cisco SSL VPN on iPhone from iOS 4 onwards.

http://blogs.cisco.com/news/apple_announces_cisco_ssl_vpn_support_on_iphone_os_4/

Now in this article, i am going to guide, the steps involved in configuring CISCO VPN on your iPhone , iPod Touch and in iPad.

Navigate to  "Settings -> General -> VPN" and then tap "ON". It will give you different options to configure VPN. Tap on  "IPSec"

For the configuration of the VPN on iPhone, we need to be ready with the following details. All these details are obtained from the VPN profile provided to us. It is a normal file with ".pcf" extention and you can open it with any notepad.

Description : This is the smal description of the
Server : Host value from .pcf file
Account : username used to connect to VPN
Password : Password provided to you to connect to VPN using above username
Group Name : This is value of "GroupName" in vpn profile. ( .pcf  file )
Secret : This is the most important part of this article. This is the value for "enc_GroupPwd" in encrypted form in "<vpnprofile>.pcf" file. We need to decrypt this value before entering in iPhone. I used the following url to decrypt the password and it worked for me all the time.

http://www.unix-ag.uni-kl.de/~massar/bin/cisco-decode/

You can use any tool that can decrypt this password for you. Just open google and type "ipsec password decrypter" and you will get number of options.

After entering the secret value, save the values. It will then ask you for the password, enter your vpn password.

You should all be fine to use your private network  now.

Thanks
SRI

Blocking And Unblocking OEM Agent in OEM 12c

Written By askMLabs on Monday, December 31, 2012 | 9:02 AM

In this present short demo, i am going to show you how to block and unblock an oem agent manually in oem 12c. There might be various reasons an oem agent may into a blocked state and this demo shows you how to unblock it.

The reasons that the agent may go into blocked state are ..
If there is any network break between oem agent and oms server
If there is any space issue on oms server and oem agent can't upload the metrics data to oms server


This demo does not contain any voice and the navigations are self explanatory. Leave your comments if you have any doubts.





Thanks

SRI

Oracle OpenWorld 2012 Update

Written By askMLabs on Monday, October 1, 2012 | 5:16 PM

Larry Ellison's major  announcements in OracleOpenWorld-2012

  1. IaaS  => Infrastructure as a Service

  2. Private Clouds

  3. Oracle Database 12c

  4. Exadata X3 machine.




Thanks
SRIKRISHNA MURTHY

COPY Schema into Same Database with impdp

Written By askMLabs on Thursday, June 7, 2012 | 4:10 PM

In this article I am going to explain the procedure to copy a schema to a different schema in the same database without exporting the source schema. This procedure works fine if you want to copy the schema to a different database.
  1. Create a directory pointing to any physical directory on the server 
  2. Create a loopback database link. It means, you have to create a database link pointing to the same database.  
NOTE : If your requirement is to copy schema to a different schema, create a database link pointing to target database. 
  1. Use the impdp to copy schema to another schema.
Assume that the database name is DB-A. I am trying to copy a schema SCOTT to a different schema SCOTT_NEW in the same database.

SQL> create a directory TEST_DIR as ‘/xxxx/exp-dir/’;
SQL> create a database link SCOTT_DB_LINK connect to SYSTEM identified by  xxxxxxx using ‘DB-A’;
If you are trying to copy schema to a different database , say DB-B , create database link as follows.
SQL> create a database link SCOTT_DB_LINK connect to system identified by xxxxx using ‘DB-B’;
(NOTE : We should be able to resolve the alias DB-A to database A and DB-B to database B.)

Verify the database link
SQL> select * from dual@SCOTT_DB_LINK;
Use the following syntax to copy schema,
impdp system/xxxxxx schemas=SCOTT directory=TEST_DIR network_link=SCOTT_DB_LINK  remap_schema=SCOTT:SCOTT_NEW logfile=TEST_DIR:SCOTT_NEW.log
Verify the new schema with the source schema with following commands.
SQL> select object_type,count(1) from dba_objects where owner='SCOTT' and status='INVALID' group by object_type;
SQL> select object_type,count(1) from dba_objects where owner='SCOTT_NEW' and status='INVALID' group by object_type;
SQL> select object_name,object_type from dba_objects where owner='SCOTT' and status='INVALID';
SQL> select object_name,object_type from dba_objects where owner='SCOTT_NEW' and status='INVALID';
Observations:
We are eliminating the creation of dump file, by using database link with the parameter network_link

Hope it helps
SRI 

12c oem template export and import using emcli

Written By askMLabs on Tuesday, May 15, 2012 | 2:28 PM

This demo explains the steps to export and import a template in oem 12c using emcli command line tool.





Thanks
SRI

Oracle VM templates for Cloud Control

Written By askMLabs on Wednesday, May 2, 2012 | 12:22 PM

CLOUD CONTROL INTEGRATION WITH OVM

Written By askMLabs on Tuesday, May 1, 2012 | 8:47 AM

OEM 12C CLOUD CONTROL INTEGRATION WITH OVM
  1. Configure Oracle Software Library    
  2. Setting up the infrastructure for Online mode   
  3. Setup MOS(My Oracle Support) Credentials    
  4. Deploying the Cloud Plug-ins    
  5. Deploying the Cloud Plug-ins to the Management Server    
  6. Deploying the Oracle Virtualization Plug-in to the Management Agent 
  7. Oracle VM Manager 3.0 Registration Prerequisites    
  8. Registering the Oracle VM Manager in oem 12c    
  9. Synchronizing the OVM Manager Targets    
Configure Oracle Software Library
  1. Oracle Software Library (Software Library) is a repository that stores software patches, virtual appliance images, reference gold images, application software and their associated directive scripts.
    Verify whether you already have the Software Library configured. If not follow the below steps to configure:
    From the Enterprise menu, select Provisioning and Patching, then click Software Library.
    From there choose actions > administration.
    If there is nothing configured yet, click Add then choose OMS Shared Filesystem location.






Upon addition of the location, a job executes to configure the Software Library. Under this location, all required entities for EMs features like Provisioning, Patching, and Cloud Management are populated.
Once the job is successful, you will see the components configured in the Software Library.
To view the Software Library, navigate to: Enterprise Manager > Patching and Provisioning > Software Library






  1. Setting up the infrastructure for Online mode

    If the enterprise manager is configured to connect to MOS , plugins or patches can be automatically downloaded. Follow the following sequence of steps ..
    1. Set up connection to MOS (Online Mode)
      Check to see if the connection to My Oracle Support is set to "Online". Navigate to
      Setup > Provisioning and Patching > Offline Patching.



       
    2. The connection setting has to be "Online". If not set, set it to Online and click Apply.



       
    3. Select the adjacent tab My Oracle Support and Proxy Connection



       
    4. Configure your Proxy Connection to connect to My Oracle Support. Provide the required Proxy Server, Port and Realm details, then click Apply.

       
    5. Once the configuration is done, click Test to check if the connectivity works correctly.

  2. Setup MOS(My Oracle Support) Credentials




  3. Deploying the Cloud Plug-ins

    Plug-ins must first be downloaded to the OMS using Self Update before they can be deployed. To enable monitoring of virtualization targets, you must download the plug-ins and deploy them. The following plug-ins must be deployed on the Management Server:
  • Oracle Virtualization
  • Oracle Cloud Application
  • Oracle Chargeback and Capacity Planning
  • Oracle Exalogic


Select one of the above plugins (list specified above) , then click Download. The Schedule Download dialog appears. In this example, "Oracle Virtualization" plug-in is selected.


Then it changes the status from "Available" to "Downloaded"
Repeat the same step to all the other plugins (Oracle Cloud Application, Oracle Chargeback and Capacity Planning, Oracle Exalogic)
Once an entity has been downloaded to the Software Library, it is ready to be applied to your installation. Select an update from the list whose status is Downloaded, then click Apply.




You will be redirected to the plug-in deployment page.


  1. Deploying the Cloud Plug-ins to the Management Server

    Complete the below steps to all the plugins mentioned in step 4.
    Select the plugin and deploy it on OMS. Right click the plugin ->Deploy on->Management server




    Plugin pre-requisites will be executed. After successful pre-requisite checks, click on deploy.
    NOTE : OMS will be bounced now.
    Once the OMS is up, navigate to Setup->Extensibility->Plug-in . The Plugin version on OMS is now 12.1.0.2.


  1. Deploying the Oracle Virtualization Plug-in to the Management Agent



Click on Add to add the management agent where plugin will be deployed


Once you have selected the agents, click continue
It runs the plugin pre-requisites and click next
Click Deploy, to deploy the plug-in on the agents
  1. Oracle VM Manager 3.0 Registration Prerequisites

    The following prerequisites must be meet before Oracle VM Manager can be registered in Oracle Enterprise Manager 12c Cloud Control.
    1. The Oracle Virtualization plug-in must be install and enabled on the Oracle Management Service.
    2. The Oracle VM Manager host must have the Oracle Management Agent (OMA) and be a monitored target in Oracle Enterprise Manager 12c Cloud Control.
    3. The Oracle VM Manager host must have the Oracle Virtualization plug-in.
    4. The preferred credentials for the Oracle VM Manager host must be configured in Oracle Enterprise Manager 12c Cloud Control.
    5. The Oracle Management Service and the Oracle VM Manager host must have consistent name resolution using DNS with both forward and reverse lookups.
  2. Registering the Oracle VM Manager in oem 12c










Table 1
Oracle VM Manager Registration Page TitleEntry Selections and Entry Syntax
  1. Name
The name entered in the "Name" text box is displayed on the Infrastructure Cloud page.
  1. EM Agent URL
The EM Agent URL is selected by clicking the magnifying glass icon. A pop-up window will appear, select the Oracle VM Manager agent from the list. The EM Agent URL syntax is: "https://<AGENT-FQDN>:3872/emd/main/"
Note: The Oracle VM Manager host can be selected as long as the host is managed target by OEM with the Oracle Virtualization plug-in.
  1. Oracle VM Manager Core
Enter "http://<ORACLE VM MANAGER HOST FQDN>:7001" in the
Oracle VM Manager Core URL text box.
  1. Automatic Synchronization
Select the Automatic Synchronization check box to enable automated synchronization between OEM and the Oracle VM API Core.
  1. Monitoring Credentials for Oracle VM Manager
Enter the Oracle VM Manager admin user name and the admin
password in the Monitoring Credentials for Oracle VM Manager text fields.
  1. Administration Credentials for Oracle VM Manager / Use Administration Credentials
Enter the Oracle VM Manager admin user name and the admin password in the Administration Credentials for Oracle VM Manager text fields.


Select the Use Administration Credentials check box.
  1. Oracle VM Manager Console URL
Enter the non-SSL Oracle VM Manager URL, i.e.http://<ORACLE VM MANAGER HOST FQDN>:7001/ovm/console/faces/login.jspx in the Oracle VM Manager Console URL text box.
  1. Submit
Once all of the information has been entered, click the Submit button to start the registration job.
  1. Synchronizing the OVM Manager Targets



Cloud Control OEM 12c Installation

Written By askMLabs on Saturday, April 28, 2012 | 6:30 PM

OEM 12C CLOUD CONTROL INSTALLATION
  1. Software
  2. OS installation
  3. Database Installation
  4. Oem 12c Prerequisites
    1. Hardware Requirements
    2. Operating System Requirements
    3. Package Requirements
    4. Kernel Parameter Requirements
    5. Library Requirements
    6. Operating System Groups and Users Requirements
    7. Unique Host Name and Static IP Address Requirements
    8. Temporary Directory Space Requirements
    9. Central Inventory Requirements
    10. UMASK Value Requirements
    11. File Descriptor Requirements
    12. Existing Database Version Requirements
    13. Host File Requirements
    14. Port Requirements
    15. Internet Connection Requirements
  5. 5.Oem 12c Installation Procedure
  6. 6.Verification Checks
  7. 7.Starting and Stopping oem 12c Services


 1. Software
The required software for the oem 12c cloud control are :
  • Oracle Linux 6.1 (x86_64)  Download
  • Oracle Database 11gR2 (x86_64)  Download
  • Enterprise Manager Cloud Control 12c (12.1.0.1) (x86_64) with BP1 patch Download
2. OS installation :
Oracle Linux 6.1 (x86_64) installation :

3. Database Installation :
Oracle Database 11gR2 installation :
Below links help to install database
4. Oem 12c Prerequisites :
4.1. Hardware Requirements :
CPU, RAM, Heap Size, and Hard Disk Space requirements vary depending on the type of installation we are choosing. Please review the here to know the exact hardware requirements.

4.2. Operating System Requirements :
Ensure that you install Enterprise Manger Cloud Control only on certified operating system as mentioned in the Enterprise Manager Certification Matrix.

4.3. Package Requirements :
make-3.81binutils-2.17.50.0.6gcc -4.1.1libaio-0.3.106glibc-common-2.3.4libstdc++ -4.1.1setarch-1.6sysstat-5.0.5rng-utils-2.0libXtst-1.0.1-3.1(x86_64)xorg-x11-utils (This package is required only for GUI-based interactive installation, and not for silent installation)

In addition, install the 32-bit version as well as the 64-bit version of glibc-devel-2.5-49 to avoid any linking errors while installing the OMS. The installer checks for this package, so if this package is not installed, the installer displays an error.

4.4 Kernel Parameter Requirements:
For installing an OMS or a Management Agent on Unix operating systems (32-bit or 64-bit), set the kernel.shmmax parameter to a value 1 byte less than 4 GB or 4294967295.

To verify the value assigned to kernel.shmmax parameter, run the following command:
cat /proc/sys/kernel/shmmax
 To set the value for kernel.shmmax parameter, run the following command:
sysctl -w kernel.shmmax=<new value>

4.5.       Library Requirements :
Install glibc-2.5.12 package

4.6 Operating System Groups and Users Requirements:
# /usr/sbin/groupadd oinstall# /usr/sbin/useradd -g oinstall oracle# passwd oracle
4.7. Unique Host Name and Static IP Address Requirements :
Ensure that you check the network configuration to verify that the host on which you are installing resolves to a unique host name and a static IP address that is visible to other hosts in the network.
You must use a static IP address. If you use a dynamic IP address, the installation might fail.
Ensure that the host name specified in /etc/hosts file is unique, and that it maps to the correct IP address. Following is the recommended format of the /etc/hosts file:
<ip address> <fully_qualified_host_name> <short_host_name>

If the DNS server is configured, then it should resolve the host name for the OMS machine correctly. For example, all these command must return the same output:
nslookup host1nslookup host1.foo.comnslookup 141.81.5.71
4.8. Temporary Directory Space Requirements :
Ensure that you allocate 400 MB of space for a temporary directory where the executables can be copied.

4.9. Central Inventory Requirements :
Ensure that you allocate 100 MB of space for the central inventory directory.
 Also ensure that the central inventory directory is not on a shared file system. If it is already on a shared file system, then switch over to a non-shared file system by following the instructions outlined in My Oracle Support note 1092645.1.
To determine whether the Oracle Inventory group exists, enter the following command:
     $ more /etc/oraInst.loc     If the oraInst.loc file exists, then the output from this command looks like:     inventory_loc=/u01/app/oracle/oraInventory     inst_group=oinstall
4.10.UMASK Value Requirements:
Ensure that you set the default file mode creation mask (umask) to 022 in the shell startup file.

4.11.File Descriptor Requirements :
If the current value is less than 4096, then as root user, update the /etc/security/limits.conf file as shown below:
         <UID> soft nofile 4096         <UID> hard nofile 4096
4.12. Existing Database Version Requirements :
Ensure that the database is patched with all the Patch Set Updates (PSU) or Critical Patch Updates (CPU) released for that release. Also ensure that you apply the patches.
If you use Oracle Database 11g Release 2 (11.2.0.1), then ensure that you apply the patches for bugs 10014178 and 8799099.
If you use Oracle Database 11g Release 1 (11.1.0.7), then ensure that you apply Patch Set Update 2 and the patches for bugs 8644757 and 7525072.
The database can also have the Automatic Memory Management (AMM) feature enabled.

4.13. Host File Requirements :
Ensure that the host name specified in the /etc/hosts file is unique, and ensure that it maps to the correct IP address of that host. Otherwise, the installation can fail on the product-specific prerequisite check page.
The following is the recommended format of the /etc/hosts file:
<ip> <fully_qualified_host_name> <short_host_name>

4.14. Port Requirements :
Ensure that the ports you assign (within the given range) to the following components are free and available:

Admin Server HTTP SSL Port = 7101 - 7200
Enterprise Manager Upload HTTP Port = 4889 - 4898
Enterprise Manager Upload HTTP SSL Port = 1159, 4899 - 4908
Enterprise Manager Central Console HTTP Port = 7788 - 7798
Enterprise Manager Central Console HTTP SSL Port = 7799 - 7809

Oracle Management Agent Port = 3872, 1830 - 1849

To verify if a port is free, run the following command:
      On Unix:
      netstat -anp | grep <port no>

4.15. Internet Connection Requirements :
Oracle recommends that the host from where you are running the installer have a connection to the Internet so that the configuration information can be automatically collected and uploaded to My Oracle Support.

5. Oem 12c Installation Procedure :




6.Verification Checks : 
Access the following URL with sysman user and navigate to different pages to verify everything looks good.
https://<hostname with FQDN>:7803/em

7. Starting and Stopping oem 12c services : 
Use the following commands to start all components :
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
$ export OMS_HOME=/u01/app/oracle/Middleware/oms
$ export AGENT_HOME=/u01/app/oracle/Middleware/agent/core/12.1.0.1.0
# Start everything
$ $ORACLE_HOME/bin/sqlplus '/as sysdba'
SQL> startup
$lsnrctl start listener
$ $OMS_HOME/bin/emctl start oms
$ $AGENT_HOME/bin/emctl start agent
Use the following commands to stop all components :
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
$ export OMS_HOME=/u01/app/oracle/Middleware/oms
$ export AGENT_HOME=/u01/app/oracle/Middleware/agent/core/12.1.0.1.0
# Stop everything
$  $OMS_HOME/bin/emctl stop oms -all
$  $AGENT_HOME/bin/emctl stop agent
$ $ORACLE_HOME/bin/sqlplus '/as sysdba'
SQL> shut immediate
$ $lsnrctl stop listener

 Hope it helps
SRI

Renaming A Datafile In A Physical Standby Environment

Written By askMLabs on Monday, February 20, 2012 | 2:45 PM

In this article we will see how to rename a datafile in a physical standby setup. Most structural changes made to a primary database are automatically propagated through redo data to a physical standby database. Some structural and configuration changes at primary database requires manual intervention at a physical standby database.

When you rename one or more datafiles in the primary database, the change is not propagated to the standby database. Therefore, if you want to rename the same datafiles on the standby database, you must manually make the equivalent modifications on the standby database because the modifications are not performed automatically, even if the STANDBY_FILE_MANAGEMENT initialization parameter is set to AUTO.



1. Verify primary and standby databases and also change the initialization parameter STANDBY_FILE_MANAGEMENT from AUTO to MANUAL.

On Primary :


SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
--------- ------------------------------ ---------------- --------------------
ORCL      orcl                           PRIMARY          TO STANDBY

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence     524
Next log sequence to archive   526
Current log sequence           526
SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PRIMARY          TO STANDBY

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_file_management              string      AUTO
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;

System altered.

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_file_management              string      MANUAL


On Standby :


SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
--------- ------------------------------ ---------------- --------------------
ORCL      sbyorcl                        PHYSICAL STANDBY NOT ALLOWED

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
Oldest online log sequence     524
Next log sequence to archive   0
Current log sequence           526
SQL> select database_role,switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY NOT ALLOWED

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

SEQUENCE# APPLIED
---------- ---------
517 YES
518 YES
519 YES
520 YES
521 YES
522 YES
523 YES
524 YES
525 IN-MEMORY

9 rows selected.

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_file_management              string      AUTO
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;

System altered.

SQL> sho parameter STANDBY_FILE_MANAGEMENT

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_file_management              string      MANUAL
SQL>


2. Verify the tablespace to which the datafile belongs and make it offline. This step is performed on primary database.


SQL> select file_name from dba_data_files where tablespace_name='EXAMPLE';

FILE_NAME
--------------------------------------------------------------------------------
/home/oracle/app/oracle/oradata/orcl/example01.dbf

SQL> alter tablespace example offline;

Tablespace altered.


3. Rename the datafile to new location and bring tablespace back online. This step is performed on primary database.


[oracle@dgaskmpri01 OPatch]$ mv /home/oracle/app/oracle/oradata/orcl/example01.dbf  /tmp/askm/example01_temp.dbf
[oracle@dgaskmpri01 OPatch]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 22 05:47:17 2011

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter tablespace example rename datafile '/home/oracle/app/oracle/oradata/orcl/example01.dbf' to '/tmp/askm/example01_temp.dbf';

Tablespace altered.

SQL> alter tablespace example online;

Tablespace altered.

SQL> select file_name from dba_data_files where tablespace_name='EXAMPLE';

FILE_NAME
--------------------------------------------------------------------------------
/tmp/askm/example01_temp.dbf

SQL>


4. Verify the same  tablespace on standby database.


SQL> select ts#,name from v$tablespace where name='EXAMPLE';

TS# NAME
---------- ------------------------------
6 EXAMPLE

SQL> select name from v$datafile where ts#=6;

NAME
--------------------------------------------------------------------------------
/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf

SQL>


5. Stop recovery on standby database and shut it down.


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Database altered.

SQL> shut immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL>


6. Rename the datafile on standby database.


[oracle@dgaskmsby01 askm]$ mv /home/oracle/app/oracle/oradata/sbyorcl/example01.dbf /tmp/askm/example01_temp.dbf
[oracle@dgaskmsby01 askm]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 22 05:53:49 2011

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

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             343935672 bytes
Database Buffers          104857600 bytes
Redo Buffers                6008832 bytes
Database mounted.
SQL> alter database rename file '/home/oracle/app/oracle/oradata/sbyorcl/example01.dbf' to '/tmp/askm/example01_temp.dbf';

Database altered.

SQL> select name from v$datafile where ts#=6;

NAME
--------------------------------------------------------------------------------
/tmp/askm/example01_temp.dbf


7. Keep standby database in recovery mode.


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Database altered.


8. Set initialization parameter STANDBY_FILE_MANAGEMENT value back to AUTO.

On Primary :


SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

System altered.


On Standby :


SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

System altered.


Reference :

Renaming a Datafile in the Primary Database

MOS ID : 733796.1

Hope It Helps

SRI

Using expdp To Export From Physical Standby Database

Written By askMLabs on Thursday, February 16, 2012 | 2:08 PM

In this article, we will discuss the steps to use expdp on physical standby database. There may be some situations where you don’t want your production database loaded with the expdp operation. The other option you have in a standby setup is that you can use your standby database for export operations. But in a physical standby database, the database is in recovery mode and if we want to open the database for expdp operation, we can open the physical standby database in read only mode. Expdp operation needs to create and maintain a master table which needs requires the physical standby database opened in read write mode.

So we have an option in expdp to export standby database. We can use expdp parameter NETWORK_LINK from any non standby database to export database.

  1. Verify primary and Standby Databases

  2. Cancel recovery and Open standby database in Read only Mode

  3. Create a physical directory on primary server to keep export dump files

  4. Create DB Link, Oracle Directory and test it.

  5. Execute expdp on primary server.




1. Verify primary and Standby Databases :

On Primary :


SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
--------- ------------------------------ ---------------- --------------------
ORCL      orcl                           PRIMARY          TO STANDBY


SQL> arcvhive log list
SP2-0734: unknown command beginning "arcvhive l..." - rest of line ignored.
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/orcl/
Oldest online log sequence     522
Next log sequence to archive   524
Current log sequence           524
SQL>



On Standby :


SQL> select name,user,database_role,switchover_status from v$database;

NAME      USER                           DATABASE_ROLE    SWITCHOVER_STATUS
--------- ------------------------------ ---------------- --------------------
ORCL      SYS                            PHYSICAL STANDBY NOT ALLOWED


SQL> select name,db_unique_name,database_role,switchover_status from v$database;

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    SWITCHOVER_STATUS
--------- ------------------------------ ---------------- --------------------
ORCL      sbyorcl                        PHYSICAL STANDBY NOT ALLOWED


SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/app/oracle/flash_recovery_area/sbyorcl/
Oldest online log sequence     522
Next log sequence to archive   0
Current log sequence           524
SQL>



2. Cancel recovery and Open standby database in Read only Mode :


SQL> select instance_name, status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
sbyorcl          MOUNTED


SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open read only;

Database altered.

SQL> select instance_name, status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
sbyorcl          OPEN


SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY


SQL>


3. Create a physical directory on primary server to keep export dump files :


[oracle@dgaskmpri01 ~]$ mkdir /tmp/askm
[oracle@dgaskmpri01 ~]$ chmod 777 /tmp/askm
[oracle@dgaskmpri01 ~]$



4. Create DB Link, Oracle Directory and test it :


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

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 22 04:25:18 2011

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> conn system/xxxxx
Connected.
SQL> create database link db_sbyorcl connect to system identified by oracle using 'sbyorcl';


Database link created.

SQL> select db_unique_name from v$database;

DB_UNIQUE_NAME
------------------------------
orcl


SQL> select db_unique_name from v$database@db_sbyorcl;

DB_UNIQUE_NAME
------------------------------
sbyorcl


SQL> create directory sby_dump_dir as '/tmp/askm';

Directory created.

SQL>


5. Execute expdp on primary server :


[oracle@dgaskmpri01 askm]$ expdp system/oracle full=y directory=sby_dump_dir network_link=db_sbyorcl dumpfile=sby_db.dmp logfile=sby_db.log

Export: Release 11.2.0.2.0 - Production on Tue Nov 22 04:50:05 2011

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_FULL_01":  system/******** full=y directory=sby_dump_dir network_link=db_sbyorcl dumpfile=sby_db.dmp logfile=sby_db.log
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 183.1 MB
Processing object type DATABASE_EXPORT/TABLESPACE


.....
.....
....


ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_METADATA", line 7564
ORA-39127: unexpected error from call to export_string :=SYS.DBMS_CUBE_EXP.SCHEMA_INFO_EXP('OE',0,1,'11.02.00.00.00',newblock)
ORA-04045: errors during recompilation/revalidation of SYS.DBMS_CUBE_EXP
ORA-16000: database open for read-only access
ORA-06508: PL/SQL: could not find program unit being called: "SYS.DBMS_CUBE_EXP"
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_METADATA", line 7564
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
ORA-39126: Worker unexpected fatal error in KUPW$WORKER.UNLOAD_METADATA [PROCACT_SCHEMA:"OE"]
ORA-08181: specified number is not a valid system change number
ORA-06512: at "SYS.DBMS_METADATA", line 5466


ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPW$WORKER", line 8358


----- PL/SQL Call Stack -----
object      line  object
handle    number  name
0x34f7b2c0     19208  package body SYS.KUPW$WORKER
0x34f7b2c0      8385  package body SYS.KUPW$WORKER
0x34f7b2c0      2935  package body SYS.KUPW$WORKER
0x34f7b2c0      9054  package body SYS.KUPW$WORKER
0x34f7b2c0      1688  package body SYS.KUPW$WORKER
0x34d28650         2  anonymous block


Job "SYSTEM"."SYS_EXPORT_FULL_01" stopped due to fatal error at 04:55:56

[oracle@dgaskmpri01 askm]$ expdp system/oracle attach=SYS_EXPORT_FULL_01

Export: Release 11.2.0.2.0 - Production on Tue Nov 22 05:03:32 2011

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


Job: SYS_EXPORT_FULL_01
Owner: SYSTEM
Operation: EXPORT
Creator Privs: TRUE
GUID: B2533E2386512016E040A8C022010D27
Start Time: Tuesday, 22 November, 2011 5:03:43
Mode: FULL
Instance: orcl
Max Parallelism: 1
EXPORT Job Parameters:
Parameter Name      Parameter Value:
CLIENT_COMMAND        system/******** full=y directory=sby_dump_dir network_link=db_sbyorcl dumpfile=sby_db.dmp logfile=sby_db.log
State: IDLING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /tmp/askm/sby_db.dmp
bytes written: 950,272


Worker 1 Status:
Process Name: DW00
State: UNDEFINED
Object Schema: OE
Object Type: DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Completed Objects: 36
Worker Parallelism: 1


Export> kill_job
Are you sure you wish to stop this job ([yes]/no): yes


[oracle@dgaskmpri01 askm]$ clear
[oracle@dgaskmpri01 askm]$



I got error while exporting the database. This is identified as bug in 10g and 11gR1. As per the oracle documentation, it is rectified in 11gR2, but I am still getting this issue on 11gR2. I need to further investigate it. Comments and Feedbacks are accepted pls Smile

Reference:

How to use Data Pump Export (expdp) to export from Physical Standby Database [ID 1356592.1]

Thanks

SRI
 
Support :
Copyright © 2013. askMLabs - All Rights Reserved
Proudly powered by Blogger