Oracle FULL EXP/IMP 11i Database SURENDER SARA NCOAUG
Export – Import Need As a last resort for resolving complex problems like fixing data dictionary Required when migrating from one platform to other, ex- from SUN SOLARIS to LINUX Can be used to fix mass fragmentation issues where tablespace is not locally managed yet !
Some Example of Why ? You have a data file what was corrupted that was offline dropped. Seems file is normal under dba_data_files select file_id, file_name, status from dba_data_files where file_id=437 FILE_ID FILE_NAME STATUS /u09/oradata/FINPROD/fndx05.dbf AVAILABLE Data dictionary will still hold the file name in the v$recover_file select * from v$recover_file; FILE# ONLINE ERROR CHANGE# TIME OFFLINE UNKNOWN ERROR NOV-03
What is the issue with Offline Drop Datafile? As long as you do hot and cold backups you are fine. As long as you do RMAN backup you are fine If you try to clone the database using RMAN cloning you will be asked to supply all the archivelogs since the file was offline drop, unless you plan to skip the file. DATA DICTIONARY ENTRY WILL NEVER BE REMOVED. Creating a new data dictionary is the only way to fix it ! ( true on 8i and 9i, 10g not tested)
Environment Setup , 8174 database and Sun Solaris 8 MINIPACK AD-H Applied Patch , is already applied as part of install base
PRE EXPORT Steps Apply latest AD minipack F or higher ( In my environment we were at AD-H) Apply the Applications consolidated export/import utility patch. Apply patch to the source administration server node Apply patch to every application tier server node in the source system. ( It is already a part of install base) If you have installed the Rapid Install, apply patch ( we were at ) select * from global_name. Will need this after the export and before the import. Create the export parameter file ( see next slide) Generate target database instance creation script adcrdb.sql using sracrdb.sql ( EXP.zip file) Record Advanced Queue settings using auque1.sql ( EXP.zip file) Record Oracle ConText default tablespace On the source database server node, use SQL*Plus to connect to the source database as sysdba and run the following query: $ sqlplus /nolog SQL> connect sys/ as sysdba; –SQL> select username, default_tablespace from dba_users where username='CTXSYS'; Shut down all Applications server processes except the database and the Net8 listener for the database
Dynamic SQL to see how many rows exist “WORKFLOW TABLES will take lot of time if not clean” select 'select count(*) from ' || owner ||'.'|| object_name || ' ;' from dba_objects where object_type = 'TABLE' and ( object_name like '%WF_JMS_IN%' or object_name like '%WF_JMS_OUT%' or object_name like '%WF_CONTROL%' or object_name like '%WF_NOTIFICATION%' ) /
Exporting 11i database exp sys/pass9999 parfile=auexpimp.dat auexpimp.dat –userid="sys/pass9999 as sysdba" –buffer= –file=/scratch/EXP/FINPROD.exp –compress=y –grants=y –indexes=y –rows=y –constraints=y –full=y –log=/scratch/EXP/finprod.log
PRE IMPORT- sracrdb.sql File – Fixing path Copy script adclondb.sql to sracrdb.sql Fix the function to look like below function file_name(X_file_name in varchar2) return varchar2 is l_slash_pos number; begin return(''''||X_file_name||''''); end;
PRE IMPORT – Delete the current database Make sure EXPORT is good Run extend_data_files.sql to produce extendme.sql Delete all datafiles, controlfiles and logfiles
PRE IMPORT – Recreate a New One Remove the password file from $ORACLE_HOME/dbs Modify init.ora to comment the line REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE Run adcrdb.sql sqlplus /nolog __1 connect internal; spool adcrdb.log; startup exit; __1
PRE IMPORT – Recreate Dictionary Run post DATABASE create script to install the data dictionary sqlplus /nolog __1 connect internal; spool sys_system_java_misc1.log; @addbjava.sql exit; __1
PRE IMPORT – ORD Install Set ORACLE_HOME connect
interMedia Install connect connect connect connect
Install Spatial Option connect begin ORDSYS.Cartridge.Register( 'SDO', 'Oracle Spatial Cartridge', ' Development', 'Oracle8 Spatial Cartridge', 'INVALID' ); end; AR import and HR import of few tables will fail if this is not installed properly
Intermedia install Pass these 4 FALSE USERS TEMP /u01/oracle/finproddb/8.1.7/ctx/lib/libctxx8.so
ctxsys connect ctxsys/ctxsys prompt prompt The output from dr0inst.sql is in dr0inst.log
Pre-Import alter database rename global_name to ;
Import DAT file userid="sys/pass9999 as sysdba" buffer= file=/scratch/EXP/FINPROD.exp grants=y indexes=y rows=y constraints=y full=y log=/scratch/EXP/impFINPROD.log ignore=y analyze=n commit=y
Import Script imp sys/pass9999 parfile=imp.dat
Script to See The data Export For example we can see what was exported for given tables select 'grep –I “ ' || object_name || ‘ “ finprod.log' from dba_objects where object_type = 'TABLE' and ( object_name like '%WF_JMS_IN%' or object_name like '%WF_JMS_OUT%' or object_name like '%WF_CONTROL%' or object_name like '%WF_NOTIFICATION%' ) /
Run auque2.sql Run auque2.sql to enable the AQ
Possible AQ That will not work ERROR at line 1: ORA-20000: Oracle Error Mkr4= ORA-24002: QUEUE_TABLE APPLSYS.WF_JMS_IN does not exist ORA-06512: at line 24 The see the AQ table for the queue that are failing – select * from user_queue_tables where queue_table in ('WF_JMS_IN', 'WF_JMS_OUT', 'WF_CONTROL','WF_NOTIFICATION_IN', 'WF_NOTIFICATION_OUT'); To see the objects related the the above queues –select owner, object_type, status, object_name from dba_objects where object_type = 'TABLE' and ( object_name like '%WF_JMS_IN%' or object_name like '%WF_JMS_OUT%' or object_name like '%WF_CONTROL%' or object_name like '%WF_NOTIFICATION%' ) ;
Check How much Data Was Exported Dynamic SQL to see how much data was exported may be needed to estimate the table level import ( AGAIN ) select 'grep -i " ' || object_name || ' " finprod.log' from dba_objects where object_type = 'TABLE' and ( object_name like '%WF_JMS_IN%' or object_name like '%WF_JMS_OUT%' or object_name like '%WF_CONTROL%' or object_name like '%WF_NOTIFICATION%' ) / grep -i " AQ\$_WF_CONTROL_H " finprod.log grep -i " AQ\$_WF_CONTROL_I " finprod.log
AQ Fix – Drop it all ! set linesize select object_name,object_type FROM user_objects where object_name like 'WF_%'; col OBJECT_NAME format a40 select * from user_queue_tables where queue_table in ('WF_JMS_IN', 'WF_JMS_OUT', 'WF_CONTROL','WF_NOTIFICATION_IN', 'WF_NOTIFICATION_OUT'); select owner, object_type, status, object_name from dba_objects where object_type = 'TABLE' and ( object_name like '%WF_JMS_IN%' ) ; connect as applsys drop view AQ$WF_JMS_IN ; drop view AQ$WF_JMS_IN_S ; drop sequence AQ$_WF_JMS_IN_N ; ALTER SESSION SET EVENTS '10851 trace name context forever, level 2'; drop table AQ$_WF_JMS_IN_H cascade constraint ; drop table AQ$_WF_JMS_IN_I cascade constraint ; drop table AQ$_WF_JMS_IN_S cascade constraint ; drop table AQ$_WF_JMS_IN_T cascade constraint ; drop table WF_JMS_IN cascade constraint ;
Identify AQ tables connect sys SELECT schema, name, objno FROM SYSTEM.AQ$_QUEUE_TABLES WHERE name like '%WF_JMS_IN%' ; SCHEMA NAME OBJNO APPLSYS WF_JMS_IN APPLSYS WF_JMS_OUT
Identify AQ SELECT oid, table_objno, name FROM SYSTEM.AQ$_QUEUES WHERE name IN ( 'AQ$_WF_JMS_IN_E', 'AQ$_WF_JMS_OUT_E', 'AQ$_WF_CONTROL_E', 'AQ$_WF_NOTIFICATION_IN_E', 'AQ$_WF_NOTIFICATION_OUT_E' ); OID TABLE_OBJNO NAME ECA3727F39B26E6FE BA0D8DD AQ$_WF_NOTIFICATION_OUT_E ECA3727F39B16E6FE BA0D8DD AQ$_WF_NOTIFICATION_IN_E ECA3727F39B06E6FE BA0D8DD AQ$_WF_CONTROL_E ECA5415C274B703AE BA0D8DD AQ$_WF_JMS_OUT_E ECA5415C274A703AE BA0D8DD AQ$_WF_JMS_IN_E
Delete the AQ data DELETE FROM SYSTEM.AQ$_QUEUE_TABLES where objno in ( SELECT objno FROM SYSTEM.AQ$_QUEUE_TABLES WHERE name like '%WF_JMS_IN%' or name like '%WF_JMS_OUT%' or name like '%WF_CONTROL%' or name like '%WF_NOTIFICATION%' ) ; DELETE FROM SYSTEM.AQ$_QUEUES WHERE table_objno in ( SELECT table_objno FROM SYSTEM.AQ$_QUEUES WHERE name IN ( 'AQ$_WF_JMS_IN_E', 'AQ$_WF_JMS_OUT_E', 'AQ$_WF_CONTROL_E', 'AQ$_WF_NOTIFICATION_IN_E', 'AQ$_WF_NOTIFICATION_OUT_E' ) );
Locate OBJ$ Entries connect as sys select distinct o.owner# from obj$ o, user$ u where o.owner#=u.user# and u. name='APPLSYS'; OWNER# SELECT obj#,name FROM SYS.OBJ$ WHERE type#=24 AND owner# =35 AND name IN ( 'AQ$_WF_JMS_IN_E', 'AQ$_WF_JMS_OUT_E', 'AQ$_WF_CONTROL_E', 'AQ$_WF_NOTIFICATION_IN_E', 'AQ$_WF_NOTIFICATION_OUT_E' ); OBJ# NAME AQ$_WF_NOTIFICATION_OUT_E AQ$_WF_NOTIFICATION_IN_E AQ$_WF_CONTROL_E AQ$_WF_JMS_OUT_E AQ$_WF_JMS_IN_E
Fix OBJ$ table SELECT obj#,name FROM SYS.OBJ$ WHERE type#=46 AND owner# = 35 AND name in ( 'AQ$_WF_JMS_IN_E', 'AQ$_WF_JMS_OUT_E', 'AQ$_WF_CONTROL_E', 'AQ$_WF_NOTIFICATION_IN_E', 'AQ$_WF_NOTIFICATION_OUT_E' ); DELETE FROM SYS.OBJ$ WHERE obj# IN ( SELECT obj# FROM SYS.OBJ$ WHERE type#=24 AND owner# =35 AND name IN ( 'AQ$_WF_JMS_IN_E', 'AQ$_WF_JMS_OUT_E', 'AQ$_WF_CONTROL_E', 'AQ$_WF_NOTIFICATION_IN_E', 'AQ$_WF_NOTIFICATION_OUT_E' ));
Final Step select name from SYS.EXPACT$ WHERE owner='APPLSYS' AND name LIKE '%WF%'; select name from SYS.NOEXP$ WHERE owner='APPLSYS' AND name LIKE '%WF%'; DELETE FROM SYS.EXPACT$ WHERE owner='APPLSYS' AND name LIKE '%WF%'; DELETE FROM SYS.NOEXP$ WHERE owner='APPLSYS' AND name LIKE '%WF%';
POSIBLE Queues you have to fix select * from user_queue_tables where queue_table in ('WF_JMS_IN', 'WF_JMS_OUT', 'WF_CONTROL','WF_NOTIFICATION_IN', 'WF_NOTIFICATION_OUT'); select owner, object_type, status, object_name from dba_objects where object_type = 'TABLE' and ( object_name like '%WF_JMS_IN%' or object_name like '%WF_JMS_OUT%' or object_name like '%WF_CONTROL%' or object_name like '%WF_NOTIFICATION%' ) ;
Contact and QA