Monday, June 24, 2024

How to export and import a large table with BasicFiles LOB(s) quicker

1. Divide the source table into chunks during export. Number of chunks depends on the capabilities of the hardware (you might want to start with 10). This gives you the opportunity to use number_of_chunks parallel processes during the import.

Below is the example export script (based on the calculation of the remainder in the division of the row block number by the fixed number of chunks) :

#!/bin/bash

case $1 in
start)

 chunks=$2 ; if [ -z $2 ] && exit

 
 for i in $(eval echo {00..${chunks}}) ; do
   expdp user_id/pass job_name=expdp_table_name_${i} tables=owner.table_name query=table_name:\"where mod\(dbms_rowid.rowid_block_number\(rowid\), ${chunks}\) = ${i}\" directory=directory_for_dumpfile dumpfile=table_name_chunk_${i}.dmp logfile=directory_for_logfile:expdp_table_name_chunk_${i}.log &
   echo $i
 done

;;
esac


2. Transfer dump files to the recipient site and run the import.

dd

#!/bin/bash

case $1 in
start)

 # enter the same number of chunks as it was during export
 chunks=$2 ; if [ -z $2 ] && exit

 for i in $(eval echo {00..${chunks}}) ; do
   impdp user_id/pass job_name=impdp_table_name_${i} directory=directory_for_dumpfile dumpfile=table_name_chunk_${i}.dmp logfile=directory_for_logfile:impdp_table_name_chunk_${i}.log
remap_table=table_name:table_name_temp remap_schema=old_schema:new_schema content=data_only data_options=disable_append_hint &
   echo $i
 done

;;
esac

The parameters content= and data_options=, as well as running all of the impdp processes in the background, do the whole job.

P.S. You don't have to make the first step; it's possible to use the direct import over database link (network_link parameter of the impdp).



Wednesday, January 3, 2024

How to perform out-of-place patching of Oracle Restart (SIHA) 19c

1. Create empty directory for future Oracle Restart Home and unpack base grid installation along with required OPatch into it.

# mkdir -p /u01/app/19.21/grid

# chown grid:oinstall /u01/app/19.21/grid

# su - grid

$ cd /u01/app/19.21/grid

$ unzip -q /u01/app/oracle/install/19/SOLARIS.SPARC64_193000_grid_home.zip -d .

$ unzip -q /u01/app/oracle/install/19/p6880880_210000_SOLARIS64.zip -d .

2. Run installation using 'software only' mode. It's possible to perform silent installation using response file from previous installation, in this case set oracle.install.option=HA_SWONLY:

$ ./gridSetup.sh -silent -responseFile /u01/app/19.21/grid/gi_install.rsp -applyRU /u01/app/oracle/install/19/1921/35742441/35642822

Follow all postinstall steps (root.sh)

3. Run roothas.sh with -prepatch option.

If it requires clsecho file, copy it from previous Oracle Restart installation and edit the ORACLE_HOME variable at the beginning of it.

# /u01/app/19.21/grid/crs/install/roothas.sh -verbose -prepatch

At this step the whole Oracle Restart stack is being stopped. 

4. Run roothas.sh with -postinstall option.

# /u01/app/19.21/grid/crs/install/roothas.sh -verbose -postpatch -dstcrshome /u01/app/19.21/grid

At this step the whole Oracle Restart stack is being started from the newest Oracle Restart Home.

5. Set CRS=TRUE for the newest ORACLE_HOME and unset for the previous.

$ /u01/app/19.19/grid/oui/bin/runInstaller -updateNodeList ORACLE_HOME=/u01/app/19.19/grid CRS=FALSE
 

$/ u01/app/19.21/grid/oui/bin/runInstaller -updateNodeList ORACLE_HOME=/u01/app/19.21/grid CRS=TRUE

$ cat /u01/app/oraInventory/ContentsXML/inventory.xml

P.S. Check the owner of the newest ORACLE_HOME (must be root). If not, run roothas.sh with -lock option.

# /u01/app/19.21/grid/crs/install/roothas.sh -verbose -lock