Sei sulla pagina 1di 193

Database Operations

1 System Operations

5 System Management

2 Deliveries - Tools Requirements

6 High Availability

3 Performance Management

7 Printing

4 Database Operations

8 Change Management

SAP AG 1999

Database Operations

Purpose
Verify the backup/recovery procedure Verify the disaster recovery procedure Verify database performance management Verify database monitoring procedure Verify growing management procedures

Key Issues
Backup/recovery concept Disaster recovery concept File distribution Database performance Database monitoring Growing management

SAP AG 1999

Key Performance Indicators

Indicator Avg. DB Request Time in Dialog Task Avg. DB Request Time in Update Task Reads / User call SQL Statements with inefficient search strategy SQL Statements with high data transfer volume DB Size Last Month DB Growth Top growing tables

Value

Target

Values depend on the avg. number of users

SAP AG 1999

Database Layer: Key Questions

Is backup strategy appropriate ? WHAT? Are emergency procedures defined ? Are administrative tasks for regular operation defined ?

Database administrator Operating system administrator WHO? System administrator Technical team lead/Technical consultant Network administrator

SAP AG 1999

Considerations for Setting Up a Backup Strategy

Backups: How often? When ?

24-hour availability? Maximum downtime?

Volume of data backed up? Backup duration? Backup cycle length? Costs? Administrator skills

SAP AG 1999

Emergency Procedures for Worst Case Scenario


Obtain new hardware

Reinstall operating system

Apply database backup

Recover database

SAP AG 1999

Monitoring Tasks

Free space

Missing indexes Database performance Last successful backup

Database logs

Expensive SQL statements

SAP AG 1999

Maintaining Your Database

Apply database updates and patches provided by your database manufacturer

Manage the growth of your database

Adapt your backup strategy to database growth

SAP AG 1999

Unit Content

Subunit 1 Subunit 2 Subunit 3 Subunit 4 Subunit 5

Backup Strategy and Tape Management Scheduling, Performing, and Monitoring Backups Restore and Recovery Advanced Backup Techniques Storage Management

SAP AG 1999

The Importance of Database Backups


Physical errors External factors
(Such as fire or water damage) (Such as hardware failure)

Logical errors
(Such as a deleted table) DROP MARA

Data loss

A good database backup strategy prevents data loss and minimizes system downtime
Procedure and Escalation Plan

SAP AG 1999

Preventing and Handling Errors

Logical data check: Verify database consistency


ORA-1578: Oracle data block corrupted

Physical data check: Verify backup on tape

Oracle data files

Database backup

SAP AG 1999

Possible Causes of Data Loss (1)


Logical error recovery
Logical errors Logical errors
(Such as a deleted table) DROP MARA

Lost information
12:50 - 4:00

12:50 Time when logical error occurred

4:00 Time when database is stopped for recovery

You must recover the complete database to a point in time before the error

SAP AG 1999

Possible Causes of Data Loss (2) Forward recovery


A database backup is restored and you want to recover data from offline redo log files

Sequence of offline redo log files:

Lost information

Point in time of the database error

Lost offline redo log file

Intact but unusable offline redo log files

Time

If one offline redo log file is lost, none of the files that follow it can be used
SAP AG 1999

Possible Causes of Data Loss (3) Disaster recovery


Physical errors
(Such as hardware failure)

External factors
(Such as fire or water damage)

Only data saved on tape can be recovered

Only tapes stored in a safe location can be recovered

SAP AG 1999

Backup Cycle Recommendations

Verify the database Verify the backup Offline Verify the backup Online Offline redo log file backup (x2)

28 days
Additional

Online Offline redo log file backup (x2)

SAP AG 1999

SAP Database Backup Tools


Oracle database
Control file Data files Online redo log files Offline redo log files

Detail log

BRBACKUP BRRESTORE BRARCHIVE


cpio/dd parallel cpio/dd

Detail log

Media

Media

SAP AG 1999

Backup Objects
Objects that need to be backed up
Database objects
Data files

BRBACKUP
Database backup Database backup
Online redo log files

BRRESTORE
Control file Profiles Offline redo log files

BRARCHIVE
Offline redo log Offline redo log file backup file backup

Computing center data


Operating system Database executables

R/3 data
R/3 interfaces SAP executables

SAP AG 1999

Tape Pools

Number of parallel backup devices Database size


Tape pools

Length of backup cycle

BRBACKUP + 30% Reserve BRARCHIVE

Frequency of backups
SAP AG 1999

Number and size of redo log files in a backup cycle

Tape Initialization
Profile init<SID>.sap contains the tape names: ... volume_backup = (<SID>B01,<SID>B02... volume_archive = (<SID>A01,<SID>A02... ...

Write the label to the tape that also contains the tape name

.tape.hdr0

Initialize new tapes, non-SAP tapes, or locked tapes: brbackup -i force or brarchive -i force Rename non-locked tapes: brbackup -i -v <tape name> or brarchive -i -v <tape name>
SAP AG 1999

Tape Label Contents and Tape Checks

Tape label contents:

Tape name Database name Timestamp of last backup Number of backups performed

Tape checks:

Tape name Lock period Use count

Profile init<SID>.sap:

Error Warning

... expir_period tape_use_count ...

= 28 = 100

Show tape label contents: brbackup -i show or brarchive -i show


SAP AG 1999

Tape Locking
Physical tape locking

C11B01

C11B02

expir_period = 30 expir_period = 30
.tape.hdr0

28 days

Days 1 2 28 29 30 31 32 33

Logical tape locking BRBACKUP BRARCHIVE


Tables SDBAH and SDBAD List of tapes used in expir_period
... C11B05, C11B06, ...

Profile: init<SID>.sap
... volume_backup = (C11... volume_archive = (C11... ...

SAP AG 1999

Scenario 1: Automatic Tape Selection

Offline

Online Archives (2x)

28 days
Additional

Online Archives (2x)

BRBACKUP BRARCHIVE
Tables SDBAH C11B01 and SDBAD C11A01

Tape management active, BRBACKUP finds tape names + Tape label check active = Only accepts tapes with requested names and with expired lock period

SAP AG 1999

Scenario 2: Manual Tape Selection

Offline

Online Archives (2x) brbackup -v SCRATCH or brarchive -v SCRATCH


Tape lock expiration will be checked + Tape management is not active = To select any tape manually

28 days
Additional

BRBACKUP BRARCHIVE
C11B01 C11A01

Tape with label name SCRATCH


Tape lock expiration will be checked + Tape name is changed to the currently required tape name = You can use this option to replace tapes in your tape pool

SAP AG 1999

Scenario 3: Tape Selection by an External Tool

Offline

Online Archives (2x)

28 days
Additional
brbackup -v C11M01,C11M02

BRBACKUP BRARCHIVE
C11B01 Search mechanism
SAP AG 1999

C11A01

Tape management is deactivated but tape name is checked + Tape label check active = Only accepts tapes - With the specified names - With expired lock period

Tape Layout

BRBACKUP:
.tape.hdr0 init<sid>.ora init<sid>.sap DB file 1 init<sid>.dba

DB file n

Control file

reorg.log struct.log

Detail log

Summary log

BRARCHIVE:
.tape.hdr0 init<sid>.ora Offline init<sid>.sap init<sid>.dba redo log 1

Offline reorg.log Detail redo log n struct.log log

Summary log

SAP AG 1999

How SAP Backup Tools Work Together


CCMS Planning Calendar Planning Goto Listing Help System MON TUE WED THU MON TUE WED THU MON TUE WED THU MON TUE WED THU FRI FRI FRI FRI SAT SUN SAT SUN SAT SUN SAT SUN

BRBACKUP

Data files

Log files
.... .... .... .... .... .... .... .... ....

init<SID>.sap
.... .... .... ....

sapr3.SDBAH sapr3.SDBAD

Log files - Command prompt x BRBACKUP -t ... or BRARCHIVE ...

BRARCHIVE

.... .... .... .... .... .... .... .... ....

Offline redo log files

SAP AG 1999

Backup Profile Parameters


compress compress_cmd compress_dir tape_copy_cmd exec_parallel tape_address tape_address_rew tape_address_arch tape_address_rew_arch
backup_ mode backup_ type volume_backup tape_ size tape_use_count expir_period backup_dev_type archive_function volume_archive tape_size_arch

init<SID>.sap
.... .... .... .... ? ??? ? ?

= hardware = compress -b 12 -c $ > $ = /oracle/<SID>/sapreorg = dd =0 = /dev/rmt/0mn = /dev/rmt/0m = /dev/rmt/1mn = /dev/rmt/1m


= all = online [offline] = (<SID>B01, <SID>B02, ...) = 32G = 100 = 28 = tape = copy_delete_save = (<SID>A01, <SID>A02, ...) = 6000M

SAP AG 1999

Profile init<SID>.sap Parameter tape_size

Correct
BRBACKUP/BRARCHIVE BRBACKUP: SAP follow-up tape

Incorrect
BRBACKUP/BRARCHIVE dd: Error

...
cpio/dd cpio/dd

...

cpio: Error or cpio continuation volume

cpio/dd

cpio/dd cpio/dd cpio/dd

Data

... Data

Data

Data

... Data

Data

Physical tape size Parameter tape_size


SAP AG 1999

Physical tape size Parameter tape_size

Hardware Compression
Tape station without hardware compression Tape station with hardware compression

400 MB 400 MB 400 MB 400 MB 400 MB 400 MB 400 MB 400 MB

BRBACKUP
400 MB

400 MB 400 MB 400 MB 400 MB 400 MB 400 MB 400 MB 400 MB

BRBACKUP
400 MB

400 MB
400 MB 400 MB 400 MB 400 MB

200 MB
200 200 200 200 200 200 200 200 MB MB MB MB MB MB MB MB init<SID>.sap compress = hardware .... .... .... compress_cmd = compress -b 12 -c $ > $ $ ....

init<SID>.sap

compress = no tape_size = 1800M

exec_parallel tape_size

= 0 = 1600M

Once per cycle: Determine compression rate


SAP AG 1999

Scheduling and Performing a Normal Database Backup


CCMS Planning Calendar Planning Goto Listing Help System MON TUE WED THU MON TUE WED THU MON TUE WED THU MON TUE WED THU FRI FRI FRI FRI SAT SUN SAT SUN SAT SUN SAT SUN

Schedule an Action for Tue 05


Start time Period (weeks): 1

18:00:00 Calendar

Full database offline + redo log backup Full database offline backup Full database online + redo log backup Full database online backup Redo log backup Partial database offline backup Partial database online backup Check optimizer statistics Adapt next extents

SAPDBA Check database

x x tape all online no

h - Backup database

SAPDBA
c - Backup device type d - Objects for backup e - Backup type g - Query only S - Start BRBACKUP
init<SID>.sap .... .... .... ....

Command prompt

BRBACKUP -t online -d tape

-m all -c -u system

tape_copy_cmd = dd or tape_copy_cmd = cpio

SAP AG 1999

Phases of a Whole Database Backup

Online

Save control file to disk Save control file to disk

*Start database *Start database

Offline

Retrieve file names of data and online redo log files from database Retrieve file names of data and online redo log files from database and retrieve names of control files from init<SID>.ora and retrieve names of control files from init<SID>.ora Shut down database Shut down database Back up tape header, init<SID>.sap, init<SID>.dba, and init<SID>.ora Back up tape header, init<SID>.sap, init<SID>.dba, and init<SID>.ora For all tablespaces to be backed up: For all tablespaces to be backed up: Begin tablespace backup mode Begin tablespace backup mode Back up tablespace data files Back up tablespace data files End tablespace backup mode End tablespace backup mode Back up saved control file Back up saved control file Log file switch Log file switch Back up data files Back up data files *Back up online redo log files *Back up online redo log files Back up control file Back up control file Start database Start database

Back up reorg.log, struct.log, detail log, and summary log Back up reorg.log, struct.log, detail log, and summary log
init<SID>.sap .... .... .... ....

tape_copy_cmd = dd or tape_copy_cmd = cpio

*Shut down database *Shut down database

SAP AG 1999

Logical Verification of a Database Backup


BRBACKUP -c -w use_dbv

Data files

A B

..

File length

? =
Log files
.... .... .... .... .... .... .... .... ....

compress_dir

Corruption Oracle 8-KB Block

Once per week. Minimum: once per cycle

SAP AG 1999

Tape readable?

Physical Verification of Offline Database Backups


BRBACKUP -t offline -c -w Data files

A B

..

Offline (binary)

? =

compress_dir

...

Check database backup


SAP AG 1999

If possible: Once each cycle

Monitoring a Database Backup


CCMS Planning Calendar Planning Goto Listing Help System MON TUE WED THU MON TUE WED THU MON TUE WED THU MON TUE WED THU FRI FRI FRI FRI SAT SUN SAT SUN SAT SUN SAT SUN

Database Operations Monitor (DB24)


sapr3.SDBAH sapr3.SDBAD

CCMS

CCMS Calendar (DB13)

SAPDBA
L - Show/Cleanup SAPDBA

x x x

Log files
.... .... .... .... .... .... .... .... ....

a - Show log files / profiles -

SAPDBA
e - BRBACKUP log files

Command prompt

cd /oracle/<SID>/sapbackup cat back<SID>.log | more cat b<timestamp>.and | more

SAP AG 1999

Offline Redo Log Files: Status and Option -cds


Status of an offline redo log file
BRARCHIVE option -cds (copy, delete, save)

BRARCHIVE -cds
Mon
42 4 2 4 2 4 2

Tue
42

Wed
42 <SID>A01 43

ARCHIVED
43 43

SAVED COPIED DELETED

4 <SID>A01 2 44 4 <SID>A02 2 44 <SID>A02

42 43 44 4 5 4 6 <SID>A03 44 45 46

42

../saparch

../saparch

SAP AG 1999

Performing Offline Redo Log File Backups


Schedule an Action for Tue 05
CCMS Planning Calendar Planning Goto Listing Help System MON TUE WED THU MON TUE WED THU FRI FRI FRI FRI SAT SUN SAT SUN SAT SUN SAT SUN

Start time Period (weeks): 1

18:00:00 Calendar

DB13

Full database offline + redo log backup Full database offline backup Full database online + redo log backup Full database online backup Redo log backup Partial database offline backup Partial database online backup Check optimizer statistics Adapt next extents

MON TUE WED THU MON TUE WED THU

-Check database SAPDBA -

x x

i - Back up offline redo log files

SAPDBA
Copy, delete, and save archive logs tape

a - Archive function c - Archive device type

Command prompt brarchive -cds -d tape -c -u system

x s - Start BRARCHIVE

SAP AG 1999

Monitoring Offline Redo Log File Backups


CCMS Planning Calendar Planning Goto Listing Help System MON TUE WED THU MON TUE WED THU FRI FRI FRI FRI SAT SUN SAT SUN SAT SUN SAT SUN

DB13

Database Operations Monitor (DB24)


sapr3.SDBAH sapr3.SDBAD

MON TUE WED THU MON TUE WED THU

CCMS Calendar (DB13)

SAPDBA
L - Show / Cleanup SAPDBA

x x x

Log files
.... .... .... .... .... .... .... .... ....

a - Show log files / profiles -

SAPDBA
f - BRARCHIVE log files

Command prompt

cd /oracle/<SID>/sapbackup cat arch<SID>.log | more cat a<timestamp>.cds | more

SAP AG 1999

Log File Cleanup


-

SAPDBA
L - Show/Cleanup SAPDBA

x x

b - Cleanup log files / directories x SAPDBA a - SAPDBA log files and dump directories b - SAPDBA daily check log files c - BRBACKUP log files d - BRARCHIVE log files f - ORACLE traces and audits

init<SID>.dba .... .... .... ....

expir_period_SAPDBA_normal expir_period_daily_check expir_period_BRBACKUP expir_period_BRARCHIVE expir_period_oracle_trace

= = = = =

11 5 30 30 1

Log files
.... .... .... .... .... .... .... .... ....

sapr3.SDBAH sapr3.SDBAD

Command prompt

delete b<timestamp>.and

SAP AG 1999

Freespace Problems in Directory saparch


Monitoring the directory saparch Detecting an archiver stuck
- . SAPGUI . .... x __________ __________ __________ __________

RZ20
-

alert_<SID>.log: Thread <n> cannot allocate new log, All online logs needed archiving

DB24
Resolving an archiver stuck
x x x

SAPDBA
f - Archive mode SAPDBA

c - Show all archive information SAPDBA FREE SPACE : ...

Dummy

Remove dummy files

and
Run BRARCHIVE
Command prompt
x

cd saparch df-k.

../saparch

<SID>A01

SAP AG 1999

Database Errors

Error types: Statement Process Instance User Media

Most importantly, be prepared for disasters. Dont think you will never see a failure. Every DBA will experience a database failure. Its just a matter of when... Good luck. Rama Velpuri

SAP AG 1999

How to Handle Problems

Do not make any rash decisions Analyze the problem in detail Create a problem-solving strategy Before restoring any files, check: What is causing the problem Whether there is enough disk space to save and restore files Whether a hardware extension is necessary The file system and mount points The availability of backups The availability of offline redo log files

SAP AG 1999

Scenario

10 10

10

3 38 38 8

Control files

10

11

12

...

36

37

3 8

Offline and online redo log files

10 1 0 10 38 38

38

Data files

Full backup
Legend: Log sequence number
SAP AG 1999

Partial Restore and Complete Recovery

mount

open

38 38

38 38

38

38

Control files

10

11

...

37

3 8

39

...

Offline and online redo log files

38 10 10

Complete recovery
38 38

38

Data files

Partial restore

SAP AG 1999

Database Reset

open

10 10

10

Control files

10 9 10

11 11

... ...

37

38

Offline and online redo log files

10 10 10

Data files

Full restore

SAP AG 1999

Point in Time Recovery

mount

Open resetlogs

10 10

10 25

25

25 1

Control files

26 10 11

...
2 24

37

... Incomplete recovery

25 1

...

Offline and online redo log files

10 10 10 25 25

25

24 1 1

Data files

Full restore

SAP AG 1999

Partial Restore and Complete Recovery (1)

Detail logs

back<SID>.log

arch<SID>.log

Recovery script

Check Database

Find backups

Restore data files

Find offline redo log files

Restore offline redo log files

Recover database

saparch

Database
SAP AG 1999

Partial Restore and Complete Recovery (2)

Detail logs

back<SID>.log

arch<SID>.log

Recovery script

Check Database

Find backups

Restore backup files

Find offline redo log files

Restore offline redo log files

Recover database

saparch

Database
SAP AG 1999

Partial Restore and Complete Recovery Limitations

Problem
No data or offline redo log file backups available

Solutions
Perform a database reset Perform a point in time recovery Use the SAPDBA function Restore individual files

Logs

No BRBACKUP/BRARCHIVE logs available

init<SID>.*

No init<SID>.* files available

Restore these files from tape using command brrestore -n init_ora Copy one of its mirrors

Control files damaged

Online redo log files damaged

See R/3 Online Help

SAP AG 1999

Database Reset Using a Full Offline Backup

Detail logs

back<SID>.log

Find full offline backups

Save current online redo log files and control file

Overwrite all data files, control files, and online redo log files

Database mount

Database open sapreorg

Database
SAP AG 1999

Database Reset Using a Consistent Online Backup

Detail logs Recovery script back<SID>.log

Find Online_Cons backups

Save online redo log files and control file

Overwrite all Data files and Offline control files redo log files

Recover database until cancel

Database open resetlogs

sapreorg

saparch

Database
SAP AG 1999

Full Restore and Recovery (1)

Detail logs

back<SID>.log

Input: time

arch<SID>.log

reorg<SID>.log

Find full offline/ online backups

Recover until?

Find offline redo log files

Status: allowed?

Not allowed if (for example): - No backup specified - No offline redo log files found - Recovery over tablespace reorg - Backup before open resetlogs

Database
SAP AG 1999

Full Restore and Recovery (2)

Recovery script

Save online redo log files and control file

Overwrite all Data files and control files Offline redo log files (if necessary)

Recover database (until time)

Database open (resetlogs)

sapreorg

saparch

Database
SAP AG 1999

Backup Requirements and Costs

Duration of a backup Time window for a recovery High availability Training Administrative workload Acquisition costs

SAP AG 1999

BRBACKUP and BRARCHIVE: One-Run Strategy


Database backup Offline redo log file backup

Data files

Offline redo log files in saparch

brbackup -m all -c -a -cds -c

Tape init header files


SAP AG 1999

...

...

Logs

Consistent Online Backups

...begin backup

...end backup

10 10

10 25

25

25

Control files

10

11

...

24

25

...

Offline redo log files in saparch

10 10 10

25

...
25

25

Data files

brbackup -t online_cons

init files

10

10

...

25

10

...

25

Logs
9

Legend: Log sequence number


SAP AG 1999

Parallel Tape Support

Control files

init<SID>.sap
exec_parallel tape_address archive_function tape_address_arch =0 = (dev1, dev2, dev3) = double_save_delete = (dev4, dev5)

Offline redo log files in saparch

BRBACKUP

BRARCHIVE

DDS DLT

DLT
SAP AG 1999

DLT

DDS

Partial Database Backups

Mon

Tues

Sun

...

Data files

brbackup -m PSAPSTABD BRARCHIVE

brbackup -m PSAPBTABD BRARCHIVE

brbackup -m all -f 7 BRARCHIVE

SAP AG 1999

Backing Up Data Tablespaces Only

System, roll, and temp tablespace

Data tablespaces

Pure index tablespaces

brbackup -m all_data

SAP AG 1999

Two-Step Disk Backup

Data files

dir2

Fast 1st step brbackup -d disk -e 4

dir1

init<SID>.sap
exec_parallel tape_address backup_root_dir =0 = (dev1, dev2, dev3) = (lvol1, lvol2)

Slow 2nd step brbackup -b last -d tape

SAP AG 1999

Structure-Retaining Database Copy

$ORACLE_HOME
dbs sapdata1
. . .

NEW_DB_HOME
dbs btabd_1 sapdata1
. . .

btabd_1

sapdata<n> origlogA

brbackup -d disk_copy
origlogB

sapdata<n> origlogA origlogB mirrlogA mirrlogB sapbackup

mirrlogA mirrlogB sapbackup saparch sapcheck sapreorg saptrace

init<SID>.sap
new_db_home = /oracle/NEW

SAP AG 1999

Split Mirror Disk Backups

Production server

Backup server

o irr

1. Split mirror 2. Mount 3. Backup 4. Unmount 5. Resync brbackup -t online/offline_split -d tape

SAP AG 1999

SAP Tools and the Oracle Standby Database

Production server Database open

Standby server

Database mounted standby or offline for backup

saparch

saparch

Recovery

ftp ftp OR NFS NFS


sapr3.SDBAH sapr3.SDBAD

brarchive -sd

-d disk -f -w

brarchive -ssd -f -m 60

brbackup -t offline_standby

SAP AG 1999

External Backup Tools Using BC-BRI

SAPDBA brbackup Backup BACKINT brarchive brrestore Inquire

init<SID>.sap
backup_dev_type util_par_file = util_file_online = init<SID>.utl

Restore
init<SID>.utl

External backup server

$ORACLE_HOME brbackup init<SID>.sap sapdata1


. . .

btabd_1

sapdata<n> saparch

SAP AG 1999

Space Management: Review


Table ABC
Segment (table/index) Tablespace

Index XYZ Table DEF


Datafile1
Segment 192K Segment 256K Segment 80K

Datafile2
Segment 192K Segment 640K

... ...

Segment 192K
Extent 48K 1
8K 8K 8K 8K

Segment 224K

...

Extent 144K
8K 8K 2 8K 8K 8K 8K 8K 8K 8K 8K 8K 8K 8K 8K 8K 8K 8K 8K

Next Extent

Initial Extent

8K 8K

Disks
File system

...

Data block

Datafile1

Datafile2

SAP AG 1999

Space Management: Fragmentation Types

Objects (tables/indexes)

Tablespace

<tablespace>.data1
2

Critical object 0 Oracle block 1 2 3 4 5 ... Internal fragmentation Free


0

1 2 4 2 0 2 3 4 1 0 1 5 0 3

External fragmentation
4 3

5 1

Gaps

Used Extents

SAP AG 1999

Daily Monitoring: sapdba -check


R/3 CCMS Planning Calendar Planning Goto Listing Help System MON TUE WED THU CheckDB CheckDB CheckDB CheckDB MON TUE WED THU CheckDB CheckDB CheckDB CheckDB MON TUE WED THU CheckDB CheckDB CheckDB CheckDB MON TUE WED THU CheckDB CheckDB CheckDB CheckDB FRI SAT CheckDB SAT CheckDB SAT CheckDB SAT CheckDB SUN sapdba -next SUN sapdba -next SUN

Schedule an Action for Tue 05


Start time
Period (weeks):

18:00:00
1
Calendar

FRI

Full database offline + redo log backup Full database offline backup Full database online + redo log backup Full database online backup Redo log backup Partial database offline backup Partial database online backup

FRI

FRI

SUN sapdba -next

<Timestamp.chk> in /oracle/<SID>/sapcheck

Database table Update optimizer statistics DBMSGORA


Check optimizer statistics Adapt next extents Check database
Start immediately

sapdba -check

Database Check: Overview of Results


Start check Check results Configure check Settings Database operations monitor History

Database table Standard


DBMSGORA

Warnings Errors Total

6 5 11

Refresh every Delete after View the last

10

seconds

inaktiv aktiv

100 days 10 days

DB16

History: All messages


Result Date Time Days Error type Error name LOG_SMALL_EN... OPT ALY NO_OPT_STATS Text LOG_SMALL_ENTRY_MAX_SIZE DB Operation opt never started or finished successful DB Operation aly never started or finished successful 6 INDEXE(S) DDXTF 0,DDXTT 0, TATAF 0, ... WITHOU

W E E E

08/21/1999 08/21/1999 08/21/1999 08/21/1999 SAP AG 1999

22:00:00 22:00:00 22:00:00 22:00:00

10 10 10 10

PROF DBO DBO DBA

Configuring sapdba -check


Number of SAPDBA check parameters

Total Status Profile param. Oracle alerts Operations


Typ DBA DBA DBA DBA DBA DBA DBA DBA DBA Parameter

67 19 28 13 7

DB17
Active Inaktiv 66 1

O... Actv. S.. Op... Val. U... Per... Unit E > E E W > E E E
Type Parameter

Date

U... C CorrMeasure P E SAPDBA: BACKUP ARCH... INIT<SID>.ORA SAPDBA: TABLESPACE A... DO A CREATE CONTROL...

Description ARCHIVE STUCK - FS SPAC... CONTROL FILES ARE MISSI... CONTROL FILE(S) ARE NOT... SEGMENT(S) #1 WOULD CAU... DATAFILE(S) #1 OFFLINE FILE TYPE DOES NOT MATC... FILE TYPE ( DATAFILE , RA...

ARCHIVE_STUCK CONTROL_FILE_MISSING CONTROL_MIRROR CRITICAL_SEGS DF_OFFLINE FILE_MISMATCH FILE_MISSING FILE_TYPE_UNKNOWN FS_FULL


Object Actv. Condition Description Repeat period Duration Corrective measure Type Changed by User Program

80

Change Database Check Parameter


P 01 / 22 / 1999 CA...

SAPDBA: RESTORE/RECO... DATA FILES ARE MISSING EXTEND FILESYSTEM OR... # 1 FILE SYSTEM(S) # 2 ARE...

Database analysis tool (SAPDBA) E ARCHIVE_STUCK W > 95 P


Yes

Error

if

greater than (old

80

Percentage

ARCHIVE STUCK - FS SPACE #1 MORE THAN #2 FULL

Time Unit

Configuration table
DBCHECKORA
SAPDBA: BACKUP ARCHIVE LOGS

Operation

Date

SAP AG 1999

Tablespace Extension
ADD A DATA FILE: File size depends on the estimated increase of the tablespace objects. Check for the number of data files in the database. RESIZE THE DATA FILE: Extend the size of the data file depending on the space available on the file system and size of critical object.

New file
<tablespace>.data1
Critical object

<tablespace>.data2

<tablespace>.data1
Critical object

OR

Extents

Original size

After Resize

Back up extended tablespace and control files

SAP AG 1999

Storage Categories of SAP Database Objects


R/3

ABAP Dictionary: Display technical settings


ZPROGRAM Transparent Table Test Table for technical settings TND 24/08/1999 Active Saved

Name Short text Last changed Status

Logical storage parameters Data class APPL1 Size category 4 Transaction data. transparent tables Data records expected: 39.000 to 3.100.000

Table TGORA (storage parameters for R/3 tables)


Category INIT NEXT MINEXTENT MAXEXTENT 0 16 40 1 300 1 16 160 1 300 2 16 640 1 300 3 16 2560 1 300 4 16 10240 1 300 5 16 20480 1 300 6 16 40960 1 300 7 16 81920 1 300 8 16 163840 1 300 9 16 327680 1 300 10 16 655360 1 150 11 16 1310720 1 150 12 16 2621440 1 150 13 16 5242880 1 150 14 16 10485760 1 150
SAP AG 1999

Table IGORA (storage parameters for R/3 indexes)


Category INIT 0 16 1 16 80 16 160 1 640 1 300 1 300 5 300 6 16 7 16 20480 1640960 1 81920 1 300 1 150 11 3276801 150 6553601 150 1310720 1 2621440 1 NEXT MINEXTENT MAXEXTENT 40 1 300 1 300 2 300 3 16 4 16 2560 16 5120 1 10240 1 300 1 300 8 300 9 16 10 16 163840 16 12 16 13 16 150 14 16 150

Using sapdba -next


Example sapdba -next: Table size: 900 MB 10 % value: 90000KB Current NEXT: 20480KB NEXT candidate: 90000KB TGORA values (KB)
10485760 5242880
MON TUE WED THU FRI SAT SUN R/3 CCMS Planning Calendar

x
WED THU FRI SAT SUN

Planning Goto Listing Help System MON TUE

sapdba -next

2621440 1310720

sapdba -next

Schedule an Action for Tue 05


MON TUE WED THU FRI SAT SUN

New value for NEXT: 163840 Next larger TGORA value: NEXT candidate: Next smaller TGORA value: Current NEXT: Technical settings: Category 3:
655360

Start time
Period (weeks):

18:00:00
1
THU

Calendar
FRI SAT

sapdba -next
SUN

163840 90000 81920 20480

327680
MON

TUE

Full database offline + redo log backup Full database offline backup
WED

163840 81920 40960 20480 10240

Full database online + redo log backup Full database online backup Redo log backup Partial database offline backup Partial database online backup Check optimizer statistics

sapdba -next

Database table Update optimizer statistics DBMSGORA


Adapt next extents Check database
Start immediately

2560

2560 640 160 40

SAP AG 1999

Daily Monitoring: Tables and Indexes

Database System

Database ORACLE Name TCC


Tablespaces

Date/time of this analysis 08/24/1999 07:01:30


Refresh Refresh Checks Checks Space statistics Space statistics

Total number 27 Total size/kb 12.123.016 Total free/kb 3.050.320 Minimum free/kb 4.024 Max. autoextensible/kb AutoExtend off
Tables and indexes

Current sizes Current sizes

25%

Space statistics Space statistics Freespace statistics Freespace statistics

Total number Total size/kb More than 1 extent Missing in database Missing in R/3 DDIC Space-critical objects

Tables Indexes 13.064 15.305 5.915.664 2.979.432 1.082 1.591 0 1 0 0 0 0 Maintain table: TCOLL

Detailed analysis Detailed analysis Missing indexes Missing indexes Space critical objects Space critical objects Space statistics Space statistics

Day Time M T W T F S S 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 ------------------------------------------------------------------------------RSDBPREV 1 C X:X:X:X:X:X:X X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X:X RSORATDB 1 C X:X:X:X:X:X:X : : : : : : :X: : : : : : : : : : :X: : : : :

SAP AG 1999

Tables and Indexes: Important Reports

Critical growth of tables/indexes in the last 4 weeks


09/05/1999 10:40:26 DB_SERVER Critical table/index growth Intervals: 08/06/1999 - 09/05/1999 Table Name ATAB~0 SMENINTT~ SKAT~001 Type INDEX INDEX INDEX Size(KB) Total 72.720 2.416 9.960 Measurements: 29 MaxExtents defined %used 300 56 300 10 300 30 FirstExtent (Kbyte) 45.936 16 2.904 Tablespace PSAPPOOLI PSAPSTABI PSAPSTABI

NextExtSize Growth (Kbyte) 10.880 160 2.400 80 2.080 80

Extents Total Growth 168 68 31 30 89 26

Table Space History


09/05/1999 10:40:26 DB_SERVER Intervals: 08/06/1999 - 09/05/1999 Measurements: 30 Scale: Day Scale: Day Size (KB) Free(KB) Used (KB) %-Used Tablespace Total Chg/day Total Total Chg/day Total Chg PSAPPOOLD 747.512 0 38.944 708.568 2.415 94 0 PSAPPOOLI 563.200 0 97.888 465.312 1.793 82 0 PSAPSTABI 921.600 0 70.288 851.312 1.909 92 0 PSAPSTABD 1.013.744 0 31.024 982.720 3.384 96 0 PSAPROLL 307.200 0 182.392 124.808 3.084 40 1 PSAPBTABD 735.216 0 231.336 503.880 1.249 68 0 PSAPBTABI 409.600 0 125.768 283.832 157 69 0 PSAPSOURCED 102.400 0 69.296 33.104 6 32 0 PSAPSOURCEI 102.400 0 47.520 54.880 3 53 0 PSAPTEMP 307.200 0 307.192 8 36 0 0 PSAPUSER1D 8.192 0 4.024 4.168 36 50 0 PSAPPROTI 33.792 0 16.592 17.200 52 50 0

Tables/Indexes Total Chg/day 6.619 0 6.751 0 4.404 0 3.325 0 15 0 2.344 0 3.222 0 47 0 54 0 0 0 4 0 114 0

Extents Total Chg/day 8.692 22 9.296 21 6.156 10 4.307 8 120 3 2.471 1 3.542 1 49 0 60 0 0 0 4 0 131 0

SAP AG 1999

Analyzing Internal Fragmentation


sapdba -analyze
SAPDBA Detail Log

DB02 >> Detail Analysis

Detail log: 9908221023.aly *********************************************************************** (12690 tables analyzed - sorted by empty space in descending order) TABLESPACE_NAME TABLE_NAME EMPTY(kb) NEVER_BEEN_USED(kb) USED(kb)

Detailed analysis for Index ATAB~0


PSAPSTABD E071K 42032 42032 5128 Data from DBA_SEGMENTS/DBA_INDEXES PSAPEL40AD D010L 31112 31112 3168 Space PSAPPOOLD ATAB 17112 17112 58368 72.720 PSAPES40AD DOKCLU 13136 13136 323448 Allocated space..Kbyte blocks...... 9.090 PSAPES40AD D010S 10088 10088 774848 *********************************************************************** extents..... 168 CHARTS OF 20 EMPTY INDEXES - USING: VALIDATE STRUCTURE (6751 indexes analyzed. sorted by empty space within BTREE = Block structure USED_BY_BTREE - USED) 8.192 TABLESPACE_NAME INDEX_NAME TOTAL(kb) USED_BY_BTREE(kb) USED(kb) Blocksize.........byte PSAPPOOLI PSAPPOOLI PSAPPOOLI PSAPPOOLI ATAB~0 T512T~0 RTXTL~0 T800Y~0 72720 7280 11920 8800 72648 7200 10072 8744 50563 4641 7745 6726

Pct_free.............. Transactions initial.. maximum.. Header minimum....byte Data maximum......byte Process freelists..... Freelist groups.......

10 2 255 159 7.230 1 1

SAP AG 1999

Reorganization: Basics

Example for a table reorganization 1) Export table


Data_1

Example for an index recreation 1) Drop index


Data_1

2 1 0

2 1 0

2 1 0

2 1 0

2) Recreate index sapreorg 2) Drop table Additional storage space required PSAPTEMP

Data_1 Data_1

0 2 1 0

0 2

3) Import table Recreate index


SAP AG 1999

1 0

Reorganization: Reasons
0 Oracle block
Disk_1
2 0 2 0 2 0 2 0 3 4 1 0 5 1 0 2 3 4 1 0 3 4 1 0 5 1 3 0 2 0 5 1 0 2 3 4 1 0 2 3 4 1 0 3 2 0 5 1 3 0 2 0 5 1 0 2 3 4 1 0

1 2 3 4 5 ...

Disk accesses [%]

Disk_2
3 2

Disk_3
3 0 5 1 3 0 2 2 2

Disk_4
3 0 3 4 1 0 0 2 3 5 1 3 4 1 0 5 1

Free Internal fragmentation Used

Disk "hot spots" Disk

SAPDBA Detail Log


Detail log: 9909050715.aly CHARTS OF 20 EMPTY INDEXES - USING: VALIDATE STRUCTURE (6751 indexes analyzed. sorted by empty space within BTREE = USED_BY_BTREE - USED) TABLESPACE_NAME INDEX_NAME TOTAL(kb) USED_BY_BTREE(kb) USED(kb) PSAPPOOLI PSAPPOOLI PSAPPOOLI PSAPPOOLI PSAPPOOLI PSAPPOOLI SAP AG 1999 ATAB~0 T512T~0 RTXTL~0 T800Y~0 T52C5~0 USOBX_C~0 72720 7280 11920 8800 5480 4160 72648 7200 10072 8744 5424 4032 20563 4641 7745 6726 3760 2627

Fragmented Indexes

Reorganization: Phases and Types


Phases Create script and restart file Check the free space Perform a reorganization Reorganization of a single object or a list of objects
Data file_1 Data file_1

Directories sapreorg/<timestamp>/<timestamp>.<extension>. sapreorg, PSAPTEMP. PSAPROLL, objects tablespace Reorganization of a tablespace


Data file_2
3 0 2 0 3 4 1 0 1 5 6 1 6 8 7 0 9 10 7 4 5 0 0 11 0

Data file_1
2

Data file_1

Data file_2

0 2 1 0 2 1 0 2 1 0

Disk "hot spots" Fragmented indexes Internal fragmentation

Internal and external fragmentation Fragmented indexes

Moving / Renaming data files

Reorganization of a tablespace with data files


Data file_1
0 2 3

Disk x
0 1 2 0 2 0 3 4 1 0 5 1 0 4 3

Disk y
0 1 2 0 2 3 4 1 0 5 1 6 1 8 4 3 0

Data file_new
2 5 1 0 0 0 11 5 0

4 1 0 10 7 4

Data file_2
9

Disk "hot spots"


SAP AG 1999

Reorganization: Methods
Reorganization of indexes Reorganization of indexes Method Runtime Security Additional space Method Runtime Security Additional space Parallel Parallel Alter index ++ ++ Objects tablespace II Alter index ++ ++ Objects tablespace rebuild PSAPTEMP rebuild PSAPTEMP Index Index recreate recreate ++ ++ PSAPTEMP PSAPTEMP II

Reorganization of tables Reorganization of tables Method Runtime Security Additional space Method Runtime Security Additional space R3Chop Parallel Compress Restrictions R3Chop Parallel Compress Restrictions Create table ++ ++ Objects tablespace TT NA No tables with Create table ++ ++ Objects tablespace NA NA NA No tables with as select PSAPROLL LONG/RAW fields as select PSAPROLL LONG/RAW fields SAPDBA unload. ++ sapreorg NO P NO export <<max_file_size SAPDBA unload. ++ sapreorg NO P NO export max_file_size SQL*loader PSAPTEMP (usually 22Gbyte) SQL*loader PSAPTEMP (usually Gbyte) Oracle Oracle export/import export/import oo ++ sapreorg sapreorg PSAPTEMP PSAPTEMP YES YES P P YES YES

Legend: Legend: ++ = very good, + = good, o = average, NA = Not applicable ++ = very good, + = good, o = average, NA = Not applicable II = Parallel on index, T = Parallel on table. (Oracle PARALLEL clause) = Parallel on index, T = Parallel on table. (Oracle PARALLEL clause) P = Parallel on process level (SAPDBA creates several processes) P = Parallel on process level (SAPDBA creates several processes)
SAP AG 1999

Reorganization: Options

Compress extents: Yes No


0 1 0 0 2 1

Reduce object size: Yes No


0 1 2 3 4
0 1 0 0 2 1

Freespace 0

1 2 0

4 3

1 2 0

4 3

Chop (export dump): Yes No sapreorg


2 GB 2 GB

Parallel export / import (Example: 2 processes in parallel)


exp_imp_degree = 2

sapreorg
4 GB

Database
Process 1 Process 2

Possible? Compress (export dump): Yes No


2 GB 2 GB

sapreorg1
dump1

sapreorg2
dump2

1 GB

2 GB

Both conditions required: exp_imp_degree = 2 and 2 dump destinations

sapreorg
SAP AG 1999

sapreorg

Unit Content: Tuning

Subunit 1 Subunit 2 Subunit 3 Subunit 4 Subunit 5 Subunit 6 Subunit 7 Subunit 8 Subunit 9 Subunit 10

Oracle Transactions I/O Tuning and Disk Configuration Database File Properties I/O Tuning: Buffer Cache Tuning the Oracle Database Writer Tuning the Oracle Log Writer Tuning Archiving Tuning the Shared Pool Tuning Rollback Segments Tuning the Temporary Tablespace

SAP AG 1999

Role of the Database in the R/3 Architecture

R/3 application layer

Oracle database

DB interface ------------------ABAP: EXEC SQL Insert . A

R/3 work process

SQL statement: Insert into .

SQL net

Shadow process

SAP AG 1999

Creating an SQL Statement

R/3 application layer


DB interface ------------------ABAP: EXEC SQL Insert . A

Oracle database

R/3 work process

SQL statement: Insert into .

SQL net

Shadow process
C

Shared Pool Insert into mara (.. Update mara set ... Select * from ...

Execution of this statement: Beginning of the Oracle transaction

SAP AG 1999

Step 1: Read block from datafile

Database Buffer Pool

1. Read data from the data file

Table Data Block

Data files
2

SAP AG 1999

Step 2: Read block from rollback

Database Buffer Pool

1. Read data from the data file 2. Read a block from the rollback segment

Table Data Block

Rollback Data Block

Data files

Rollback Segments

SAP AG 1999

Step 3: Write REDO for Rollback

Database Buffer Pool

1. Read data from the data file 2. Read a block from the rollback segment 3. Write REDO information to change the rollback block

Table Data Block

Rollback Data Block

1 REDO Log Buffer 2


Change vector for RB-Block

Data files

Rollback segments

SAP AG 1999

Step 4: Copy old data block to rollback

Database Buffer Pool

1. Read data from the data file 2. Read a block from the rollback segment 3. Write REDO information to change the rollback block 4. Copy the old data block value to the rollback data block
1

Table Data Block

4
Rollback Data Block

REDO Log Buffer 2 3


Change vector for RB-Block

Data files

Rollback segments

SAP AG 1999

Step 5: Write REDO for data block

Database Buffer Pool

1. Read data from the data file 2. Read a block from the rollback segment 3. Write REDO information to change the rollback block 4. Copy the old data block value to the rollback data block 5. Write REDO information to change the data block

Table Data Block

4
Rollback Data Block

1 REDO Log Buffer 2 3


Change vector for RB-Block

Data files

Change vector for Data-Block

Rollback Segments

SAP AG 1999

Step 6: Change the data block

Database Buffer Pool

1. Read the data from the data file 2. Read a block from the rollback segment 3. Write REDO information to change the rollback block 4. Copy the old data block value to the rollback data block 5. Write REDO information to change the data block 6. Change the data block

Changed Data Block

4
Rollback Data Block

1 REDO Log Buffer 2 3


Change vector for RB-Block

Data files

Change vector for Data-Block

5 5

Rollback Segments

SAP AG 1999

The Shadow Process

Database Buffer Pool 6 . A B C


Rollback Data Block Changed Data Block

1 REDO Log Buffer 2 3


Change vector for RB-Block

Data files

Change vector for Data-Block

5 5

Rollback segments

SAP AG 1999

The Shadow Process

LGWR DBWR

Shadow process

ARCH CKPT

All read operations are performed by Oracle shadow processes!

SAP AG 1999

The Shadow Process

So far, no data has been written to disks

ON

SAP AG 1999

COMMIT Change

B C

6 4 1 2 3 5

COMMIT
SAP AG 1999

Log Writer LGWR

REDO Log Buffer

IT M C O M

Change vector for RB-Block LGWR

Change vector for Data-Block

LGWR

OrigLog

MirrorLog

Online REDO log files

SAP AG 1999

Acknowledge Transaction

Data were successfully written to the REDO log


C

REDO log buffer


Change vector for RB-Block LGWR Change vector for Data-Block

LGWR

Online REDO log files

SAP AG 1999

Database Writer DBWR

Database Buffer Pool


Table Data Block

Rollback Data Block

Data files

Rollback segments

SAP AG 1999

Checkpoint CHKPT
Database Buffer Pool
Changed Data Block

Rollback Data Block

REDO Log Buffer


Change vector for RB-Block

Data files

DBWR Rollback segments

Change vector for Data-Block

Control files

CKPT Online REDO log files


SAP AG 1999

Overview of Oracle Transaction


Database Buffer Pool 6 . A B C
Rollback Data Block Changed Data Block

1 REDO Log Buffer 2 3


Change vector for RB-Block

Data files

Change vector for Data-Block

Control files Rollback segments CHKPT


Log switch

5 5

Online REDO log files ARCH


Log switch

SAP AG 1999

Offline REDO log files

Are your data safe?

1. Roll forward: Apply redo until all records from last completed checkpoint have been applied
Data files

Rollback Segments

Online REDO log files

2. Rollback: Rollback segments are used to undo the effects of uncommitted transactions applied by the roll forward phase (this generates redo and archives)

Data files

Rollback Segments

SAP AG 1999

Placement of Oracle Files

Temporary Data files

REDO log files

Rollback segments Control files

Offline REDO log files

SAP AG 1999

General Storage Systems

Several I/O subsystems for SAP R/3 are possible. The most important ones are RAID Write back caching Read/Write cached I/O subsystem

SAP AG 1999

RAID Levels

RAID Level RAID 0

Advantages Striping Low cost Good performance Reliability Good performance with striping Reliability Low cost Striping

Disadvantages Low reliability

RAID 1

Expensive

RAID 5

Poor write performance

SAP AG 1999

Disk Striping
Datafile Data file

Disk

Data file

Datafile Disk 1

Disk 2

SAP AG 1999

RAID 5 System

Disk Array Controller

Data block 1 Data block 2 Data block 3 Data block 4 Data block 5

P 4K

4K P

4K 4K P

4K 2K

4K 2K

P P 1 2 3 4 5

SAP AG 1999

Using RAID

RAID

Type of RAID

Control file
Avoid

Database file
Avoid

REDO log file


Avoid (1) Recommended

Archive log file


Avoid

NONE

Shadowing

Recommended

OK

Recommended

Striping + shadowing Parity check

OK

Recommended (2) Recommended (3)

OK

OK

OK

Avoid

Avoid

SAP AG 1999

Using Disk Caching

Type of caching

Control file OK never

Database file OK never

REDO log file (avoid) ? never

Archive log file avoid never

Write-through Write-back, unprotected Write-back, protected

OK (1)

OK (1)

OK (1)

OK (1)

SAP AG 1999

Read/Write cached I/O subsystem

Cache director
500 M

B/s

Host (database server)

Cache

Disk director

SAP AG 1999

Properties of the Database Files

Each Oracle database file has specific properties The typical I/O load to a file depends on its usage within the database The properties of a database file must be considered when it is placed in a file system

SAP AG 1999

REDO Log Files

REDO log files contain REDO information

he es r t fil fo g d 5 o Lo ai ed R R No ne li On

SAP AG 1999

REDO Log Layout


Recommended configuration

Standard SAP configuration

Disk 1/2 Disk 1/2


OrigLog A MirrLogB SAPARCH OrigLogA (# 1,3,5,7,9)

LGWR
MirrLogA (# 1,3,5,7,9)

Disk 5/6 ARCH

Disk 3/4

ARCH

LGWR
OrigLog B MirrLogA

SAPARCH OrigLogB (# 0,2,4,6,8)

Disk 9/10 Disk 5/6

Disk 3/4

LGWR
MirrLogB (# 0,2,4,6,8)

ARCH

Disk 7/8
SAP AG 1999

REDO Log Layout

Alternative REDO configuration without RAID


Disk 1
OrigLogA (# 1,3,5,7,9) MirrLogC (# 1,3,5,7,9) MirrLogE (# 1,3,5,7,9)

LGWR
MirrLogA (# 1,3,5,7,9)

Disk 5 Disk 2

Disk 7

+
Disk 6

+
Disk 8

OrigLogB (# 0,2,4,6,8)

LGWR
MirrLogB (# 0,2,4,6,8)

Disk 3
MirrLogD (# 0,2,4,6,8) MirrLogF (# 0,2,4,6,8)

Disk 4

SAP AG 1999

Archive Log Files

Archived online REDO log files

Offline REDO log files

5 id Ra No

SAP AG 1999

Rollback Segments

Contain UNDO information

Rollback segments (PSAPROLL)

5 id Ra No

SAP AG 1999

Data Files

Contain table and index data

Data files

SAP AG 1999

Temporary Tablespace

Used for sort operations

PSAPTEMP

5 id Ra No

SAP AG 1999

Control Files

Control files contain information about database layout

SAP AG 1999

Example of a Disk Layout

Disk striping or RAID 5 RAID 1 + Striping RAID 1 + Striping RAID 1 + Striping RAID 0* or 1 + Striping

Index data (SAPDATA1-N) Index data (SAPDATA1-N)

Table data (SAPDATA1-N) Table data (SAPDATA1-N)

Temporary tablespace (PSAPTEMP) Rollback segments (PSAPROLL) REDO log group 1 and mirror log (OrigLogA, MirrorLogA) REDO log group 2 and mirror log (OrigLogB, MirrorLogB)

RAID 1 + Striping

Archive log destination (SAPARCH)

SAP AG 1999

Oracle DB_Block_Buffer
. A B C

DB_BLOCK_SIZE (in SAP = 8k)

DB_BLOCK_BUFFERS

B C

Buffer Cache Datafiles


SAP AG 1999

Multiple Buffer Cache Structure

Buffer_POOL Default = Normal Oracle Buffer Cache

Buffer Cache as defined in init<SID>.ora with DB_BLOCK_BUFFERS = 1250000 Buffer_POOL_Keep= (BUFFERS:560000,LRU_LATCHES:8) Buffer_POOL_Recycle= (BUFFERS:250000,LRU_LATCHES:24)

SAP AG 1999

Analyzing Buffer Cache with ST04

Buffer Wait Time/ Buffer Busy Waits < 40 ms

15/ 1 CBO 20/ 1 RBO

SAP AG 1999

Database Block Buffer Sizing

The database buffer quality percentage is not sufficient to make decisions about the size of the buffer Before increasing the DB Block Buffer Check the available memory resources on the database server Check the executed SQL statements for possible improvements (indexes, ABAP) Our experience is that the buffer hit quality in a well tuned SAP/Oracle system (including SQL statement tuning and index usage) Should be over 95% running with the Oracle cost-based optimizer Should be higher equal 98% running with the Oracle rulebased optimizer
SAP AG 1999

Database Block Buffer

SAP AG 1999

LRU mechanism

*LRU = Least Recently Used DB block buffer is accessed


at laced -List s is p dres f the LRU ka Bloc nning o egi the b

LRU*-List

= Used Blocks

Buffers in the LRU list are aging

Unused buffers at the end of the list are replaced in the buffer cache Shadow process starts searching at the end of the LRU list

SAP AG 1999

DB_Block_LRU_Latches
(Available only with Oracle 7.3 onwards) Single LRU latch Multiple LRU latches

Buffer cache
SAP AG 1999

LRU latch

Buffer cache

LRU latches

Full Table Scan

LRU list DB block buffer is read from the table

Bloc k is p laced a

t the

end o f

the L RU-L ist

Only a small number of buffers at the end of the list are replaced in the buffer cache

SAP AG 1999

Checking the LRU Latches

Query V$LATCH and sort for latch name:

Misses / Gets < 0.1%

Immediate Misses / Immediate Gets < 0.1%

SAP Recommendation: SAP Recommendation: DB_BLOCK_LRU_LATCHES = 22**CPUs DB_BLOCK_LRU_LATCHES = CPUs

SAP AG 1999

Exercise: Monitor the LRU Latches

Latch name

Latch Gets number

Misses

Sleeps Immediate while wait Gets number

Immediate Misses Number

cache buffer chains cache buffer lru chain

SAP AG 1999

DBWR Events

When a checkpoint occurs Every 3 seconds No clean reusable buffer available

SAP AG 1999

Important DBWR Structures

Buffer cache

LRU queue
Max scan septh Changed by scan depth increment/decrement steps Min scan depth

Shadow process scan depth = 1/4 Buffer cache size

DBWR scan depth (varies)

DBWR

Shadow process Data files Dirty queue


Max dirty queue length Max write batch

SAP AG 1999

DBWR Shadow Process Actions


Read a new buffer 2.2 Move buffer to the tail of the dirty queue 1. Shadow process scan Yes depth exceeded ?

Buffer cache

No
2. Dirty buffer found on the LRU queue ? shadow process Scan Depth

Buffers Scanned 5 0001234 6 Sleep on event free buffer wait Signal DBWR

No
3. Use the buffer and move it to the head of LRU

Yes

Yes
2.1 Dirty queue length >= Max dirty queue length ?

No

LRU queue

Max dirty queue length

Dirty queue

4. Dirty buffers moved or known clean buffers small

Yes

Buffers moved by shadow process 5 0001234 6

Signal DBWR
SAP AG 1999

DBWR Actions
Signal from shadow process
Go IDLE, Wait for signals 2.1 Free LRU latch

Yes

1. Get LRU latch, reenable message

2. Dirty queue empty and known free buffers > 1/2 DBWR scan depth?

No
4.1 Scan LRU for dirty blocks

No

4. Full write batch in the dirty queue ?

Yes
4.2 Stop if dirty queue has a write batch or max scan depth reached 5. Release LRU latch

Yes
8. New signals?

No

6. Write batch of dirty blocks to the data files

7. Move blocks from dirty queue to tail of LRU

SAP AG 1999

Synchronous I/O Versus Asynchronous I/O

Read/Write without Async I/O 1. I/O request Wait for completion 2. I/O request 20 ms

Read/Write with Async I/O

20 ms 20 ms

Generate I/O requests 1-4 in parallel

20 ms 20 ms

Wait for completion 3. I/O request Wait for completion 4. I/O request

20 ms

Wait for completion 20 ms

20 ms Generate I/O requests 5-8 in parallel 20 ms Wait for completion

20 ms 20 ms 20 ms 40 ms

Completion of 4 I/O Requests:

80 ms

Completion of 8 I/O Requests:

SAP AG 1999

DBWR Processes

DB_WRITER_PROCESS 1

DB_WRITER_PROCESS 2

Data files

DB_WRITER_PROCESS n

Buffer cache

LRU latches

SAP AG 1999

DBWR I/O Slaves

Slave 1

DB_WRITER PROCESS

Slave 2

Slave n

Data files

Buffer cache

LRU latches

SAP AG 1999

Monitoring I/O problems of the DBWR

Before tuning the DBWR analyze view V$SYSTEM_EVENT for I/O problems causing a slow DBWR For details refer to unit Monitoring File System Requests write complete waits write complete waits free buffer waits free buffer waits ----------------------Should not have any major impact Should not have any major impact

SAP AG 1999

Monitoring the DBWR


Query V$SYSSTAT with RSORAVDV

WHERE name like 'summed dirty% or name like 'write requests

Summed dirty queue length / write requests < 1 WHERE name like 'free buffer%' or name like 'dirty buffers%' Free buffers requested / dirty buffers inspected < 1 % Free buffers requested / free buffers inspected < 1 %

SAP AG 1999

Rules and Thresholds: DBWR

Check first for I/O problems causing a slow DBWR


DBWR problem if
Dirty buffers inspected / free buffers requested > 1% Free buffers inspected / free buffers requested > 1% Summed dirty queue length / write requests > 1

Possible reasons:
I/O problems DB_BLOCK_BUFFERS too small Throughput I/O subsystem (expensive statements, DBWR problems, ...)

Possible solutions:
Tune I/O, tune expensive SQL statements, use async I/O if possible Increase DB_BLOCK_BUFFERS if possible Use multiple database writer processes

In any case dont change any parameterization without detailed problem analysis

SAP AG 1999

Checkpoint

Start Checkpoint 1 DBWR CHKPT Stop Checkpoint 1 Start Checkpoint 2 Stop Checkpoint 2 Start Checkpoint 3 Stop Checkpoint 3 Start Checkpoint 4

SAP AG 1999

Monitoring Checkpoints

WHERE name like 'background checkpoint%'

Query V$SYSSTAT with RSORAVDV

background checkpoints started = background checkpoints completed Alert file:

Thread 1 advanced to log sequence 248 Current log# 2 seq# 248 mem# 0: /oracle/PRD/orig_logA/redologs02.log Thread 1 cannot allocate new log, sequence 249 Checkpoint not complete
-> Checkpoint not complete -> System is inaccessible

SAP AG 1999

Rules and Thresholds: Checkpoint

Check first for I/O problems causing a slow DBWR


Checkpoint problem if
Background checkpoints started = background checkpoints completed Checkpoint not complete in the alert log file

Possible reasons:
I/O problems DB_BLOCK_BUFFERS too small SAP Recommendation if problems: Throughput I/O subsystem (expensive statements, DBWR problems, ...) SAP Recommendation if problems:

Possible solutions:

LOG_CHECKPOINT_TO_ALERT = TRUE LOG_CHECKPOINT_TO_ALERT = TRUE

Tune I/O, tune expensive SQL statements, use async I/O if possible Increase DB_BLOCK_CHECKPOINT_BATCH Increase DB_BLOCK_BUFFERS if possible Increase DB_FILE_ SIMULTANEOUS_WRITES Use multiple database writer processes In case of Checkpoint not complete increase the number of Online Redo Log Groups or increase the size of the existing groups but only if the time between two Online Redo Log switches is lower the 1 minute

In any case dont change any parameterization without detailed problem analysis

SAP AG 1999

Checkpoint Analysis in the Alert File

Time stamp starting checkpoint Logswitch Information Time stamp checkpoint completed

SAP AG 1999

Exercise: Monitor the DBWR

Query V$SYSSTAT with RSORAVDV

SAP AG 1999

Exercise: Monitor the DBWR

Name Background checkpoints completed Background checkpoints started Dirty buffers inspected Free buffer inspected Free buffer requested Summed dirty queue length Write requests

Value

Ratios

SAP AG 1999

Oracle Database: Possible Errors

When running multiple database writer (DBWR) slaves your system crashes and you receive the following error: ORA-07404: sfareq: Timeout occurred waiting for request to complete Because: The master database writer timed out waiting for a write or close to complete. One of the database writers may have stopped running. Action: Check all database writer trace files. Shut down the database and try to warm start.

SAP AG 1999

Log Writer Fundamentals

REDO Log Buffer


Change vector for RB-Block LGWR

Change vector for Data-Block

LGWR

OrigLog

MirrorLog

Online REDO log files


SAP AG 1999

LGWR: Normal Operation Versus Online Backup


2048 Byte I/O request DBWR OS OS splits 1 Oracle write request to 4 I/O request 2048 Byte 2048 Byte 2048 Byte
OS Block OS Block OS Block OS Block

1 Oracle Block 8192 Byte = 4 OS Blocks 2048 Byte

2048 Byte I/O request DBWR OS 2048 Byte 2048 Byte 2048 Byte Backup tool read 2 new and 2 old blocks

SAP AG 1999

LGWR Events

Each COMMIT When the REDO log buffer is 30% filled up After 3 seconds idle time When DBWR writes

SAP AG 1999

Oracle REDO Log Buffer

SAP AG 1999

Transaction ST04

REDO Buffer Size 1 MB

SAP Recommendation: SAP Recommendation: LOG_BUFFER_SIZE = 1024000 LOG_BUFFER_SIZE = 1024000


SAP AG 1999

Monitoring I/O problems of the LGWR Before tuning the LGWR analyze view V$SYSTEM_EVENT for I/O problems causing a slow LGWR For details refer to unit Monitoring File System Requests

(15 ms cached disk subsystem) (15 ms cached disk subsystem)

log file sync log file sync Average <= 40 ms Average <= 40 ms

SAP AG 1999

Monitoring LGWR Activity


Check only the first 10 rows sorted after Wait time (ms)

SAP AG 1999

Oracle REDO Log Buffer

event log file sync log file parallel write log buffer space db file sequential reads

Position

Wait time (ms)

Avg. wait. (ms)

Threshold (ms) 40 (15) 40 (15) ---------

---------

---------

sorted after Wait time (ms)

log file sync / log file parallel write <2

SAP AG 1999

Rules and Threshold: LGWR

Problems with the average commit time


Log file sync and log file parallel write out of the ranges Solution: I/O tuning Only Log file sync out of the ranges Check for problems writing into the log buffer

Problems with the average write time LGWR


See above

Problems with the waiting for space in REDO log buffer


Log buffer space among the first 10 rows in V$SYSTEM_EVENT sorted after Wait time (ms) Solution: First of all check for I/O problems Increase the size of the log buffer but only after I/O has been tuned

In any case dont change any parameterization without detailed problem analysis

SAP AG 1999

REDO Log Allocation

B C . A B C

Allocation latch

REDO Log buffer

SAP AG 1999

REDO Log Copies

B . C

B C

Allocation latch

REDO copy latch (LOG_SIMULTANEOUS_COPIES)

SAP AG 1999

REDO Log Copies Versus Allocation Latch

Allocation latch

REDO copy latch

Log-Entry < LOG_SMALL_ENTRY_MAX_SIZE

Log-Entry >= LOG_SMALL_ENTRY_MAX_SIZE

SAP AG 1999

Monitoring REDO Log Buffer Allocation

WHERE name like 'redo small copies%' or name like 'redo entries%'

Redo allocations: misses / gets < 0.001 Redo copy: misses / gets < 0.001

redo small copies / redo entries < 10 %

SAP AG 1999

Rules and Thresholds: REDO Latches

REDO small copies / REDO entries < 10%


Otherwise: Shadow processes wait too long for REDO latch because allocation latch is busy Solution: Decrease Log_small_entry_max_size (Check recommended Oracle database parameters, SAP Note 124361)

REDO allocations: misses / gets and immediate misses / immediate gets < 0.001
Otherwise: Shadow processes wait too long for allocation latch Solution: Decrease Log_small_entry_max_size to handle more requests with REDO copy latches

REDO copy latches: misses / gets and immediate misses / immediate gets < 0.001
Otherwise: Shadow processes wait too long for REDO latch because latch is busy Solution: Increase LOG_SIMULTANEOUS_COPIES to twice the number of installed CPUs

SAP AG 1999

Exercise: Monitor REDO-Latches

Redo allocations: misses / gets < 0.001

Redo copy: misses / gets < 0.001

redo small copies / redo entries < 10 %

SAP AG 1999

REDO Log Buffer: Important Parameters

LOG_BUFFER LOG_SIMULTANOUS_COPIES LOG_SMALL_ENTRY_MAX_SIZE LGWR_IO_SLAVES

SAP standard SAP standard recommendations recommendations Check note 124361 Check note 124361
SAP AG 1999

Archiver Fundamentals

ARCH

Read the control file to find any unarchived logs

ARCH
LOG_ARCHIVE_BUFFERS

2 Open online REDO log members to be read

ARCH ARCH 5a ARCH

3 Allocate REDO log buffers (log_archive_buffers)


Read the online REDO log, Fill up archive buffers with LOG_ARCHIVE_BUFFER_SIZE

Read the log_archive_buffer Write the archive files with LOG_ARCHIVE_BUFFER_SIZE. Update control file, change REDO log status

ARCH

SAP AG 1999

Rules and Thresholds: Archiving

Archiver should be fast enough to complete archiving before REDO is needed

Otherwise: Solution:

System becomes stuck Check the disks archives are placed on Increase LOG_ARCHIVE_BUFFER_SIZE Increase LOG_ARCHIVE_BUFFER_SIZE Use ARCH_IO_SLAVES

SAP AG 1999

Oracle Archiver: Important Parameters

LOG_ARCHIVE_BUFFERS LOG_ARCHIVE_BUFFER_SIZE ARCH_IO_SLAVES

SAP AG 1999

Oracle Shared Pool Structure

Shared_Pool_Reserved_Size Available only for some SQL statements

Shared pool available for all SQL statements Shared pool size as defined in the init<SID>.ora

Shared pool used for information about DD objects Self configured by the database

SAP AG 1999

Storing Statements

Statement: ABAP coding: SELECT from table WHERE field1 in itab Shared SQL Area: SELECT * FROM TABLE WHERE MANDT =:A1 AND FIELD1 IN (:A2, :A3, :A4, ..., :A600) Optimizer access path stored in Shared SQL Area: SELECT * FROM TABLE WHERE MANDT = 000 AND FIELD1 = 123 OR SELECT * FROM TABLE WHERE MANDT = 000 AND FIELD1 = 124 .... One OR clause ~20KB IN clause with 600 entries ~12MB
SAP AG 1999

Transaction ST04

?
reloads / pins <= 0,04 >= 2

SAP AG 1999

Shared SQL Area

SAP AG 1999

Shared Pool Sizing: Reusing SQL Statements

Used more than 3 times > 80%

Used less than 3 times < 20%

SAP AG 1999

Rules and Thresholds: Shared Pool Size

User / Recursive calls >= 2


Otherwise: Solution: Too many recursive calls, transactions become slow Check first historical data Increase SHARED_POOL_SIZE

Reloads / pins <= 0.04 Otherwise: Too many parse calls, transactions become slow Solution: Check for statements with IN clauses with multiple values Change IN to FOR ALL ENTRIES Increase SHARED_POOL_SIZE Statements used less than 3 times < 20% Otherwise: Memory on database server is wasted Solution: Decrease SHARED_POOL_SIZE Dont increase the SHARED_POOL_SIZE larger then 400 MB without detailed analysis

SAP AG 1999

Exercise: Oracle Shared Pool

Check also the historical data for User / Recursive calls


SAP AG 1999

Oracle Shared Pool Fragmentation

Reserved shared pool defined with SHARED_POOL_RESERVED_SIZE

SHARED_POOL_RESERVED_MIN_ALLOC

> 5000 Byte

Shared pool defined with SHARED_POOL_SIZE

SAP AG 1999

Monitoring Shared Pool Reserved Size

Query V$SHARED_POOL_RESERVED with ST04

NAME

VALUE (NOT OPTIMIZED) 8397744 714128 474 2964240 0 0 0 0

VALUE (OPTIMIZED) 741392 2559392 101609 6152 12021 6568 6952 0

FREE_SPACE MAX_USED_SIZE REQUESTS MAX_FREE_SIZE REQUEST_MISSES LAST_MISS_SIZE MAX_MISS_SIZE REQUEST_FAILURES

Recommended Settings for the init<SID>.ora: SHARED_POOL_RESERVED_SIZE = 10% of Shared Pool Size SHARED_POOL_RESERVED_MIN_ALLOC between 2048 and 3072

SAP AG 1999

Shared Pool: CURSOR_SPACE_FOR_TIME

SAP Recommendation: SAP Recommendation: Dont change the default value (FALSE) Dont change the default value (FALSE)

SAP AG 1999

Problems Related to the Oracle Shared Pool

ORA-04031, 00000, "out of shared memory when trying to allocate %s bytes (%s,%s)" Because: More shared memory is needed than was allocated in the shared pool. Action: Reduce your use of shared memory, or increase the amount of available shared memory by increasing the value of the init.ora parameter "shared_pool_size".

SAP AG 1999

Rollback Segments: Where Needed


COMMIT Job B: Update AUFNR SET OFFEN = N Where ...

Job A: SELECT * from AUFNR Where OFFEN = J Shadow process A


MANDT 001 001 001 .. AUFTR OFFEN 101 J 102 J 103 J .. ...

Shadow process B
te Crea k ac Rollb

MANDT 001 001 Upd 001 ate 001 ..

AUFTR OFFEN 100 J 101 N 102 N 103 N .. ...

Rollback Image of AUFNR

MANDT 001 001 001 Original Table AUFNR 001 ..

AUFTR OFFEN 100 J 101 J 102 J 103 J .. ...

Changed Table AUFNR

SAP AG 1999

Rollback Segments: Fundamentals

PRS_1

PRS _2

PRS _3

PRS _4

PRS _5

PRS _6

PRS _7

PRS _8

PRS _9

PRS _n

Transaction is assigned to the rollback segment with the least number of active transactions

B C

SAP work process uses DML (insert, update, delete)

SAP AG 1999

Rollback Segments: Block Allocation

E3 T1

T1

T2

E2 T2

T1

...

SAP AG 1999

Rollback Segments: Cyclical Reuse

E4 T1

T1

T2

E1 T1

T2

...

SAP AG 1999

Rollback Segments: Space Management

SAP AG 1999

First Approach Rollback Segments

Undo header + undo block : Buffer Busy Waits / Reads * 100 <= 0,1%

SAP AG 1999

Rules and Thresholds: # Rollback Segments

Buffer Busy Waits / Reads * 100 <= 0.1 Otherwise: Check classes undo header and undo block. Maybe the high number of waits is caused by shadow processes waiting too long for rollback segments Reason: Write load may be too high on a few rollback segment data files caused by a small number of rollback segments. Solution: Increase the number of rollback segments Thresholds for the number of Rollback Segments SAP recommendation: At least workprocesses / 4 Oracle recommendation: Concurrent users / 2

SAP AG 1999

Monitoring RBS: Contention During Access

SAP AG 1999

Monitoring RBS: Space Management Operations

Calculate Optimal Size: Number of RBS with HWM > Optimal size < 10%

SAP AG 1999

Rules and Thresholds: Rollback Segment Size

1. Number of RBS with HWM greater Optimal size < 10% Otherwise: To many space management operations on Rollback Segments Transaction take longer Solution: Create new Rollback Segments with appropriate storage parameters SAP recommendations for the setup of the Rollback Segments see note 165247 2. Create more than 1 tablespace for the rollback segments and create as many datafiles on different disks as possible Otherwise: Administration becomes more difficult Write load may be focussed on a few disks DBWR becomes slow because disk are to busy

SAP AG 1999

ORA-1555: Mechanism Overwriting Rollback

Transaction T1

COMMIT

Transaction T2 Update MARA ... Select from MARA = Select old values from rollback

Update Rollback Block with old MARA values

Rollback Segment

Table MARA

SAP AG 1999

ORA-1555: Long processing time

ORA-1555: Snapshot Too Old

1. Expensive query
Database buffer pool Large number of Large number of buffers used on the buffers used on the database server database server ORA 1555

Application server
Snap dump

2. Long processing time between two data fetches


Database buffer pool ORA 1555

High processing High processing time on the time on the application server application server

Application server

SAP AG 1999

ORA-1555: Delayed Block Cleanout


Database buffer pool

1.

A table is changed, changed, dirty blocks are written to disk, then the changes are committed A query runs against this table
B C . A B C

2.
. A

3.
. A B . A C B C

Further change activity writes to the RBS until it wraps and the lowest SCN in the RBS is higher than the starting SCN of the query When the query reads a dirty block, the required rollback information is already overwritten

4.

ORA-1555: Snapshot Too Old


SAP AG 1999

ORA 1555

ORA-1555: Possible Solutions

Tune the SQL statement or the ABAP coding which causes the ORA-1555 Change the application design so that fewer COMMITs take place Increase the number of rollback segments Increase the size of the rollback segments

SAP AG 1999

Operations Requiring Temporary Segments


Operations Requiring Temporary Segments

CREATE INDEX SELECT ... ORDER BY SELECT DISTINCT ... SELECT ... GROUP BY SELECT ... UNION SELECT ... INTERSECT SELECT ... MINUS

SAP AG 1999

Oracle Sort Operations


Select Order By ...

Sort_Area_Size (Process PGA)


SORT_AREA_RETAINED_SIZE Non-Direct Sort

Buffer Cache Memory out of SORT_AREA_SIZE


SWBS (32 K) SDB (2) LRU-List = Sorted Data Blocks SWBS = SORT_WRITE_BUFFER_SIZE SDB = SORT_DIRECT_BUFFERS Direct Sort

DBWR
PSAPTEMP

SAP AG 1999

Setup of the Temporary Tablespace


Select Order By ...

Sort_Area_Size (Process PGA)


SORT_AREA_RETAINED_SIZE

Memory out of SORT_AREA_SIZE


SWBS (32 K) SDB (2)

Direct Sort

Size of INITIAL and NEXT default settings of PSAPTEMP

INITIAL

NEXT

NEXT

PSAPTEMP

SAP AG 1999

Creating a Temporary Segment

Alter tablespace PSAPTEMP temporary;


PSAPTEMP

Tables SMON

T DED T N DED NO E N NO E MM AP MM AP CO Y S E COBY S RE B R

Indexes

SAP AG 1999

Monitor Temporary Tablespace

Sorts: Memory / disks < 0.1 %

SAP AG 1999

Rules and Thresholds Temporary Tablespace

1.Check Temporary Tablespace for correct type PERMANENT


Otherwise: Solution: Possible hanging situations might be occur Set temporary tablespace to PERMANENT

2. Disk sorts / memory sorts < 0.1 %


Otherwise: Possible performance lost because of long running sorts Solution: Check your statements for unneeded sort or group by clauses Check your statements for selectivity Check for indexes which avoid sort operations Increase SORT_AREA_SIZE ==> !!! More memory on DB server may be needed !!!

3. Dont tune your system for expensive sort operations


Otherwise: Solution: Necessary resources (like memory) are wasted for few expensive sort operations Try to avoid expensive sort operations

SAP AG 1999

Temporary Segments: Possible Errors

ORA-01575: time-out waiting for space management resource Because: The system timed out before it could acquire the necessary resources to do space management. Action: Wait a few minutes, then retry the operation.

SAP AG 1999

Potrebbero piacerti anche