Tuesday, June 28, 2011

Steps to set database on flashback mode in RAC for Oracle 11g

 

---- Check if flashback on?

SELECT flashback_on, log_mode
FROM v$database;

--- Check for Flashback Parameters existing

set linesize 121
col name format a30
col value format a30

SELECT name, value
FROM gv$parameter
WHERE name LIKE '%flashback%';

---- Stop the RAC Database , it will stop all the instances of the DB

srvctl stop database -d sfodb

--- Start the DB in mount state

srvctl start instance -d sfodb -i sfo38u1 -o mount 

-- Set the Flashback on

alter database flashback on;

--- Open the database

alter database open;

--- Start the remaining instances of the RAC

srvctl start instance -d sfodb -i sfo38u2 -o mount exclusive

-- Verify the flashback settings

select INST_ID,Name, FLASHBACK_ON from gv$database;

Saturday, June 18, 2011

ORA-00257: archiver error. Connect internal only, until freed.

 

Error:

ORA-00257: archive error, Connect internal only, until freed.
followed by
The database is not available due to the following conditions: Stuck Archiver
followed by
Warning: Disk group +DG_UAT_FLASH_01 is 92% used


*Cause: 
The archiver process received an error while trying to archive a redo log.  If the problem is not resolved soon, the database will stop executing transactions. The most likely cause of this message is the destination device is out of space to store the redo log file.

*Action: 
Check archiver trace file for a detailed description of the problem. Also verify that the device specified in the initialization  parameter  ARCHIVE_LOG_DEST is set up properly for archiving.

Method   1. Without increasing DB_RECOVERY_FILE_DEST_SIZE.

Approach 1: Move the archive log from the FRA to some other location to free up FRA

Step 1: Check whether the database is in archive log mode and automatic archiving is enabled

SQL> archive log list

Database log mode            Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     5559
Current log sequence           5561

Step 2:  As the archive destination is defined by USE_DB_RECOVERY_FILE_DEST, find the archive destination by

SQL> show parameter db_recovery_file_dest;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      +DG_UAT_FLASH_01
db_recovery_file_dest_size           big integer 110G

Note the value for db_recovery_file_dest_size. Here it is 11G.

Step 3:  Find the space used in flash recovery area by :

SQL> SELECT * FROM V$RECOVERY_FILE_DEST;

NAME
--------------------------------------------------------------------------------
SPACE_LIMIT SPACE_USED SPACE_RECLAIMABLE NUMBER_OF_FILES
----------- ---------- ----------------- ---------------
+DG_UAT_FLASH_01
1.1811E+11 3.0249E+10        2.7808E+10            1140

Step 4:  If SPACE_USED is equal to SPACE_LIMIT of db_recovery_file_dest, move the archive logs to different destination.

Step 5:  Archive all the log files

SQL> alter system archive log all;

Step 6:  Just switch the logs to verify:

SQL> alter system switch logfile;

Second Approach: Delete the Archive Log , when it is not needed to free up the DB_RECOVERY_FILE_DEST
Alternatively, we can solve this type of problem without increasing DB_RECOVERY_FILE_DEST_SIZE is to delete (archive log) files from DB_RECOVERY_FILE_DEST if we are sure we have backups and the archived logs are no longer necessary.

$rman target /
RMAN>delete archivelog until time 'SYSDATE-1';

Method 2:  By increasing DB_RECOVERY_FILE_DEST_SIZE.

Step 1:  See the path of flash recovery area.

SQL> show parameter db_recovery_file_dest;

Step 2: Disable the Flash Recovery Area

SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='';

Step 3: Increase the Flash Recovery Area

SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 200g;

Step 4: Enable the Flash Recovery Area

SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = ‘+DG_UAT_FLASH_01’;

Friday, June 17, 2011

OEM OMS 10g Server Commands to start, stop and know the status (opmnctl)


Check status of the GRID management server

1) export ORACLE_HOME=/app/oracle/product/10g/oms10g/opmn

2) cd $ORACLE_HOME/bin

3) ./opmnctl status

oracle@omsrvrap$  export ORACLE_HOME=/app/oracle/product/10g/oms10g/opmn
oracle@omsrvrap$  cd $ORACLE_HOME/bin
oracle@omsrvrap$  opmnctl status

Processes in Instance: EnterpriseManager0.omsrvrap.dbosmsrvr.siva.com
-------------------+--------------------+---------+---------
ias-component      | process-type       |     pid | status 
-------------------+--------------------+---------+---------
LogLoader          | logloaderd         |     N/A | Down   
HTTP_Server        | HTTP_Server        |    9146 | Alive  
dcm-daemon         | dcm-daemon         |     N/A | Down   
OC4J               | home               |    9147 | Alive  
OC4J               | OC4J_EM            |    9148 | Alive  
OC4J               | OC4J_EMPROV        |    9150 | Alive  
OC4J               | OCMRepeater        |    9151 | Alive  
WebCache           | WebCache           |    9152 | Alive  
WebCache           | WebCacheAdmin      |    9153 | Alive  
DSA                | DSA                |     N/A | Down   


Stop the GRID management server

1) export ORACLE_HOME=/app/oracle/product/10g/oms10g/opmn

2) cd $ORACLE_HOME/bin

3) ./opmnctl stopall

oracle@omsrvrap$  export ORACLE_HOME=/app/oracle/product/10g/oms10g/opmn
oracle@omsrvrap$  cd $ORACLE_HOME/bin
oracle@omsrvrap$  opmnctl status

opmnctl: stopping opmn and all managed processes...

Start the GRID management server

1) export ORACLE_HOME=/app/oracle/product/10g/oms10g/opmn

2) cd $ORACLE_HOME/bin

3) ./opmnctl startall


oracle@omsrvrap$  export ORACLE_HOME=/app/oracle/product/10g/oms10g/opmn
oracle@omsrvrap$  cd $ORACLE_HOME/bin
oracle@omsrvrap$  opmnctl status

opmnctl: starting opmn and all managed processes...

OEM Grid 10g Agent commands to start, stop and know the status. ( emctl )

Oracle10g OEM GRID Agent ( emctl )Commands

Check status of the GRID control agent

1) export ORACLE_HOME=/app/oracle/product/10g/agent10g

2) cd $ORACLE_HOME/bin

3) ./emctl status agent

oracle@dbsrvr1$ export ORACLE_HOME=/app/oracle/product/10g/agent10g
oracle@dbsrvr1$ cd $ORACLE_HOME/bin
oracle@dbsrvr1$ ./emctl status agent
Oracle Enterprise Manager 10g Release 5 Grid Control 10.2.0.5.0.
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 10.2.0.5.0
OMS Version : 10.2.0.5.0
Protocol Version : 10.2.0.5.0
Agent Home : /app/oracle/product/10g/agent10g
Agent binaries : /app/oracle/product/10g/agent10g
Agent Process ID : 20124
Parent Process ID : 20080
Agent URL : https://dbsrvr1.dbsrvr.siva.com:3872/emd/main/
Repository URL : https://hp6600ap.dbsrvr.siva.com:1159/em/upload
Started at : 2010-03-09 12:04:07
Started by user : oracle
Last Reload : 2010-03-09 12:08:39
Last successful upload : 2009-07-09 14:26:42
Total Megabytes of XML files uploaded so far : 291.89
Number of XML files pending upload : 0
Size of XML files pending upload(MB) : 0.00
Available disk space on upload filesystem : 35.13%
Last successful heartbeat to OMS : 2010-03-09 12:26:07
Agent is Running and Ready

STOP the GRID control agent

1) export ORACLE_HOME=/app/oracle/product/10g/agent10g

2) cd $ORACLE_HOME/bin

3) ./emctl stop agent

oracle@dbsrvr1$ export ORACLE_HOME=/app/oracle/product/10g/agent10g
oracle@dbsrvr1$ cd $ORACLE_HOME/bin
oracle@dbsrvr1$ ./emctl stop agent
Oracle Enterprise Manager 10g Release 5 Grid Control 10.2.0.5.0.
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
Stopping agent ... stopped.


START the GRID control agent

1) export ORACLE_HOME=/app/oracle/product/10g/agent10g

2) cd $ORACLE_HOME/bin

3) ./emctl start agent

.

oracle@dbsrvr1$ export ORACLE_HOME=/app/oracle/product/10g/agent10g
oracle@dbsrvr1$ cd $ORACLE_HOME/bin
oracle@dbsrvr1$ /emctl start agent
Oracle Enterprise Manager 10g Release 5 Grid Control 10.2.0.5.0.
Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
Starting agent ................................ started.

Wednesday, June 15, 2011

ORA-00980: synonym translation is no longer valid

 

Error:  ORA-00980: synonym translation is no longer valid

Cause:

1. Synonym created on non-existing object by mistake.

2. The synonyms referencing the object is dropped but synonym is not dropped

3. Dropped a user, but the synonyms referencing the objects owned by that dropped user.

Query to find the invalid synonyms

select * from dba_synonyms s
where table_owner not in('SYSTEM','SYS')
and db_link is null
and not exists
(select 1
from dba_objects o
where s.table_owner=o.owner
and s.table_name=o.object_name);

select 'drop '||decode (s.owner,'PUBLIC','PUBLIC SYNONYM ','SYNONYM'||s.owner||'.')||s.synonym_name||';'
from dba_synonyms s
where table_owner not in('SYSTEM','SYS')
and db_link is null
and not exists
(select 1 from dba_objects o
where s.table_owner=o.owner
and s.table_name=o.object_name)

The query above generate the script to drop the synonyms whose translation is no longer valid

 

 

Wednesday, June 01, 2011

OEM Agent Log Files


The OEM Agent files are placed on AGENT_HOME/sysman/log/ by default.

OEM Agent Log File Management Agent log file emagent.log
OEM Agent Trace File Management Agent trace file emagent.trc
OEM Agent startup log file Management Agent startup log file emagent.nohup

Sunday, May 29, 2011

What is mounting the databases in Oracle?

After starting the instance, the Oracle software associates the instance with specific database. This is called mounting the database.

Oracle Database Memory Structure


image

Friday, May 27, 2011

ORA-00942: table or view does not exist or Warning: View altered with compilation errors.


Error:

SQL> ALTER VIEW HR.TMP_TABLE_REORG COMPILE;

Warning: View altered with compilation errors.

How to find out the cause:

Use the query below to find the query which makes the View

SQL> set long 10000
SQL> set pages 0
SQL> select dbms_metadata.get_ddl('VIEW','TMP_TABLE_REORG','HR') from dual;

Output will look like;

SQL>  select "TABLE_NAME","COLUMN_NAME","CONSTRAINT_NAME","T_TABLE_NAME","START_TIME  ","END_TIME","RELOAD_START_TIME","RELOAD_END_TIME","OBJECT_SIZE_MB","T_F_CW02TMP _MB","N_REQ_CW02TMP_MB","PRE_ORIG_ROWCNT","PRE_TMP_ROWCNT","POST_ORIG_ROWCNT","
P  OST_TMP_ROWCNT" from REORG_USR.tmp_table_reorg;
OST_TMP_ROWCNT" from REORG_USR.tmp_table_reorg

Try to run the “Select statement” which makes the query. You will get error message as; It means that physical table that view depends on does not exist cause the issue.

ORA-00942: table or view does not exist

Wednesday, May 25, 2011

ASM – Automatic Storage Management

 

ASM : is the vertical integration of File system and Volume Manager, specifically built for Oracle Database files.

Advantages:

  1. Dynamic storage management, without shut downs of the Oracle database, storage can be adjusted.
  2. I/O Load balancing : distribute the I/O Load across all available resource to optimize the performance, while removing the manual need.
  3. Provide fault tolerance by maintaining redundant copy of data, per file basis.
    Supports mirroring at file level not at volume level.
  4. Supports online disk reconfiguration and dynamic rebalancing
  5. stripes files not the logical volumes
  6. Supports RAC and eliminates need of
    Cluster File system or Cluster Logical Volume Manager.

image

ASM divides data files into extent. This extent is different from data file extent.
Spread each extents across all the disks. It uses indexes to track the placement of each extent.

Monday, May 23, 2011

Oracle Database Storage Structure

 

Oracle DB Storage Structure

image

Relationship of Database, Tablespace and Data files

image

 

How table data is stored in Oracle Database

image

Content of Database Data Block

image

How to find the instance names of ASM on the cluster nodes

 

crsctl status resource ora.asm –f | grep servername

How to current directory to be displayed in the prompt, while using ASMCMD command?

asmcmd –p

-p causes the current directory to be displayed in the prompt.

+ signs denotes the root directory

To list the Disk group details

 ASMCMD [+] > ls -l +

State    Type    Rebal  Name
MOUNTED  EXTERN  N      DG_Test_DATA_01/
MOUNTED  EXTERN  N      DG_Test_FLASH_01/

To list the sizing information for each Disk group

ASMCMD [+] > ls -s +

Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name
  1024   4096  8388608   3407872   665384                0          665384              0  DG_Test_DATA_01/
  1024   4096  8388608    524288   152944                0          152944              0  DG_Test_FLASH_01/

To display the content of current directory and its subdirectory

ASMCMD [+] > ls *

To find  file name matching the given query
ASMCMD [+] > find + *.dbf

Friday, May 20, 2011

How to find the Oracle databases running in a Unix Server?

 

First Option:
It will list all the currently running instances

ps -eaf | grep pmon | grep -v grep | awk ' {print $9}' | cut -c10-18

Second Option:
Check for the Oratab entries

Difference between Oracle Database Crash and Oracle Instance Crash both in Standalone and RAC Environment

 

  Instance Crash Database Crash
RAC Instance and DB crash are different.

In RAC, there is not a single instance mounting the database. It's always more than one. Now, as long as you have at least one instance up and running and have the db opened via it, the other instance's crash is called instance crash only.
If all the instances of the cluster get crashed, it eventually would mean that the db has to go down , this would be called database crash.

Stand alone Instance and DB crash are same Instance and DB crash is one because, there would be just a single instance linked with a database. So if that crashes, you would have the db going down, aka, getting crashed as well.
Definition An instance crash will therefore mean that the crash occurs in the instance due to an Oracle bug or similar. In other words a s/w error and not a database error Database crash means that the database itself is damaged in some way. A disk is no more. Data files are corrupted. Etc. The database itself thus causes the crash - and a database crash will also cause all database instances (RAC or single) for that database to crash too.

Tuesday, May 17, 2011

Oracle Enterprise Manager – OEM

 

OEM Management Framework configuration consists of

  1. Managed Targets
  2. Management Services
  3. Grid Control
  4. DB Console
  5. Application Server Console


OEM Services in Windows.image

OEM DB Console in Unix

Start dbconsole

emctl start dbconsole

Stop dbconsole

emctl stop dbconsole

Status dbconsole

emctl status dbconsole

Accessing Enterprise Manager Database Control, using browser client

http://hostname:portnumber/em

Monday, May 16, 2011

ORA-19511: Error received from media manager layer

 

RMAN Backup Failed with

Error Message:
ORA-19506: failed to create sequential file, name="<SYS00S_1846:751266012:1:33>.df", parms=""
ORA-27028: skgfqcre: sbtbackup returned error
ORA-19511: Error received from media manager layer, error text:
   Vendor specific error: OB2_StartObjectBackup() failed ERR(-17)

Cause:
The root cause of the backup failures was that the VLS ran out of tapes. 

Resolution:
Free up tapes from expired backups or add new tapes. 
Reboot the VLS to get the backups working again.

How to find the Preferred node in Oracle RAC?

 

To find the preferred node in Oracle RAC from the configuration. It find the details from Oracle Cluster Registry (OCR). It displays the Oracle Restart configuration information

$ srvctl config service -d db01
db01_Kline PREF: db0101t1 AVAIL: db01t2
db01_watch PREF: db01t2 db01t1 AVAIL:

To find the status of the services, on which instances, it  is running

$ srvctl status service -d db01
Service db01_Kline is running on instance(s) db01t2
Service db01_watch is running on instance(s) db01t2, db01t1


To relocate the services from one node to another or one instance to another

srvctl relocate service -d db_unique_name -s service_name {-c source_node -n target_node | -i old_instance_name -t new_instance_name} [-f]


What is Service in Oracle RAC?

Services allow you granular definition of workload and the DBA can dynamically define which instances provide the service. Connection Load Balancing (provided by Oracle Net Services) still needs to be set up to allow the user connections to be balanced across all instances providing a service.

Wednesday, May 11, 2011

GV$ Views on Oracle RAC


When administrating a RAC system use the dictionary views of GV$ and not V$.
GV$ has additional columns inst_id .

For almost every V$ view described in this chapter, Oracle has a corresponding GV$ (global V$) view. In Real Application Clusters, querying a GV$ view retrieves the V$ view information from all qualified instances.

In addition to the V$ information, each GV$ view contains an extra column named INST_ID of datatype NUMBER. The INST_ID column displays the instance number from which the associated V$ view information was obtained. The INST_ID column can be used as a filter to retrieve V$ information from a subset of available instances

GV$ V$
Across all the nodes:
The beauty of system dictionary views of GV$ which reflect information across the various nodes of a RAC system
Only the current node
The V$ views of the data dictionary, which relate to the current status of the single node you are connected to

For example;

select distinct(username) from v$session;

It only reflects connections to the connected node and not the entire RAC.
Whereas;

select distinct(username) from gv$session;


It gives the view of all sessions within the RAC.
The GV$ dictionary views have the additional INST_ID column which give the node that the action is occurring in

How to reset the Unix Prompt to default? ( PS1)


How do I get my prompt to show the current directory, like on DOS?

PS1 – stands for Prompt String 1

In korn shells

PS1='$PWD$ '


in Bourne shells

PS1="`pwd` "