Showing posts with label Oracle Database Concepts. Show all posts
Showing posts with label Oracle Database Concepts. Show all posts

Monday, 3 March 2014

ASM Background Processes

Like normal database instances ASM instance too have the usual background processes like SMON, PMON, DBWr, CKPT and LGWr. In addition to that the ASM instance also have the following background processes,

RABL - Rebalancer: It opens all the device files as part of disk discovery and coordinates the ARB processes for rebalance activity.

ARBx - Actual Rebalancer: They perform the actual rebalancing activities. The number of ARBx processes depends on the ASM_POWER_LIMIT init parameter.

ASMB - ASM Bridge: This process is used to provide information to and from the Cluster Synchronization Service (CSS) used by ASM to manage the disk resources. Responsible to communicate the database Instance to the ASM Instance, provides the heartbeat to the ASM instance.

ORBn - Rebalance ASM data extent movements. There can be many of this at the same time.

OSMB - (ASM) Any database instance that is using an ASM disk group will contain a background process called OSMB. The OSMB process is responsible for communicating with the ASM instance..Helps to manage the drive storage.

Saturday, 1 February 2014

How to Kill oracle datapump export job

In oracle expdp and impdp we can Kill job at any moment.Below are the steps how can we kill the datapump job.

17:18:37 dev > select * from dba_datapump_jobs;

OWNER_NAME JOB_NAME OPERATION
------------------------------ ------------------------------ ------------------------------
JOB_MODE STATE DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
------------------------------ ------------------------------ ---------- ----------------- -----------------
SYSTEM SYS_EXPORT_FULL_01 EXPORT
FULL EXECUTING 1 0 2


17:19:11 dev > !ps -ef | grep expdp
orauat 1945838 2142428 0 17:19:25 pts/0 0:00 grep expdp



$ expdp system/manager attach=SYSTEM.SYS_EXPORT_FULL_01

Export: Release 11.2.0.1.0 - Production on Fri Dec 9 17:23:04 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

Job: SYS_EXPORT_FULL_01
Owner: SYSTEM
Operation: EXPORT
Creator Privs: TRUE
GUID: B3A5B7EACDCC30C8E0430A0B014030C8
Start Time: Friday, 09 December, 2011 14:09:19
Mode: FULL
Instance: dev
Max Parallelism: 1
EXPORT Job Parameters:
Parameter Name Parameter Value:
CLIENT_COMMAND system/******** directory=EXP_dev dumpfile=fulldp_c lone_091211_system.dmp logfile=fulldp_dev_091211_system.log full=y
State: EXECUTING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /orabackup/EXP_dev/fulldp_dev_091211_system.dmp
bytes written: 4,096

Worker 1 Status:
Process Name: DW00
State: EXECUTING
Object Schema: APPS
Object Name: EAM_DEPT_APPROVERS_PUB
Object Type: DATABASE_EXPORT/SCHEMA/PACKAGE/PACKAGE_SPEC
Completed Objects: 11,280
Worker Parallelism: 1


Export> KILL_JOB
Are you sure you wish to stop this job ([yes]/no): yes

Saturday, 29 June 2013

Oracle SGA - System Global Area

  • SGA is dynamic and sized using SIZE_MAX_SIZE
  •  SGA memory allocated and tracked in granules by SGA components
    – Contiguous virtual memory allocation
     – Size based on SGA_MAX_SIZE                                                                                                 

    The SGA consists of several memory structures
    – Shared pool
    – Database buffer cache
    – Redo log buffer

There are two optional memory structures that can be configured within the SGA:
– Large pool
– Java pool

Shared Pool
The shared pool environment contains both fixed and variable structures. The fixed structures remain relatively the same size, whereas the variable structures grow and shrink based on user and program requirements. The actual sizing for the fixed and variable structures is based on an initialization parameter and the work of an Oracle internal algorithm.
It consists of two key performance-related memory structures:
– Library cache
– Data dictionary cache

  a) Library Cache
The library cache size is based on the sizing defined for the shared pool. Memory is allocated when a statement is parsed or a program unit is called. If the size of the shared pool is too small, statements are continually reloaded into the library cache, which affects performance.
The library cache is managed by a least recently used (LRU) algorithm. As the cache fills, less recently used execution paths and parse trees are removed from the library cache to make room for the new entries. If the SQL or PL/SQL statements are not reused, they eventually are aged out.

The library cache consists of two structures:
• Shared SQL: The Shared SQL stores and shares the execution plan and parse tree for SQL statements run against the database. The second time that an identical SQL statement is run, it is able to take advantage of the parse information available in the shared SQL to expedite its execution. To ensure that SQL statements use a shared SQL area whenever possible, the text, schema, and bind variables must be exactly the same.
• Shared PL/SQL: The shared PL/SQL area stores and shares the most recently executed
PL/SQL statements. Parsed and compiled program units and procedures (functions,
packages, and triggers) are stored in this area.

b) Data Dictionary Cache
The data dictionary cache is also referred to as the dictionary cache or row cache. Caching data dictionary information into memory improves response time. Information about the database (user account data, data file names, segment names, extent locations, table descriptions, and user privileges) is stored in the data dictionary tables. When this information is needed by the database, the data dictionary tables are read, and the data that is returned is stored in the data dictionary cache.


Database Buffer Cache
When a query is processed, the Oracle server process looks in the database buffer cache for any blocks it needs. If the block is not found in the database buffer cache, the server process reads the block from the data file and places a copy in the database buffer cache. Because subsequent requests for the same block may find the block in memory, the requests may not require physical reads. The Oracle server uses a least recently used algorithm to age out buffers that have not been accessed recently to make room for new blocks in the database buffer cache.

Redo Log Buffer Cache
The redo log buffer cache is a circular buffer that contains changes made to data file blocks.This information is stored in redo entries. Redo entries contain the information necessary to recreate the data prior to the change made by INSERT, UPDATE, DELETE, CREATE,ALTER, or DROP operations.

Large Pool
When users connect through the shared server, Oracle needs to allocate additional space in the shared pool for storing information about the connections between the user processes, dispatchers, and servers. The large pool relieves the burden on areas within the shared pool. The shared pool does not have to give up memory for caching SQL parse trees in favor of shared server session information, I/O, and backup and recover processes. The performance gain is from the reduction of overhead from increasing and shrinkage of the shared SQL cache.

Java Pool
The Java pool is an optional setting but is required if installing and using Java. Its size is set, in bytes, using the JAVA_POOL_SIZE parameter.

Saturday, 22 June 2013

Oracle Background Processes

There are many Oracle background processes. DBA should have knowledge of atleast Mandatory background processes i.e.,DBWR, PMON, CKPT,LGWR, SMON

Below are the Optional background processes
ARCn, LMON, Snnn,QMNn, LMDn,CJQ0, Pnnn,LCKn, Dnnn

Lets have detailed knowledge of mandatory background processes:

Database Writer(DBWR)
The server process records changes to rollback and data blocks in the buffer cache. Database
Writer (DBWn) writes the dirty buffers from the database buffer cache to the data files. It
ensures that a sufficient number of free buffers—buffers that can be overwritten when server
processes need to read in blocks from the data files—are available in the database buffer
cache. Database performance is improved because server processes make changes only in the
buffer cache.
DBWn defers writing to the data files until one of the following events occurs:
• Incremental or normal checkpoint
• The number of dirty buffers reaches a threshold value
• A process scans a specified number of blocks when scanning for free buffers and cannot fine any.
• Timeout occurs.
• A ping request in Real Application Clusters environment.
• Placing a normal or temporary tablespace offline.
• Placing a tablespace in read only mode.
• Dropping or Truncating a table.
ALTER TABLESPACE tablespace name BEGIN BACKUP

LOG Writer(LGWR)
LGWR performs sequential writes from the redo log buffer cache to the redo log file under the following situations:
• When a transaction commits
• When the redo log buffer cache is one-third full
• When there is more than a megabyte of changes records in the redo log buffer cache
• Before DBWn writes modified blocks in the database buffer cache to the data files
• Every 3 seconds.
Because the redo is needed for recovery, LGWR confirms the commit only after the redo is written to disk.
LGWR can also call on DBWn to write to the data files.
Note: DBWn does not write to the online redo logs.

System Monitor(SMON)
If the Oracle instance fails, any information in the SGA that has not been written to disk is lost. For example, the failure of the operating system causes an instance failure. After the loss
of the instance, the background process SMON automatically performs instance recovery when the database is reopened. Instance recovery consists of the following steps:
1. Rolling forward to recover data that has not been recorded in the data files but that has been recorded in the online redo log. This data has not been written to disk because of
the loss of the SGA during instance failure. During this process, SMON reads the redo log files and applies the changes recorded in the redo log to the data blocks. Because all
committed transactions have been written to the redo logs, this process completely recovers these transactions.
2. Opening the database so that users can log on. Any data that is not locked by unrecovered transactions is immediately available.
3. Rolling back uncommitted transactions. They are rolled back by SMON or by the individual server processes as they access locked data.
SMON also performs some space maintenance functions:
• It combines, or coalesces, adjacent areas of free space in the data files.
• It deallocates temporary segments to return them as free space in data files. Temporary segments are used to store data during SQL statement processing.

Process Monitor(PMON)
The background process PMON cleans up after failed processes by:
• Rolling back the user’s current transaction
• Releasing all currently held table or row locks
• Freeing other resources currently reserved by the user
• Restarts dead dispatchers

Checkpoint(CKPT)
An event called a checkpoint occurs when the Oracle background process DBWn writes all the modified database buffers in the SGA, including both committed and uncommitted data,to the data files.
Checkpoints are implemented for the following reasons:
• Checkpoints ensure that data blocks in memory that change frequently are written to data files regularly. Because of the least recently used algorithm of DBWn, a data block that changes frequently might never qualify as the least recently used block and thus might never be written to disk if checkpoints did not occur.
• Because all database changes up to the checkpoint have been recorded in the data files,redo log entries before the checkpoint no longer need to be applied to the data files if instance recovery is required. Therefore, checkpoints are useful because they can expedite instance recovery.
At a checkpoint, the following information is written:
• Checkpoint number into the data file headers
• Checkpoint number, log sequence number, archived log names, and system change numbers into the control file.
CKPT does not write data blocks to disk or redo blocks to the online redo logs.

Saturday, 8 June 2013

startup oracle database instance concepts

startup NOMOUNT: During startup nomount Instance started.It creates the SGA and starts up the background processes but does not provide access to the database.

startup MOUNT: During Startup mount Control file opened for this instance.It mounts the database for certain DBA activities but does not provide user access to the database.

alter database OPEN: During startup database all the files get opened as described by the control file for this instance.It enables users to access the database.

Saturday, 1 June 2013

Manage Oracle tablespaces

Here are the commands to Create Tablespace, Resize datafile, tablespace offline/online/read only, drop tablespace

Create tablespace:
CREATE TABLESPACE TEST DATAFILE '/u01/oradata/test01.dbf' SIZE 500m;

Create Undo tablespace:
CREATE UNDO TABLESPACE undo1 DATAFILE '/u01/oradata/undo01.dbf' SIZE 500m;

Create Temporary tablespace:
CREATE TEMPORARY TABLESPACE temp TEMPFILE '/u01/oradata/temp01.dbf' SIZE 500m;

Set Temp tablespace as default tablespace:
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

Take a tablespace offline:
ALTER TABLESPACE TEST OFFLINE;

Take a tablespace online:
ALTER TABLESPACE TEST ONLINE;

Put Tablespace in Read-Only mode:
ALTER TABLESPACE TEST READ ONLY;

Drop tablespace:
DROP TABLESPACE TEST INCLUDING CONTENTS AND DATAFILES;

Enabling Automatic Extension of Data Files
ALTER DATABASE DATAFILE '/u01/oradata/test01.dbf' SIZE 500M AUTOEXTEND ON;

Adding Data Files to a Tablespace:
ALTER TABLESPACE test ADD DATAFILE '/u01/oradata/test02.dbf' SIZE 500M;

Resize Datafile:
alter database datafile '/u01/oradata/test01.dbf' RESIZE 1G;

Saturday, 18 May 2013

Manage Redo Log Groups and Members

Below are the examples how to add redo log groups, how to add redo log members,how to drop redo log group,how to drop redo log member,how to clear redo log

Adding Online Redo Log Groups
ALTER DATABASE ADD LOGFILE GROUP 5 ('/u01/orcl/data/redo05a.log','/u01/orcl/data/redo05b.log') SIZE 500M;


Adding Online Redo Log Members
ALTER DATABASE ADD LOGFILE MEMBER
'/u01/orcl/data/redo05c.log' TO GROUP 1,
'/u01/orcl/data/redo05c.log' TO GROUP 2,
'/u01/orcl/data/redo05c.log' TO GROUP 3;


Dropping Online Redo Log Groups
Restrictions
• An instance requires at least two groups of online redo log files.
• An active or current group cannot be dropped.
• When an online redo log group is dropped, the operating system files are not deleted.

ALTER DATABASE DROP LOGFILE GROUP 5;


Dropping Online Redo Log Members
Restrictions
• If the member you want to drop is the last valid member of the group, you cannot drop
that member.
• If the group is current, you must force a log file switch before you can drop the
member.
• If the database is running in ARCHIVELOG mode and the log file group to which the
member belongs is not archived, then the member cannot be dropped.
• When an online redo log member is dropped, the operating system file is not deleted.

ALTER DATABASE DROP LOGFILE MEMBER '/u01/orcl/data/redo05c.log';



Clearing online redo log files:
Restrictions
You can clear an online redo log file whether it is archived or not. However, when it is not
archived, you must include the keyword UNARCHIVED. This makes backups unusable if the
online redo log file is needed for recovery.

ALTER DATABASE CLEAR LOGFILE '/u01/orcl/data/redo05c.log';


Information about group and members can be obtained by querying the data dictionary.
• V$LOG
• V$LOGFILE

Saturday, 11 May 2013

SHUTDOWN Database Concepts

Shutdown Options:
a)Shutdown normal
b) Shutdown transactional
c) Shutdown immediate
d) Shutdown abort

Here are the difference between Shutdown Normal, transactional, immediate and abort:

Shutdown Normal
Normal is the default shutdown mode. Normal database shutdown proceeds with the following conditions:
• No new connections can be made.
• The Oracle server waits for all users to disconnect before completing the shutdown.
• Database and redo buffers are written to disk.
• Background processes are terminated, and the SGA is removed from memory.
• Oracle closes and dismounts the database before shutting down the instance.
• The next startup does not require an instance recovery.

Shutdown Transactional
A transactional shutdown prevents clients from losing work. A transactional database shutdown proceeds with the following conditions:
• No client can start a new transaction on this particular instance.
• A client is disconnected when the client ends the transaction that is in progress.
• When all transactions have finished, a shutdown immediately occurs.
• The next startup does not require an instance recovery.

Shutdown Immediate
Immediate database shutdown proceeds with the following conditions:
• Current SQL statements being processed by Oracle are not completed.
• The Oracle server does not wait for users currently connected to the database to disconnect.
• Oracle rolls back active transactions and disconnects all connected users.
• Oracle closes and dismounts the database before shutting down the instance.
• The next startup does not require an instance recovery.

Shutdown Abort
If the normal and immediate shutdown options do not work, you can abort the current
database instance. Aborting an instance proceeds with the following conditions:
• Current SQL statements being processed by the Oracle server are immediately terminated.
• Oracle does not wait for users currently connected to the database to disconnect.
• Database and redo buffers are not written to disk.
• Uncommitted transactions are not rolled back.
• The instance is terminated without closing the files.
• The database is not closed or dismounted.
• The next startup requires instance recovery, which occurs automatically.