26
QUESTIONS ON BACKUP AND RECOVERY 1. What is the value of cold backup? 2. What's the difference between startup and startup mount? When we do "alter database open“, what does it mean? 3. What's the archive log function? 4. When I did 'alter database open', I still get an error. But once I issued 'recover database' and then 'alter database open‘, everything works just fine. What happens between these steps? 1 I T E C 4 5 0 F a l l 2 0 1 2

Questions on Backup and Recovery

  • Upload
    sue

  • View
    31

  • Download
    0

Embed Size (px)

DESCRIPTION

Questions on Backup and Recovery. What is the value of cold backup? What's the difference between startup and startup mount? When we do "alter database open“, what does it mean? What's the archive log function? - PowerPoint PPT Presentation

Citation preview

Page 1: Questions on Backup and Recovery

1

ITEC 450QUESTIONS ON BACKUP AND RECOVERY1. What is the value of cold backup?2. What's the difference between startup

and startup mount? When we do "alter database open“, what does it mean?

3. What's the archive log function?4. When I did 'alter database open', I still

get an error. But once I issued 'recover database' and then 'alter database open‘, everything works just fine. What happens between these steps?

Fall 2012

Page 2: Questions on Backup and Recovery

ITEC 450

2

MODULE 4 DATABASE TUNINGSection 5 Optimization of Physical Design

Fall 2012

Page 3: Questions on Backup and Recovery

3

ITEC 450TECHNIQUES FOR OPTIMIZING DATABASE Partitioning – breaking a single large table

into sections (partitions) stored in multiple files

Raw versus file systems – OS-controlled file or not

Clustering – enforcing the physical sequence of data on disk

Free space and compression – storage management

File placement and allocation Page size (block size in Oracle) – using the

proper page size for efficient data storage and I/O

Fall 2012

Page 4: Questions on Backup and Recovery

4

ITEC 450

PARTITIONING Partitioning supports very large tables and indexes by decomposing

them into smaller and more manageable pieces called partitions.

Fall 2012

SQL queries and DML statements do not need to be modified in order to access partitioned tables

After partitions are defined, DDL statement can access and manipulate individual partitions if they choose to, rather than entire tables or indexes

Page 5: Questions on Backup and Recovery

5

ITEC 450

RAW DEVICE VS. FILE SYSTEM Raw device is a UNIX feature to bypass

operating system cache mechanism. File system is a common way to manage

storage. Raw device might provide a slight

performance benefit, but the database storage management is a nightmare.

Unless it is required by DBMS features, you should avoid to implementing Raw Device.

Fall 2012

Page 6: Questions on Backup and Recovery

6

ITEC 450

CLUSTERINGClustering is used to store one or more tables

physically together with the share common columns and are often used together.

Because related rows are physically stored together, disk access time improves.

Clustering usually is enforced by the DBMS with a cluster index.

Like indexes, clusters do not affect application design. Data stored in a clustered table is accessed by SQL in the same way as data stored in a non-clustered table.

Fall 2012

Page 7: Questions on Backup and Recovery

7

ITEC 450

CLUSTERING EXAMPLEFall 2012

Page 8: Questions on Backup and Recovery

8

ITEC 450

FREE SPACE AND COMPRESSION Free space – pre-allocate storage of

tablespace, tables and indexes to store newly added data In DDL statements, a parameter is PCTFREE Benefits and disadvantages are listed in the

textbook Compression – shrink the size of a

database Tables or indexes can be algorithmically

compressed. The DMBS will handle the reading and writing

automatically.

Fall 2012

Page 9: Questions on Backup and Recovery

9

ITEC 450

FILE PLACEMENT AND ALLOCATIONA database is very I/O intensive, the location of the files can

be critical to database performance and recovery. Separate the indexes from the data – traditional approach Analyze the access patterns of your applications and

separate the files for tables/indexes that are frequently accessed together

Place transaction logs on a separate disk device from the actual data, and spread out log members (redo01.log, redo02.log, redo03.log) to different physical disk devices

Place control files (control01.ctl, control02.ctl, control03.ctl) like transaction logs to different physical disk devices. It’s common to have control01.ctl shares the same device with redo01.log, etc.

Place archive logs on a complete separate disk device from any database files

Fall 2012

Page 10: Questions on Backup and Recovery

10

ITEC 450

BLOCK SIZEThe block or page size is the smallest unit of

I/O, and used to store data records. The size selection is depending on record

lengths – small block size is good for small record length; large block size is good for long record length

Typical page size are 2K, 4K, 8K, 16K, and 32K.

Common used sizes are 2K and 4K Data Warehouse or Data Mart applications

use 8K, 16K or 32K. Oracle allows to specify block size on

tablespace level – tablespace for small row-size tables uses 2K, tablespace for large row-size tables uses 8K.

Fall 2012

Page 11: Questions on Backup and Recovery

ITEC 450

11

MODULE 4 DATABASE TUNINGSection 6 Storage Management

Fall 2012

Page 12: Questions on Backup and Recovery

12

ITEC 450

SPACE MANAGEMENTAs a DBA, you should track the following: Objects approaching an “out of space”

condition Free space available – physical and logical

perspective Segment or partition size – understand large

or small tables Number of extents – less than hundreds Fragment usage information – performance

concern Amount of reserved space that is currently

unused – any waste situation

Fall 2012

Page 13: Questions on Backup and Recovery

13

ITEC 450

DATA PAGE LAYOUTSThree basic components exist in a data page

(block in Oracle term) Page header – general page information, such as

a page identifier, an identifier indicating to which table the page belongs, free space pointers

Offset table – pointers to each data row on the data page

Data rows – actual rows of user data (table or index) Row header – general row information, such as row length,

information on variable-length data Offset tables – pointers to manage and control for variable-

length fields Row data – actual data for the row

Fall 2012

Page 14: Questions on Backup and Recovery

14

ITEC 450

RAID TECHNOLOGY (WEEK 6)RAID is an acronym for Redundant Arrays of

Inexpensive Disks. Please refer http://www.acnc.com/04_01_00.html

RAID-0 – data striping: striped disk array without fault tolerance.

RAID-1 – data mirroring: all data is written to two or more drives.

RAID-5 – data stripping with distributed parity blocks, and it requires a minimum of 3 drives to implement (commonly 5 drives)

RAID-10 – mirrored data stripping: very high reliability with high performance.

Fall 2012

Page 15: Questions on Backup and Recovery

15

ITEC 450

MODERN STORAGE TECHNOLOGY Storage Area Networks (SAN) – interconnected

network of storage devices (dedicate connections between host and storage) Shared storage between multiple hosts High I/O performance Server and storage consolidation Used for database files, I/O intensive/high

performance Network-Attached Storage (NAS) – storage that can

be accessed directly from the network Shared storage between multiple hosts Simpler management due to reducing duplicate storage Application based storage access at file level Good for shared folders, program files

Fall 2012

Page 16: Questions on Backup and Recovery

ITEC 450

16

MODULE 4 DATABASE TUNINGSection 7 Data Movement and Distribution in Oracle

Fall 2012

Page 17: Questions on Backup and Recovery

17

ITEC 450

THE LOAD UTILITYOracle has SQL*Loader utility to perform bulk

inserts of data into database tables. You can transform data before loading You can selectively load from the input file

based on conditions You can load all or part of a table You can perform simultaneous data loads Two main steps to use SQL*Loader

Prepare the data file – contains data in certain formats, field terminators

Create a control file – defines how to map the data fields to a table and specifies if the data needs to be transformed

Fall 2012

Page 18: Questions on Backup and Recovery

18

ITEC 450

DATA PUMP EXPORT AND IMPORTOracle offers the Data Pump technology for fast

data movement between Oracle databases. Migrating databases from development to test

or production Copying data between dev/test and production

databases Transferring data between Oracle databases on

different operating system platforms Backing up important tables or databases Reorganizing fragmented table data Extracting the DDL for tables and other objects

Fall 2012

Page 19: Questions on Backup and Recovery

19

ITEC 450

DATA PUMP EXPORT EXAMPLES Create a directory in Operating System for the

dump directory C:\app\Administrator\admin\orcl450\dpdir1

Within Oracle, define and verify the directory for Data PumpSQL> create directory dpdir1 as ‘C:\app\Administrator\admin\orcl450\

dpdir1’;SQL> select * from dba_directories where directory_name like 'DP%';

Export a table from command line (Run-> cmd)C:\> expdp system/password TABLES=hr.employees

DIRECTORY=dpdir1 dumpfile=output01.dmp Export a schema

C:\> expdp system/password SCHEMAS=hr DIRECTORY=dpdir1 dumpfile=output02.dmp

You can also export a tablespace or full database

Fall 2012

Page 20: Questions on Backup and Recovery

20

ITEC 450

DATA PUMP IMPORT EXAMPLESYou can import the information from the dump

file generated from Export. Import to extract the DDL from the export

dump fileC:\> impdp system/password DIRECTORY=dpdir1

dumpfile=output01.dmp SQLFILE=emp01.sql Import a table to another schema

C:\> impdp system/password DIRECTORY=dpdir1 dumpfile=output01.dmp REMAP_SCHEMA=hr:scott

You can also import a schema, tablespace or full database

Fall 2012

Page 21: Questions on Backup and Recovery

21

ITEC 450

DATABASE REFRESHING OPTIONS Backup and restore

Backup the source database, and restore to the target location

Commonly used for full database refresh Bath databases have similar physical structures

Data pump Export the source database/schema/table, and then

import to the target database Can be used for full, schema, or table level database

refresh SQL*Loader

Dump the source database tables to files in certain format, and then use SQL*Loader to upload the table data

Often used for table refresh, different DMBS, or user ad-hoc files

Fall 2012

Page 22: Questions on Backup and Recovery

22

ITEC 450

LOCK CONFLICTS A share lock partially locks data where there

is still partial access allowed to data by other sessions

An exclusive lock completely prohibits changes to data, but still allows read access

Locking of transactions and tables (using transactional control commands or LOCK TABLE) create locking situations manually

Fall 2012

Page 23: Questions on Backup and Recovery

23

ITEC 450HOW TO DETECT LOCK

CONFLICTSFall 2012

Page 24: Questions on Backup and Recovery

24

ITEC 450HOW TO DETECT LOCK

CONFLICTSFall 2012

Page 25: Questions on Backup and Recovery

25

ITEC 450HOW TO DETECT LOCK

CONFLICTSFall 2012

Page 26: Questions on Backup and Recovery

26

ITEC 450

WHAT IS A DEADLOCK? Deadlock: one thing is waiting for another,

but that other thing is also waiting for something A pending lock request cannot be serviced,

because the lock required will never be released Can cause serious performance issues

Most common cause is manual locking of data using LOCK TABLE or the FOR UPDATE clause

Usually deadlocked sessions must be rolled back manually Ways of resolving a deadlock manually are:

Rollback one of the deadlocked transactions Kill one of the sessions executing one of the

deadlocked transactions

Fall 2012