Beruflich Dokumente
Kultur Dokumente
Fundamentals II
Electronic Presentation
D11297GC11
Production 1.1
December 2001
D34297
Authors Copyright © Oracle Corporation, 2001. All rights reserved.
Donna Keesling This documentation contains proprietary information of Oracle Corporation. It is provided under a
license agreement containing restrictions on use and disclosure and is also protected by copyright
James Womack law. Reverse engineering of the software is prohibited. If this documentation is delivered to a U.S.
Government Agency of the Department of Defense, then it is delivered with Restricted Rights and the
following legend is applicable:
and Reviewers Use, duplication or disclosure by the Government is subject to restrictions for commercial computer
software and shall be deemed to be Restricted Rights software under Federal law, as set forth in
Lance Ashdown subparagraph (c)(1)(ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software
Tammy Bednar (October 1988).
Louise Beijer This material or any portion of it may not be copied in any formor by any means without the express
Howard Bradley prior written permission of the Education Products group of Orac le Corporation. Any other copying is
Senad Dizdar a violation of copyright law and may result in civil and/or criminal penalties.
Joel Goodman If this documentation is delivered to a U.S. Government Agency not within the Department of
Scott Gossett Defense, then it is delivered with “ Restricted Rights,” as defined in FAR 52.227-14, Rights in Data-
General, including Alternate III (June 1987).
Stefan Lindblad
Howard Ostrow The information in this document is subject to change without notice. If you find any problems in the
Radhanes Petronilla documentation, please report them in writing to Worldwide Education Services, Oracle Corporation,
500Oracle Parkway, Box SB-6, Redwood Shores, CA 94065. Oracle Corporation does not warrant
Maria Jesus Senise Garcia that this document is error-free.
Peter Sharman
Oracle and all references to Oracle Products are trademarks or registered trademarks of Oracle
Ranbir Singh Corporation.
Harald Van Breederode
John Watson All other products or company names are used for identification purposes only, and may be
trademarks of their respective owners.
Steven Wertheimer
Junichi Yamazaki
Publisher
John B Dawson
1
Networking Overview
Network
Client
Server
Network Network
Client
Middle tier
Server
• Client can be a thin client or a PC
• Middle tier can contain applications and services
• Server holds actual data
DECnet
DECnet
TCP/IP
TCP/IP
APPC/LU6.2
TCP/IP
• Connectivity
• Directory Services
• Scalability
• Security
• Accessibility
• Protocol independence
• Comprehensive platform support
• Integrated GUI administration tools
• Multiple configuration options
• Tracing and diagnostic toolset
• Basic security
2
1
3
Connection
Manager
Server
• Encryption
– Encodes between network nodes
– DES, RSA, 3DES
• Authentication
– Authenticates users through third-party services and
Secure Sockets Layer (SSL)
– Kerberos, Radius, CyberSafe
• Data Integrity
– Ensures data integrity during transmission
– MD5, SHA
fdh37djf246gs’b[da,\ssk
Web browser
Application Oracle
Web server server
JavaNet OPS
Client
Server
HTTP
IIOP
Web
browser
Oracle
Web Server
browser supporting
HTTP and IIOP
Client
Database Server
Client Oracle
RDBMS
Web browser
HTTP, IIOP
TCP/IP TCP/IP
• Database services
• Service Name
– A logical representation of a database
– The way a database is presented to clients
• Connect Descriptor
– Location of the database
– Name of the database service
• Listener
– Receives client connection requests
– Hands requests to the database server
• Service Registration
– Database registers information with the listener
– Service handlers available for each instance
• Service Handlers
– Connection points
– Dispatcher or dedicated server
• Localized management
– Local file on each computer in the network
• Centralized management
– LDAP-compliant directory server
– Oracle Names server
• ldap.ora
• listener.ora
• names.ora
• sqlnet.ora
• tnsnames.ora
Client Server
Listener
tnsnames.ora
sqlnet.ora listener.ora
sqlnet.ora
3
4
2
1
listener
Client Server
Server or
dispatcher
6 process
5 3
port
4 2
1 port
Listener
1. LISTENER =
2. (ADDRESS_LIST =
3. (ADDRESS= (PROTOCOL= TCP)(Host= stc-
sun02)(Port= 1521)))
4. SID_LIST_LISTENER =
5. (SID_LIST =
6. (SID_DESC =
7. (ORACLE_HOME= /home/oracle)
8. (GLOBAL_DBNAME = ORCL.us.oracle.com)
9. (SID_NAME = ORCL)))
• Prompt syntax:
LSNRCTL> <command name>
Client Server
TCP/IP
…
names.directory_path = (HOSTNAME)
sqlnet.ora
listener.ora
Client Server
TCP/IP
1521
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = stc-sun02.us.oracle.com)
(ORACLE_HOME = /u03/ora9i/rel12)
(SID_NAME = TEST)
sqlnet.ora listener.ora
• listener.ora file
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = stc-sun02.us.oracle.com)
(ORACLE_HOME = /u03/ora9i/rel12)
(SID_NAME = TEST)
• Connecting from the client
sqlplus system/manger@stc-sun02.us.oracle.com
Client Server
sqlnet.ora
tnsnames.ora listener.ora
sqlplus system/manager@MY_SERVICE
SQL*Plus:Release 9.0.1.0.0-Production on Thu Nov 15 13:46:24 2001
(c) Copyright 2001 Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.0.1.0.0 - Production
JServer Release 9.0.1.0.0 - Production
SQL>
Client Server
Instance
SGA
User Server
process process
Snnn
Snnn
Database server
Client
User User
process process
TEST.world =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = stc-sun02)
(PORT = 1521)
)
(CONNECT_DATA=(SERVICE_NAME=TEST.us.oracle.com)
(SERVER=DEDICATED)
)
)
Dispatcher Dispatcher
process process
D001 D002
1
User User
process process
DISPATCHERS = “(PROTOCOL=TCP)(DISPATCHERS=2)\
(PROTOCOL=IPC)(DISPATCHERS=1)”
MAX_DISPATCHERS = 5
Dispatcher
D004
Dispatcher Dispatcher Dispatcher Dispatcher
D001 D002 D003 D005
TCP/IP TCP/IP IPC
SHARED_SERVERS = 6
MAX_SHARED_SERVERS = 10
CIRCUITS = 100
SHARED_SERVER_SESSIONS = 100
$ lsnrctl services
• V$CIRCUIT
• V$SHARED_SERVER
• V$DISPATCHER
• V$SHARED_SERVER_MONITOR
• V$QUEUE
• V$SESSION
• Statement failure
• User process failure
• User error
• Network failure
• Instance failure
• Media failure
• Business requirements
• Operational requirements
• Technical considerations
• Management concurrence
• 24-hour operations
• Testing and validating backups
• Database volatility
Datafile 3 Archived
Password
file log files
Database
Datafile 3
Password Archived
file log files
Database
Disk 1
(Member a)
log1a.rdo log2a.rdo log3a.rdo
Disk 2
(Member b)
log1b.rdo log2b.rdo log3b.rdo
• Full checkpoint
– All dirty buffers are written
– SHUTDOWN NORMAL, IMMEDIATE, or TRANSACTIONAL
– ALTER SYSTEM CHECKPOINT
• Incremental checkpoint (Fast-Start checkpoint)
– Periodic writes
– Only write the oldest blocks
• Partial checkpoint
– Dirty buffers belonging to the tablespace
– ALTER TABLESPACE BEGIN BACKUP
– ALTER TABLESPACE tablespace OFFLINE NORMAL
Datafile 3
Password Archived
file log files
Database
Datafile 3
Password Archived
file log files
Database
1. Datafiles out-of-synch
2. Roll forward (redo) Instance
SGA
3. Committed and non- Shared pool
committed data in files Java pool Large pool
Shared SQL
and PL/SQL
4. Roll back (undo)
Database Redo log Data dict.
5. Committed data in files buffer cache buffer cache
Database
Parameter Definition
Improved
response
SMON
P000
P001
P002
Undo P003
Tables
segment
FAST_START_PARALLEL_ROLLBACK parameter
FALSE None
HIGH 4 * CPU_COUNT
• V$FAST_START_SERVERS
• V$FAST_START_TRANSACTIONS
052
054 053
Redo history
051
052
Online redo log files
LGWR
No redo
history
Online redo
log files 052 053
053
054
052
052 053
053
054
LGWR
Redo
history
Online redo
log files 052 053
051
054 053 051
052
052 051
053
054 053 053
Archived
log files
1 SHUTDOWN NORMAL/IMMEDIATE/TRANSACTIONAL
Initialization Control
parameters file
053 053
DBA
LOG_ARCHIVE_MAX_PROCESSES=2
ARC0ARC1
053
053 053
LOG_ARCHIVE_START=TRUE 052
052
LOG_ARCHIVE_MAX_PROCESSES=n
ARC0 051
3
2
Initialization
parameters
LOG_ARCHIVE_START
1
051 052
• LOG_ARCHIVE_MIN_SUCCEED_DEST parameter
LOG_ARCHIVE_MIN_SUCCEED_DEST = 2
Online redo
log files
Group 1 Group 2
Archived log file
053 053
052
052
ARC0
ARC0 052
053 053
052 /ORADATA/archive/arch%s.arc
LOG_ARCHIVE_DEST_n
LOG_ARCHIVE_FORMAT
Dynamic Views
V$ARCHIVED_LOG
V$ARCHIVE_DEST
V$LOG_HISTORY
V$DATABASE
V$ARCHIVE_PROCESSES
Command Line
Server
session
(polling)
Recovery Enterprise
Target Manager Manager
database (RMAN)
Server
session
(rcvcat)
Recovery
Disk Disk catalog DB
Disk
Server
Channel (disk)
Session
Target RMAN
database Server
Channel (sbt)
Session
Media
Recovery Oracle server
management
Manager session
library
Media
management
server software
Tape library or
single tape
• Target database
• Recovery catalog database
• Auxiliary database
– Standby database
– Duplicate database
– TSPITR instance
• Interactive mode
– Use it when doing analysis
– Minimize regular usage
– Avoid using with log option
• Batch mode
– Meant for automated jobs
– Minimize operator errors
– Set the log file to obtain information
RUN command:
RMAN> RUN {
backup
incremental level 0
format ‘/u01/db01/backup/%d_%s_%p’
fileperset 5
(database include current controlfile);
sql ‘alter database archive log current’;
}
dbms_backup_restore
dbms_rcvcat dbms_rcvman
Recovery
Manager
dbms_rcvcat
dbms_rcvman dbms_rcvman dbms_rcvman
PL/SQL
Recovery Target
catalog control file
V$DATAFILE
V$CONTROLFILE
V$LOGFILE
DBA_DATA_FILES
NOARCHIVELOG ARCHIVELOG
mode mode
Physical backup
Online or
offline storage
• Conceptually simple
• Easy to perform
• Require little operator interaction
2
SHUTDOWN IMMEDIATE
3
HOST cp <files> /backup/
1
STARTUP OPEN
4
Online redo
Archived redo log files
Password file Parameter file log files
LGWR
ARCHIVELOG mode
052 051 ARC0
054 053
051
052 051 051
054 053 052
052
053
053
Online redo Archived redo
log files log files
Dynamic views
V$BACKUP
V$DATAFILE_HEADER
Database
2
3
File 1
backup copy SCN 1 Query_Data
SCN 1 File 1
Users File 1
4 SCN 2
DBW0
Users File 2
SCN 2
Logging Nologging
4
DBVERIFY
Error
1 2 3 reporting
Online
Online Offline
Datafiles
Backup set
RMAN> RUN {
2> ALLOCATE CHANNEL t1 TYPE 'SBT'
3> MAXPIECESIZE = 4G;
4> BACKUP
5> FORMAT 'df_%t_%s_%p' FILESPERSET 3
6> (tablespace users); }
RMAN> BACKUP
2> FORMAT '/BACKUP/df_%d_%s_%p.bus'
3> DATABASE filesperset = 2;
Datafile Datafile
Datafile 1 1
1
Datafile Datafile
Datafile 2 2
2
BACKUP1 BACKUP2
Backup set
Datafile Datafile
1 1
Datafile Datafile
2 2
RMAN> BACKUP
2> FORMAT '/disk1/backup/ar_%t_%s_%p'
3> ARCHIVELOG ALL DELETE ALL INPUT;
Archived Archived
log file log file Copy of archived log
RMAN> COPY
2> DATAFILE '/ORADATA/users_01_db01.dbf' TO
3> '/BACKUP/users01.dbf' tag=DF3,
4> ARCHIVELOG 'arch_1060.arc' TO
5> 'arch_1060.bak';
RMAN> COPY
2> DATAFILE 3 TO '/BACKUP/file3.dbf',
3> DATAFILE 1 TO '/BACKUP/file1.dbf';
Datafile
Datafile Control Redo log
1 files file 1
1
Image copy
Datafile Redo log
2 file 2
Datafile
3 Datafile
3 Database
Image copy
Level 0 Level 0
Lvl 0 2 2 1 2 2 2 0
Day Sun Mon Tue Wed Thu Fri Sat Sun
Level 0 Level 0
Lvl 0 2 2C 1 2 2C 2C 0
Day Sun Mon Tue Wed Thu Fri Sat Sun
Datafiles Datafile
2,4 4
• V$ARCHIVED_LOG
• V$BACKUP_CORRUPTION
• V$COPY_CORRUPTION
• V$BACKUP_DATAFILE
• V$BACKUP_REDOLOG
• V$BACKUP_SET
• V$BACKUP_PIECE
Online
Redo log
• Advantages
– Easy to perform, with low risk of error
– Recovery time is the time it takes to restore all files
• Disadvantages
– Data is lost and must be reapplied manually
– The entire database is restored to the point of the last
whole closed backup
• Complete Recovery
– Uses redo data or incremental backups
– Updates the database to the most current point in time
– Applies all redo changes
• Incomplete Recovery
– Uses backup and redo logs to produce a noncurrent
version of the database
• Advantages
– Only need to restore lost files
– Recovers all data to the time of failure
– Recovery time is the time it takes to restore lost files
and apply all archived log files
• Disadvantages
– Must have all archived log files since the backup from
which you are restoring
Case 1 Read-Only
rman target /
RMAN> STARTUP MOUNT
RMAN> RESTORE DATABASE;
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN;
Instance
User Server SGA
process process Shared pool
PGA Shared SQL
Locks Large Pool
and PL/SQL
Data Redo log Data dict.
buffer buffer cache
User Server
process process SMON DBWn PMON CKPT LGWR ARCn
PGA
1 1 1
Datafile 1 Control Redo log
files file 1
Parameter 1 0 Archived
Datafile 2 Redo log log files
file file 2
1
Datafile 3
Password
file
Database
RECOVER DATABASE
until time ‘2001-03-04:14:22:03’
using backup controlfile
Scenario:
• The current time is 12:00 p.m. on March 9, 2001.
• The EMPLOYEES table has been dropped.
• The table was dropped at approximately 11:45 a.m.
• Database activity is minimal because most staff are
currently in a meeting.
• The table must be recovered.
Scenario:
• The current time is 12:00 p.m. on March 9,2001.
• The EMPLOYEES table was dropped while someone
was trying to fix bad blocks.
• Log files exist on the same disk.
• The table was dropped at approximately 11:45 a.m.
• Staff are currently in a meeting.
Findings:
• Redo logs are not multiplexed.
• One of the online redo logs is missing.
• The missing redo log is not archived.
• The redo log contained information from 11:34 a.m.
• Twenty-six minutes of data will be lost.
• Users can recover their data.
Scenario:
• The current time is 12:00 p.m. on March 9, 2001.
• The tablespace containing the EMPLOYEES table has
been dropped.
• The error occurred around 11:45 a.m.
• Many employee records were updated this morning,
but not since 11:00 a.m.
• Backups are taken every night.
Findings:
• The backup from last night contains datafiles and
control files required for recovery.
• The EMP_TS tablespace has one datafile.
• The current log sequence number is 61.
• You confirm that the tablespace was dropped at
11:44:54 a.m. on March 9, 2001.
• Datafile number 4 is offline.
RMAN> run {
2> allocate channel c1 type DISK;
3> allocate channel c2 type DISK;
4> set until time = ‘2000-12-09:11:44:00';
5> restore database;
6> recover database;
7> alter database open resetlogs; }
RMAN> RUN {
2> SET UNTIL SEQUENCE 120 THREAD 1;
3> ALTER DATABASE MOUNT;
4> RESTORE DATABASE;
5> RECOVER DATABASE; # recovers through log 119
6> ALTER DATABASE OPEN RESESTLOGS;
7> }
Reporting
Target Control file REPORT Stored
LIST scripts
database
Catalog Maintenance
Register
Resynchronize
Reset Catalog
Change/Delete/Catalog database
Backup /Restore/Recover
3. Grant privileges
Catalog
4. Create catalog database
• Example on UNIX
$ ORACLE_SID=db01; export ORACLE_SID
$ rman target /
RMAN> connect catalog rman_db01/rman_db01@catdb
• Example on Windows NT
C:\> set ORACLE_SID=db01
C:\> rman target /
RMAN> connect catalog rman_db01/rman_db01@catdb
Reporting
Target Control file REPORT Stored
LIST scripts
database
Catalog Maintenance
Register
Resynchronize
Reset Catalog
Change/Delete/Catalog database
Backup /Restore/Recover
Catalog
database
RMAN >
Target
Control file database
Reporting
Target Control file REPORT Stored
LIST scripts
database
Catalog Maintenance
Register
Resynchronize
Reset Catalog
Change database
Backup /Restore/Recover
Reporting
Target Control file REPORT Stored
LIST scripts
database
Catalog Maintenance
Register
Resynchronize
Reset Catalog
Change database
Backup /Restore/Recover
Oracle
database
Export
Import
Oracle
database
• Command-line interface
• An interactive dialog
• Parameter files
• Oracle Enterprise Manager
• Syntax:
exp keyword = value, value2, … ,valuen
• Examples:
exp hr/hr TABLES=employees,departments
rows=y file=exp1.dmp
Direct Path
Direct Path
Conventional Path
Parameter file
…..(Other Parameters)
DIRECT = Y
…...(Other Parameters)
Mode Description
• Syntax:
imp keyword = value or keyword = value,
value2, … value n
• Examples:
imp hr/hr TABLES=employees,departments
rows=y file=exp1.dmp
• Physical investigation:
– Use views and tools to derive information
– View trace files and log files
– View command output and log files
– Use views and tools to confirm proper database
configuration
• Database configuration:
– Archiving is enabled
– Control files and log files are mirrored
– Control file is backed up
• Instructor-facilitated workshop
• Group-oriented
• Hands-on approach
• Simulated “real-world” environment
• Minimize down time and data loss
• Use tools and diagnostics to determine the type of
failure
Other applications
Oracle
database
Export
SQL*Loader
Import
Oracle
database
Direct-load INSERT
Server
EMPLOYEES table process
Slave Slave
process process
EMPLOYEES table
Parameter file
SQL*Loader Rejected
(optional)
Field processing
Discarded Accepted
Record selection
Bad
Selected file
Oracle server
Discard file Rejected
Inserted
(optional)
Log file
Database datafiles
Array
insert
Conventional
Direct
Table Data path
save
High-water
mark
Space used only by conventional load
Temporary segments
load1.dat SQL*Loader
load1.ctl
SQL*Loader
load2.dat
load2.ctl
SQL*Loader
load3.dat
load3.ctl
Table
High-water
mark
$sqlldr hr/hr \
> control=case1.ctl \
> log=case1.log direct=Y
case1.ctl
SQL*Loader
EMPLOYEES table
case1.log
• Bad file
– SQL*Loader rejects records when the input format is
invalid
– If the Oracle database finds that the row is invalid, the
record is rejected and SQL*Loader puts it in the bad
file
• Discard file
– This can be used only if it has been enabled
– This file contains records that were filtered out
because they did not match any record-selection
criteria specified in the control file
• Header Information
• Global Information
• Table Information
• Datafile Information
• Table Load Information
• Summary Statistics
• Additional statistics for direct path loads and
multithreading Information