Introduction To Oracle: Opera Global Technical Services
This document provides an introduction to Oracle, including its architectural components and how it works. It discusses the Oracle instance, database, and storage structures like datafiles and tablespaces. It also summarizes key components like the System Global Area (SGA) and background processes, and how the CREATE DATABASE command is used.
Download as PPT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
198 views
Introduction To Oracle: Opera Global Technical Services
This document provides an introduction to Oracle, including its architectural components and how it works. It discusses the Oracle instance, database, and storage structures like datafiles and tablespaces. It also summarizes key components like the System Global Area (SGA) and background processes, and how the CREATE DATABASE command is used.
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 91
Introduction to Oracle
Prepared by: Shayne Capo
Senior Database Administrator Opera Global Technical Services
Opera Global Technical Services Opera Global Technical Services Oracle Architectural Components Opera Global Technical Services Architectural Components There are several files, processes and memory structures in an Oracle Server. Some of them are used when processing a SQL statement (or manipulating an application like Opera). Others are used to improve the performance of the database, ensure that the database can be recovered in the event of a software or hardware error, or perform other tasks necessary to maintain the database. The Oracle server consists of: Oracle Instance Oracle database Opera Global Technical Services Oracle Server
Opera Global Technical Services Oracle instance A combination of background processes and memory structures that access an Oracle database Instance must be started before accessing the database Every time started, a System Global Area (SGA) is allocated and Oracle background processes are started Background processes perform functions on behalf of the invoking process They consolidate functions that would otherwise be handled by multiple Oracle programs running for each user Always opens one and only one database Opera Global Technical Services Oracle Instance Opera Global Technical Services Oracle database service Opera Global Technical Services Oracle Database The physical structure consists of 3 file types + other file structures
Opera Global Technical Services Opera Global Technical Services Overview of Primary Components System Global Area (SGA) Shared Pool Database Buffer Cache Redo Log Buffer Cache Large Pool Background Processes Program Global Area (PGA)
Opera Global Technical Services System Global Area (SGA) The SGA consists of several memory structures Shared pool Database buffer cache Redo log buffer Other structures (e.g. lock latch management, statistical data)
There are two optional memory structures that can be configured within the SGA Large Pool Java pool Opera Global Technical Services Shared Pool Used to store the most recently executed SQL statements Consists of two key performance related memory structures Library cache Stores information about the most recently used SQL PL/SQL statements Enables the sharing of commonly used statements Managed by Least Recently Used (LRU) algorithm Data Dictionary cache Collection of the most recently used definitions in the database Includes information about database files, tables, indexes, columns, users, priviliges and other database objects During parse phase, the server process looks at the data dictionary for information to resolve object names and validate access Caching the data dictionary information into memory improves response time on queries SHARED_POOL_SIZE determines size
Opera Global Technical Services Database Buffer Cache The database buffer cache stores copies of data blocks that have been retrieved from the data files It enables great performance gains on selects and updates Managed trhough Least Recently Used (LRU) algorithm Consists of: DB_CACHE_SIZE DB_KEEP_CACHE_SIZE DB_RECYCLE_CACHE_SIZE
Opera Global Technical Services Large Pool Optional area of memory in the SGA configured only in a shared server environment LARGE_POOL_SIZE
Services the parsing requirements for Java commands Required when installing and using Java (the Opera application does) JAVA_POOL_SIZE Java Pool Opera Global Technical Services Redo Log Buffer Cache Records all changes made to the database data blocks Primary purpose is recovery Changes recorded within are called redo entries Redo entries contain information to reconstruct or redo changes
In Oracle Database 10g, Automatic Shared Memory Management (ASMM) feature is introduced to automatically determine the size of Database buffer cache (default pool), Shared pool, Large pool and Java pool by setting the parameter SGA_TARGET. SGA_TARGET Opera Global Technical Services Overview of Primary Components Opera Global Technical Services Background Processes The relationship between the physical and memory structures is maintained and enforced by Oracles background processes Mandatory processes: DBWn PMON CKPT LGWR SMON Optional processes: ARCn Dnnn Snnn Pnnn LCKn QMNn LMON LMDn RECO
Opera Global Technical Services Database Writer (DBWn) DBWn writes when: Checkpoint occurs Dirty buffers reach threshold There are no more free buffers Tablespace OFFLINE, READ ONLY, BEGIN BACKUP Table DROP, TRUNCATE Timeout Opera Global Technical Services Log Writer (LGWR) LGWR writes: At Commit When 1/3 of the Log Buffer is full Before DBWn writes to the datafiles When 1MB of redo is generated Every 3 seconds Opera Global Technical Services System Monitor (SMON) Responsible for: Instance recovery Rolling forward Opening the database Rolling back Coalescing free space Deallocating temporary segments Opera Global Technical Services Process Monitor (PMON) Cleans up after failed processed by: Rolling back the transaction Releasing locks Releasing resources reserved for the user Restarting dead dispatchers Opera Global Technical Services Checkpoint (CKPT) Responsible for: Signaling DBWn at checkpoints Updating datafile headers Updating control files Reducing time to recover Ensure committed data is written to disk Opera Global Technical Services Archiver (ARCn) Responsible for: Optional background process Automatically archives online redo logs when running in ARCHIVELOG mode Opera Global Technical Services
Opera Global Technical Services Oracle Storage Structures
Opera Global Technical Services Physical vs. Logical
Opera Global Technical Services Datafiles A datafile is a physical structure Can hold data for only one tablespace Can resize dynamically Space allocated upon creation Opera database datafiles: System01.dbf, sysaux01.dbf, tempseg01.dbf, undotbs01.dbf, findata01.dbf, finindx01.dbf, logdata01.dbf, logindx01.dbf, namedata01.dbf, nameindx01.dbf, opera_data01.dbf, opera_indx01.dbf, oxi_data01.dbf, oxi_indx01.dbf, quickdata01.dbf, quickindx01.dbf, ratedata01.dbf, rateindx01.dbf, resvdata01.dbf, resvindx01.dbf, tools01.dbf Opera Global Technical Services Tablespaces Largest logical unit Can reside in one or more datafiles May contain one or more segments Can be taken offline Can be made readonly (SYSREAD) OPERA database tablespaces: system, sysaux, tempseg, undotbs, findata, finindx, logdata, logindx, namedata, nameindx, opera_data, opera_indx, oxi_data, oxi_indx, quickdata, quickindx, ratedata, rateindx, resvdata, resvindx, tools
Opera Global Technical Services Logical Overview SEGMENTS Second largest logical unit Can belong to only one tablespace, but can reside in multiple datafiles Is made up of one or more extents EXTENTS Third largest logical unit Can belong to only one segment and cannot spawn datafiles Is made up of contiguous Oracle Blocks When segments grow, new extents are added BLOCKS Smallest logical unit Can belong to only one extent Corresponds to one or more operating system blocks DB_BLOCK_SIZE=8m in OPERA Opera Global Technical Services
Create Database
Opera Global Technical Services Create Database Command CREATE DATABASE "opera" MAXINSTANCES 32 MAXLOGHISTORY 1 MAXLOGFILES 192 MAXLOGMEMBERS 3 MAXDATAFILES 1024 DATAFILE 'd:\oracle\oradata\OPERA\system01.dbf' SIZE 300M AUTOEXTEND ON NEXT 10240K MAXSIZE 2048M EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE 'd:\oracle\oradata\OPERA\sysaux01.dbf' SIZE 120M AUTOEXTEND ON NEXT 10240K MAXSIZE 2048M DEFAULT TEMPORARY TABLESPACE TEMPSEG TEMPFILE 'd:\oracle\oradata\OPERA\tempseg01.dbf' SIZE 20M reuse AUTOEXTEND ON NEXT 640K MAXSIZE 2048M UNDO TABLESPACE "UNDOTBS1" DATAFILE 'd:\oracle\oradata\OPERA\undotbs01.dbf' SIZE 200M reuse AUTOEXTEND ON NEXT 5120K MAXSIZE 2048M CHARACTER SET UTF8 NATIONAL CHARACTER SET UTF8 LOGFILE GROUP 1 ('d:\oracle\oradata\OPERA\redo01a.log','d:\oracle\oradata\OPERA\redo01b.log') SIZE 102400K, GROUP 2 ('d:\oracle\oradata\OPERA\redo02a.log','d:\oracle\oradata\OPERA\redo02b.log') SIZE 102400K, GROUP 3 ('d:\oracle\oradata\OPERA\redo03a.log','d:\oracle\oradata\OPERA\redo03b.log') SIZE 102400K, GROUP 4 ('d:\oracle\oradata\OPERA\redo04a.log','d:\oracle\oradata\OPERA\redo04b.log') SIZE 102400K, GROUP 5 ('d:\oracle\oradata\OPERA\redo05a.log','d:\oracle\oradata\OPERA\redo05b.log') SIZE 102400K, GROUP 6 ('d:\oracle\oradata\OPERA\redo06a.log','d:\oracle\oradata\OPERA\redo06b.log') SIZE 102400K, GROUP 7 ('d:\oracle\oradata\OPERA\redo07a.log','d:\oracle\oradata\OPERA\redo07b.log') SIZE 102400K, GROUP 8 ('d:\oracle\oradata\OPERA\redo08a.log','d:\oracle\oradata\OPERA\redo08b.log') SIZE 102400K, GROUP 9 ('d:\oracle\oradata\OPERA\redo09a.log','d:\oracle\oradata\OPERA\redo09b.log') SIZE 102400K, GROUP 10 ('d:\oracle\oradata\OPERA\redo10a.log','d:\oracle\oradata\OPERA\redo10b.log') SIZE 102400K; Opera Global Technical Services
Data Dictionary
Opera Global Technical Services Data Dictionary Central to the database Describes the database and all its objects Set of READ ONLY tables and views Maintained by the Oracle Server Stored in the SYSTEM tablespace Owned by SYS Modified by DDL statements Opera Global Technical Services Data Dictionary Provides information about: Logical and physical structures Definitions and space allocations of objects Integrity constraints Users, Roles and Privileges Auditing information Opera Global Technical Services Data Dictionary Views Simplified version of the base tables accessed through public synonyms created with catalog.sql
Base Tables contain information about the database
Simplified version of the base tables
Accessed through public synonyms Opera Global Technical Services Data Dictionary Views Three sets of views, each with a different scope
DBA, ALL, USER views can be accessed only when the database is up and running Examples are: xxx_tables xxx_users xxx_database
Opera Global Technical Services Dynamic Views Virtual tables that gather current database activity from the last database startup database in mounted state Information accessed from memory and control files Synonyms begin with V$ Listed in V$FIXED_TABLE Examples are: V$SESSION V$INSTANCE V$SGA V$VERSION
Opera Global Technical Services
Control File
Opera Global Technical Services Control File Small physical binary file Automatically created at create database Maintains integrity of database Continuously updated Contains database information Belongs to only one database Opera Global Technical Services Control File
A control file contains: Database name Tablespace names Name and location of datafiles and redo log files Current redo log sequence number Checkpoint information Begin and end of undo segment Redo log archive information Backup information (RMAN only) Opera Global Technical Services Control Files initOPERA.ora
################################ #File Configuration ################################ control_files=("d:\oracle\oradata\opera\control01.ctl", "g:\oracle\oradata\opera\control02.ctl") Opera Global Technical Services Create Controlfile Syntax CREATE CONTROLFILE REUSE DATABASE "OPERA" NORESETLOGS NOARCHIVELOG MAXLOGFILES 32 MAXLOGMEMBERS 3 MAXDATAFILES 200 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( 'B:\ORACLE\ORADATA\OPERA\REDO01A.RDO', 'D:\ORACLE\ORADATA\OPERA\REDO01B.RDO' ) SIZE 100M, . . GROUP 10 ( 'B:\ORACLE\ORADATA\OPERA\REDO10A.RDO', 'D:\ORACLE\ORADATA\OPERA\REDO10B.RDO' ) SIZE 100M -- STANDBY LOGFILE DATAFILE 'B:\ORACLE\ORADATA\OPERA\SYSTEM01.DBF', 'B:\ORACLE\ORADATA\OPERA\UNDOTBS01.DBF', 'B:\ORACLE\ORADATA\OPERA\SYSAUX01.DBF', 'B:\ORACLE\ORADATA\OPERA\FINDATA01.DBF', 'B:\ORACLE\ORADATA\OPERA\FINDATA02.DBF', 'B:\ORACLE\ORADATA\OPERA\FININDX01.DBF', 'B:\ORACLE\ORADATA\OPERA\FININDX02.DBF', . . 'B:\ORACLE\ORADATA\OPERA\OPERA_DATA08.DBF', 'B:\ORACLE\ORADATA\OPERA\LOGDATA04.DBF' CHARACTER SET UTF8; Opera Global Technical Services Control File Information about the control file can be obtained by querying the following:
V$CONTROLFILE V$CONTROLFILE_RECORD_SECTION
Opera Global Technical Services
Redo Logs
Opera Global Technical Services Redo Logs Record all changes made to data Provides a means to recover the database Can be organized into groups (multiplexing) Minimum of two groups required
Opera Global Technical Services How Redo Logs Work Written in a cyclic fashion When one group is full LGWR moves to the next group Log switch and checkpoint occurs Opera Global Technical Services Redo Log Information Information about the redo logs can be obtained by querying the following:
V$LOG V$LOGFILE V$LOGHIST V$BACKUP_REDOLOG
Opera Global Technical Services Archived Redo Logs Filled online redo logs can be archived The two advantages are: A backup of the datafiles + redo logs + archive logs can be used to restore the database up to the last committed transaction. The backup can be made online. When running in ARCHIVELOG mode a redo log file cannot be overwritten until Checkpoint has completed Redo Log has been archived By default the database is created in NOARCHIVELOG mode Opera Global Technical Services Archive Parameters Archiving uses the ARCn background process to write the redo logs to archive initOPERA.ora archive parameters: ###################################### # Archive ###################################### #log_archive_dest_1 = "location=D:\oracle\admin\opera\archive mandatory REOPEN=120" #log_archive_format=ARC%S_%R.%T
Opera Global Technical Services Enable Archiving Set initOPERA.ora archiving parameters Mount the database in exclusive mode D:\>sqlplus sys/opera10g as sysdba SQL>Startup mount exclusive
Set the database in ARCHIVELOG mode SQL>ALTER DATABASE ARCHIVELOG;
Startup the database SQL>ALTER DATABASE OPEN;
Opera Global Technical Services
Instance Management
Opera Global Technical Services SQL*Plus Ability to perform DML commands insert, update, delete
Ability to perform DDL commands create, alter, drop
Ability to start and stop the database
D:\>sqlplus sys/opera10g as sysdba Opera Global Technical Services Initialization Files Instance specific Instance parameters set explicit or implicit(default) Database name Memory allocation Control file names Undo Segment settings pfile and spfile Comment out parameters # IFILE points to location of pfile initOPERA.ora
Opera Global Technical Services Database States Startup / Open (Database open) Shutdown (Database closed) Nomount (Instance started) Mount (Control files opened)
Opera Global Technical Services Startup Command STARTUP command:
FORCE: SHUTDOWN ABORT + STARTUP RESTRICT: users with RESTRICTED SESSION only OPEN: (default) enables normal access RECOVER: begin media recovery MOUNT: useful for some recovery scenarios NOMOUNT: useful for some recovery scenarios Opera Global Technical Services Alter Database Startup ALTER DATABASE command:
ALTER DATABASE {MOUNT | OPEN} ALTER DATABASE OPEN [READ WRITE | READ ONLY]
READ WRITE: (default) enables normal access READ ONLY: no redo log will be generated Database required to be in nomount or mount mode.
Opera Global Technical Services Shutdown Command Shutdown command:
Opera Global Technical Services Monitor the Instance alertSID.log file: Records results of major events Very useful for diagnosing database errors alertOPERA.log Each entry has a timestamp Located in BACKGROUND_DUMP_DEST Trace files in USER_DUMP_DEST
Opera Global Technical Services initOPERA.ora Default for OPERA:
######################################### # Diagnostics and Statistics ######################################### background_dump_dest=D:\oracle\admin\opera\bdump core_dump_dest=D:\oracle\admin\opera\cdump max_dump_file_size=4096 user_dump_dest=D:\oracle\admin\opera\udump
Opera Global Technical Services Tablespaces And Datafiles
Opera Global Technical Services Tablespaces and Datafiles All objects in the database are stored logically in TABLESPACES and physically in DATAFILES
TABLESPACES: - Belong to only one Database - Consist of one or more Datafiles - Are divided in Segments, Extents and Blocks DATAFILES - Belong to only one Tablespace - Physical files on the operating system Opera Global Technical Services Types of Tablespaces SYSTEM Created in create database Contains the data dictionary Contains the System Undo Segment
NON-SYSTEM Eases space administration Separate segments Can aid in controlling user space quotas
Opera Global Technical Services Space Management Locally managed tablespace: Free extents managed in the tablespace A bitmap records free extents
Dictionary-managed tablespace: Free extents managed in the data dictionary Extent allocation or deallocation triggers a DML statement on the data dictionary Opera Global Technical Services Locally Managed Tablespaces Reduced contention on the data dictionary No undo data generation when space allocation or deallocation occurs No coalescing required UNIFORM sized extents are more reusable
CREATE TABLESPACE opera_data DATAFILE g:\oracle\oradata\opera\opera_data01.dbf SIZE 512M AUTOEXTEND ON NEXT 100M MAXSIZE 2048M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M SEGMENT SPACE MANAGEMENT AUTO;
Opera Global Technical Services Dictionary Managed Tablespaces Extents managed in the data dictionary Each segment may have a different storage clause Coalescing required
CREATE TABLESPACE opera_data DATAFILE g:\oracle\oradata\opera\opera_data01.dbf SIZE 512M EXTENT MANAGEMENT DICTIONARY DEFAULT STORAGE (initial 1M NEXT 1M PCTINCREASE 0); Opera Global Technical Services Undo Tablespace Store undo segments Cannot store any other objects Extents are locally managed
Opera Global Technical Services Temporary Tablespace Used for sort operations Cannot store any permanent objects Locally managed extents Tempfiles are always NOLOGGING
Default temporary tablespace define at database creation. Can change the default temporary tablespace ALTER DATABASE DEFAULT TEMPORARY TABLESPACE tempseg; Cannot be taken offline or dropped until a new temporary tablespace is available Opera Global Technical Services Read Only Tablespace The following command makes a tablespace read only:
ALTER TABLESPACE sys_read READ ONLY;
This causes a checkpoint Data within the tablespace is available only for Selects Objects can be dropped
SYS_READ tablespace Opera Global Technical Services Resizing Tablespaces ALTER DATABASE ALTER TABLESPACE Can change the size of a tablespace by: Alter the size of the datafile Alter the datafile to have AUTOEXTEND turned on Add a datafile ALTER DATABASE DATAFILE g:\oracle\oradata\opera\opera_data01.dbf RESIZE 4096m; ALTER DATABASE DATAFILE g:\oracle\oradata\opera\opera_data01.dbf AUTOEXTEND ON NEXT 100m MAXSIZE 4096m; ALTER TABLESPACE opera_data ADD DATAFILE g:\oracle\oradata\opera\opera_data02.dbf size 2048m;
Opera Global Technical Services Moving or Renaming Datafiles Shutdown the database Physically on the OS move the datafile Startup mount the database Execute: ALTER DATABASE RENAME FILE g:\oracle\oradata\opera\opera_data01.dbf TO h:\oracle\oradata\opera_data01.dbf; Open the database Opera Global Technical Services Tablespace Information Information about tablespaces and datafiles can be obtained in the following views: Tablespaces DBA_TABLESPACES V$TABLESPACE Datafiles DBA_DATA_FILES V$DATAFILE Temporary files DBA_TEMP_FILES V$TEMPFILE Opera Global Technical Services
32bit and 64bit Architectures
Opera Global Technical Services 32bit Architecture Windows Server 2003
32-bit x86 systems
Mainstream deployments where 64bit applications or drivers are unavailable
Most common on servers with 1-4 processors Opera Global Technical Services 64bit Architecture Windows Server 2003 x64 Editions Gradually replacing 32bit windows as mainstream offering Can combine 32bit and 64bit software
Windows Server 2003 for Itanium-based Systems Intended for the most demanding database and large deployments on 8-way+ Designed for pure 64bit software stacks Opera Global Technical Services 32bit vs. 64bit Memory Limits
Opera Global Technical Services Memory Model Process Memory restrictions 32bit 4GB (Total user & kernel) 64bit 8TB 32bit Windows All instances memory requirements must fit in the 4GB limit 64bit Windows A process has 8TB to play with
Opera Global Technical Services
Opera Global Technical Services 4GB RAM Tuning Increase addressable memory available to the Oracle process by adding the /3GB switch to the boot.ini file:
Reboot server to enable
Opera Global Technical Services Whats wrong with 32bit? Nothing..but 32bits = 4GB per process Use /3GB switch in boot.ini Doing this restricts the OS non-paged pool Certain OS pools get cut in half Opera Global Technical Services Why 64bit? Each thread dedicated user connection
All Oracle memory has to come out of the address space
Options on Windows Windows Itanium First 64bit database on Windows Windows x64 EM64T/Opteron can recompile 32bit to 64bit Opera Global Technical Services
Opera Global Technical Services
OPERA Information
Opera Global Technical Services OPERA Commands sqlplus opera/opera Select * from installed_app; select license_code from installed_app_licenses; ALTER USER user_name IDENTIFIED BY new_password; DROP USER user_name [CASCADE];
Opera Global Technical Services OPERA File Locations alertOPERA.log G:\oracle\admin\opera\bdump Arvhive logs D:\oracle\admin\opera\archive Control Files D:\oracle\oradata\opera\control01.ctl G:\oracle\oradata\opera\control02.ctl OPERA datafiles :\oracle\oradata\opera\<datafile_name>.dbf
Opera Global Technical Services OPERA Memory Settings initOPERA.ora memory settings:
#LARGE / CUSTOM (2GB+ of Memory) Shared_pool_size = 262144000 db_cache_size = 256m pga_aggregate_target=512m Opera Global Technical Services Daylight Savings Time
Opera Global Technical Services DST Changes The Energy Policy Act of 2005 was signed into law in August 2005 to extend daylight saving time.
Beginning in 2007, daylight saving time in the U.S. will begin on the second Sunday in March and end the first Sunday in November rather than beginning on the first Sunday in April and ending the last Sunday in October, as it did in the past.
Under the new rules for 2007, DST will start on March 11, 2007 end on November 04, 2007. As a result the database may report incorrect time zone data between 03/11/2007 04/01/2007 and between 10/28/2007 11/04/2007 (and on different dates in subsequent years), unless the required patches are applied. Opera Global Technical Services What is the database timezone? The database time zone is not as important as it sounds. First of all it does not influence functions like sysdate, or systimestamp. These function take their contents (date and time, and in the case of systimestamp also time zone) completely from the OS without any "Oracle" intervention.
The only function of the database time zone is that it functions as a time zone in which the values of the "TIMESTAMP WITH LOCAL TIME ZONE" (TSLTZ) datatype are normalized when they are stored in the database.
However, these values are always converted into the session time zone on insert and retrieval, so the actual setting of the database time zone is more or less immaterial. Opera Global Technical Services DST Patch Who needs the DST patch? ONLY locations where the database is not in the same time zone as the hotel would be affected. Mostly larger sites will be impacted, like Candlewood datacenter. All sites just need to make sure they have the OS patches/updates applied. The patch is applied to the database. It replaces two files and requires the database to be restarted. The patch is included in the Micros 403 database CD. Opera Global Technical Services