Wednesday 3 August 2016

Error faced while Database Cloning from 64 bit to 32 bit version



Few days back, I faced this issue when I was performing a task of cloning from Higher Version to Lower Version.

I was cloning a production database which runs on 64 bit platform to a 32 bit platform. Cloning completed successfully without any error. But i found 2 issues

1. First , When I tired logging into the cloned database as non sys user Credentials , I faced some error.

2. When i tried to do ALTER TABLESPACE TEMP ADD TEMPFILE i encountered the below error

ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56319]


Solution:

Whenever you change the platform between 32 bit and 64 bit you should run the script ‘utlirp.sql’ which is located in (Oracle_Home/rdbms/admin  directory)

For this, you need to open your database in ‘Upgrade’ Mode .

Follow Below steps.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup upgrade;                                                  //open in Upgrade Mode

ORACLE instance started.
Total System Global Area 535662592 bytes
Fixed Size 1334380 bytes
Variable Size 155190164 bytes
Database Buffers 373293056 bytes
Redo Buffers 5844992 bytes
Database mounted.
Database opened.

SQL> @/$ORACLE_HOME/RDBMS/ADMIN/utlirp.sql


SQL> shutdown immediate;
SQL> startup;

Database was back again, to normal operations :)

Tuesday 2 August 2016

How to Recover archive gaps in standby database - using 2 methods




Using Both Methods


1.       Manually Log Shipping (when the missing logs are very less)
2.       Performing Incremental Backup (When there is a very huge gap)

METHOD 1:

When the logs missing or corrupt is less in number (say below 15), we can ship the logs which were missing in the standby site from the primary site (scp/sftp/ftp) and then we can register the log file in the standby so that the gap can be resolved.
This is easy process if you have missing or corrupt logs in lesser number.

Otherwise we can use the incremental backup strategy, and perform the recovery at standby site.


Lets go through the Archive log Shipping process

First, Find the archives which are missing by issuing the following command. This would give the gap sequences
SQL> select * from v$archive_gap


Or you can use the v$managed_standby view to find where the log apply stuck.
SQL> select sequence#,process,status from v$managed_standby;

Now, Copy the logs to the standby site from the primary site
Using the below command

At standby site, Do the log file registration at the standby site until all the missing log files are registered, Use this below command.
SQL> alter database register logfile '/log/file/location/log_file_name_n.arc';

Now apply would take place and your standby will become sync with the primary.


METHOD 2 :
when the difference is huge (say around 500 logs) the above method is very time consuming and not a proper approach. Else you have to rebuild the standby database from scratch.
As an enhancement from 10g, an incremental backup created with BACKUP INCREMENTAL... FROM SCN can be used to refresh the standby database with changes at the primary database since the last SCN at Standby and then managed recovery can resume.

Step 1:
Use this below command to find the SCN difference, on both the database – Primary DB & Standby DB
SQL> select current_scn from v$database;


Step 2 :
Stop the managed standby apply process:
SQL> alter database recover managed standby database cancel;

Step 3: 
Now Shutdown the standby database
SQL> shut immediate

Step 4:  
On the primary, take an incremental backup from the SCN number where the standby has been stuck:
RMAN> run {
allocate channel c1 type disk format '/u01/backup/%U.bkp';
backup incremental from scn ********* database;
}

Step 5:  On the primary, create a new standby controlfile and copy this file to standby side:
SQL> alter database create standby controlfile as '/u01/backup/for_standby.ctl';

$ scp * oracle@dataguard : /u01/backup


Step 6 :
Bring up the Standby instance in nomount mode:
SQL> startup nomount

Step 7
Now, replace the previous controlfile with this new one created at primary , and Bring the database to MOUNT state.
(Because, this Primary Side control file has the information of the SCN and we have to perform the recovery using this controlfile)

SQL> alter database mount standby database;

Step 8 :
Open the RMAN prompt and Catalog the backup piece.
(Because , RMAN does not know about these files yet; so you must let it know – by a process called cataloging)
$ rman target=/
RMAN> catalog start with '/u01/backup';

Step 9 :
Recover these files:
RMAN> recover database;

Step 10 :
After performing the recovery , exit RMAN and start managed recovery process:
SQL> alter database recover managed standby database disconnect from session;

Step 11 :

Again Check the SCN’s in primary and standby to make sure that both are in SYNc:
SQL> select current_scn from v$database;


 See Also

Configure Standby in case you re-create redologs of Primary site



Frequently Asked Interview Questions for 2+ Candidate


::     Frequently Asked Interview Questions for 2+ Candidate   ::

Experience Level  :  2 -3 years

What is main purpose of CHECKPOINT?
A Checkpoint is a database event, which synchronizes the data blocks in memory with the datafiles on disk.
A checkpoint has two purposes:
1. to establish data consistency
2. Enable faster database recovery

The following are the parameter that will be used by DBA to adjust time or interval of how frequently its checkpoint should occur in database.
LOG_CHECKPOINT_TIMEOUT = 3600;                                // Every one hour
LOG_CHECKPOINT_INTERVAL = 1000;               //number of OS blocks.


What does RESETLOGS option do?

1. Creates a new incarnation of the database, putting a new SCN in all data file headers.
2. Reset Log Sequence number to 1
3. Reformats ONLINE REDO LOGFILES if they exists


In what scenarios open resetlogs required ?
An ALTER DATABASE OPEN RESETLOGS statement is required,
1. after incomplete recovery (Point in Time Recovery) or
2. recovery with a backup control file.
3. recovery with a control file recreated with the reset logs option.


What to do if my Global Inventory is corrupted ?
No need to worry if your global Inventory is corrupted, you can recreate global Inventory on machine using Universal Installer and attach already Installed oracle home by option
-attachHome
./runInstaller -silent -attachHome -invPtrLoc $location_to_oraInst.loc
ORACLE_HOME=”Oracle_Home_Location” ORACLE_HOME_NAME=”Oracle_Home_Name”
CLUSTER_NODES=”{}”


Oracle version 11.2.0.4.0 what does each number refers to?
Oracle version number refers :
11 – for Major database release number
2 – for Database Maintenance release number
0 – for Application server release number
4 – for Component Specific release number
0 – for Platform specific release number


What is Row chaining and how can you find it? and how you will resolve the issue ?
When you are inserting record if a row is not fit into the single block… it will chain across multiple blocks leaving  a pointer between these  blocks.

Find using below query
SQL> analyze table <owner>.<table_name>;

SQL> select table_name,chain_cnt from dba_tables where table_name=’tablename';

To Overcome :
create a table with bigger the block size
1) Create tablespace tbs1 data file ‘/u01/oradata/test/data01.dbf’ size 100m blocksize 16k;
2) alter table tablename move to tbs1;
Here tbs1 is the tablespace name with larger block size and  before creating tablespace it is assumed that you have created a db buffer cache for it.

What is row migration? When does it occur? Where can you find this information?
Row migration happens when update occurs at one column and the row is not adequate to fit in the block then the entire row will be moved to the new block.

Find using below query
SQL> select table_name,chain_cnt from dba_tables where table_name=’tablename';

To Overcome :
-set pct_free storage parameter for table to adequate value


Do you know about statistics , what is the use of it? What kind of statistics exists in database?
Statistics is a collection information about data or database
There are different types of statistics that oracle maintains-
1)System-Statistics: statistics about the hardware like cpu speed,I/O speed,read time write time etc : select * from aux_stats$
2)Object statistics : For a table oracle collects the information about no.of rows,no.of blocks,avg row length etc.We can view
SQL>select table_name,num_rows,blocks,avg_row_len from dba_tables
for index oracle collect statistics on index column about no.of rows,no.of root blocks,no.of branch blocks,no.of leaf blocks,no.of distinct values etc.

See also

Interview Questions for 2+ Year experienced Candidates

Interview Questions on Architecture for 1+ Experienced

DBA 1+ year Interview 

General Tips to Prepare for an Oracle DBA Job Interview *Popular*

 

FREE Sign-Up with Gmail and Receive Pdf's and Updates via Mail -Click Here