41
1 Copyright © 2007, Oracle. All rights reserved. Database Architecture and ASM

Les 01 Arch

Embed Size (px)

DESCRIPTION

Oracle DBA Interview Questions and Answers, CBT, Oracle E-books, Certifications http://oracledba-interview.blogspot.com

Citation preview

Page 1: Les 01 Arch

1Copyright © 2007, Oracle. All rights reserved.

Database Architecture and ASM

Page 2: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 2

Objectives

After completing this lesson, you should be able to:

• Describe the Oracle Database architecture

• Describe Automatic Storage Management (ASM)

• Set up initialization parameter files for ASM and database instances

• Start up and shut down ASM instances

• Administer ASM disk groups

Page 3: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 3

The Oracle Database

The Oracle Relational Database Management System (RDBMS) is a database management system that provides an open, comprehensive, integrated approach to information management.

Page 4: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 4

Database

Data filesOnline redo

log filesControl

files

Oracle Database Architecture: Overview

Databasebuffercache

Shared pool

Data dictionarycache

Librarycache

PMONSMON Others

Serverprocess

PGA

Archived log files

Userprocess

Instance

ARCn

SGA

DBWn

Redo logbuffer

LGWRCKPT

Page 5: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 5

Connecting to the Database

• Connection: Communication between a user process and an instance

• Session: Specific connection of a user to an instance through a user process

SQL> Select … Session

Connection

USERUser

Page 6: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 6

Database

Oracle Database Server Structures

PMONSMON Others

Data filesOnline redo

log filesControl

files

Instance

ARCn DBWn LGWRCKPT

Storage structures

Userprocess

Serverprocess

Memory structures

Processes

Databasebuffercache

Shared pool

Data dict.cache

Librarycache

SGA

Redo logbuffer

Page 7: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 7

Oracle Memory Architecture

SGA

Database buffercache

Redo log buffer

Java pool

Streams pool

Shared pool

Large pool

PGA PGA PGA Background

processServer

process 1Server

process 2

Shared SQL area

Library cache

Data Dictionary cache

Other

I/O Buffer

Response queue

Request queue

Free memory

Page 8: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 9

Process Architecture

• User process:– Is started when a database user or a batch process connects

to Oracle Database

• Database processes– Server process: Connects to the Oracle instance and is

started when a user establishes a session– Background processes: Are started when an Oracle instance

is started

PMONSMON Others

Instance

ARCn DBWn LGWRCKPT

PGA

Userprocess

Serverprocess Background processes

Databasebuffercache

Shared pool

Data dictionarycache

Librarycache

SGA

Redo logbuffer

Page 9: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 10

Process Structures

…Server n processes

SGA

…Oracle background processes

PMON SMON Others RECO ARCn DBWn LGWRCKPT

Server ServerServerServer Server

Databasebuffercache

Shared pool

Data dict.cache

Librarycache

SGA

Redo logbuffer

Page 10: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 12

Database Storage Architecture

Online redo log files

Password file

Parameter file Archived redo log files

Control files Data files

Alert log and trace files

Backup files

Page 11: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 14

Logical and Physical Database Structures

Database

Logical Physical

Tablespace Data file

OS block

Segment

Extent

Oracle datablock

Schema

Page 12: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 16

Tablespaces and Data Files

• Tablespaces consist of one or more data files.

• Data files belong to only one tablespace.

USERS tablespace

Data file 1 Data file 2

Page 13: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 17

SYSTEM and SYSAUX Tablespaces

• The SYSTEM and SYSAUX tablespaces are mandatory tablespaces.

• They are created at the time of database creation.

• The SYSTEM tablespace is used for core functionality (for example, data dictionary tables).

• The auxiliary SYSAUX tablespace is used for additional database components (such as the Enterprise Manager Repository).

Page 14: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 18

Segments, Extents, and Blocks

• Segments exist within a tablespace.

• Segments are made up of a collection of extents.

• Extents are a collection of data blocks.

• Data blocks are mapped to disk blocks.

Segment Extents Data blocks

Disk blocks

Page 15: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 19

Database Architecture:Summary of Structural Components

• Memory structures:– System Global Area (SGA): Database buffer cache, redo

buffer, and various pools– Program Global Area (PGA)

• Process structures:– User process and server process– Background processes: SMON, PMON, DBWn, CKPT,

LGWR, ARCn, and so on

• Storage structures:– Logical: Database, schema, tablespace, segment, extent, and

Oracle block– Physical: data files, control files, and redo log files

Page 16: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 20

Automatic Storage Management:Review

• Portable and high-performance cluster file system

• Manages Oracle database files

• Data spread across disksto balance load

• Integrated mirroring acrossdisks

• Solves many storage management challenges

ASM

Filesystem

Volumemanager

Operating system

Application

Database

Page 17: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 22

ASM: General Architecture

ASM instance

SID=+ASM

ASM disks ASM disks

ASM disk group 1

DB instance

SID=SALES

ASMBRBAL

ARB0

ARBA

ASM disks ASM disks ASM disks

ASM disk group 2

ASM disks

DBW0

RBAL

FG

GMON

Page 18: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 23

Creating an ASM Instance

Page 19: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 24

ASM Instance Initialization Parameters

INSTANCE_TYPE = ASM

DB_UNIQUE_NAME = +ASM

ASM_POWER_LIMIT = 1

ASM_DISKSTRING = '/dev/rdsk/*s2', '/dev/rdsk/c1*'

ASM_DISKGROUPS = dgroupA, dgroupB

SPFILE = '+DATA/ORCL/orclspfile.ora_1'

Page 20: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 25

Starting Up an ASM Instance

$ export ORACLE_SID='+ASM'

$ sqlplus /nolog

SQL> CONNECT / AS sysasm

Connected to an idle instance.

SQL> STARTUP;

Total System Global Area 284565504 bytes

Fixed Size 1299428 bytes

Variable Size 258100252 bytes

ASM Cache 25165824 bytes

ASM diskgroups mounted

Page 21: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 26

SYSASM Role

• SYSASM role to manage ASM instances avoids overlap between DBAs and storage administrators

• For ASM instances, SYSDBA will be deprecated in the future:– Oracle Database 11g Release 1 behaves as in 10g– In future releases SYSDBA privileges restricted in ASM

instances

SQL> CONNECT / AS SYSASM

SQL> CREATE USER ossysasmusername IDENTIFIED by passwd;

SQL> GRANT SYSASM TO ossysasmusername;

SQL> DROP USER ossysasmusername;

SQL> CONNECT ossysasmusername / passwd AS SYSASM;

Page 22: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 27

Accessing an ASM Instance

Disk group Disk group

Storage system

As SYSASM or SYSDBA

As SYSOPERASM

instance

All operations Limitedoperations

Page 23: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 28

Using Enterprise Manager to Manage ASM Users

Page 24: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 29

Shutting Down an ASM Instance

SHUTDOWN NORMAL

ASM instance

Database instance A Database instance B

1 1

2

3

Page 25: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 30

ASM Storage: Concepts

Database

Tablespace

Segment

Extent

Oracleblock

Data file

Physicalblock

ASMdisk group

ASM disk

ASM file

Allocation unitFile-system

fileor

raw device

Page 26: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 31

ASM Disk Group

• Is a pool of disks managed as a logical unit

• Partitions total disk space into uniform sized units

• Spreads each file evenly across all disks

• Uses coarse- or fine-grain striping on the basis of file type

• Administers disk groups, not files

Disk group

ASMinstance

Page 27: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 33

Failure Group

Controller 1 Controller 2

Failure group 1 Failure group 2

Disk group A

Controller 3

Failure group 3

1 7 13

1 7 131 7 13

1 7 13

1 7 131 7 13

1 7 13

1 7 131 7 13

2

3

4

5

6

Page 28: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 34

Disk Group Mirroring

• Mirror at AU level

• Mix primary and mirror AUs on each disk

• External redundancy:Defers to hardwaremirroring

• Normal redundancy: – Two-way mirroring– At least two failure groups

• High redundancy: – Three-way mirroring– At least three failure groups

Page 29: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 35

Disk Group Dynamic Rebalancing

• Automatic online rebalance wheneverstorage configurationchanges

• Only move data proportional to storage added

• No need for manual I/O tuning

• Online migration tonew storage

• Configurable loadon system using ASM_POWER_LIMIT

Page 30: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 36

Managing Disk Groups

CREATE DISKGROUP

ALTER DISKGROUP

DROP DISKGROUPASMinstance

Database instance

Page 31: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 37

Creating and Dropping Disk Groups

CREATE DISKGROUP dgroupA NORMAL REDUNDANCY

FAILGROUP controller1 DISK

'/devices/A1' NAME diskA1 SIZE 120G FORCE,

'/devices/A2',

'/devices/A3'

FAILGROUP controller2 DISK

'/devices/B1',

'/devices/B2',

'/devices/B3';

DROP DISKGROUP dgroupA INCLUDING CONTENTS;

Page 32: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 38

Adding Disks to Disk Groups

ALTER DISKGROUP dgroupA ADD DISK

'/dev/rdsk/c0t4d0s2' NAME A5,

'/dev/rdsk/c0t5d0s2' NAME A6,

'/dev/rdsk/c0t6d0s2' NAME A7,

'/dev/rdsk/c0t7d0s2' NAME A8;

ALTER DISKGROUP dgroupA ADD DISK '/devices/A*';

Disk formatting

Disk group rebalancing

Page 33: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 39

ASM Disk Group Compatibility

• Compatibility of each disk group is separately controllable:– ASM compatibility controls ASM metadata on-disk structure– RDBMS compatibility controls minimum consumer client level– Useful with heterogeneous environments

• Setting disk group compatibility is irreversible.

DB instance

COMPATIBLE.RDBMSCOMPATIBLE

ASM diskgroup

>=<=

COMPATIBLE.ASM

ASM instance

<= COMPATIBLE

Page 34: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 41

ASM Disk Group Attributes

Name Property Values Description

au_size C 1|2|4|8|16|32|64MB Size of allocation units in the disk group

compatible.rdbms AC Valid database version Format of messages exchanged between DB and ASM

compatible.asm AC Valid ASM instance version

Format of ASM metadata structures on disk

disk_repair_time A 0 M to 232 D Length o time before removing a disk once OFFLINE

template.tname.redundancy

A UNPROTECT|MIRROR|HIGH Redundancy of specified template

template.tname.stripe

A COARSE|FINE Striping attribute of specified template

CREATE DISKGROUP DATA NORMAL REDUNDANCY

DISK '/dev/raw/raw1','/dev/raw/raw2'

ATTRIBUTE 'compatible.asm'='11.1';

C: CREATEA: ALTER

Page 35: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 42

Using Enterprise Manager to Edit Disk Group Attributes

Page 36: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 43

Miscellaneous ALTER Commands

Remove a disk from dgroupA:

Add and drop a disk in a single command:

Cancel a disk drop operation:

ALTER DISKGROUP dgroupA DROP DISK A5;

ALTER DISKGROUP dgroupA DROP DISK A6

ADD FAILGROUP fred DISK '/dev/rdsk/c0t8d0s2' NAME A9;

ALTER DISKGROUP dgroupA UNDROP DISKS;

Page 37: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 44

ASMCMD Utility

$ export ORACLE_SID=+ASM

$ asmcmd

ASMCMD> ls -l DGROUP1/ORCL/DATAFILE

Type Redund Striped Time Sys Name

DATAFILE MIRROR COARSE OCT 05 21:00:00 Y HRAPPS.257.570923611

DATAFILE MIRROR COARSE OCT 05 21:00:00 Y TBSASM.256.570922917

ASMCMD>

SQL> CREATE TABLESPACE tbsasm DATAFILE '+DGROUP1' SIZE 100M;

Tablespace created.

SQL> CREATE TABLESPACE hrapps DATAFILE '+DGROUP1' SIZE 10M;

Tablespace created.

Page 38: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 45

ASMCMD Utility

$ asmcmd help

md_backup

md_restore

lsdsk

full

nodg

newdg

User created directoriesTemplatesDisk group compatibilityDisk group nameDisk names and failure groups

ASMCMD> md_backup –b /tmp/dgbackup070222 –g admdsk1 –g asmdsk2ASMCMD> md_restore –t full –g asmdsk1 –i backup_fileASMCMD> lsdsk -k DATA *_0001

repair/remap

Page 39: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 46

ASM Scalability and Performance

• Extent size grows automatically according to file size.

• ASM support variable extents size to:– Raise maximum possible file size– Reduce memory utilization in shared pool

• ASM imposes the following limits:– 63 disk groups in a storage system– 10,000 ASM disks in a storage system– 4 petabyte maximum storage for each ASM disk– 40 exabyte maximum storage for each storage system– 1 million files for each disk group

Page 40: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 48

Summary

In this lesson, you should have learned how to:

• Describe the Oracle Database architecture

• Describe Automatic Storage Management (ASM)

• Set up initialization parameter files for ASM and database instances

• Start up and shut down ASM instances

• Administer ASM disk groups

Page 41: Les 01 Arch

Copyright © 2007, Oracle. All rights reserved.1 - 49

Practice 1 Overview:Database Architecture and ASM

This practice covers the following topics:

• Creating and starting an ASM instance

• Creating and using ASM disk groups

• Managing an ASM instance

• Dynamic disk group rebalancing