Monthly Archives: May 2014

log4j2

Screen Shot 2014-05-31 at 03.57.21Eclipse put log4j2.xml on classpath.
Open Run Configurations -> Arguments -> VM Arguments and enter: -Dlog4j.configurationFile=log4j2.xml

IMPDP

Prerequisites
Installed Oracle database
Created database

Create Linux user


su root
useradd brv11p2
usermod -g oinstall brv11p2
usermod -a -G dba brv11p2
passwd brv11p2
cd /home
chmod -R g+rwx oinstall

Prepare .bash_profile for Linux user


# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

export ORACLE_INSTALL=/home/oracle
export ORACLE_SID=brv11p2
PATH=$PATH:$ORACLE_INSTALL/bin:$ORACLE_INSTALL/app/oracle/product/11.2.0/dbhome_1/bin/

export PATH

export ORACLE_BASE=$ORACLE_INSTALL/app/oracle
export ORACLE_HOME=$ORACLE_INSTALL/app/oracle/product/11.2.0/dbhome_1

Create table space


SQL> CREATE BIGFILE TABLESPACE "tablespace" DATAFILE '/path/to/dbfile.dbf' SIZE 120G AUTOEXTEND ON NEXT 4G MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

Create user

SQL> create user whoever identified by password;
SQL> grant create session to whoever;
SQL> grant all privileges to sparcsn4;

Create database directories

Execute the following commands to create a database directory. This directory must point to a valid directory on the same server as the database:

SQL> CREATE DIRECTORY dmpdir AS 'path/to/directory/with/dumpfile/';

SQL> GRANT read, write ON DIRECTORY dmpdir TO whoever;

impdp parameter files
First import step excludes tables that just take space


vi step1.par
EXCLUDE=TABLE:"IN ('EDI_TRANSACTION','ROAD_DOCUMENTS','FRM_JOB_LOG','EDI_TRANSACTION_KEYWORD','EDI_BATCH_PROCESS','EDI_INTERCHANGE','EDI_EVENT','EDI_SEGMENT','EDI_BATCH','EDI_ERROR')"

Second import step creates the skipped tables


vi step2.par
DIRECTORY=dmpdir
CONTENT=METADATA_ONLY
TABLES=EDI_TRANSACTION,ROAD_DOCUMENTS,FRM_JOB_LOG,EDI_TRANSACTION_KEYWORD,EDI_BATCH_PROCESS,EDI_INTERCHANGE,EDI_EVENT,EDI_SEGMENT,EDI_BATCH,EDI_ERROR

Import database

Single dumpfile


impdp DIRECTORY=dmpdir dumpfile=thedumpfile parfile=/path/to/parfile.par

Numbered dumpfile %U


impdp DIRECTORY=dmpdir dumpfile=thedumpfile_%U parfile=/path/to/parfile.par

PS: Oracle introduced a default directory from 10g R2, called DATA_PUMP_DIR, that can be used:

SQL> SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';

DIRECTORY_PATH
--------------------------------------------------------------------------------
/app/oracle/product/10.2.0/rdbms/log/