OCA 06 - Managing Database Storage Structures

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 49

06 - Managing Database Storage Structures

By Muhammad Asghar Khan


Reference: OCA Oracle Database 11g - Admin I Exam Guide by John Watson

1/3

Agenda

Understand Tablespaces and Datafiles

Tablespaces Segment Oracle Block Extents Data Files OS Block Exersice 6-1: Segments, Extents, Blocks

Oracle-Managed Files (OMF) Automatic Storage Management (ASM)



2

Local File System Clustered File System


http://asghars.blogspot.com

2/3

Agenda

Raw Devices ASM Devices

EXERCISE 6-2 Document a Databases Physical Structure Create and Manage Tablespaces

Types of tablespaces Tablespace extent management Tablespace segment management Create Tablespace Taking a Tablespace Online or Offline Rename a Tablespace and Its Datafiles Mark a Tablespace as Read Only Resizing a Tablespace Changing Alert Thresholds Dropping Tablespaces
http://asghars.blogspot.com

3/3

Agenda

EXERCISE 6-3: Create, Alter, and Drop Tablespaces Extent Management Segment Management Manual Management EXERCISE 6-4: Change Tablespace Characteristics

Manage Space in Tablespaces


http://asghars.blogspot.com

1/6

Understand Tablespaces and Datafiles

Data is stored logically in segments and physically in datafiles The separation of logical from physical storage is a necessary part of the relational database paradigm Figure shows the Oracle storage model sketched as ERD
5 http://asghars.blogspot.com

2/6

Understand Tablespaces and Datafiles

Tablespaces

There is a many-to-many relationship b/w segment & datafile The tablespace resolves the many-to-many relationship b/w segments and datafiles One tablespace can contain many segments and be made up of many datafiles This means that any one segment may be spread across multiple datafiles, and any one datafile may contain all of or parts of many segments Tablespaces are identified by name, unique in the database
http://asghars.blogspot.com

3/6

Understand Tablespaces and Datafiles

Segment

Represents any database object that stores data and therefore requires space in a tablespace Typical segment is a table, but there are other segment types, notably index segments and undo segments Any one segment can exist in only one tablespace, but the tablespace can spread it across all the files making up the tablespace Segments are schema objects, identified by the segment name qualified with the owning schema name
http://asghars.blogspot.com

4/6

Understand Tablespaces and Datafiles

Oracle Block

Datafiles are formatted into Oracle blocks, consecutively numbered The size of the Oracle blocks is fixed for a tablespace; the default (with release 11g) is 8 KB The size of an Oracle block can range from 2 KB to 16 KB on Linux or Windows, to 32 KB on some other operating systems It is the unit of I/O for the database The block size is controlled by the parameter DB_BLOCK_SIZE
http://asghars.blogspot.com

5/6

Understand Tablespaces and Datafiles

Extents

An extent is a set of consecutively numbered Oracle blocks within one datafile Managing space one block at a time would be a crippling task, so blocks are grouped into extents Every segment will consist of one or more extents, consecutively numbered

Data File

Datafile is, physically, made up of a number of operating system blocks


http://asghars.blogspot.com

6/6

Understand Tablespaces and Datafiles


Datafiles and the operating system blocks are entirely dependent on the operating systems file system The alternatives to file systems for datafile storage are raw devices or ASM Raw devices are now very rarely used for datafile storage because of manageability issues

OS Block

An operating system block is the unit of I/O for your file system The operating system block size is configurable for some file systems (for example, when formatting an NTFS file system you can choose from 512 B to 64 KB), but typically system administrators leave it on default (512 B for NTFS, 1 KB for ext3) The configuration that should always be avoided would be where the operating system blocks were bigger than the Oracle blocks
http://asghars.blogspot.com

10

1/3

Exersice 6-1: Segments, Extents, Blocks


1.

Identify the segment types

2.
i.
11

Identify precisely where a segment is


First creates the table HR.NEWTAB
http://asghars.blogspot.com

2/3

Exersice 6-1: Segments, Extents, Blocks


ii.

Query DBA_EXTENTS to find the segment and extent

iii.

Two extent is in file number 4 and each is 8 blocks long Force Oracle to allocate another extent to the segment
http://asghars.blogspot.com

12

3/3

Exersice 6-1: Segments, Extents, Blocks


iv.

Query shows that this new extent

v.

Determine the name of the file in which the extents were allocated, and the name of the tablespace to which the datafile belongs

13

http://asghars.blogspot.com

1/1

Oracle-Managed Files (OMF)

Use of OMF is intended to remove the necessity for the DBA to have any knowledge of the file systems To enable OMF, set some or all of these instance parameters:

DB_CREATE_FILE_DEST DB_CREATE_ONLINE_LOG_DEST_1 DB_CREATE_ONLINE_LOG_DEST_2 DB_CREATE_ONLINE_LOG_DEST_3 DB_CREATE_ONLINE_LOG_DEST_4 DB_CREATE_ONLINE_LOG_DEST_5 DB_RECOVERY_FILE_DEST

OMF will generate filenames and (by default) set the file sizes
14 http://asghars.blogspot.com

1/6

Automatic Storage Management (ASM)

Datafiles can exist on four types of device: local file systems, clustered file systems, ASM disk groups, and raw devices Local File System

Files exist as normal operating system files in a directory structure on disks directly attached to the computer running the instance These could be internal IDE or SATA drives or more sophisticated SCSI disks, or external drives

15

http://asghars.blogspot.com

2/6

Automatic Storage Management (ASM)

Clustered File System


A clustered file system is external disks, mounted concurrently on more than one computer Clustered file systems can be bought from operating system vendors, or Oracle Corporations OCFS (Oracle Clustered File System) is an excellent alternative It is possible to create datafiles on disks with no file system at all In old days before clustered file systems or ASM), raw devices were the only way to implement a Parallel Server database Parallel Server itself was replaced with RAC in database release 9i http://asghars.blogspot.com

Raw Devices

16

3/6

Automatic Storage Management (ASM)

ASM Devices

ASM is a facility introduced with database release 10 g ASM is a logical volume manager designed for Oracle database files It cannot be used for the Oracle Home, or for the alert log and trace files To set up ASM, the system administrators must provide the physical volumes. These can be actual disks, partitions of disks, or devices provided by a SAN (storage area network) or some form of network-attached storage (NAS) ASM is covered in detail in the second OCP examination
http://asghars.blogspot.com

17

4/6

Automatic Storage Management (ASM)

The DBA then groups these physical volumes (known as ASM disks) into logical volumes (known as ASM disk groups) The disk groups are formatted into allocation units, which are contiguous blocks of space on a physical volume The default allocation unit size is 1 MB, but this can be increased up to 64 MB if the nature of the application is such (typically, a data warehouse) that it would benefit from this Every file created on an ASM disk group will always be striped across all the ASM disks that make up the group
http://asghars.blogspot.com

18

5/6

Automatic Storage Management (ASM)


Mirroring is also enabled by default If a volume group consists of just two disks and a third is added, ASM will automatically launch a rebalance operation to bring it into use by restriping the ASM files Similarly, if a disk leaves the group, the disk group will immediately rebalance itself to reinstantiate lost mirrors A key feature of ASM is that it can work as a clustered file system Figure on next slide sketches the ASM structures as an entity-relationship diagram
http://asghars.blogspot.com

19

6/6

Automatic Storage Management (ASM)

20

http://asghars.blogspot.com

EXERCISE 6-2 Document a Databases Physical Structure


1.

1/2

Determine the name and size of the controlfile(s)

2.

Determine the name and size of the online redo log file members

21

http://asghars.blogspot.com

EXERCISE 6-2 Document a Databases Physical Structure


3.

2/2

Determine the name and size of the datafiles and the tempfiles

22

http://asghars.blogspot.com

1/12

Create and Manage Tablespaces

All databases must have a SYSTEM tablespace and a SYSA UX tablespace, and (for practical purposes) a temporary tablespace and an undo tablespace Subsequently, the DBA may create many more tablespaces for user data, and possible additional tablespaces for undo and temporary data Types of tablespaces

Permanent

A permanent tablespace stores regular schema objects, such as tables and indexes We can also enable the encryption for permanent tablespace
http://asghars.blogspot.com

23

2/12

Create and Manage Tablespaces

Temporary

Temporary tablespaces are used to store the temporary tables, temporary indexes and intermediate sort results Undo tablespace stores only system-managed undo segments

Undo

Tablespace extent management

Dictionary Managed

Dictionary managed tablespaces are managed by the data dictionary This is for backward compatibility; it is recommended that you use locally managed tablespaces

24

http://asghars.blogspot.com

3/12

Create and Manage Tablespaces

Locally Managed

Locally managed tablespaces are managed via bitmaps

Extent allocation be automatic or uniform by specifying the size Segement management for a tablespace can be automatic or manual Automatic segment management offers high performance for free space managemen

Tablespace segment management

25

http://asghars.blogspot.com

4/12

Create and Manage Tablespaces

Create Tablespace

To create a tablespace with EM Database Control, navigate Home Page Server Tab Storage Section Tablespaces linkCreate Button The Create Tablespace window prompts for a tablespace name, and the values for Extent Management, Type, and Status

26

http://asghars.blogspot.com

5/12

Create and Manage Tablespaces

The Add button lets you specify one or more datafiles for the new tablespace. Each file must have a name and a size, and can optionally be set to autoextend up to a maximum file size

27

http://asghars.blogspot.com

6/12

Create and Manage Tablespaces

The Storage tab gives access to options for extent management and compression

28

http://asghars.blogspot.com

7/12

Create and Manage Tablespaces

Taking a Tablespace Online or Offline

An online tablespace or datafile is available for use; an offline tablespace or datafile exists as a definition in the data dictionary and the controlfile but cannot be used In EM on tablespaces page select newtab and clicke Edit button Select Offline from Status section and click Apply
http://asghars.blogspot.com

29

8/12

Create and Manage Tablespaces

Rename a Tablespace and Its Datafiles


A tablespace can be renamed while it is in use, but to rename a datafile, the datafiles must be offline In edit mode on General tab you can change the name for tablespace and click Apply

To rename datafile

30

http://asghars.blogspot.com

9/12

Create and Manage Tablespaces

Mark a Tablespace as Read Only


Making a tablespace read only, none of the objects within it can be changed with DML statements Making a tablespace read only can have advantages for backup and restore operations

Resizing a Tablespace

A tablespace can be resized either by adding datafiles to it or by adjusting the size of the existing datafiles
http://asghars.blogspot.com

31

10/12

Create and Manage Tablespaces

Changing Alert Thresholds


The MMON process of the instance monitors, how full every tablespace is If a tablespace fills up beyond a certain point, MMON will raise an alert The easiest way to see alerts, is to look at the database home page of Database Control, where they are displayed in the Alerts section To view or change the alert levels, select the tablespace and click the Edit button, then in the Edit Tablespace window take the Thresholds tab The alert system uses the maximum possible size of the tablespace as the basis for its calculations, which is meaningless if the tablespaces datafiles were created with the syntax AUTOEXTEND ON MAXSIZE UMLIMITED, or if a MAXSIZE was not specified
http://asghars.blogspot.com

32

11/12

Create and Manage Tablespaces

When using automatic extension, it is goo d practice to set a maximum limit

33

http://asghars.blogspot.com

12/12

Create and Manage Tablespaces

Dropping Tablespaces

To drop a tablespace, use the DROP TABLESPACE command

34

http://asghars.blogspot.com

1/6

EXERCISE 6-3: Create, Alter, and Drop Tablespaces


1.

Create a tablespace

2.

Create a table in the new tablespace, and determine the size of the first extent

35

http://asghars.blogspot.com

2/6

EXERCISE 6-3: Create, Alter, and Drop Tablespaces


3.

Add extents manually, and observe the size of each new extent

36

http://asghars.blogspot.com

3/6

EXERCISE 6-3: Create, Alter, and Drop Tablespaces


4.

Take the tablespace offline, observe the effect, and bring it back online

37

http://asghars.blogspot.com

4/6

EXERCISE 6-3: Create, Alter, and Drop Tablespaces


5.

Make the tablespace read only, observe the effect, and make it read-write again

38

http://asghars.blogspot.com

5/6

EXERCISE 6-3: Create, Alter, and Drop Tablespaces


6.

Enable OMF for datafile creation and create a tablespace, using the minimum syntax now possible

7.

Determine the characteristics of the OMF file

39

http://asghars.blogspot.com

6/6

EXERCISE 6-3: Create, Alter, and Drop Tablespaces


8.

Adjust the OMF file to have more sensible characteristics

9.

Drop the tablespace, and use an operating system command to confirm that the file has indeed gone

40

http://asghars.blogspot.com

1/5

Manage Space in Tablespaces

Space management in tablespace occuers at the following levels

Tablespace, done by sizing data files (already discussed) Segment, done by allocating extents Row, done by maintaing bitmaps
There are two techniques for managing extent usage: dictionary management or local management Dictionary Management

Extent Management

It uses two tables in the data dictionary SYS.UET$ has rows describing used extents, and SYS.FET$ has rows describing free extents Dictionary management should never be used
http://asghars.blogspot.com

41

2/5

Manage Space in Tablespaces

Local Management

It uses bitmaps stored in each datafile Each bit in the bitmap covers a range of blocks, and when space is allocated, the appropriate bits are changed from zero to one When creating a locally managed tablespace, an important option is uniform size

If you know how big segments are likely to be, UNIFORM SIZE may well be the best option, otherwise Oracle Corporation recommends AUTOALLOCATE
http://asghars.blogspot.com

42

3/5

Manage Space in Tablespaces

If a database has been upgraded from previous versions, it will include dictionary-managed tablespaces Any dictionary-managed tablespaces should be converted to local management with this PL/SQL procedure call

Segment Management

There are two techniques for managing segment space usage: manual or automatic Automatic Management

Automatic Management should always be used


http://asghars.blogspot.com

43

4/5

Manage Space in Tablespaces

In an automatic management every segment created in a tablespace has a set of bitmaps that describe how full each block is There are five bitmaps for each segment, and each block will appear on exactly one bitmap The bitmaps track the space used in bands:
Blocks that are 75% to 100% used Blocks that are 50% to to 75% used Blocks that are 25% to 50% used Blocks that are 0% to 25% used

If the block size is 4 KB and the row to be inserted is 1500 bytes, an appropriate block will be found by searching the 25% to 50% bitmap
http://asghars.blogspot.com

44

5/5

Manage Space in Tablespaces

As rows are inserted, are deleted, or change size through updates, the bitmaps get updated accordingly The old manual space management method used a free list, which stated which blocks were available for insert but without any information on how full they were To see if any tablespaces are using manual management

Manual Management

It is not possible to convert tablespace from manual to automatic segment space management
http://asghars.blogspot.com

45

1/4

EXERCISE 6-4: Change Tablespace Characteristics


1.

Create a tablespace using manual segment space management

2.

Confirm that the new tablespace is indeed using the manual technique

46

http://asghars.blogspot.com

2/4

EXERCISE 6-4: Change Tablespace Characteristics


3.

Create a table and an index in the tablespace. These segments will be created with freelists, not bitmaps

4.

Create a new tablespace that will (by default) use automatic segment space management

47

http://asghars.blogspot.com

3/4

EXERCISE 6-4: Change Tablespace Characteristics


5.

Move the objects into the new tablespace:

6.

Confirm that the objects are in the correct tablespace

48

http://asghars.blogspot.com

4/4

EXERCISE 6-4: Change Tablespace Characteristics


7.

Drop the original tablespace Rename the new tablespace to the original name. This is often necessary, because some application software checks tablespaces names Tidy up by dropping the tablespace, first with this command

8.

9.

49

http://asghars.blogspot.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy