Showing posts with label oracle dba. Show all posts
Showing posts with label oracle dba. Show all posts

Sunday, 28 July 2013

Importing Partitioned tables tips in oracle


One of the neatest new features that data pump offers is the ability to manage partition implementation during the import process. The source table had to have been partitioned when exported. Then during the import, there are three options: NONE, DEPARTITION and MERGE. NONE means to import the structure exactly the same as it was in the source database, therefore, partitioned if it was so.

DEPARTITION means to create a separate table for every partition and sub-partition. This might be useful when attempting to backwards port tables as non-partitioned for deployment in a development environment, i.e. developer sandbox. The table naming scheme is as follows: table_name_sys_pxxx or table_name_sys_subpxxx for partitions and sub-partitions, respectively. This is just table_name || parititon_name. Here is an example of a schema with fairly complex partitioning being imported with each of these three options.

C$\> impdp bert/bert directory=data_pump_dir dumpfile=bmf.dmp remap_schema=BMF:BMF2 partition_options=none
C$\> impdp bert/bert directory=data_pump_dir dumpfile=bmf.dmp remap_schema=BMF:BMF3 partition_options=departition
C$\> impdp bert/bert directory=data_pump_dir dumpfile=bmf.dmp remap_schema=BMF:BMF4 partition_options=merge

Note that schema BMF2 has all the exact same counts as BMF for tables vs. partitions vs. subpartitions. So the NONE option did, in fact, import it exactly the same. Now look at BMF, which had been imported with the DEPARTITION option. It has 1387 tables! Finally, BMF4 imported with MERGE has just the eight tables and no partitions or subpartitions.

SQL>  select owner, count(*) from dba_tables where owner like 'BMF%' group by owner order by 1;
BMF                                     8
BMF2                                    8
BMF3                                 1387
BMF4                                    8
SQL>  select table_owner, count(*) from dba_tab_partitions where table_owner like 'BMF%' group by table_owner order by 1;
BMF                                   194
BMF2                                  194
SQL>  select table_owner, count(*) from dba_tab_subpartitions where table_owner like 'BMF%' group by table_owner order by 1;
BMF                                  1360
BMF2                                 1360
Import Remapping Options
Often during the import process, something may need to be loaded in the target differently than it was in the source. Back in the old export days, there were thefromuser and touser parameters to load objects into a different schema. And while that was handy, it was never quite enough. Data pump has addressed this need by adding a plethora of remapping options. Look back at the prior section where there was the partition example. Was the remap_schema option being used to load into BMF2, BMF3 and BMF4 noticed? That is pretty much the same as the fromuser andtouser concept. But there is more. Do another BMF schema remap where there are the objects to be created in a different tablespace as well. Here is how it is done:

C:\> impdp bert/bert directory=data_pump_dir dumpfile=bmf.dmp remap_schema=BMF:BMF5 remap_tablespace=users:accounting partition_options=none


If one wanted to rename tables during the import, there is the remap_table parameter. The most powerful remapping concept is remap_data. With this, a table can be loaded and the values can be changed for columns using a function that returns the same data type as that column. The function itself can be practically unlimited, except not permitted to issue either COMMIT and/or ROLLBACK commands. A strong argument could be made that this makes the Data Pump a sort of ETL (Extract, Translate and Load) toolset now because this remapping function can handle the translate portion.

Tuesday, 23 July 2013

How to recover and open the database if the archive log required for recovery is missing.

How to recover and open the database if the archive log required for recovery is missing.


As part of recovery process, our restore went fine and also were able to re-create controlfile. During recovery, it asked for Archive logs. We checked with our Unix team for required archivelogs and found out they don’t have required archive logs.
It was critical for us to recover database because of some project deadline.
Error:
SQL> recover database until cancel using backup controlfile;
ORA-00279: change 9867098396261 generated at 03/21/2008 13:37:44 needed for
thread 1
ORA-00289: suggestion : /arcredo/XSCLFY/log1_648355446_2093.arc
ORA-00280: change 9867098396261 for thread 1 is in sequence #2093
Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: ‘/u100/oradata/XSCLFY/SYSTEM01_SCLFY.dbf’
ORA-01112: media recovery not started
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1: ‘/u100/oradata/XSCLFY/SYSTEM01_SCLFY.dbf’
After doing some research, I found out one hidden parameter (_ALLOW_RESETLOGS_CORRUPTION=TRUE) will allow us to open database even though it’s not properly recovered.
We forced open the database by setting the _ALLOW_RESETLOGS_CORRUPTION=TRUE. It allows us to open database but instance crashed immediately after open. I checked the alert.log file and found out we have undo tablespace corruption.
Alert log shows below error
Errors in file /u01/XSCLFYDB/admin/XSCLFY/udump/xsclfy_ora_9225.trc:
ORA-00600: internal error code, arguments: [4194], [17], [9], [], [], [], [], []
Tue Mar 25 12:45:55 2008
Errors in file /u01/XSCLFYDB/admin/XSCLFY/bdump/xsclfy_smon_24975.trc:
ORA-00600: internal error code, arguments: [4193], [53085], [50433], [], [], [], [], []
Doing block recovery for file 433 block 13525
Block recovery from logseq 2, block 31 to scn 9867098416340
To resolve undo corruption issue, I changed undo_management to “Manual” in init.ora. Now it allowed us to open database successfully. Once database was up and running, I created new undo tablespace and dropped old corrupted undo tablespace. I changed back the undo_management to “Auto” and undo_tablespace to “NewUndoTablespace”.
It resolved our issue and database was up and running without any issue.
_ALLOW_RESETLOGS_CORRUPTION=TRUE allows database to open without consistency checks. This may result in a corrupted database. The database should be recreated.
As per Oracle Metalink, there is no 100% guarantee that setting _ALLOW_RESETLOGS_CORRUPTION=TRUE will open the database. However, once the database is opened, then we must immediately rebuild the database. Database rebuild means doing the following, namely: (1) perform a full-database export, (2) create a brand new and separate database, and finally (3) import the recent export dump. This option can be tedious and time consuming, but once we successfully open the new database, then we expect minimal or perhaps no data loss at all. Before you try this option, ensure that you have a good and valid backup of the current database.Solution:
1) Set _ALLOW_RESETLOGS_CORRUPTION=TRUE in init.ora file.
2) Startup Mount
3) Recover database
4) Alter database open resetlogs.
5) reset undo_management to “manual” in init.ora file.
6) startup database
7) Create new undo tablespace
changed undo_management to “AUTO” and undo_tablespace to “NewTablespace”
9) Bounce database.

Monday, 15 July 2013

How to speedup copying files using scp command in LINUX

scp output.dat 192.168.111.11:/tmp/               2%   27MB   5.2MB/s   03:01 ETA
scp -c blowfish output.dat 192.168.111.11:/tmp/   6%  100MB   6.8MB/s   02:52 ETA
scp -c arcfour output.dat 192.168.111.11:/tmp/   24%  235MB   7.2MB/s   01:42 ETA



To clear history in linux--------history -c

arcfour, blowfish, how to copy files faster in linux, imp command for dba, LINUX, Oracle, oracle dba, PERFORMANCE TUNING, scp, scp command in linux, scp make fast, speedup scp command, 

Wednesday, 19 June 2013

Where RAC database stores data

Storage Options for RAC

1--CFS (Cluster File System) – Easy to manage but only available on some platforms.  Does not address striping and mirroring.
2--RAW – Available on all platforms but difficult to manage. Does not address striping and mirroring.
3--NFS – Easy to manage but only available on some platforms.  Does not address striping and mirroring.
4--ASM (Automatic Storage Management) – Easy to manage, available on ALL platforms, and DOES address striping and mirroring.

CFS (Cluster Filesystems)

The idea of CFS is to basically share file filesystems between nodes.
Easy to manage since you are dealing with regular files.
CFS is configured on shared storage.  Each node must have access to the storage in which the CFS is mounted.
NOT available on all platforms.  Supported CFS solutions currently:
OCFS on Linux and Windows (Oracle)
DBE/AC CFS (Veritas)
GPFS (AIX)
Tru64 CFS (HP Tru64)
Solaris QFS

RAW (character devices)

Hard to manage since you are dealing with character devices and not regular files.
Adding and resizing datafiles is not trivial.
On some operating systems volume groups need to deactivated before LVs can be manipulated or added.

NFS (Network Filesystem)

NOT available on all platforms.  Supported NFS solutions currently:
Network Appliance
Redhat Linux
Fujitsu Primecluster
Solaris Suncluster

ASM

Stripes files rather than logical volumes.
Enables online disk reconfiguration and dynamic rebalancing.
Provides adjustable re balancing speed.
Provides redundancy on a file basis.
Supports only Oracle files.
Is cluster aware.
Is automatically installed as part of the base code set