Oracle Basics

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 30

Oracle Basics

SAPs perspective

- Kishore Soma

Contents
Oracle History Oracle architecture DB Startup options DB shut down options Database mode Backup types Limitations of Oracle database Troubleshooting tips References

Oracle History
History of Oracle 1977 Larry Ellison and friends founded software Development Laboratory 1979 - SDL changed its company-name to "Relational Software, Inc." (RSI) and introduced its product Oracle V2 as an early commercially-available relational database system 1982: RSI in its turn changed its name, becoming known as "Oracle Corporation", 1984: Oracle Corporation released Oracle version 4, which supported read-consistency. 1985: Oracle Corporation released Oracle version 5, , which supported the client-server model 1988: Oracle RDBMS version 6 came out with support for PL/SQL embedded within Oracle Forms v3, row-level locking and hot backups. 1989: Oracle Corporation entered the application products market and developed its ERP product, (later to become part of the Oracle E-Business Suite 1992: Oracle version 7 appeared with support for referential integrity, stored procedures and triggers. 1999: The release of Oracle8i aimed to provide a database inter-operating better with the Internet 2001: Oracle9i went into release with 400 new features 2003: Oracle Corporation released Oracle Database 10g. (The g stands for "grid"; emphasizing a marketing thrust of presenting 10g as "grid-computing ready".) 2005: Oracle Database 10.2.0.1 also known as Oracle Database 10g Release 2 (10gR2) appeared 2007: Oracle Corporation released Oracle Database 11g for Linux and for Microsoft Windows.

Oracle Architecture

Contd.

Oracle Architecture Contd.,

Oracle Memory structure Oracles memory structure consists of two memory areas known as: System Global Area (SGA): Allocated at instance startup, and is a fundamental component of an Oracle Instance
- The parameter used to define SGA is SGA_MAX_SIZE

Program Global Area (PGA): Allocated when the server process is started

Oracle Architecture Contd.,

The Oracle database has a logical layer and a physical layer. The physical layer consists of the files that reside on the disk; the components of the logical layer map the data to these physical components. The physical structure The Logical structure

Oracle Architechture Contd.,


The Physical Structure Data files
- The datafiles contain all the database data. The data of logical database structures, such as tables and indexes, is physically stored in the datafiles allocated for a database.

Control Files
- Every Oracle database has a control file. A control file contains entries that specify the physical structure of the database such as Database name and the Names and locations of datafiles and redo log files.

Redo Log Files


- The primary function of the redo log is to record all changes made to data. If a failure prevents modified data from being permanently written to the datafiles, then the changes can be obtained from the redo log, so work is never lost.

Oracle Architecture Contd.,

The physical structure (contd.,)

Archive Log Files


- Oracle automatically archives log files when the database is in ARCHIVELOG mode. This prevents oracle from overwriting the redo log files before they have been safely archived to another location.

Parameter Files
- Parameter files contain a list of configuration parameters for that instance and database.

Alert and Trace Log Files


- Each server and background process can write to an associated trace file. When an internal error is detected by a process, it dumps information about the error to its trace file. The alert log of a database is a chronological log of messages and errors.

Oracle Architecture Contd.,

Logical Structure Tablespaces


- A database is divided into logical storage units called tablespaces, which group related logical structures together. One or more datafiles are explicitly created for each tablespace to physically store the data of all logical structures in a tablespace.

Oracle Data Blocks


- At the finest level of granularity, Oracle database data is stored in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk. The standard block size is specified by the DB_BLOCK_SIZE initialization parameter.

Oracle Architecture Contd.,

Logical Structure (contd.,)

Extents
- The next level of logical database space is an extent. An extent is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information.

Segments
- Above extents, the level of logical database storage is a segment. A segment is a set of extents allocated for a certain logical structure. The different types of segments are :
Data segment stores table data Index segment stores index data Temporary segment temporary space used during SQL execution Rollback Segment stores undo information

Schema Overview
- A schema is a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objects are the logical structures that directly refer to the database's data. Schema objects include structures like tables, views, and indexes.

10

Oracle Architecture Contd.,

Oracle Process Structure


Oracle takes advantage of various types of processes: User process: Started at the time a database user requests connection to the Oracle server Server process: Connects to the Oracle Instance and is started when a user establishes a session Background processes: Started when an Oracle Instance is started

11

Oracle Architecture Contd.,

Background process
- DBWn (DBwriter) This background process is responsible for managing the contents of the data block buffer cache and dictionary cache. DBWR performs batch writes of changed block. - PMON process cleans up failed user processes. PMON is responsible for releasing the lock i.e. cleaning up the cache and freeing resources that the process was using - CKPT All modified information in database buffer in the SGA is written to the datafiles by a database write process (DBWR). This event indicates a checkpoint. The checkpoint process is responsible for signaling DBWR at checkpoints and updating all of the datafiles and control files of the database. - LGWR process manages the writing of the contents of the redo log buffer to the online redo log files. LGWR writes the log entries in batch form. The Redo log buffers entries always contain the most up-to-date status of the database. - Arch The Archiver process reads the redo log files once Oracle has filled them and writes a copy of the used redo log files to the specified archive log destination(s). - SMON- process performs instance recovery at the start of the database.

SMON also cleans up temporary segments that are no longer in use

12

Oracle Architecture Contd.,

Directory structure of Oracle (As per SAP standards)

There are the following main structures:


$ORACLE_HOME for Oracle-specific objects with the default directory /oracle/<DBSID>/<Oracle version> $SAPDATA_HOME for SAP-specific objects with the default directory /oracle/<DBSID> Executables with the directory /usr/sap/<SAPSID>/SYS/exe/run Oracle Home directory $ORACLE_HOME/dbs/
spfile<DBSID>.ora: Oracle spfile init<DBSID>.ora: Profile for Oracle init<DBSID>.sap: Profile for BR*Tools cntrl<DBSID>.dbf: Database control file

$ORACLE_HOME/bin/ contains binaries such as oracle, sqlplus, exp, imp rwsr-xr-x ora<dbsid> dba oracle

13

Oracle Architecture Contd.,

Online Redo-Logs directories


- /oracle/<SID>/origlogA/
log_g11m1.dbf log_g13m1.dbf

- /oracle/<SID>/origlogB/
log_g12m1.dbf log_g14m1.dbf

- /oracle/<SID>/mirrlogA/
log_g11m2.dbf log_g13m2.dbf

- /oracle/<SID>/mirrlogB/
log_g12m2.dbf log_g14m2.dbf

SAPData directories
- sapdata1/
cntrl/cntrl<DBSID>.dbf: Database control file system_1/system.data1

- sapdata<n>/
14

Oracle Architecture Contd.,

saparch/ - This directory will have the log files of archive log backup taken with brarchive sapbackup/ - This directory contains the backup log files, brbackup logs Sapcheck/ - This directory contains logs of update statistics, checkdb, cleanup logs, etc saptrace/
- background/
alert_<DBSID>.log: Oracle Alert file *.trc: Oracle trace files

- usertrace/
*.trc: User trace files

oraarch/: Oracle offline redo log files

15

Oracle Architecture Contd.,

Naming conventions of Data Files

The naming conventions are as follows:


- Directory: <SAPDATA_HOME>/sapdata<n>/<tablespace suffix>_<file number> - File: <tablespace suffix>.data<file number>

<tablespace suffix> is the second half of the tablespace name, for example, UNDO for the tablespace PSAPUNDO. <n> is the sequentially assigned number of the SAP directory in which the data file will be stored. <file number> is the sequentially assigned number of the data file in the tablespace. The same number also appears in the subdirectory that is created for each new file in a tablespace. For example, the first data file for PSAPUNDO is called:
- Directory: <SAPDATA_HOME>/sapdata<n>/undo_1 - File: undo.data1

16

Parameter files

Parameter file init<DBSID>.ora file, which is a normal disk file. It is still used for viewing by many SAP transactions, so must be kept up-to-date with the newer spfile (see below). Spfile<DBSID>.ora, which is a new binary server-side parameter file introduced by Oracle, available as part of the standard installation from SAP Web AS 6.40. If your SAP system was upgraded from an older release, you have to create it yourself initially using SQL*Plus because it was not part of older SAP installations.

17

DB startup options

Type

What Happens Database instance is built up Operating system resources are allocated using configuration information stored in the profile init<DBSID>.ora or the spfile.

How

No mount

brspace -f dbstart -s nomount SQL> startup nomount

Mount

Database control files are evaluated. Information about the file structure of the database is read Data files and logs are not yet opened.

brspace -f dbstart -s mount SQL> startup mount

Open

All files in the database system are opened. If required, instance recovery is performed immediately after opening the database. Pending database transactions are ended.

brspace -f dbstart SQL> startup

18

DB shutdown options

Type

What Happens No new database logon possible. After all database user have logged off, the database is closed properly: all files are closed, the database is dismounted, and the instance is shut down. The database is consistent after shutdown. Only the current commands are executed. PMON ends all sessions and performs a rollback of the open transactions. The database is then closed properly (as for a normal shutdown). The database is consistent after shutdown. DBWR and ARCH might require up to 1 hour post-processing time. No new connections are allowed and no new transactions can be started. Oracle waits for all open transactions to finish, then disconnects all users (that is, work processes in the SAP system) and shuts down the database. Emergency database shutdown Users are not logged off and open transactions are not rolled back. The database is not consistent after shutdown. An instance recovery is automatically performed at the next database startup.

How

Normal

brspace -f dbshut -m normal SQL> shutdown

Immediate

brspace -f dbshut -m immediate SQL> shut immediate

Transactional

brspace -f dbshut -m transactional SQL>shut transactional

Abort

brspace -f dbshut -m abort SQL> shut abort

19

Database Modes
Noarchive log mode In this Mode, there will not be any offline redolog files archived. If the database is in noarchive log mode, online redo logs can (and will) be overwritten without making sure they are saved. This implies that a database cannot be recovered even if backups were made. Archive log mode If the database is in archive log mode, the database makes sure that online redo logs are not overwritten before the have been archived i.e., online redo logs are archived in this mode

20

Backup Types

Online The starting point of the backup is set using the command ALTER TABLESPACE <tablespace name> BEGIN BACKUP. The header of the tablespace files holds information on the checkpoint and redo log files, that is, the system change number (SCN). When the next redo log file switch or checkpoint occurs (normal database operations continue), the header information remains unchanged. Once the backup of the tablespace is complete, the command ALTER TABLESPACE <tablespace name> END BACKUP makes sure that the header information of the files is updated. Offline After an offline backup of the complete database, you have a backup of the database that is consistent. If you work with the database after the backup, the backup is no longer up-to-date. In this case, you have to recover the database after you restore the backup, using the redo log files.

21

Backup types Contd.,

Online_cons
- In this backup, the archive logs generated during the backup are also taken

22

Backup Types Contd.,

Whole backup

Backs up all database files, but this backup is not cataloged as a level-0 backup, which means that you cannot use it as a reference backup for an incremental backup with RMAN. The syntax for a whole backup is as follows:
- In profile init<DBSID>.sap: backup_mode = all - With BRBACKUP: brbackup -m all

Full backup
Backs up all database files. You can perform a full backup with or without RMAN. If you do not use RMAN, then RMAN is called separately to catalog the backup as level 0. This means that you can use this backup as a reference backup for an incremental backup with RMAN. The syntax for a full backup is:
- In profile init<DBSID>.sap: backup_mode = full - With BRBACKUP: brbackup -m full

In the context of the Recovery Manager this backup is an incremental level-0 backup

23

Backup types Contd.,

Incremental backup To be able to make an incremental backup, we must first make a full backup (level 0). A full backup of the database backs up all Oracle database blocks that have already been used to store data. We can then make incremental backups. An incremental backup (level 1, cumulative) of the database backs up all Oracle database blocks that have changed since the last full backup (level 0).

24

Limitations of Oracle

Maximum number of files per database - DB_FILES


- Soft limit
The SAP software value for DB_FILES is 254.

- Hard limit
The hard limit for DB_FILES depends on the operating system but is usually 1022 per tablespace and 65533 per database.

The Maximum data file size depends Operation System Minimum Oracle 10.2 patchset is 10.2.0.2
- Oracle 10.2.0.1 is an UNSUPPORTED version - 10.2.0.3 is not supported in SAP environments

Oracle version 9.2 left Oracle Customer Care support end July 2008
- SAP customers who use Oracle 9.2 after 31 July 2010 will be affected regardless of where they purchased the Oracle license (from SAP or Oracle)

Oracle version 10.1 left Oracle Customer Care support end Jan 2009

25

SAPs Oracle support end dates

26

Troubleshooting Tips

Alert log file - Oracle's alert.log chronologically records messages and errors arising from the daily database operation.
- The directory where it is found can be determined by the background_dump_dest initialization parameter - The naming convention of the alert log file is alert_<SID>.log

DB connectivity
- The db connectivity can be test with SAP program; R3trans (R3trans is used to transport data between SAP Systems and for the migration between different SAP releases. ) - To test the connectivity;
R3trans x or R3trans d (this will logon to the database and check for the connectivity with SAP and DB)

27

28

References

http://Help.sap.com http://en.wikipedia.org http://service.sap.com http://sdn.sap.com/irj/dba

29

Kishore Soma Engineer SAP BASIS Team GSMC Wipro Ltd (Infotech Div.)

You might also like