Oracle9i Database Administration Fundamentals II
-
Upload
api-3696260 -
Category
Documents
-
view
161 -
download
8
Transcript of Oracle9i Database Administration Fundamentals II
Oracle9i Database Administration Fundamentals II
Electronic Presentation
D11297GC20Production 2.0August 2002D37069
®
Copyright © Oracle Corporation, 2002. All rights reserved.
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 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:
Restricted Rights Legend
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 subparagraph (c)(1)(ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software (October 1988).
This material or any portion of it may not be copied in any form or by any means without the express prior written permission of the Education Products group of Oracle Corporation. Any other copying is a violation of copyright law and may result in civil and/or criminal penalties.
If this documentation is delivered to a U.S. Government Agency not within the Department of Defense, then it is delivered with “Restricted Rights,” as defined in FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
The information in this document is subject to change without notice. If you find any problems in the 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 warrantthat this document is error-free.
Oracle and all references to Oracle Products are trademarks or registered trademarks of Oracle Corporation.
All other products or company names are used for identification purposes only, and may be trademarks of their respective owners.
Authors
Donna KeeslingJames Womack
Technical Contributorsand Reviewers
Lance AshdownTammy BednarLouise BeijerHarald van BreederodeHoward BradleySenad DizdarSteven GeorgeJoel GoodmanScott GossettJohn HibbardStefan LindbladRoman NiehoffHoward OstrowRadhanes PetronillaMaria Jesus Senise GarciaPeter SharmanRanbir SinghSergey StetsenkoJohn WatsonSteven WertheimerJunichi Yamazaki
Publisher
May Lonn Chan-Villareal
Copyright © Oracle Corporation, 2002. All rights reserved.
Networking Overview
1-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Explain the solutions in Oracle9i that can be used
to manage complex networks• Describe Oracle networking add-on solutions
1-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Network Environment Challenges
• Configuring the network environment• Maintaining the network• Tuning, troubleshooting, and monitoring the
network• Implementing security in the network• Integrating legacy systems
1-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Simple Network: Two-Tier
• Network connects client and server• Client and server speak the same language or
protocol
Network
Client
Server
1-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Simple to Complex Network: N-Tier
• Client can be a thin client or a PC• Middle tier can contain applications and services• Server holds actual data
Network
Middle tier
Network
Client Server
1-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Complex Network
TCP/IP
TCP/IPTCP/IP
TCP/IP SSL
TCP/IP SSL
Named Pipes
1-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle9i Networking Solutions
• Connectivity• Directory Services• Scalability• Security• Accessibility
1-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Connectivity: Key Features ofOracle Net Services
• Protocol independence• Comprehensive platform support• Integrated GUI administration tools• Multiple configuration options • Tracing and diagnostic toolset• Basic security
1-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Connectivity: Oracle Net Services
Protocol
Oracle Net
Client Server
Any platform Any platform
Administration and configuration
Protocol
Oracle Net
1-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Connectivity: Database Connectivity with HTTP
Web browser Oracle9iHTTP
1-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Directory Services: Directory Naming
• Process of resolving a network alias using an LDAP-compliant directory server
• Clients must be configured to use the LDAP compliant server
1-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Directory Services: OracleInternet Directory
• Oracle’s LDAP compliant directory service• Provides the following features:
– Integrates tightly with Oracle9i
– Simplifies network administration– Provides a secure and reliable directory structure
1-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Scalability: Oracle Shared Server
• Enables a large number of users to connect to a database simultaneously
• Database resources are shared resulting in efficient memory and processing usage
• Connections are routed via a dispatcher• Server processes are not dedicated to each client• Server processes serve client processes as
needed
1-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Scalability: Oracle Connection Manager
Oracle Connection Manager offers:• Multiplexing of connections• Cross-protocol connectivity• Network access control
1-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Scalability: Oracle Connection Manager
Server
Oracle ConnectionManager
1 2
3
1-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Security: Advanced Security
• 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
1-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Advanced Security Encryption
Client
Corporate earnings are up 45% this quarter
1
Decrypt
Server
2Encrypt
fdh37djf246gs’b[da,\ssk
3
Corporate earnings are up 45% this quarter
Oracle Advanced SecurityInstalled
Oracle Advanced Security Installed
1-20 Copyright © Oracle Corporation, 2002. All rights reserved.
Security: Oracle Net Services and Firewalls
• Oracle works with key firewall vendors to provide firewall support
• Oracle Net Firewall Proxy Kit allows firewall vendors to provide connection support for Oracle environments
• Oracle Net Firewall Proxy is based on Oracle Connection Manager
• Oracle supports two categories of firewalls:– Proxy-based firewalls– Stateful packet inspection firewalls
1-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Accessibility: Heterogeneous Services
• Enables access of legacy data as if it resides in a single, local relational database
• Enables Oracle procedure calls to access non-Oracle systems, services, or APIs
1-22 Copyright © Oracle Corporation, 2002. All rights reserved.
Accessibility: External Procedures
• Functions written in a 3GL language that can be called from PL/SQL
• Allows the developer more flexibility than SQL or PL/SQL provide
• Listener can listen for external procedure calls• Connections to external procedure can be
configured during or after server installation
1-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Net Services Configuration and Administration Tools
• Oracle Net Manager– Used for configuring and managing Oracle Net– Client- or server-based tool– Integrated with Oracle Enterprise Manager
• Oracle Net Configuration Assistant• Oracle Net Control utilities
– Listener Control utility– Oracle Connection Manager Control utility– Oracle Names Control utility
1-24 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Net Manager
1-25 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Net Configuration Assistant
1-26 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Explain Oracle’s solutions for managing complex
networks:– Oracle Net Services – HTTP Connectivity– Oracle Internet Directory– Oracle Shared Server– Connection Manager
• Describe Oracle’s add-on solutions:– Oracle Advanced Security– Heterogeneous Services
Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Net Architecture
2-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Explain the key components of the Oracle Net
stack communication architecture • Explain Oracle Net’s role in client-server
connections• Describe how Web client connections are
established through Oracle networking products
2-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Net Connections
• Oracle Net is used to establish connections between applications on a network depending on the following: – The network configuration– The location of the nodes – The application – The network protocol
• The connections types can be:– Client-Server Application– Java Application– Web Client Application
2-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Client-Server Application Connection
Oracle Database ServerClient
Two Task Common
Client Application(uses OCI)
Oracle NetFoundation Layer
Oracle Protocol Support
Network Protocol
Two Task Common
Oracle RDBMS(uses OPI)
Oracle NetFoundation Layer
Oracle Protocol Support
Network Protocol
OracleNet
OracleNet
2-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Web Client Application Connections
Web browsers can connect to an Oracle server in the following ways: • Using an application Web server as a middle tier
that is configured with either of the following:– JDBC Oracle Call Interface (OCI) driver– Thin JDBC driver
• Connecting directly to an Oracle server by using HTTP
2-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Web Client Application Connection: Application Web Server Middle-Tier
Web browserOracleserver
Application Web server
Client Server
HTTP Oracle Net
Java application or applet
2-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Web Client Application Connection: Java Application Client
Oracle Database ServerApplication Web
Server (client)
Two-Task Common
Java application
Oracle NetFoundation Layer
Oracle ProtocolSupport
Network Protocol
Two-Task Common
OracleRDBMS
Oracle NetFoundation Layer
Oracle ProtocolSupport
Network Protocol
JDBC OCI Driver
2-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Web Client Application Connection: Java Applet Client
Application Web Server (client)
JavaTTC
Java Applet
JavaNet
TCP/IP NetworkProtocol
JDBC Thin driver
Oracle Database Server
Two-Task Common
OracleRDBMS
Oracle NetFoundation Layer
Oracle Protocol Support
TCP/IP NetworkProtocol
2-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Web Connections Using HTTP
Oracleserver
supportingHTTP
Client Server
Web browser
HTTP
2-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Web Browser Direct Connection
Oracle Database Server
Client
HTTP
Web browser
TCP/IP
HTTP
Oracle
RDBMS
Oracle Protocol Support
TCP/IP
2-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Connectivity Concepts and Terminology
• 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
2-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Connectivity Concepts and Terminology
• Service Registration– Database registers information with the listener– Service handlers available for each instance
• Service Handlers– Connection points– Dispatcher or dedicated server
2-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Net Configuration Models
• Localized management– Local file on each computer in the network
• Centralized management– LDAP-compliant directory server– Oracle Names server
2-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Overview of Naming Methods
• Naming methods are used by a client application to resolve a connect identifier to a connect descriptor when attempting to connect to a database service.
• Oracle Net provides five naming methods: – Host naming – Local naming – Directory naming – Oracle Names – External naming
2-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Net Configuration Files
listener.ora sqlnet.ora
tnsnames.oranames.oraldap.ora
2-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Explain the key components of the Oracle Net
stack communication architecture • Explain Oracle Net Services role in client-server
connections• Describe how Web client connections are
established through Oracle networking products
Copyright © Oracle Corporation, 2002. All rights reserved.
Basic Oracle Net ServerSide Configuration
3-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Identify how the listener responds to incoming
connections• Describe Dynamic Service Registration• Configure the listener by using Oracle Net
Manager• Control the listener by using the Listener Control
Utility• Configure the listener for HTTP connections
3-3 Copyright © Oracle Corporation, 2002. All rights reserved.
The Listener Process
listener.ora
Listener
Client Server
tnsnames.ora
sqlnet.ora
3-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Connection Methods
When a connection request is made by a client to a server, the listener performs one of the following:• Spawns a server process and bequeaths (passes)
the connection to it• Hands off the connection to a dispatcher in an
Oracle Shared Server configuration• Redirects the connection to a dispatcher or server
process
3-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Spawn and Bequeath Connections
Listener
ServerClient
Dedicated Server Process
1 2
3
3-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Direct Hand-Off Connections
Listener
Dispatcher1 2
3SharedServer
Process
SharedServer
Process
3-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Redirected Session
port
Listener
Client Server
port
Server ordispatcher
process
12
3
4
56
3-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Service Configuration and Registration
The listener can be configured in two ways:• Dynamic service registration
– Does not require configuration in listener.orafile
– The listener relies on the PMON process
• Static service configuration– Used for Oracle8 and earlier releases– Requires listener.ora configuration
– Required for Oracle Enterprise Manager and other services
3-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Static Service Registration:The listener.ora File
Default settings for the listener.ora file with Oracle software installation:• Listener name LISTENER• Port 1521• Protocols TCP/IP and IPC• SID name Default instance• Host name Default host name
3-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Static Service Registration: The listener.ora File
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)))
3-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Static Service Registration: Create a Listener
3-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring Services
3-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Dynamic Service Registration:Configure Registration
To ensure that service registration is functional, the following initialization parameters must be configured:• SERVICE_NAMES
• INSTANCE_NAME
3-20 Copyright © Oracle Corporation, 2002. All rights reserved.
Dynamic Service Registration:Registering Information with the Listener
• By default, PMON registers with a local listener on the server on the default local address of TCP/IP, port 1521
• PMON can register with a non default listener if:– LOCAL_LISTENER initialization parameter is defined – LISTENERS attribute of the DISPATCHERS
initialization parameter is defined for Oracle Shared Server
3-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Configure the Listener for Oracle9i JVM: HTTP
• The listener can be configured to accept connections from clients using HTTP.
• Use Static Listener Registration if the database is Oracle8i or an earlier version, even if Oracle9ilistener is used.
• If both the listener and the database are Oracle9i, configuration occurs dynamically during service registration.
3-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Listener Control Utility (LSNRCTL)
Listener Control Utility commands can be issued from the command-line or from the LSNRCTL prompt.
• UNIX command-line syntax:•
• Prompt syntax:
• Control a non-default listener:
$ lsnrctl <command name>
LSNRCTL> <command name>
LSNRCTL> set current_listener listener02
3-24 Copyright © Oracle Corporation, 2002. All rights reserved.
LSNRCTL Commands
Use the following commands to control the listener:• Starting the listener:
• Stopping the listener:
$lsnrctl START listener_name
$lsnrctl STOP listener_name
3-26 Copyright © Oracle Corporation, 2002. All rights reserved.
LSNRCTL SET and SHOW Modifiers
• Change listener parameters with SET:
• Display the values of parameters with SHOW:
LSNRCTL> SET trc_level ADMIN
LSNRCTL> SHOW trc_directory
3-28 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Configure the listener by using Oracle Net
Manager• Control the listener by using the Listener Control
Utility• Configure the listener for HTTP connections
3-29 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 3 Overview
This practice covers the following topics:• Configuring a non-default LISTENER• Starting and stopping your listener• Viewing the LISTENER log file
Copyright © Oracle Corporation, 2002. All rights reserved.
Naming Method Configuration
4-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Describe the difference between host naming and
local service name resolution• Use Oracle Net Configuration Assistant to
configure:– Host Naming method– Local naming method– Net service names
• Perform simple connection troubleshooting
4-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Overview of Naming Methods
• Naming methods are used by a client application to resolve a connect identifier to a connect descriptor when attempting to connect to a database service.
• Oracle Net provides five naming methods: – Host naming – Local naming – Directory naming – Oracle Names – External naming
4-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Host Naming
Clients can connect to a server using a host name under the following conditions:• Connecting to an Oracle database service using
Oracle Net Services Client software• Client and server are connecting using TCP/IP
protocol• Host names are resolved through an IP address
translation mechanism such as DNS or a local /etc/hosts file
• No advanced features such as Oracle Connection Manager or security options are used
4-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Host Naming: Client Side
sqlnet.ora
…names.directory_path = (HOSTNAME)
Server
listener.ora
Client
TCP/IP
4-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Host Naming: Server Side
Client
sqlnet.ora listener.ora
Server
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = stc-sun02.us.oracle.com)
(ORACLE_HOME = /u03/ora9i/rel12)
(SID_NAME = TEST)
1521
TCP/IP
4-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Host Naming: Example
• listener.ora file:
• Connecting from the client:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = stc-sun02.us.oracle.com)
(ORACLE_HOME = /home1/user461/oracle)
(SID_NAME = TEST)
sqlplus system/[email protected]
4-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring Host Naming Using Net Manager
4-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Local Naming
listener.ora
ServerClient
tnsnames.ora
sqlnet.ora
4-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring the tnsnames.ora File Using Net Manager
4-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring the tnsnames.ora File Using Net Manager
4-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring the tnsnames.ora File Using Net Manager
4-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring the tnsnames.ora File Using Net Manager
4-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring the tnsnames.ora File Using Net Manager
4-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring the tnsnames.ora File Using Net Manager
4-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring the Local Naming Method Using Net Manager
4-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Generated Files:tnsnames.ora
# TNSNAMES.ORA Network Configuration
# File:D:\oracle\ora92\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
U461 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)(HOST = ed-pdsun1)(PORT = 8461))
)
(CONNECT_DATA =
(SERVICE_NAME = U461)
)
)
4-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Generated Files:sqlnet.ora
# SQLNET.ORA Network Configuration File:
D:\oracle\ora92\NETWORK\ADMIN\sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES)
4-20 Copyright © Oracle Corporation, 2002. All rights reserved.
Troubleshooting the Client Side
The following error codes are related to problems on the client side:
ORA-12154 “TNS:could not resolve service name”
ORA-12198 “TNS:could not find path to destination”
ORA-12203 “TNS:unable to connect to destination”
ORA-12533 “TNS:illegal ADDRESS parameters”
ORA-12541 “TNS:no listener”
4-22 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Describe the difference between host naming and
local service name resolution• Use Oracle Net Manager to configure:
– Host naming method– Local naming method– Net service names
• Perform simple connection troubleshooting
4-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 4 Overview
This practice covers the following topics:• Local Naming configuration• Configuration of net service names• Testing the configuration
Copyright © Oracle Corporation, 2002. All rights reserved.
Usage and Configurationof the Oracle Shared Server
5-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Identify the components of the Oracle Shared
Server• Describe the Oracle Shared Server architecture• Configure the Oracle Shared Server• Identify and explain usefulness of related data
dictionary views
5-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Server Configurations
• Dedicated server process• Shared server process
5-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Dedicated Server Processes
Client Server
Userprocess
Serverprocess
PMONDBWnSMON LGWRCKPT ARCn
Instance
SGA
5-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Shared Server
Shared serverprocesses
Database serverClient
Snnn
Snnn
Userprocess
Userprocess
Snnn
InstanceSGA
DispatcherD003
DispatcherD001
DispatcherD002
5-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Benefits of Oracle Shared Server
• Reduces the number of processes against an instance
• Increases the number of possible users• Achieves load balancing• Reduces the number of idle server processes• Reduces memory usage and system overhead
5-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Using a Dedicated Server with Oracle Shared Server
TEST.world =(DESCRIPTION =(ADDRESS =(PROTOCOL = TCP)(HOST = stc-sun02)(PORT = 1521)
)
(CONNECT_DATA=(SERVICE_NAME=TEST.us.oracle.com)(SERVER=DEDICATED) ) )
5-9 Copyright © Oracle Corporation, 2002. All rights reserved.
2
1
Database serverClient
Connecting
Userprocess
Userprocess
Listener
Dispatcherprocess
D001
Dispatcherprocess
D002
3
5-10 Copyright © Oracle Corporation, 2002. All rights reserved.
PMONDBWnSMON LGWRCKPT ARCn
RequestQueue Response queue
for (D002)Response queue
for (D003)
InstanceSGA
Processing a Request
Shared serverprocesses
Database server
client
Snnn
Snnn
Userprocess
Listener
DispatcherD002
DispatcherD003
Snnn Response queue for (D001)
4
53
2
1 6
DispatcherD001
Userprocess
5-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Shared Server: User session data is held in the SGA SGA
Usersession
data
Cursor state
Shared pool and other memory
structures
Stackspace
PGA
Dedicated Server: User session data is kept in the PGA
The SGA and PGA
SGA
Shared pool and other memory structures
Stackspace
User session
data
Cursor state
PGA
5-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Configuring Oracle Shared Server
• Required initialization parameters– DISPATCHERS
– SHARED_SERVERS
• Optional initialization parameters– MAX_DISPATCHERS
– MAX_SHARED_SERVERS
– CIRCUITS
– SHARED_SERVER_SESSIONS
5-14 Copyright © Oracle Corporation, 2002. All rights reserved.
DISPATCHERS
Specifies the number of dispatchers initially started for a given protocol
DISPATCHERS = "(PROTOCOL=TCP)(DISPATCHERS=2)\
(PROTOCOL=IPC)(DISPATCHERS=1)"
DispatcherD002
TCP/IP
DispatcherD003
IPC
DispatcherD001
TCP/IP
5-16 Copyright © Oracle Corporation, 2002. All rights reserved.
MAX_DISPATCHERS
• Specifies the maximum number of dispatcher processes that can run simultaneously
• Issues the ALTER SYSTEM command to add more dispatchers than initially started
MAX_DISPATCHERS = 5
DispatcherD002
TCP/IP
DispatcherD003IPC
DispatcherD001
TCP/IP
DispatcherD004
DispatcherD005
5-18 Copyright © Oracle Corporation, 2002. All rights reserved.
SHARED_SERVERS
Specifies the number of server processes created when an instance is started up
SHARED_SERVERS = 6
S001
S002
S003
S004
S005
S006
5-20 Copyright © Oracle Corporation, 2002. All rights reserved.
MAX_SHARED_SERVERS
• Specifies the maximum number of shared servers that can be started
• Allows shared servers to be allocated dynamically based on the length of the request queue
MAX_SHARED_SERVERS = 10
S001
S002
S003
S004
S005
S006
S007
S008
S009
S010
5-21 Copyright © Oracle Corporation, 2002. All rights reserved.
CIRCUITS
• Specifies the total number of virtual circuits that are available for inbound and outbound network sessions
• Contributes to total SGA size
CIRCUITS = 100
5-22 Copyright © Oracle Corporation, 2002. All rights reserved.
SHARED_SERVER_SESSIONS
• Specifies the total number of Oracle Shared Server user sessions to allow
• Setting this parameter enables you to reserve user sessions for dedicated servers
SHARED_SERVER_SESSIONS = 100
5-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Related Parameters
Other initialization parameters affected by Oracle Shared Server that may require adjustment:• LARGE_POOL_SIZE
• SESSIONS
5-25 Copyright © Oracle Corporation, 2002. All rights reserved.
• Verify that the dispatcher has registered with the listener when the instance was started by issuing:
• Verify that you are connected using shared servers by making a single connection then query V$CIRCUIT view to show one entry per shared server connection.
Verifying Setup
$ lsnrctl services
5-27 Copyright © Oracle Corporation, 2002. All rights reserved.
Dynamic Views
• V$CIRCUIT
• V$SHARED_SERVER
• V$DISPATCHER
• V$SHARED_SERVER_MONITOR
• V$QUEUE
• V$SESSION
5-28 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Identify the components of the Oracle Shared
Server• Describe the Oracle Shared Server architecture• Configure the Oracle Shared Server• Identify and explain usefulness of related data
dictionary views
5-29 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 5 Overview
This practice covers the following topics:• Configuring Oracle Shared Server• Defining LOCAL_LISTENER for instance
registration• Using the Listener Control utility to verify services• Verifying shared server configuration and
performance using V$ views
• Verifying instance registration
Copyright © Oracle Corporation, 2002. All rights reserved.
Backup and Recovery Overview
6-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Describe the basics of database backup, restore,
and recovery• List the types of failures that may occur in an
Oracle environment• Define a backup and recovery strategy
6-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Backup and Recovery Issues
• Protect the database from numerous types of failures
• Increase Mean-Time-Between-Failures (MTBF)• Decrease Mean-Time-To-Recover (MTTR)• Minimize data loss
6-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Categories of Failures
• Statement failure• User process failure• User error• Network failure• Instance failure• Media failure
6-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Causes of Statement Failures
• Logic error in an application• Attempt to enter invalid data into the table• Attempt an operation with insufficient privileges• Attempt to create a table but exceed allotted quota
limits• Attempt an INSERT or UPDATE to a table, causing
an extent to be allocated, but with insufficient free space available in the tablespace
6-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Resolutions for Statement Failures
• Correct the logical flow of the program• Modify and reissue the SQL statement• Provide the necessary database privileges• Change the user’s quota limit by using the ALTER
USER command
• Add file space to the tablespace• Enable resumable space allocation
6-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Causes of User Process Failures
• The user performed an abnormal disconnect in the session
• The user’s session was abnormally terminated• The user’s program raised an address exception,
which terminated the session
6-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Resolution of User Process Failures
• The PMON process detects an abnormally terminated user process
• PMON rolls back the transaction and releases any resources and locks being held by it
6-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Possible User Errors
SQL> DROP TABLE employees;
SQL> TRUNCATE TABLE employees;
SQL> UPDATE employees
2> SET salary = salary * 1.5;
SQL> COMMIT;
SQL> DELETE FROM employees;
SQL> COMMIT;
6-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Resolution of User Errors
• Train the database users• Recover from a valid backup• Import the table from an export file• Use LogMiner to determine the time of error• Recover with a point-in-time recovery• Use LogMiner to perform object-level recovery• Use FlashBack to view and repair historical data
6-12 Copyright © Oracle Corporation, 2002. All rights reserved.
146146
Database
Datafile 1
Datafile 2
Datafile 3
Controlfiles
Redo log file 1
Redo log file 2
145
Causes of Instance FailureInstance
SGA
Redo logbuffer
Databuffer
Large PoolLocks
Shared pool
Data dict.cache
Shared SQLand PL/SQL
PMONDBWnSMON LGWRCKPT ARCnUser
processServer
processPGA
Userprocess
Serverprocess
PGA
146
146
146
Parameterfile
Passwordfile
6-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovery from Instance Failure
• No special recovery action is needed from DBA• Start the instance• Wait for the “database opened” notification• Notify users• Check the alert log to determine the reason for the
failure
6-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Causes of Media Failures
• Head crash on a disk drive• Physical problem in reading from or writing to
database files• File was accidentally erased
6-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Resolutions for Media Failures
• The recovery strategy depends on which backup method was chosen and which files are affected
• If available, apply archived redo log files to recover data committed since the last backup
6-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Defining a Backup and Recovery Strategy
• Business requirements• Operational requirements• Technical considerations• Management concurrence
6-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Business Requirements
• Mean time to recover• Mean time between failure• Evolutionary process
6-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Operational Requirements
• 24-hour operations• Testing and validating backups• Database volatility
6-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Technical Considerations
• Resources: hardware, software, manpower, and time
• Physical image copies of the operating system files
• Logical copies of the objects in the database• Database configuration• Transaction volume that affects desired frequency
of backups
6-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Disaster Recovery Issues
• How will your business be affected in the event of a major disaster, such as:– Earthquake, flood, or fire – Complete loss of machine– Malfunction of storage hardware or software– Loss of key personnel, for example the database
administrator
• Do you have a plan for testing your strategy periodically?
6-25 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Evaluate potential failures in your environment• Develop a strategy dictated by business,
operational, and technical requirements• Consider a test plan for a backup and recovery
strategy
Copyright © Oracle Corporation, 2002. All rights reserved.
Instance and Media Recovery Structures
7-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Describe the Oracle processes, memory
structures, and files relating to recovery• Identify the importance of checkpoints, redo log
files, and archived log files• Describe ways to tune instance recovery
7-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Overview
Database
Datafile 1
Datafile 2
Datafile 3
Controlfile
Redo log file 1
Redo log file 2
InstanceSGA
Redo logbuffer
Databasebuffer cache
Large PoolJava Pool
Shared pool
Data dict.cache
Shared SQLand PL/SQL
ARCn
Userprocess
Serverprocess
PGA
Parameterfile
Passwordfile
Archivedlog files
PMONDBWnSMON LGWRCKPT
7-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Large Pool
• Can be configured as a separate memory area in the SGA to be used for:– Oracle backup and restore operations– I/O server processes– Session memory for the shared servers
• Is sized by the LARGE_POOL_SIZE parameter
7-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Database Buffer Cache, DBWn, and Data files
InstanceSGA
Database buffer cache
Large poolJava pool
Shared pool
Data dict.cache
Shared SQLand PL/SQL
ARCn
Userprocess
Serverprocess
PGA
Database
Datafile 1
Datafile 2
Datafile 3
Controlfile
Redo log file 1
Redo log file 2
Parameterfile
Passwordfile
Archived log files
PMONDBW0SMON LGWRCKPTDBW1
Redo logbuffer
7-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Redo Log Buffer, LGWR, and Redo Log Files
InstanceSGA
Database buffer cache
Large poolJava pool
Shared pool
Data dict.cache
Shared SQLand PL/SQL
ARCn
Userprocess
Serverprocess
PGA
Database
Datafile 1
Datafile 2
Datafile 3
Controlfile
Redo log file 1
Redo log file 2
Parameterfile
Passwordfile
Archived log files
PMONSMON LGWRCKPT
Redo logbuffer
DBWn
7-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Group 1
log1a.rdo
log1b.rdo
Group 2
log2a.rdo
log2b.rdo
Group 3
Multiplexed Redo Log Files
Disk 1(Member a)
Disk 2(Member b)
log3a.rdo
log3b.rdo
7-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Redo Log Files in Enterprise Manager
7-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Database Checkpoints
• Checkpoints are used to determine where recovery should start
• Checkpoint position - where recovery starts• Checkpoint queue - link list of dirty blocks
7-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Types of Checkpoints
• 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 OFFLINENORMAL
7-19 Copyright © Oracle Corporation, 2002. All rights reserved.
CKPT Process
InstanceSGA
Database buffer cache
Large poolJava pool
Shared pool
Data dict.cache
Shared SQLand PL/SQL
ARCn
Userprocess
Serverprocess
PGA
Database
Datafile 1
Datafile 2
Datafile 3
Controlfile
Redo log file 1
Redo log file 2
Parameterfile
Passwordfile
Archived log files
PMONSMON LGWRCKPT
Redo logbuffer
DBWn
7-20 Copyright © Oracle Corporation, 2002. All rights reserved.
Multiplexed Control Files
InstanceSGA
Databasebuffer cache
Large poolJava pool
Shared pool
Data dict.cache
Shared SQLand PL/SQL
ARCn
Userprocess
Serverprocess
PGA
Database
Datafile 1
Datafile 2
Datafile 3
Redo log file 1
Redo log file 2
Parameterfile
Passwordfile
Archived log files
PMONDBWnSMON LGWRCKPT
Controlfiles
Redo logbuffer
7-22 Copyright © Oracle Corporation, 2002. All rights reserved.
Control Files in Enterprise Manager
7-23 Copyright © Oracle Corporation, 2002. All rights reserved.
ARCn Process and Archived Log Files
InstanceSGA
Database buffer cache
Large poolJava pool
Shared pool
Data dict.cache
Shared SQLand PL/SQL
ARC0
Userprocess
Serverprocess
PGA
Database
Datafile 1
Datafile 2
Datafile 3
Controlfile
Redo log file 1
Redo log file 2
Passwordfile
Archived log filesdest 1
PMONDBWnSMON LGWRCKPT
Parameterfile
Passwordfile
Archived log filesdest 2
ARC1
Redo logbuffer
7-25 Copyright © Oracle Corporation, 2002. All rights reserved.
Database Synchronization
• All datafiles (except offline and read-only) must be synchronized for the database to open.
• Synchronization is based on the current checkpoint number.
• Applying changes recorded in the redo log files synchronizes datafiles.
• Redo log files are automatically requested by the Oracle server.
7-26 Copyright © Oracle Corporation, 2002. All rights reserved.
Database
Datafile 1
UndoDatafile
Datafile 3
Controlfile
Redo log file 1
Redo log file 2
146.5146.5
146.5
146.5
146.5
145
Phases for Instance Recovery
1. Datafiles out-of-synch2. Roll forward (redo)3. Committed and non-
committed data in files4. Roll back (undo)5. Committed data in files
SQL*Plus Serverprocess
PGA
Undo
Checkpoint
InstanceSGA
Redo logbuffer
Databasebuffer cache
Large poolJava pool
Shared pool
Data dict.cache
Shared SQLand PL/SQL
ARCnPMONDBWnSMON LGWRCKPT
7-28 Copyright © Oracle Corporation, 2002. All rights reserved.
Tuning Crash and Instance Recovery Performance
• Tuning the duration of instance and crash recovery
• Tuning the phases of instance recovery
7-29 Copyright © Oracle Corporation, 2002. All rights reserved.
Tuning the Duration of Instance and Crash Recovery
Methods to keep the duration of instance and crash recovery within user-specified bounds:• Set initialization parameters to influence the
number of redo log records and data blocks involved in recovery.
• Size the redo log file to influence checkpointing frequency.
• Issue SQL statements to initiate checkpoints.• Parallelize instance recovery operations.
7-30 Copyright © Oracle Corporation, 2002. All rights reserved.
Initialization ParametersInfluencing Checkpoints
Parameter
FAST_START_MTTR_TARGET
LOG_CHECKPOINT_TIMEOUT
LOG_CHECKPOINT_INTERVAL
Definition
Expected MTTR specified in seconds
Amount of time that has passed
since the incremental checkpoint at
the position where the last write to
the redo log occurred
Number of redo log file blocks that
can exist between an incremental
checkpoint and the last block written
to the redo log
7-32 Copyright © Oracle Corporation, 2002. All rights reserved.
Controlling Instance Crash Recovery Time
7-33 Copyright © Oracle Corporation, 2002. All rights reserved.
V$INSTANCE_RECOVERY
• Used to monitor the mechanisms that are available to limit recovery I/O
• Statistics from this view to calculate which parameter has the greatest influence on checkpointing
7-35 Copyright © Oracle Corporation, 2002. All rights reserved.
Tuning the Phases of Crash and Instance Recovery
• Tuning the roll forward phase• Tuning the rollback phase
7-36 Copyright © Oracle Corporation, 2002. All rights reserved.
Tuning the Rolling Forward Phase
• Parallel block recovery• RECOVERY_PARALLELISM specifies the number of
concurrent recovery processes
7-37 Copyright © Oracle Corporation, 2002. All rights reserved.
Tuning the Rolling Back Phase
• Fast-start on-demand rollback• Fast-start parallel rollback
7-38 Copyright © Oracle Corporation, 2002. All rights reserved.
Fast-Start On-Demand Rollback
Server process encountering data to be rolled back performs the following:• Rolls back the block containing the required row • Hands off further recovery, which may be in
parallel, to SMON
Improvedresponse
7-39 Copyright © Oracle Corporation, 2002. All rights reserved.
Fast-Start Parallel Rollback
SMON
Undosegment
Tables
P001
P000
P002
P003
7-40 Copyright © Oracle Corporation, 2002. All rights reserved.
Controlling Fast-Start Parallel Rollback
FAST_START_PARALLEL_ROLLBACK parameter
Value
FALSE
LOW (default)
HIGH
Maximum Parallel Recovery Servers
None
2 * CPU_COUNT
4 * CPU_COUNT
7-41 Copyright © Oracle Corporation, 2002. All rights reserved.
Monitoring Parallel Rollback
• V$FAST_START_SERVERS: Provides information about all the recovery slaves performing parallel transaction recovery
• V$FAST_START_TRANSACTIONS: Contains information about the progress of the transactions that Oracle is recovering
7-43 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Identify components of the instance and database
that are significant to recovery• Tune crash and instance recovery
7-44 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 7 Overview
This practice covers the following topics:• Querying dynamic performance views to
determine the current state and structure of the database
• Explaining the use of specific initialization parameters
• Mirroring of the control files and redo log files
12-16 Copyright © Oracle Corporation, 2002. All rights reserved.
User-Managed Recovery Procedures:RECOVER Command
• Recover a mounted database:
• Recover an open database: •
SQL> RECOVER DATABASE
SQL> RECOVER TABLESPACE users
SQL> RECOVER DATAFILE 2> ’/ORADATA/u03/users01.dbf’
Or
SQL> RECOVER DATAFILE2> ’/ORADATA/u03/users01.dbf’
Or
12-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Using Archived Redo Log Files During Recovery
• To change archive location, use the ALTER SYSTEM ARCHIVE LOG. . . command.
• To apply redo log files automatically:– Issue the SET AUTORECOVERY ON command before
starting media recovery.– Enter auto when prompted for an archived log file.– Use the RECOVER AUTOMATIC. . . command.
12-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Restoring Datafiles to a New Locationwith User-Managed Procedures
• Use operating system commands to restore the datafile to the new location.
• Use the ALTER DATABASE RENAME FILEcommand to record the change in the control file.
12-20 Copyright © Oracle Corporation, 2002. All rights reserved.
Complete Recovery Methods
• Closed database recovery for:– System datafiles– Undo segment datafiles– Whole database
• Open database recovery, with database initially opened (for file loss)
• Open database recovery with database initially closed (for hardware failure)
• Data file recovery with no datafile backup
12-22 Copyright © Oracle Corporation, 2002. All rights reserved.
Complete Recovery of a Closed Database
Closed database recovery is used for:• System tablespace datafiles• Rollback segment datafiles• Whole database
12-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Shut down the instance1
Closed Database Recovery: Example
Restore datafile 1(Log Sequence 144)2
Open the database4
Mounted Database
Recovered Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
Closed Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
144Datafile 1
146Datafile 2
146Datafile 3
146Redo log
file 1
145Redo log
file 2 3
146Control
files3
3
Archivedlog file
144
12-25 Copyright © Oracle Corporation, 2002. All rights reserved.
Open Database Recovery When the Database Is Initially Open
Use this method when: • The database is currently open• The database will remain open during the recovery• The media failure does not affect the SYSTEM
tablespace
12-26 Copyright © Oracle Corporation, 2002. All rights reserved.
1
Open Database Recovery: Example
2
4
3
Take datafile 2 offline
Restore datafile 2(Log Sequence 144)
Bring datafile 2 online
Open Database
Archivedlog file
144
Recovered Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
Open Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
146Datafile 1
144Datafile 2
146Datafile 3
146Redo log
file 1
145Redo log
file 23
146Control
files 3
12-28 Copyright © Oracle Corporation, 2002. All rights reserved.
Open Database Recovery When the Database Is Initially Closed
Use this method when:• The database is currently closed• The database will be opened during recovery• The media failure does not affect the SYSTEM
tablespace
12-29 Copyright © Oracle Corporation, 2002. All rights reserved.
Take datafile 2 offline2
Open Database Recovery: Example
Restore datafile 24
Bring datafile 2 online6
1 Mount the database
3 Open the database
5
Open Database
Archivedlog file
144
Recovered Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
Closed Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
146Datafile 1
144Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1
145Redo log
file 255
12-31 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovery of a Datafile Without a Backup
• Datafile is lost that was never backed up• Cannot be used when it is a file from the SYSTEM
tablespace• Cannot be used if the control file has been
recreated
12-32 Copyright © Oracle Corporation, 2002. All rights reserved.
Re-Creating Lost Datafiles Without Backup
• Used when missing datafile cannot be restored because it had never been backed up.
• Description of missing datafile is still in data dictionary and control file.
• Re-create the datafile:
• Re-create the datafile with a different filename:
SQL> ALTER DATABASE CREATE DATAFILE ’filename’;
SQL> ALTER DATABASE CREATE DATAFILE ’filename’AS ’new file name’;
12-33 Copyright © Oracle Corporation, 2002. All rights reserved.
Open Database
Recovery without a Backup: Example
Bring the datafile or tablespace online
4
1 Take the datafile or tablespace offline
2 Re-create the datafile
3 Archivedlog file
144
Recovered Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
Open Database
146Datafile 1
146Datafile 2
146Datafile 3
146Control
files
146Redo log
file 1145
Redo logfile 2
146Datafile 4
146Datafile 4
146Datafile 1
144Datafile 2
146Datafile 3
Datafile 4
146Control
files
146Redo log
file 1
145Redo log
file 233
12-35 Copyright © Oracle Corporation, 2002. All rights reserved.
Read-Only Tablespace Recovery
Backup 2 Recovery
Case 1
Case 2
Case 3
Backup 1
Read-Only
Read-WriteRead-Only
Read-OnlyRead-Write
12-36 Copyright © Oracle Corporation, 2002. All rights reserved.
Read-Only Tablespace Recovery Issues
Special considerations must be taken for read-onlytablespaces when:• Re-creating a control file• Renaming datafiles• Using a backup control file
12-37 Copyright © Oracle Corporation, 2002. All rights reserved.
Loss of Control Files
You may need to create control files if:• All control files are lost because of a failure• The name of a database needs to be changed• The current settings in the control file need to be
changed
12-38 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovering Control Files
Methods to recover from loss of control file:• Use the current control file• Create a new control file• Use a backup control file
12-39 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Determine what type of recovery is required• Determine which files need to be restored and
recovered• Recover a database in NOARCHIVELOG mode• Recover a database in ARCHIVELOG mode• Restore datafiles to different locations if the
original location is unavailable
12-40 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 12 Overview
These practices cover the following topics:• Performing complete database recovery with the
database in NOARCHIVELOG mode• Performing complete database recovery with the
database in ARCHIVELOG mode
Copyright © Oracle Corporation, 2002. All rights reserved.
RMAN Complete Recovery
13-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Describe the use of RMAN for restoration and
recovery• Perform complete recovery in ARCHIVELOG mode• Restore datafiles to different locations• Relocate and recover a tablespace by using
archived redo log files
13-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Restoration and Datafile Media Recovery Using RMAN
• Restore files from backup sets or image copies by using the RMAN RESTORE command
• Recover files by using the RMAN RECOVERcommand
13-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Using RMAN to Recover a Database in ARCHIVELOG Mode
rman target /
RMAN> STARTUP MOUNT
RMAN> RESTORE DATABASE;
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN;
13-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Using the Recovery Wizard
13-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Using RMAN to Restore Datafiles to a New Location
• Use the SET NEWNAME command to restore the datafile to the new location.
• Use the SWITCH command to record the change in the control file.
SET NEWNAME FOR DATAFILE 1 to ‘/<newdir>/system01.dbf’;
SWITCH DATAFILE ALL;
13-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Restoring to a New Location
13-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Using RMAN to Recover a Tablespace
Use the following RMAN commands to restore and recover a tablespace: • RESTORE TABLESPACE
• RECOVER TABLESPACE
run{
sql “alter tablespace users offline immediate”;
restore tablespace users;
recover tablespace users;
sql “alter tablespace users online”;
}
13-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Tablespace Recovery
13-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Using RMAN to Relocate a Tablespace
• Use the SET NEWNAME command to restore the files.
• Use the SWITCH command to record the new names in the control file.
• Use the RECOVER TABLESPACE command to recover the datafiles of the tablespace.
13-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Recover a database in ARCHIVELOG mode • Restore datafiles to different locations if the
original location is unavailable
13-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Practices 13-1 and 13-2 Overview
These practices cover the following topics:• Using RMAN to recover a tablespace• Using RMAN to recover relocated datafiles
Copyright © Oracle Corporation, 2002. All rights reserved.
User-Managed Incomplete Recovery
14-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following: • Describe the steps of incomplete recovery• Perform an incomplete database recovery• Identify the loss of current online redo log files
14-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Incomplete Recovery Overview
InstanceSGA
Redo logbuffer
Databuffer
Large PoolLocks
Shared pool
Data dict.cache
Shared SQLand PL/SQL
PMONDBWnSMON LGWRCKPT ARCnUser
processServer
processPGA
Userprocess
Serverprocess
PGA
Parameterfile
Passwordfile
Archivedlog files
11
Database
Datafile 1
Datafile 2
Datafile 3
Controlfiles
Redo log file 1
Redo log file 2
01
1
1
14-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Situations RequiringIncomplete Recovery
• Complete recovery fails because an archived log is lost.
• All unarchived redo log files and a datafile are lost.• User error
– An important table was dropped.– Invalid data was committed in a table.
• Current control file is lost and a backup control file must be used to open the database.
14-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Types of Incomplete Recovery
• There are three types of incomplete recovery:– Time-based recovery– Cancel-based recovery– Change-based recovery
• You may need to recover using a restored control file when: – Control files are lost– Performing incomplete recovery to a point when the
database structure is different than the current
14-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Incomplete Recovery Guidelines
• Follow all steps carefully.• Take whole database backups before and after
recovery.• Always verify that the recovery was successful.• Back up and remove archived logs.
14-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Incomplete Recovery and the Alert Log
• Check the alert log before and after recovery• Contains error information, hints, and SCNs
14-10 Copyright © Oracle Corporation, 2002. All rights reserved.
User-Managed Procedures for Incomplete Recovery
1. Shut down and back up the database.2. Restore all datafiles. Do not restore the control file,
redo logs, password file, or parameter file.3. Mount the database.4. Recover the datafiles to a point before the time of
failure.5. Open the database with RESETLOGS.
6. Perform a closed database backup.
14-11 Copyright © Oracle Corporation, 2002. All rights reserved.
RECOVER Command Overview
• Recover a database until cancel:
• Recover a database until time:
• Recover using backup control file:
RECOVER DATABASE until cancel
RECOVER DATABASE
until time ‘2002-07-24:14:22:03’
RECOVER DATABASE
until time ‘2002-07-24:14:22:03’
using backup controlfile
14-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Time-Based Recovery: Example
Scenario:• The current time is 12:00 p.m. on March 9, 2002.• 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.
14-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Shut down and back up1
Mount the database
2
UNTIL TIME Recovery
Restore all datafiles
3
Open with Resetlogs5
Back up the database6
Datafile 3
Redo logFile 2
Datafile 2
Control Files
Redo logFile 1
Datafile 1
Database
145
146146
146
146
146
EMP
Datafile 3
Redo logFile 2
Datafile 2
Control Files
Redo logFile 1
Datafile 1
Recovered Database
0
11
1
1
1
EMP
Datafile 3
Datafile 2
Datafile 1
Restored Database
146144
144
144
EMP Redo logFile 2
145
Archivedlog file
1444
Redo logFile 1
146Control
Files
14-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Cancel-Based Recovery: Example
Scenario:• The current time is 12:00 p.m. on March 9,2002.• 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.
14-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Cancel-Based Recovery: Example
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.
14-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Using a Backup Control File During Recovery
Scenario:• The current time is 12:00 p.m. on March 9, 2002.• 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.
14-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Using a Backup Control File During Recovery
Findings:• The backup from last night contains datafiles and
control files that are 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, 2002.• Datafile number 4 is offline.
14-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Loss of Current Redo Log Files
If the database is closed:• Attempt to open the database.• Find the current log sequence number.• Recover the database using UNTIL CANCEL.
• Drop and re-create log files if necessary.• Open the database using RESETLOGS.
• Perform a whole-database backup.
14-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Perform incomplete database recovery• Recover from the loss of current online redo log
files
14-24 Copyright © Oracle Corporation, 2002. All rights reserved.
Practices 14-1 and 14-2 Overview
These practices cover the following topics:• Recovery from user failure• Recovery with lost archived redo log files
Copyright © Oracle Corporation, 2002. All rights reserved.
RMAN Incomplete Recovery
15-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following: • Perform an incomplete database recovery by
using UNTIL TIME
• Perform an incomplete database recovery by using UNTIL SEQUENCE
15-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Incomplete Recovery of a DatabaseUsing RMAN
1. Mount the database.2. Allocate multiple channels for parallelization.3. Restore all datafiles.4. Recover the database by using UNTIL TIME, UNTIL
SEQUENCE, or UNTIL SCN.5. Open the database by using RESETLOGS.
6. Perform a whole database backup.
15-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Specifying the Restore Time
15-5 Copyright © Oracle Corporation, 2002. All rights reserved.
RMAN Incomplete RecoveryUNTIL TIME: Example
RMAN> RUN {
2> ALLOCATE CHANNEL c1 TYPE DISK;
3> ALLOCATE CHANNEL c2 TYPE DISK;
4> SET UNTIL TIME = ‘2001-12-09:11:44:00';
5> RESTORE DATABASE;
6> RECOVER DATABASE;
7> ALTER DATABASE OPEN RESETLOGS; }
15-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Specifying the Sequence
15-8 Copyright © Oracle Corporation, 2002. All rights reserved.
RMAN Incomplete Recovery UNTIL SEQUENCE: Example
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> }
15-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Perform an incomplete database recovery by
using UNTIL TIME
• Perform an incomplete database recovery by using UNTIL SEQUENCE
15-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 15 Overview
This practice covers recovery with lost archived redo log files.
Copyright © Oracle Corporation, 2002. All rights reserved.
RMAN Maintenance
16-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Perform cross-checking of backups and copies• Update the repository when backups have been
deleted• Change the availability status of backups and
copies• Make a backup or copy exempt from the retention
policy• Catalog backups made with operating system
commands
16-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Cross Checking Backups and Copies
Use the CROSSCHECK command to:
• Ensure repository information is synchronized with actual files
• Check the status of a backup or copy• Update the repository when files have been
deleted with operating system commands
16-4 Copyright © Oracle Corporation, 2002. All rights reserved.
The CROSSCHECKCommand
• Cross-check all backups in the database:
• Cross-check all copies in the database:
CROSSCHECK BACKUPSET OF DATABASE;
CROSSCHECK COPY;
16-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Deleting Backups and Copies
Use the DELETE command to:
• Delete physical backups and image copies• Update repository status to DELETED
• Remove records from the recovery catalog
16-6 Copyright © Oracle Corporation, 2002. All rights reserved.
The DELETE Command
• Delete a specific backup set:
• Delete an expired backup without the confirmation:
•
• Delete all backups, copies, and archived redo log files based on the configured retention policy:
DELETE BACKUPSET 102;
DELETE NOPROMPT EXPIRED BACKUP OF TABLESPACE users;
DELETE OBSOLETE;
16-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Deleting Backups and Copies
Use the BACKUP … DELETE INPUT command to:
• Delete input files upon successful creation of the backup set
• Delete archived redo log files, datafile copies, and backup sets
16-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Changing the Availability of RMAN Backups and Copies
• Change the status of a backup or copy to Unavailable with the CHANGE … UNAVAILABLEcommand.
• Return the status to Available with the CHANGE … AVAILABLE command.
16-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Changing the Availability Status
• Change the status of a specific datafile:
• Change the status of a control file backup:
• Change the status of archived redo log files:
CHANGE DATAFILECOPY ’/DB01/BACKUP/users01.dbf’ UNAVAILABLE;
CHANGE BACKUP OF CONTROLFILE UNAVAILABLE;CHANGE BACKUP OF CONTROLFILE AVAILABLE;
CHANGE COPY OF ARCHIVELOG SEQUENCE BETWEEN 230 AND 240 UNAVAILABLE;
16-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Exempting a Backup or Copy from the Retention Policy
• Use the CHANGE … KEEP command to exempt a backup or copy from the retention policy.
• Use the CHANGE … NOKEEP command to cancel the exemption.
16-11 Copyright © Oracle Corporation, 2002. All rights reserved.
The CHANGE … KEEP Command
• Create a long-term backup:
• Make a datafile exempt from the retention policy for 60 days:
CHANGE BACKUPSET 123 KEEP FOREVER NOLOGS;
CHANGE DATAFILECOPY ’/DB01/BACKUP/users01.dbf’ KEEP UNTIL ’SYSDATE+60’;
16-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Cataloging Archived Redo Log Files and User-Managed Backups
You can use the CATALOG command to add information to the repository about:• An operating system datafile copy • An archived redo log copy • A control file copy
16-13 Copyright © Oracle Corporation, 2002. All rights reserved.
The CATALOG Command
• Catalog a backup taken with an operating system command:
• Catalog archived redo log files:
CATALOG DATAFILECOPY ’/DB01/BACKUP/users01.dbf’;
CATALOG ARCHIVELOG ’/ORADATA/ARCHIVE1/arch_12.arc’, ’/ORADATA/ARCHIVE1/arch_13.arc’;
16-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Uncataloging RMAN Records
Use the CHANGE … UNCATALOG command to:• Update the record in the repository to DELETED
status• Delete a specific backup or copy record from the
recovery catalog
16-15 Copyright © Oracle Corporation, 2002. All rights reserved.
The CHANGE … UNCATALOG Command
• Remove records for deleted archived redo log files:
• Remove records for a deleted datafile:
CHANGE ARCHIVELOG … UNCATALOG;
CHANGE DATAFILECOPY '/DB01/BACKUP/users01.dbf' UNCATALOG;
16-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Perform cross-checking of backups and copies• Update the repository when backups have been
deleted• Change the availability status of backups and
copies• Make a backup or copy exempt from the retention
policy• Catalog backups made with operating system
commands
16-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 16 Overview
This practice covers the following topics:• Performing cross checking• Cataloging files in the repository
Copyright © Oracle Corporation, 2002. All rights reserved.
Recovery Catalog Creationand Maintenance
17-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Describe the contents of the recovery catalog• List the RMAN features which require the recovery
catalog• Create the recovery catalog• Maintain the recovery catalog by using RMAN
commands• Use RMAN to register, resynchronize, and reset a
database
17-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
• Query the recovery catalog to generate reports and lists
• Create, store, and run scripts• Describe methods for backing up and recovering
the recovery catalog
17-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Overview
Targetdatabase
Storedscripts
ReportingREPORTLIST
Backup
Restore/Recovery Recovery Manager (RMAN)
Catalog Maintenance Register Resynchronize Reset Change/Delete/CatalogBackup /Restore/Recover
Enterprise Manager
Control file
Catalog database
17-5 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovery Catalog Contents
The recovery catalog is an optional repository containing information on:• Datafile and archived redo log file backup sets and
backup pieces• Datafile copies• Archived redo log files• The physical structure of the target database
17-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovery Catalog Contents
The recovery catalog can also contain:• Persistent RMAN configuration settings• Stored job scripts
17-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Benefits of Using a Recovery Catalog
The following features are available only when you use a recovery catalog:• Metadata about multiple target databases in one
catalog• Metadata about multiple incarnations of a single
target database• Historical metadata• Reporting on the target database at a noncurrent
time
17-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Creating Recovery Catalog
Targetdatabase
1. Create tablespace
2. Create catalog owner
3. Grant privileges
4. Create catalog
5. Connect to target database
6. Register target database
Control file
Catalog database
17-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Connecting Using a Recovery Catalog
• Example on UNIX
• Example on Windows NT
C:\> set ORACLE_SID=db01
C:\> rman target /
RMAN> connect catalog rman_db01/rman_db01@catdb
$ ORACLE_SID=db01; export ORACLE_SID
$ rman target /
RMAN> connect catalog rman_db01/rman_db01@catdb
17-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovery Catalog Maintenance
Targetdatabase
Storedscripts
Reporting REPORTLIST
Backup
Restore / Recovery Recovery Manager (RMAN)
Catalog Maintenance Register Resynchronize Reset Change/Delete/CatalogBackup /Restore/Recover
Enterprise Manager
Control file
Catalog database
17-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Catalog Maintenance
17-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Resynchronization of the Recovery Catalog
Resynchronization of the recovery catalog happens:• Automatically with BACKUP and COPY commands• Manually with RESYNC CATALOG command
RMAN >
TargetdatabaseControl file
Catalog database
17-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Using RESYNC CATALOGfor Resynchronization
Issue the RESYNC CATALOG command when you:
• Add or drop a tablespace• Add or drop a datafile• Relocate a database file $ rman target / catalog rman/rman@catdbRMAN> RESYNC CATALOG;
17-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Resetting a Database Incarnation
• Use the RESET DATABASE command:– To direct RMAN to create a new database
incarnation record – To distinguish between opening with RESETLOGS
and an accidental restore operation of an old control file
• Open with RESETLOGS after RESET DATABASE
17-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovery Catalog Reporting
Targetdatabase
Storedscripts
Reporting REPORTLIST
Backup
Restore/Recovery Recovery Manager (RMAN)
Catalog Maintenance Register Resynchronize Reset ChangeBackup /Restore/Recover
Enterprise Manager
Control file
Catalog database
17-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Viewing the Recovery Catalog
Data dictionary views:• RC_DATABASE
• RC_DATAFILE
• RC_STORED_SCRIPT
• RC_STORED_SCRIPT_LINE
• RC_TABLESPACE
17-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Stored Scripts
Targetdatabase
Storedscripts
Reporting REPORTLIST
Backup
Restore/Recovery Recovery Manager (RMAN)
Catalog Maintenance Register Resynchronize Reset ChangeBackup /Restore/Recover
Enterprise Manager
Control file
Catalog database
17-22 Copyright © Oracle Corporation, 2002. All rights reserved.
Script Examples
• Use CREATE SCRIPT to store a script.
• Use EXECUTE SCRIPT to run a script.
RMAN> create script Level0Backup {
backup
incremental level 0
format ‘/u01/db01/backup/%d_%s_%p’
fileperset 5
(database include current controlfile);
sql ‘alter system archive log current’;
}
RMAN > run {execute script Level0Backup;}
17-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Managing Scripts
• Use REPLACE SCRIPT to rewrite a script
• Use DELETE SCRIPT to remove a script
• Use PRINT SCRIPT to display a script
RMAN> REPLACE SCRIPT Level0Backup {
…
fileperset 3
…}
RMAN> DELETE SCRIPT Level0Backup;
RMAN> PRINT SCRIPT Level0Backup;
17-24 Copyright © Oracle Corporation, 2002. All rights reserved.
Backup of Recovery Catalog
• Whole database backup of the database containing the recovery catalog
• Tablespace backup of the tablespace containing the recovery catalog
• Export: – If catalog database is not very large, you can export
the database at regular intervals. – If catalog database is large, export the schema
containing the recovery catalog.
17-25 Copyright © Oracle Corporation, 2002. All rights reserved.
Recovering the Recovery Catalog
• Create a database from a previous backup of the recovery catalog database.
• Relocate the catalog into another database and import the data.
• Import the entire database from an export.
17-26 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned that:• Before using the recovery catalog, you must
register the target database• You should resynchronize the catalog frequently
using the control file• Scripts can be stored in the recovery catalog
17-27 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 17 Overview
This practice covers the following topics:• Creating the recovery catalog• Registering a target database with the recovery
catalog• Listing the incarnation of a target database• Storing a script in the recovery catalog and
executing it
Copyright © Oracle Corporation, 2002. All rights reserved.
Export and Import Utilities
18-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Describe the uses of the Export and Import
utilities• Describe Export and Import concepts and
structures• Perform simple Export and Import operations• List guidelines for using Export and Import
18-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Export and Import Utilities
Oracledatabase
Oracledatabase
Export
Import
18-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Oracle Export and Import Utility Overview
You can use these utilities to do the following:• Archive historical data• Save table definitions to protect them from user
error failure• Move data between machines and databases or
between different versions of the Oracle server• Transport tablespaces between databases
18-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Methods of Invoking the Export and Import Utilities
• Command-line interface• An interactive dialog• Parameter files• Oracle Enterprise Manager
18-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Full Database Mode
Tables definitions
Tables data
Grants
Indexes
Tables constraints
Export Modes
Table Mode
Table definitions
Table data (all or selected rows)
Owner’s table grants
Owner’s table indexes
Table constraints
User Mode
Tables definitions
Tables data
Owner’s grants
Owner’s indexes
Tables constraints
Tablespace Mode
Table definitions
Grants
Indexes
Table constraints
Triggers
18-9 Copyright © Oracle Corporation, 2002. All rights reserved.
Invoking Export
• Syntax:
• Examples:
exp hr/hr TABLES=employees,departments
rows=y file=exp1.dmp
exp keyword = value, value2, … ,valuen
exp system/manager OWNER=hr direct=y
file=expdat.dmp
exp \'username/password AS SYSDBA\'
TRANSPORT_TABLESPACE=y
TABLESPACES=ts_emp log=ts_emp.log
18-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Using the Export Wizard
18-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Direct-Path Export Concepts
Buffercache
Generate SQLcommands
Write blocks
Direct Path
Dump file
Export
Export Oracle Server
Read blocksEvaluating
bufferTTC
buffer
Buffercache
manager
SQLcommand
processing
Two-Taskcommon
(TTC)
Direct PathConventional Path
18-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Direct-Path Export Features
• The type of Export is indicated on the screen output, export dump file, and the log file.
• Data is already in the format that Export expects, avoiding unnecessary data conversion.
• Uses an optimized SQL SELECT statement.
18-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Direct-Path Export Restrictions
• The direct-path option cannot be invoked interactively.
• Client-side and server-side character sets must be the same.
• The BUFFER parameter has no affect.
18-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Specifying Direct-Path Export
• As command line argument to the Export command:
• As a keyword in a parameter file:exp parfile=<Parameter file>
exp userid=hr/hr full=y direct=y
Parameter file …..(Other Parameters)
DIRECT = Y…...(Other Parameters)
18-17 Copyright © Oracle Corporation, 2002. All rights reserved.
Uses of the Import Utility for Recovery
• Create table definitions• Extract data from a valid Export file• Import from a complete or cumulative Export file• Recover from user-error failures
18-18 Copyright © Oracle Corporation, 2002. All rights reserved.
Import Modes
Mode Description
Table Import specified tables into a schema.
User Import all objects that belong to a schema
Tablespace Import all definitions of the objects contained in the tablespace
Full Database Import all objects from the export file
18-19 Copyright © Oracle Corporation, 2002. All rights reserved.
Invoking Import
• Syntax:
• Examples:
imp hr/hr TABLES=employees,departments
rows=y file=exp1.dmp
imp keyword = value or keyword = value,
value2, … value n
imp system/manager FROMUSER=hr file=exp2.dmp
imp \'username/password AS SYSDBA\'
TRANSPORT_TABLESPACE=y
TABLESPACES=ts_employees
18-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Using the Import Wizard
18-22 Copyright © Oracle Corporation, 2002. All rights reserved.
Invoking Import as SYSDBA
• You need to invoke Import as SYSDBA under the following conditions:– At the request of Oracle technical support– When importing a transportable tablespace set
• To invoke Import as SYSDBA:imp \’username/password AS SYSDBA\’
18-23 Copyright © Oracle Corporation, 2002. All rights reserved.
Import Process Sequence
1. New tables are created2. Data is imported3. Indexes are built4. Triggers are imported5. Integrity constraints are enabled on the new tables6. Any bitmap, functional, and/or domain indexes are
built
18-24 Copyright © Oracle Corporation, 2002. All rights reserved.
Globalization Support Considerations
• The Export file identifies the character encoding scheme that is used for the character data in the file.
• The Import utility translates data to the character set of its host system.
• A multibyte character set Export file must be imported into a system that has the same characteristics.
18-25 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Describe the uses of Export and Import• Describe Export and Import concepts and
structures• Perform simple Export and Import operations• List guidelines for using Export and Import
18-26 Copyright © Oracle Corporation, 2002. All rights reserved.
Practice 18 Overview
This practice covers the following topics:• Using the Export utility• Using the Import utility
Copyright © Oracle Corporation, 2002. All rights reserved.
Workshop
19-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Document a database configuration by using the
Database Configuration Worksheet• Configure an Oracle9i database to support stated
business requirements• Recover a failed database while minimizing down
time and data loss
19-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
• Enable and use trace output for troubleshooting• Identify and troubleshoot:
– Listener problems– Client configuration issues
19-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Workshop Methodology
• Group-oriented and interactive• Intensive hands-on diagnosis and problem
resolution• Variety of failure scenarios• Recovery solutions• Variety of configuration errors• Develop troubleshooting skills
19-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Workshop Approach
• 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
19-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Business Requirements
• Twenty-four hour availability• Peak usage varies across all time zones• Daily backups are required• Complete database recovery is required
19-8 Copyright © Oracle Corporation, 2002. All rights reserved.
Resolving a Database Failure
• Phase I: Diagnose the problem• Phase II: Restore appropriate files• Phase III: Recover the database• Phase IV: Back up the database
19-10 Copyright © Oracle Corporation, 2002. All rights reserved.
Resolving a Network Failure
• Use OS utilities like ping and telnet to test network connectivity.
• Use Oracle Net utilities to test service connectivity.
• Check log files initially to diagnose problems.• Use tracing only when needed.• Trim the trace files regularly because of their
potential growth.
19-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Enable Tracing
• Oracle Net Manager• Edit sqlnet.ora file
TRACE_DIRECTORY_CLIENT = /u01/user01/NETWORK/LOG
NAMES.DEFAULT_DOMAIN = us.oracle.com
TRACE_UNIQUE_CLIENT = on
TRACE_FILE_CLIENT = client.trc
TRACE_LEVEL_CLIENT = SUPPORT
NAMES.DIRECTORY_PATH= (TNSNAMES)
19-12 Copyright © Oracle Corporation, 2002. All rights reserved.
Using Trace Files
Trace files will give you a better understanding of: • The flow of packets between network nodes • Which component of Oracle Net is failing • Pertinent error codes
19-14 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
• 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
Copyright © Oracle Corporation, 2002. All rights reserved.
Loading Data into a Database
D-2 Copyright © Oracle Corporation, 2002. All rights reserved.
Objectives
After completing this lesson you should be able to do the following:• Demonstrate usage of direct-load insert
operations• Describe the usage of SQL*Loader• Perform basic SQL*Loader operations• List guidelines for using SQL*Loader and direct-
load INSERT
D-3 Copyright © Oracle Corporation, 2002. All rights reserved.
Data Loading Methods
SQL*Loader
Other applications
Export
Import
Direct-load INSERT
Oracledatabase
Oracledatabase
D-4 Copyright © Oracle Corporation, 2002. All rights reserved.
Direct-Load INSERT
Direct-load INSERT can be performed in the followingways:• Normal (serially) or in parallel• Into partitioned tables, nonpartitioned tables, or
single partitions of a table• With or without logging of redo data
D-6 Copyright © Oracle Corporation, 2002. All rights reserved.
Serial Direct-Load INSERT
Free space after delete Blocks used by inserted rows
High-water markUsed block
EMPLOYEES table
INSERT /*+ APPEND */ INTO emp
NOLOGGING
SELECT * FROM t_employees;
COMMIT;
Serverprocess
D-7 Copyright © Oracle Corporation, 2002. All rights reserved.
Parallel Direct-Load INSERT
Free space after delete Temporary segments
Used block
Slaveprocess
ALTER SESSION ENABLE PARALLEL DML;
INSERT /*+PARALLEL(hr.employees,2) */
INTO hr.employees NOLOGGING
SELECT * FROM hr.old_employees;
High-water mark
SlaveprocessEMPLOYEES table
D-9 Copyright © Oracle Corporation, 2002. All rights reserved.
SQL*Loader
Database datafiles
Input datafilesLoader control file
SQL*Loader
Log fileInserted
Selected
Parameter file(optional)
Rejected
Bad file
Rejected
Record selectionAccepted
Discard file(optional)
DiscardedField processing
Oracle server
D-11 Copyright © Oracle Corporation, 2002. All rights reserved.
Conventional and Direct Path Loads
Directpath
Arrayinsert
Datasave
Table
High-water mark
Space used only by conventional load
Instance
SGA Shared pool
Conventional
D-13 Copyright © Oracle Corporation, 2002. All rights reserved.
Comparing Direct and ConventionalPath Loads
Conventional Load
Uses COMMITs to makechanges permanent
Redo log entries alwaysgenerated
Enforces all constraints
INSERT triggers fire
Can load into clusteredtables
Other users can make changes to tables
Direct Path Load
Uses data saves
Generates redo only underspecific conditions
Enforces only primary key, unique, and NOT NULL
INSERT triggers do not fire
Cannot load intoclustered tables
Other users cannotmake changes to tables
D-15 Copyright © Oracle Corporation, 2002. All rights reserved.
Parallel Direct-Path Load
Temporary segments
load2.datload2.ctl
load3.datload3.ctl
SQL*Loader
SQL*Loader
SQL*Loader
Table
High-water mark
load1.datload1.ctl
D-16 Copyright © Oracle Corporation, 2002. All rights reserved.
Using SQL*Loader
SQL*Loader
case1.log
case1.ctl
EMPLOYEES table
$sqlldr hr/hr \
> control=case1.ctl \
> log=case1.log direct=Y
D-18 Copyright © Oracle Corporation, 2002. All rights reserved.
SQL*Loader Control File
The loader control file tells SQL*Loader:• Where to find the load data• The data format• Configuration details
– Memory management– Record rejection– Interrupted load handling details
• How to manipulate the data
D-21 Copyright © Oracle Corporation, 2002. All rights reserved.
Control File Syntax Considerations
• The syntax is free-format • Syntax is case insensitive • Comments extend from the two hyphens ( -- ) that
mark the beginning of the comment to the end of the line
• The CONSTANT keyword is reserved
D-22 Copyright © Oracle Corporation, 2002. All rights reserved.
Input Data and Datafiles
• SQL*Loader reads data from one or more files specified in the control file
• From SQL*Loader’s perspective, the data in the datafile is organized as records
• A datafile can be in one of three formats:– Fixed-record format– Variable-record format– Stream-record format
D-25 Copyright © Oracle Corporation, 2002. All rights reserved.
Logical Records
SQL*Loader can be instructed to follow one of the following two logical record-forming strategies:• Combine a fixed number of physical records to
form each logical record• Combine physical records into logical records
while a certain condition is true
D-26 Copyright © Oracle Corporation, 2002. All rights reserved.
Data Conversion
During a conventional path load, data fields in the datafile are converted into columns in the database in two steps:• The field specifications in the control file are used
to interpret the format of the datafile and convert it to a SQL INSERT statement using that data
• The Oracle database server accepts the data and executes the INSERT statement to store the data in the database
D-27 Copyright © Oracle Corporation, 2002. All rights reserved.
Discarded or Rejected Records
• 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
D-29 Copyright © Oracle Corporation, 2002. All rights reserved.
Log File Contents
• Header Information• Global Information• Table Information• Datafile Information• Table Load Information• Summary Statistics• Additional statistics for direct path loads and
multithreading Information
D-31 Copyright © Oracle Corporation, 2002. All rights reserved.
SQL*Loader Guidelines
• Use a parameter file to specify commonly used command line options
• Place data within the control file only for a small, one-time load
• Improve performance by:– Allocating sufficient space– Sorting the data on the largest index– Specifying different files for temporary segments
for parallel loads
D-32 Copyright © Oracle Corporation, 2002. All rights reserved.
Summary
In this lesson, you should have learned how to:• Describe the usage of SQL*Loader• Perform basic SQL*Loader operations• Demonstrate proficiency using direct-load INSERT
operations• List guidelines for using SQL*Loader and direct-
load INSERT