Saturday, November 30, 2013

SHUTDOWN AND STARTUP OF ORACLE DATABASE WITH SHELL SCRIPTING


Shutdown Script.

Steps:-
1) --> vi shut.sh
2) --> copy below text in that file.
3) -->save and quit.
4) --> chmod 777 shut.sh

test now

sh shut.sh

#!/bin/bash

export ORACLE_SID=orcl
sqlplus "/as sysdba" << EOF
shutdown immediate;
exit;
EOF

export ORACLE_SID=+ASM
sqlplus "/as sysdba" << EOF
shutdown immediate;
exit;
EOF


Startup Script
Steps:-
1) vi start.sh
2) copy the following Text in the file
3) chmod 777 start.sh
4) save and quit

Test script now.

export ORACLE_SID=+ASM
sqlplus "/as sysdba" << EOF
startup;
exit;
EOF


export ORACLE_SID=orcl
sqlplus "/as sysdba" << EOF
startup;
exit;
EOF

Enjoy.


Tuesday, September 24, 2013

FAILOVER TNS ENTRY IN RAC ENVIRONMENT

orcl =
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = orcl1-vip)(PORT = 1521))
 (ADDRESS = (PROTOCOL = TCP)(HOST = orcl2-vip)(PORT = 1521))
 (LOAD_BALANCE = yes)
 (CONNECT_DATA =
 (SERVER = DEDICATED)
 (SERVICE_NAME = orcl)
 (FAILOVER = ON)(FAILOVER_MODE = (TYPE = SELECT)
 (METHOD = BASIC)(RETRIES = 120)(DELAY = 3)
   )
   )
  )

Sunday, August 25, 2013

CHECK THE DEGREE OF PARALLEL INDEXES

FOLLOWING SCRIPT WILL SHOW YOU THE MISMATCH DEGREE OF PARALLELISM


REPORT MISMATCH INDEXES.
==========================

SET PAGESIZE 1000
col table_name format a35
col index_name format a35
Rem Tables that have Indexes with not the same DOP
Rem !!!!! This command can take some time to execute !!!
Rem ---------------------------------------------------;
set lines 150
select substr(t.owner,1,15) Owner ,
t.table_name ,
substr(trim(t.degree),1,7) Degree ,
substr(trim(t.instances),1,9) Instances,
i.index_name ,
substr(trim(i.degree),1,7) Degree ,
substr(trim(i.instances),1,9) Instances
from all_indexes i,
all_tables t
where ( trim(i.degree) != trim(t.degree) or
trim(i.instances) != trim(t.instances) ) and
i.owner = t.owner and
i.table_name = t.table_name
and i.owner<>'SYS';



FOLLOWING SCRIPT WILL GENERATE THE SCRIPT TO RUN THE SCRIPT OF MIS-PARALLEL SCRIPT.  
AFTER RUN THE SCRIPT IT WILL SHOW YOU SOME COMMANDS AND RUN IT MANUALLY.

GENERATE ALTER STATMENTS
===========================

SET SERVEROUT ON
SET PAGESIZE 1000
SET LONG 10000

BEGIN
FOR I_CURS IN (
select substr(t.owner,1,15) Owner ,
t.table_name table_name,
substr(trim(t.degree),1,7) T_Degree ,
substr(trim(t.instances),1,9) T_Instances,
i.index_name INDEX_NAME,
substr(trim(i.degree),1,7) I_Degree ,
substr(trim(i.instances),1,9) I_Instances
from all_indexes i,
all_tables t
where ( trim(i.degree) != trim(t.degree) or
trim(i.instances) != trim(t.instances) ) and
i.owner = t.owner and
i.table_name = t.table_name
and i.owner<>'SYS')
LOOP
IF
I_CURS.T_DEGREE<>I_CURS.I_DEGREE
AND I_CURS.T_DEGREE<>'DEFAULT'
then
DBMS_OUTPUT.put_line ( 'alter INDEX '||I_CURS.OWNER||'.'||I_CURS.INDEX_name||' PARALLEL '||I_CURS.T_DEGREE||';' );
ELSE IF
I_CURS.T_DEGREE<>I_CURS.I_DEGREE
AND I_CURS.T_DEGREE='DEFAULT'
then
DBMS_OUTPUT.put_line ( 'alter INDEX '||I_CURS.OWNER||'.'||I_CURS.INDEX_name||' PARALLEL ;' );
Else
NULL;
END IF;
END IF;
END LOOP;
END;
/


MOVE LESS THAN 5 GB TABLES AND INDEXES INTO OTHER TABLESPACE AND REBUILD INDEXES

·      Note:- DO NOT RUN ON PRODUCTION WITHOUT TEST THIS ON TEST ENVIRONMENT.


           --> Accept source tablespace name parameter
·        --> Loop on all tables less than 5GB  inside the tablespace.
·        --> Move Each table to target tablespace and rebuild its indexes
·        --> Indexes reside on same source tablespace will be moved to target tablespace.

·        -->  Reset of indexes reside in different tablespaces will be rebuild their in place.


CREATE OR REPLACE PROCEDURE move_smaller_than_5g (v_source_ts in varchar,v_target_ts in varchar)
AS
BEGIN
FOR i
IN (SELECT OWNER ,SEGMENT_NAME
FROM dba_segments
where TABLESPACE_NAME = v_source_ts
and SEGMENT_TYPE='TABLE'
AND BYTES<5368709120
GROUP BY OWNER,SEGMENT_NAME,SEGMENT_TYPE)
LOOP
EXECUTE IMMEDIATE 'ALTER TABLE '|| i.owner|| '.'|| i.SEGMENT_NAME|| '  MOVE TABLESPACE '|| v_target_ts;
--DBMS_OUTPUT.put_line ('ALTER TABLE '|| i.owner|| '.'|| i.SEGMENT_NAME|| '  MOVE TABLESPACE '|| v_target_ts);
for ii in(
select A.owner,A.index_name,A.index_type,A.PARTITIONED,A.status,B.CREATED,A.LAST_ANALYZED,A.TABLESPACE_NAME from dba_indexes A ,DBA_OBJECTS B, dba_part_indexes C where A.table_name = i.SEGMENT_NAME
AND A.OWNER=B.OWNER
AND A.INDEX_NAME=B.OBJECT_NAME
Group by a.owner,a.index_name,A.index_type,A.PARTITIONED,A.status,B.CREATED,A.LAST_ANALYZED,A.TABLESPACE_NAME
order by 1,2)
loop
IF II.TABLESPACE_NAME =v_source_ts
THEN
EXECUTE IMMEDIATE 'ALTER INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  rebuild NOLOGGING PARALLEL 12 TABLESPACE '|| v_target_ts;
EXECUTE IMMEDIATE 'ALTER  INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  LOGGING NOPARALLEL ';
--DBMS_OUTPUT.put_line ('ALTER INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  rebuild NOLOGGING PARALLEL 12 TABLESPACE '|| v_target_ts);
--DBMS_OUTPUT.put_line ('ALTER  INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  LOGGING NOPARALLEL ');
ELSE
EXECUTE IMMEDIATE 'ALTER  INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  rebuild NOLOGGING PARALLEL 12';
EXECUTE IMMEDIATE 'ALTER  INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  LOGGING NOPARALLEL ';
--DBMS_OUTPUT.put_line ('ALTER  INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  rebuild NOLOGGING PARALLEL 12');
--DBMS_OUTPUT.put_line ('ALTER  INDEX '|| ii.owner|| '.'|| ii.index_NAME|| '  LOGGING NOPARALLEL ');
END IF;
END LOOP;
END LOOP;
END;
/

PERFORMANCE IMPROVEMENT with STALE PARTITIONS

First check the list of Stale Partitions and Tables in your Database.

SQL> select TABLE_NAME,PARTITION_NAME,STALE_STATS from dba_tab_statistics where owner=upper('&OWNER') and STALE_STATS='YES';
Enter value for owner:

Enter Your Schema Name.

It will provide you the list of tables and partitions (optional if you have partitions)

after that

create file in /home/oracle/stats_gather.sh

then
#####################Copy the following in your stats_gather.sh file ###################
#!/bin/ksh
set -x

gather_stats()
{
sqlplus -s /nolog > /home/oracle/stat_gather.log <<sqlconn

connect / as sysdba

set timing on

select to_char(sysdate,'DD-MON-YYYY HH:MI:SS') from dual;

THIS IS FOR TABLES

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME ',TABNAME=>'TABLE NAME ',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME ',TABNAME=>'TABLE NAME ',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME ',TABNAME=>'TABLE NAME ',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME ',TABNAME=>'TABLE NAME ',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME ',TABNAME=>'TABLE NAME ',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');


THIS IS FOR PARTITIONS

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME',TABNAME=>'TABLE NAME ',PARTNAME=>'PARTITION NAME',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME',TABNAME=>'TABLE NAME ',PARTNAME=>'PARTITION NAME',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME',TABNAME=>'TABLE NAME ',PARTNAME=>'PARTITION NAME',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME',TABNAME=>'TABLE NAME ',PARTNAME=>'PARTITION NAME',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');

exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'SCHEMA NAME',TABNAME=>'TABLE NAME ',PARTNAME=>'PARTITION NAME',ESTIMATE_PERCENT=>10,DEGREE=>8,CASCADE=>true,granularity=>'PARTITION');



select to_char(sysdate,'DD-MON-YYYY HH:MI:SS') from dual;


exit
sqlconn
}

ORACLE_HOME=YOUR ORACLE HOME
PATH=$PATH:YOUR ORACLE PATH
ORACLE_SID=YOUR ORACLE SID
export ORACLE_HOME PATH ORACLE_SID
gather_stats

uuencode /home/oracle/stat_gather.log | mailx -m -s "stats gather " youremail@yourdomain.com


NOW SAVE AND EXIT THE FILE

Note how to run this

nohup sh stats_gather.sh &

press enter

press enter

press enter  press enter 3 to 4 times

now verify that its running

tail -f nohup.out

the output should be like following:-

+ ORACLE_HOME=YOUR ORACLE HOME
+ PATH=YOUR ORACLE PATH:/usr/local/bin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/usr/contrib/Q4/bin:/opt/perl/bin:/opt/ipf/bin:/opt/gvsd/bin:/opt/nettladm/bin:/opt/fcms/bin:/
opt/wbem/bin:/opt/wbem/sbin:/opt/sas/bin:/opt/graphics/common/bin:/opt/atok/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/sec_mgmt/bastille/bin:/opt/caliper/bin:/opt/drd/bin:/opt/dsau/bin:/opt/d
sau/sbin:/opt/resmon/bin:/opt/firefox:/opt/gnome/bin:/opt/ignite/bin:/opt/propplus/bin:/usr/contrib/kwdb/bin:/opt/mozilla:/opt/perl_32/bin:/opt/perl_64/bin:/opt/prm/bin:/opt/sfm/bin:/opt/swm/
bin:/opt/sec_mgmt/spc/bin:/opt/ssh/bin:/opt/sentinel/bin:/opt/swa/bin:/opt/hpsmh/bin:/opt/thunderbird:/opt/langtools/bin:/opt/gwlm/bin:/opt/cfg2html:.:YOUR ORACLE HOME
+ ORACLE_SID=YOUR ORACLE SID




Thursday, February 28, 2013

RAC on ASM 11g Rman Backup restore to Non Rac Single Instance Machine with SET NEWNAME



Note:- STEP 01 and 02 are mainly required when you configure Grid Infrastructure.



STEP 01
userdel -r oracle
userdel -r grid
groupdeloinstall
groupdeldba
groupdeloper
groupdelasmadmin
groupdelasmdba
groupdelasmoper

OUT PUT
[root@clone ~]# userdel -r oracle
[root@clone ~]# userdel -r grid
userdel: user grid does not exist
[root@clone ~]# groupdeloinstall
[root@clone ~]# groupdeldba
[root@clone ~]# groupdeloper
groupdel: group oper does not exist
[root@clone ~]# groupdelasmadmin
groupdel: group asmadmin does not exist
[root@clone ~]# groupdelasmdba
groupdel: group asmdba does not exist
[root@clone ~]# groupdelasmoper
groupdel: group asmoper does not exist
[root@clone ~]#
STEP 02
/usr/sbin/groupadd -g 510 oinstall
/usr/sbin/groupadd -g 511 asmadmin
/usr/sbin/groupadd -g 512 asmdba
/usr/sbin/groupadd -g 513 asmoper
/usr/sbin/groupadd -g 514 dba
/usr/sbin/groupadd -g 515 oper
OUTPUT
[root@clone ~]# /usr/sbin/groupadd -g 510 oinstall
[root@clone ~]# /usr/sbin/groupadd -g 511 asmadmin
[root@clone ~]# /usr/sbin/groupadd -g 512 asmdba
[root@clone ~]# /usr/sbin/groupadd -g 513 asmoper
[root@clone ~]# /usr/sbin/groupadd -g 514 dba
[root@clone ~]# /usr/sbin/groupadd -g 515 oper

STEP 03
useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper grid
useradd -u 502 -g oinstall -G dba,asmdba,oper oracle

OUTPUT

[root@clone ~]# useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper grid
[root@clone ~]# useradd -u 502 -g oinstall -G dba,asmdba,oper oracle

STEP 04
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle

OUTPUT
[oracle@clone app]$ mkdir -p /u01/app/11.2.0/grid
[oracle@clone app]$ mkdir -p /u01/app/grid
[oracle@clone app]$ mkdir -p /u01/app/oracle

STEP 05
chown -R grid:oinstall /u01
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/



OUTPUT
[root@clone u01]# chown -R grid:oinstall /u01
[root@clone u01]# mkdir -p /u01/app/oracle
[root@clone u01]# chown-R oracle:oinstall /u01/app/oracle
[root@clone u01]# chmod -R 775 /u01/

su - oracle
cd /home/oracle
vi .bash_profile
add the following lines in .bash_profile
export ORACLE_HOSTNAME=clone.edi.pict.com.pk
export ORACLE_UNQNAME=pictdb
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=pictdb
export PATH=$PATH:$ORACLE_HOME/bin

then save and quit

STEP 06
Make the following Directories
mkdir -p /u01/app/oracle/admin/pictdb/adump
mkdir -p /u01/pictdb/controlfile/
mkdir -p /u01/app/oracle
mkdir -p/u01/oracle/product/oradata/pictdb/

Output
[root@clone ~]# mkdir -p /u01/app/oracle/admin/pictdb/adump
[root@clone ~]# mkdir -p /u01/pictdb/controlfile/
[root@clone ~]# mkdir -p /u01/app/oracle


STEP 07
Create Pfile
cd /u01/app/oracle
vipfile.txt
(Note:- Copy below all the lines in pfile.txt)
*.audit_file_dest='/u01/app/oracle/admin/pictdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files=‘/u01/app/oracle/oradata/pictdb/control01.ctl','/u01/app/oracle/oradata/pictdb/control02.ctl'
*.cursor_sharing='FORCE'
*.db_block_size=8192
*.db_create_file_dest=''
*.db_domain=''
*.db_name='pictdb'
*.db_recovery_file_dest=''
*.db_recovery_file_dest_size=858993459200
*.diagnostic_dest='/u01/app/oracle'
*.log_archive_dest_state_2='ENABLE'
*.log_buffer=99682688
*.open_cursors=3000
*.pga_aggregate_target=2522873856
*.processes=1500
*.remote_login_passwordfile='EXCLUSIVE'
*.sec_case_sensitive_logon=FALSE
*.session_cached_cursors=1000
*.sessions=2000
*.sga_max_size=2g
*.sga_target=2g
*.undo_tablespace='UNDOTBS1'

SAVE AND QUIT

STEP 08

[oracle@clone oracle]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Wed Feb 27 11:41:06 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to an idle instance.

STEP 09
SQL> startup nomountpfile='/u01/app/oracle/pfile.txt';
ORACLE instance started.

Total System Global Area 2137886720 bytes
Fixed Size                  2230072 bytes
Variable Size             486541512 bytes
Database Buffers         1543503872 bytes
Redo Buffers              105611264 bytes

STEP 10
SQL> create spfile from pfile='/u01/app/oracle/pfile.txt';
File created.


STEP 11
SQL>shu abort
ORACLE instance shut down.

STEP 12
SQL> startup nomount

OUTPUT

ORACLE instance started.
Total System Global Area 2137886720 bytes
Fixed Size                  2230072 bytes
Variable Size             486541512 bytes
Database Buffers         1543503872 bytes
Redo Buffers              105611264 bytes
SQL>
STEP 13

SQL> exit

STEP 14

su - root

[root@clone u01]# chown -R oracle:oinstall /u01/habib/

STEP 15

su - oracle

STEP 16
[oracle@clone ~]$ cd /u01/habib/bakup-Feb-25-13/
ls -ltra

OUTPUT
[oracle@clone bakup-Feb-25-13]$ ls -ltra
total 36973672
-rwxrwxr-x 1 oracle oinstall14533926912 Feb 26 10:16 datafiles_PICTDB_1385_1_1.bkp
-rwxrwxr-x 1 oracle oinstall11333345280 Feb 26 10:20 datafiles_PICTDB_1386_1_1.bkp
-rwxrwxr-x 1 oracle oinstall   36339712 Feb 26 10:20 PICTDB_c-4197939688-20130225-00.ctl
-rwxrwxr-x 1 oracle oinstall10967695360 Feb 26 10:11 datafiles_PICTDB_1384_1_1.bkp
-rwxrwxr-x 1 oracle oinstall  302272512 Feb 26 10:20 archivelogs_PICTDB_1388_1_1.bkp
-rwxrwxr-x 1 oracle oinstall  320047104 Feb 26 10:20 archivelogs_PICTDB_1389_1_1.bkp
-rwxrwxr-x 1 oracle oinstall   36339712 Feb 26 10:21 PICTDB_c-4197939688-20130225-01.ctl
-rwxrwxr-x 1 oracle oinstall    2523136 Feb 26 10:21 controlfiles_PICTDB_1391_1_1.bkp
-rwxrwxr-x 1 oracle oinstall  291505664 Feb 26 10:21 archivelogs_PICTDB_1390_1_1.bkp
drwxrwxr-x 2 oracle oinstall        4096 Feb 26 10:21 .
drwxrwxr-x 3 oracle oinstall        4096 Feb 26 11:04 ..

NOTE: the permission should be like this

STEP 17
Enter user-name: sys/oracle as sysdba

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

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

System altered.

STEP 18

SQL> startup nomount force

OUTPUT
ORACLE instance started.
Total System Global Area 2137886720 bytes
Fixed Size                  2230072 bytes
Variable Size             486541512 bytes
Database Buffers         1543503872 bytes
Redo Buffers              105611264 bytes

STEP 19
SQL> show parameter control

OUTPUT

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
control_file_record_keep_time        integer                          7
control_files                        string       /u01/app/oracle/oradata/pictdb
                                                               /control01.ctl, /u01/app/oracl
                                                               e/oradata/pictdb/control02.ctl

STEP 20
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

STEP 21

[oracle@clonedbs]$ cd /u01/app/oracle/

STEP 22
[oracle@clone oracle]$ vi pfile.txt

Output
*.audit_file_dest='/u01/app/oracle/admin/pictdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.cursor_sharing='FORCE'
*.db_block_size=8192
*.db_create_file_dest=''
*.db_domain=''
*.db_name='pictdb'
*.db_recovery_file_dest=''
*.db_recovery_file_dest_size=858993459200
*.diagnostic_dest='/u01/app/oracle'
*.log_archive_dest_state_2='ENABLE'
*.log_buffer=99682688
*.open_cursors=3000
*.pga_aggregate_target=2522873856
*.processes=1500
*.remote_login_passwordfile='EXCLUSIVE'
*.sec_case_sensitive_logon=FALSE
*.session_cached_cursors=1000
*.sessions=2000
*.sga_max_size=2g
*.sga_target=2g
*.undo_tablespace='UNDOTBS1'
*.control_files='/u01/app/oracle/oradata/pictdb/control01.ctl','/u01/app/oracle/oradata/pictdb/control02.ctl'

STEP 23
[oracle@clone oracle]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Feb 28 11:06:15 2013

Copyright (c) 1982, 2011, 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-01031: insufficient privileges  ( in case of error , use the following )

[oracle@clone oracle]$ rman

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Feb 28 11:06:23 2013

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

RMAN> connect target sys/oracle

connected to target database: PICTDB (not mounted)

RMAN>

STEP 24

RMAN> restore controlfile from '/u01/habib/bakup-Feb-28-13/ PICTDB_c-4197939688-20130228-00.ctl';

OUTPUT
Starting restore at 27-FEB-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1146 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/pictdb/control01.ctl
output file name=/u01/app/oracle/oradata/pictdb/control02.ctl
Finished restore at 27-FEB-13

STEP 25
RMAN> alter database mount;

OUTPUT
RMAN> alter database mount;
database mounted
STEP 26
RMAN> catalog start with '/u01/habib/bakup-Feb-28-13';

OUTPUT

searching for all files that match the pattern /u01/habib/bakup-Feb-25-13

List of Files Unknown to the Database
=====================================
File Name: /u01/habib/bakup-Feb-25-13/PICTDB_c-4197939688-20130225-01.ctl
File Name: /u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1390_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1384_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/controlfiles_PICTDB_1391_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1385_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/PICTDB_c-4197939688-20130225-00.ctl
File Name: /u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1386_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1389_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1388_1_1.bkp

Do you really want to catalog the above files (enter YES or NO)? YES

cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/habib/bakup-Feb-25-13/PICTDB_c-4197939688-20130225-01.ctl
File Name: /u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1390_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1384_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/controlfiles_PICTDB_1391_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1385_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/PICTDB_c-4197939688-20130225-00.ctl
File Name: /u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1386_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1389_1_1.bkp
File Name: /u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1388_1_1.bkp

RMAN> exit
Recovery Manager complete.
[oracle@clone oracle]$

STEP 27
[oracle@clone ~]$ sqlplus
SQL*Plus: Release 11.2.0.3.0 Production on Wed Feb 27 14:36:55 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Enter user-name: / as sysdbaandEnter user-name: sys/oracle as sysdba
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set pages60;
SQL>select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/pictdb/datafile/system.317.798137375
+DATA/pictdb/datafile/sysaux.329.798137375
+DATA/pictdb/datafile/undotbs1.330.798137375
+DATA/pictdb/datafile/users.331.798137375
+DATA/pictdb/datafile/undotbs2.336.798137469
+DATA/pictdb/datafile/pictcsts.339.798167895
+DATA/pictdb/datafile/pictcsts.340.798168017
+DATA/pictdb/datafile/pictcsts.341.798168123
+DATA/pictdb/datafile/pictcsts.342.798168239
+DATA/pictdb/datafile/pictcsts.343.798168337
+DATA/pictdb/datafile/pictcsts.344.798168857
+DATA/pictdb/datafile/users.1749.800532427

12 rows selected.


STEP 28
SQL>select 'set newname for datafile' || '  '|| file# || ' to ' || ' /u01/app/oracle/oradata/pictdb/ ' from v$datafile;
OUTPUT
set newname for datafile  1 to '/u01/app/oracle/oradata/pictdb/system.dbf';
set newname for datafile  2 to '/u01/app/oracle/oradata/pictdb/sysaux.dbf';
set newname for datafile  3 to '/u01/app/oracle/oradata/pictdb/undotbs1.dbf';
set newname for datafile  4 to '/u01/app/oracle/oradata/pictdb/users.dbf';
set newname for datafile  5 to '/u01/app/oracle/oradata/pictdb/undotbs2.dbf';
set newname for datafile  6 to '/u01/app/oracle/oradata/pictdb/pict1.dbf';
set newname for datafile  7 to '/u01/app/oracle/oradata/pictdb/pict2.dbf';
set newname for datafile  8 to '/u01/app/oracle/oradata/pictdb/pict3.dbf';
set newname for datafile  9 to '/u01/app/oracle/oradata/pictdb/pict4.dbf';
set newname for datafile  10 to '/u01/app/oracle/oradata/pictdb/pict5.dbf';
set newname for datafile  11 to '/u01/app/oracle/oradata/pictdb/pict6.dbf';
set newname for datafile  12 to '/u01/app/oracle/oradata/pictdb/users2.dbf';

NOTE:- FILE NAME YOU CAN GIVEN BY YOUR OWN CHOICE.

STEP 29

[oracle@clone /]$ rman target /   Or    rman target sys/oracle

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Feb 28 11:39:33 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: PICTDB (DBID=4197939688, not open)

run
{
setnewname for datafile  1 to '/u01/app/oracle/oradata/pictdb/system.dbf';
setnewname for datafile  2 to '/u01/app/oracle/oradata/pictdb/sysaux.dbf';
setnewname for datafile  3 to '/u01/app/oracle/oradata/pictdb/undotbs1.dbf';
setnewname for datafile  4 to '/u01/app/oracle/oradata/pictdb/users.dbf';
setnewname for datafile  5 to '/u01/app/oracle/oradata/pictdb/undotbs2.dbf';
setnewname for datafile  6 to '/u01/app/oracle/oradata/pictdb/pict1.dbf';
setnewname for datafile  7 to '/u01/app/oracle/oradata/pictdb/pict2.dbf';
setnewname for datafile  8 to '/u01/app/oracle/oradata/pictdb/pict3.dbf';
setnewname for datafile  9 to '/u01/app/oracle/oradata/pictdb/pict4.dbf';
setnewname for datafile  10 to '/u01/app/oracle/oradata/pictdb/pict5.dbf';
setnewname for datafile  11 to '/u01/app/oracle/oradata/pictdb/pict6.dbf';
setnewname for datafile  12 to '/u01/app/oracle/oradata/pictdb/users2.dbf';
restore database;
switchdatafile all;
recover database;
}

OUTPUT
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 27-FEB-13
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

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 00005 to /u01/app/oracle/oradata/pictdb/undotbs2.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/pictdb/pict1.dbf
channel ORA_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/pictdb/pict3.dbf
channel ORA_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/pictdb/users2.dbf
channel ORA_DISK_1: reading from backup piece /backup/daily_rmanbk/backups/bakup-Feb-25-13/datafiles_PICTDB_1384_1_1.bkp
channel ORA_DISK_2: starting datafile backup set restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
channel ORA_DISK_2: restoring datafile 00001 to /u01/app/oracle/oradata/pictdb/system.dbf
channel ORA_DISK_2: restoring datafile 00002 to /u01/app/oracle/oradata/pictdb/sysaux.dbf
channel ORA_DISK_2: restoring datafile 00004 to /u01/app/oracle/oradata/pictdb/users.dbf
channel ORA_DISK_2: restoring datafile 00010 to /u01/app/oracle/oradata/pictdb/pict5.dbf
channel ORA_DISK_2: reading from backup piece /backup/daily_rmanbk/backups/bakup-Feb-25-13/datafiles_PICTDB_1386_1_1.bkp
channel ORA_DISK_3: starting datafile backup set restore
channel ORA_DISK_3: specifying datafile(s) to restore from backup set
channel ORA_DISK_3: restoring datafile 00003 to /u01/app/oracle/oradata/pictdb/undotbs1.dbf
channel ORA_DISK_3: restoring datafile 00007 to /u01/app/oracle/oradata/pictdb/pict2.dbf
channel ORA_DISK_3: restoring datafile 00009 to /u01/app/oracle/oradata/pictdb/pict4.dbf
channel ORA_DISK_3: restoring datafile 00011 to /u01/app/oracle/oradata/pictdb/pict6.dbf
channel ORA_DISK_3: reading from backup piece /backup/daily_rmanbk/backups/bakup-Feb-25-13/datafiles_PICTDB_1385_1_1.bkp
channel ORA_DISK_1: failover to piece handle=/u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1384_1_1.bkp tag=TAG20130225T000017
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 01:07:18
channel ORA_DISK_2: errors found reading piece handle=/backup/daily_rmanbk/backups/bakup-Feb-25-13/datafiles_PICTDB_1386_1_1.bkp
channel ORA_DISK_2: failover to piece handle=/u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1386_1_1.bkp tag=TAG20130225T000017
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 01:07:49
channel ORA_DISK_3: errors found reading piece handle=/backup/daily_rmanbk/backups/bakup-Feb-25-13/datafiles_PICTDB_1385_1_1.bkp
channel ORA_DISK_3: failover to piece handle=/u01/habib/bakup-Feb-25-13/datafiles_PICTDB_1385_1_1.bkp tag=TAG20130225T000017
channel ORA_DISK_3: restored backup piece 1
channel ORA_DISK_3: restore complete, elapsed time: 01:18:29
Finished restore at 27-FEB-13

datafile 1 switched to datafile copy
inputdatafile copy RECID=16 STAMP=808503733 file name=/u01/app/oracle/oradata/pictdb/system.dbf
datafile 2 switched to datafile copy
inputdatafile copy RECID=17 STAMP=808503733 file name=/u01/app/oracle/oradata/pictdb/sysaux.dbf
datafile 3 switched to datafile copy
inputdatafile copy RECID=18 STAMP=808503733 file name=/u01/app/oracle/oradata/pictdb/undotbs1.dbf
datafile 4 switched to datafile copy
inputdatafile copy RECID=19 STAMP=808503733 file name=/u01/app/oracle/oradata/pictdb/users.dbf
datafile 5 switched to datafile copy
inputdatafile copy RECID=20 STAMP=808503733 file name=/u01/app/oracle/oradata/pictdb/undotbs2.dbf
datafile 6 switched to datafile copy
inputdatafile copy RECID=21 STAMP=808503734 file name=/u01/app/oracle/oradata/pictdb/pict1.dbf
datafile 7 switched to datafile copy
inputdatafile copy RECID=22 STAMP=808503734 file name=/u01/app/oracle/oradata/pictdb/pict2.dbf
datafile 8 switched to datafile copy
inputdatafile copy RECID=23 STAMP=808503734 file name=/u01/app/oracle/oradata/pictdb/pict3.dbf
datafile 9 switched to datafile copy
inputdatafile copy RECID=24 STAMP=808503734 file name=/u01/app/oracle/oradata/pictdb/pict4.dbf
datafile 10 switched to datafile copy
inputdatafile copy RECID=25 STAMP=808503734 file name=/u01/app/oracle/oradata/pictdb/pict5.dbf
datafile 11 switched to datafile copy
inputdatafile copy RECID=26 STAMP=808503734 file name=/u01/app/oracle/oradata/pictdb/pict6.dbf
datafile 12 switched to datafile copy
inputdatafile copy RECID=27 STAMP=808503734 file name=/u01/app/oracle/oradata/pictdb/users2.dbf

Starting recover at 27-FEB-13
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8992
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=7611
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8993
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8994
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8995
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=7612
channel ORA_DISK_1: reading from backup piece /u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1390_1_1.bkp
channel ORA_DISK_1: piece handle=/u01/habib/bakup-Feb-25-13/archivelogs_PICTDB_1390_1_1.bkp tag=TAG20130225T004301
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_8992_798137451.dbf thread=1 sequence=8992
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch2_7611_798137451.dbf thread=2 sequence=7611
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_8993_798137451.dbf thread=1 sequence=8993
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_8994_798137451.dbf thread=1 sequence=8994
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_8995_798137451.dbf thread=1 sequence=8995
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch2_7612_798137451.dbf thread=2 sequence=7612
unable to find archived log
archived log thread=1 sequence=8996
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/27/2013 16:23:54
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 8996 and starting SCN of 3872155705
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 8996 and starting SCN of 3872155705

(Note:- This is not an error)

STEP 30
RMAN> exit
recovery Manager complete.


STEP 31
Sqlplus/ as sysdbaorsys/oracle as sysdba
ALTER DATABASE RENAME FILE '+DATA/pictdb/onlinelog/group_2.334.798137451' TO '/u01/app/oracle/oradata/pictdb/redo01.log';
ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_2.268.798137451' TO '/u01/app/oracle/oradata/pictdb/redo02.log';
ALTER DATABASE RENAME FILE '+DATA/pictdb/onlinelog/group_1.333.798137451' TO '/u01/app/oracle/oradata/pictdb/redo03.log';
ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_1.267.798137451' TO '/u01/app/oracle/oradata/pictdb/redo04.log';
ALTER DATABASE RENAME FILE '+DATA/pictdb/onlinelog/group_3.337.798137491' TO '/u01/app/oracle/oradata/pictdb/redo05.log';
ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_3.269.798137491' TO '/u01/app/oracle/oradata/pictdb/redo06.log';
ALTER DATABASE RENAME FILE '+DATA/pictdb/onlinelog/group_4.338.798137491' TO '/u01/app/oracle/oradata/pictdb/redo07.log';
ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_4.270.798137493' TO '/u01/app/oracle/oradata/pictdb/redo08.log';
OUTPUT
SQL> ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_2.268.798137451' TO '/u01/app/oracle/oradata/pictdb/redo02.log';
ALTER DATABASE RENAME FILE '+DATA/pictdb/onlinelog/group_1.333.798137451' TO '/u01/app/oracle/oradata/pictdb/redo03.log';
ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_1.267.798137451' TO '/u01/app/oracle/oradata/pictdb/redo04.log';
ALTER DATABASE RENAME FILE '+DATA/pictdb/onlinelog/group_3.337.798137491' TO '/u01/app/oracle/oradata/pictdb/redo05.log';
ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_3.269.798137491' TO '/u01/app/oracle/oradata/pictdb/redo06.log'';
ALTER DATABASE RENAME FILE '+DATA/pictdb/onlinelog/group_4.338.798137491' TO '/u01/app/oracle/oradata/pictdb/redo07.log';
ALTER DATABASE RENAME FILE '+FRA/pictdb/onlinelog/group_4.270.798137493' TO '/u01/app/oracle/oradata/pictdb/redo08.log';
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.

STEP 32
SQL> alter database open;
OUTPUT
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open





STEP 33
SQL> alter database open resetlogs;

OUTPUT

Database altered.

NOTE:- NOW YOUR DATABASE READY TO USE.

Monday, February 18, 2013

ORA-39006: internal error , ORA-39065: unexpected master process exception in DISPATCH , ORA-01403: no data found , ORA-39097: Data Pump job encountered unexpected error 100


ORA-39006: internal errorORA-39065: unexpected master process exception in DISPATCHORA-01403: no data foundORA-39097: Data Pump job encountered unexpected error 100

Solution:-

sqlplus / as sysdba 

@?/rdbms/admin/catmeta.sql 

@?/rdbms/admin/catmet2.sql  

@?/rdbms/admin/utlrp.sql


Note:- Try everything at your own risk, if any thing happens wrong with your database so blogger will not be responsible.