Download presentation
Presentation is loading. Please wait.
1
Introduction To Oracle 10g
Majed Bouchahma
2
Course Objectives Introduction to ORACLE & its products
Introduction to Oracle Architecture - Oracle Physical structure-Data Files, Control Files and Redo Log Files. - Oracle Logical Structure- Tablespaces, Segments, Extents and Blocks - Schema objects-Tables, Sequences, Synonyms, Views - Oracle Memory Structures and Background Processes, Data Dictionary
3
What is Oracle ? Oracle is a relational database management system.
It is a management system which uses the relational data model. In the relational data model, data is seen by the users in form of tables alone. Oracle Server: Is a database management system that provides an open, comprehensive, integrated approach to information management. Consists of an Oracle Instance and an Oracle database
4
Oracle in Industry In today’s world, data is the key for business
Every organization stores its data in multiple databases One of the most widely used database in industry is Oracle Oracle can work on various Operating Systems (Windows, Unix, etc.) The demand for Oracle in today’s world is immense Many projects across the industry use Oracle as back-end for deploying its various applications.
5
Database Architecture - Introduction
Three Major Instances: Database instance File Structure Data Structures Database Instance: Oracle Database consists of Software Modules & Database Files Instance –After the complete installation of Oracle 10g, when you start the Oracle database , then you have what is referred to as an“Oracle 10g Database Instance”. It is the actual execution of DBMS software that manages data in the databases tablespace.
6
Properties Of Database Instance
Created on loading the software from disk to memory. It is an aggregation of processes and memory structures It is sharable thus allowing multiple users to access the same database.
7
Oracle Instance Database Buffer Cache Shared Pool Redo Log Buffer
Large Pool Java Pool DBWn CKPT LGWR SMON RECO Optional PMON ARCn SGA Data Files Control Files Archive Log Files Redo Log Files Server process PGA User process
8
Memory Components and Background Processes
Two Main Components: SGA( System Global Area) -a group of shared memory structures that contain data and control information for one Oracle database instance. -the data in the instance's SGA is shared among the multiple concurrent users. -allocated when you start the database instance. -de-allocated when the instance is shutdown. PGA (Program Global Area) -Each server process has a PGA allocated that is a private area for each server -Work area for each application.
9
SGA Memory Areas Shared pool contains machine-language code and execution plans for frequently used SQL commands. Database Buffer Cache stores data values which are written later to the data files by the database writer (DBWn). Redo Log Buffer stores a copy of the changed data from user transaction. This data is periodically written to the Redo Log Files by the Log Writer (LGWR). Large Pool is a work area given for backup and recovery operations. Java Pool stores the machine-language and execution plans for Java commands used in application programs and database operations.
10
PGA Memory Areas Each server process has a PGA allocated that is a private area for each server. This is the work area for each application. The application code, along with copies of the data, is located here. There are various background processes that support and monitor the server processes. These background processes also handle the data management and keep the database running smooth and efficiently.
11
Processes System Monitor (SMON) :
-general server housekeeping functions. Process Monitor (PMON) : - monitors and manages individual user sessions . -performs database locking/unlocking functions on UPDATE and DELETE query. Database Writer (DBWn) : -writes changed data from the database buffer cache to data files. -an oracle 10G instance can have 10 writer instances DBW0-DBW9. Log Writer (LGWR) : -writes the redo log data from the Redo Log Buffer to the Redo Log Files. -Redo Log files aid in database recovery. -keep track of the database changes whenever they are committed
12
Processes (contd.) Checkpoint (CKPT) :
-responsible for signaling DBWn and LGWR to write the contents of the Database Buffer Cache and the Redo Log Cache to the data files and Redo Log files respectively. Archiver (ARCn) : -reads the Redo Log files after they are filled & copies it to a corresponding Archive Log File. -there can be up to 10 separate archive processes per instance Arc0-Arc9. Recoverer (RECO) : -detect and correct errors as a result of communications problems in a distributed database environment.
13
File Structure- Three Basic Oracle Files
Control Files Redo Log Files Data Files identifies Provides changes to Parameter File 1 2 3
14
Parameter File – the init.ora file
Purpose: - specifies the configuration information about the database instance. The parameters include: Names and locations of the control files Block size Cache sizes Database name Instance name Domain name Is read each time a database instance is started Has a .ora suffix
15
Control Files Purpose:
- contain a list of all other files that make up the database such as data files and Redo Log files. -also contain important information about the contents and operating state of the database. The data includes:- By default, an Oracle 10g database creates three control files,CONTROL01.CTL, CONTROL02.CTL and CONTROL03.CTL and they are mirror images of each other. The name of the database Date the database was created Current state of the database: read-only, need-recovery Database status when last closed Interval covered by each archived redo log Backups performed Since this is a critical file you should have more than one control file and they should be on separate disk drives Have a .ctl suffix
16
Data Files Purpose: -contain the actual data stored in the database.
-contains user data stored in tables + includes indexes, data dictionary, and rollback segments. Characteristics: Data files are composed of Oracle blocks, which are in turn composed of operating system blocks Oracle block sizes range from 2 Kb to 32 Kb – average size is 8 Kb Data files belong to only one database and to only one tablespace within that database Data files are the lowest level of granularity between an Oracle database and the operating system When you map out a database onto the OS I/O sub-systems, the smallest unit you can put in any location is a data file Have a .dbf suffix
17
Redo Log Files Purpose:
- store changes made to the database as a result of transaction and internal Oracle activities. Characteristics: By default, an Oracle 10g database contains three redo log groups, REDO01.log, REDO02.log and REDO03.log Every Oracle 10g database must have at least two redo log groups The database will write log entries to a subsequent redo log group when the previous redo log group fills up As a general rule , there should be one redo log group for approximately every four database users that create action queries Oracle 10g keeps track of the Redo Log file by using a redo log sequence number, this number is recorded inside the file as they are used The redo log sequence number is different than the operating system file name that is used to identify the physical file If the database is in ARCHIVELOG mode full Redo Log files are copied to Archive Log files before they are reused, otherwise they are written over Have a .log suffix
18
Tables / Clusters / Indexes Rows Columns
Storage Architecture Physical storage structures Data files Segments Extents Blocks Logical storage structures Tablespaces Tables / Clusters / Indexes Rows Columns 1. Physical storage structure - Datafile : a physical datafile belonging to a single tablespace - Segment : a set of one or more extents that contains all the data for a specific structure within a tablespace - Extents : a set of contiguous data blocks in a database - Block : multiple physical file blocks allocated from an existing datafile 2. Logical storage structure - Tablespace : a logical repository for physically grouped data - Table / Clusters / Indexes
19
Data Structures Database Instance Tablespaces Segments Extents
Data Blocks Segments
20
Physical Storage Architecture
Relationship among Segments, Extents, and Blocks Extent 24K 2K 72K Segment 96K Database Blocks
21
Logical Storage Architecture
Relationship between tablespaces and datafiles USER Tablespace System Tablespace Database DATA3.ORA DATA1.ORA DATA2.ORA < Tablespace > 1. 각 tablespace는 여러 개의 OS 파일을 가질수 있다. 2. Tablespace는 database가 돌고있는 중에 online할수 있다. 3. SYSTEM, RBS을 제외한 tablespace는 offline 할 수 있다. 4. Read-write <=> Read-only 변환 가능 5. 해당 tablespace에 생성된 오브젝트는 다른 테이블스페이스에 할당되지 않는다. <Tablespace Uses> 1. Controlling space allocation and assign space quotas to users 2. 각 tablespace를 online, offline하여 관리 3. Data storage를 분산하면 I/O 경합이 줄어 효율이 향상될 것이다. 4. 부분 backup과 부분 recovery가 가능하다. 5. Static data에 대해 read-only tablespace로 할 수 있다. < SYSTEM tablespace> 1. Database operation을 위해 필요함 2. Data dictionary 정보, stored procedures/package/trigger 의 definition 3. SYSTEM rollback segment 4. Can contain user data
22
Cont’d Objects stored in tablespaces
INDEX Tablespace (one or more datafiles) Database Files (Physical structures associated with only one tablespace) Objects (stored in tablespace may span serveral datafiles) < Non-system Tablespace > 1. Database 관리상 편하다 2. Rollback segment, temporary segment, application data/index, user space 3. Rollback segment tablespace 4. Temporary Tablespace : 영구적인 data, index는 저장안함, dba가관리 ( V$SORT_SEGMENT ) 5. Resizing datafile (AUTOEXTEND option) 6. Read-only tablespace : online, no active tx, no active rbs, not online backup
23
General Block Information (Block add, Segment type)
85 ~ 100 bytes Table info in Cluster Row info in Block (2 byte per row) using when New Row Insert or Update (pctfree, pctused) Table or Index Data Header Table Dictionary Row Dictionary Free Space Row Data 1. Block의 구조 자세히 - Header : general block information - Table directory : information about the table - Row directory : row information about the actural rows in the block (1row당 2bytes) - Free space : for insert or updates of rows, or for additional transaction entries - Row data : stores table or index data 2. Space Management Parameters - PCTFREE : udpate를 위해 비워두는 공간 (default 10) - PCTUSED : pctused 밑으로 내려가면 freelist에 등록되어 새로운 row insert(40) - INITRANS : block header에 처음 할당되는 tx entries의 개수 (각 tx entry는 23bytes) - MAXTRANS : block에 동시에 access할 수 있는 tx 의 개수 (255개까지) block 의 free space 를 사용한다. 즉, tx이 많을 경우 pctfree를 늘린다 3. Chaning and Migration - Analyze table table_name list chained rows; - utlchain.sql (create chained_rows)
24
PCTFREE / PCTUSED PCTFREE PCTUSED 20% Free space 61% Free space
1. PCTFREE ={ (max# bytes per rows) - (#bytes inserted per rows) } / (max# of bytes per row) * 100 2. default : pctree 10, pctused 40 3. pctfree + pctused < 100 (90% recommanded) 4. Example (1) Setting a Lower PCTFREE - block Enhances the rate of use (reduces the number of blocks that will be used) - block reorg로 인해 process cost가 는다 - row migration 가능성이 높다 (2) Setting a Higer PCTFREE - update를 위해 여유공간을 많이 둔다 (사용될 블럭의 수가 많이든다) - block reorg가 필요없어서 process cost가 적다 - chain row를 줄일수 있다 (3) Setting a Lower PCTUSED - block이 free될 가능성이 작아 process cost를 줄인다 - unused space가 많아 진다 (4) Setting a Higher PCTUSED - block이 free될 가능성이 높아 process cost가 는다 - space usage가 높아진다 PCTFREE = 20 PCTUSED = 40 Insert new row until 80% 20% use when Update Can insert new row when below 60% When Usage is below 40% (61% Free space), block is listed in FREELIST
25
A set of contiguous database blocks within a datafile.
Extent A set of contiguous database blocks within a datafile. Extent are allocated when. - The segment is created (INITIAL EXTENT) - The segments grows (NEXT EXTENT) - The table is altered to allocate extents. Extent are de-allocated when the - The segment is dropped and truncated. - The segment is larger than optimal and contains free extents (for rollback segments only) Each segment is created with at least one extend( initial extent ) ( Rollback segment : 2) ALTER TABLE table_name DEALLOCATE UNUSED 1. Storage Parameter - INITIAL : 5 blocks NEXT : 5blocks MAXEXTENTS - MINEXTENTS PCTINCREEASE OPTIMAL - FREELISTS FREELIST GROUPS(OPS) 2. Storage Parameter가 쓰이는 곳 - table, clusters, indexes, rollback segments, tablespaces(default setting only) 3. Object level > tablspace level > system level 4. initial -> next -> next*(1+pctincrease/100)
26
Segment a set of one or more extents that contains all the data for a specific type of logical storage structure within a tablespace Data Segment - A collection of extents that holds all of the data for a table or a cluster Index Segment - A collection of extents that holds all of the index data for search optimization on large tables and clusters Rollback Segment - A collection of extents that holds rollback data for rollback, read-consistency, or recovery Temporary segment - A collection of extents that holds data belonging to temporary tables created during a sort operation Bootstrap segment - An extent that contains dictionary definitions for dictionary tables to be loaded when the database is opened. 1. 각각의 Segment 역할
27
TABLESPACE SEGMENT EXTENTS and DATA BLOCKS
Tablespace is used to store related database objects. One tablespace is used to store all of the system tables; another tablespace may be created for all indexes or a tablespace may be created to store all of the tables for a specific application. The idea is to store data that has something in common or has similar characteristics. The database server stores the data in each tablespace in data files with .dbf extensions. Segments are used to organize tablespace data within a tablespace. A segment stores an individual database object like a table or index. Extents are contiguous units of storage, usually disk space, within a segment. Oracle uses extents for performance reasons by storing data that needs to be retrieved in a single disk I/O. An extent is made up of multiple data blocks Data Blocks are the smallest unit of Oracle database storage. Oracle 10g stores 8,192 bytes (8K) in one data block. A data block is comprised of multiple operating system blocks. Depending on the operating system an operating system block can store 512 to 4K bytes. A data block contains header, directory and row data: Block Header - operating system block address Table Directory - identifies the database table for which the following data belongs Row Directory - identifies the database rows for which the data belongs Row Data - stores the actual row values
28
Thank You…. Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.